Friday, 26 August 2016

Send Data From Winform To CrystalReport


 var dialog = new PrintDialog();
            crystalreport.CrystalReport1 objRpt = new ElectionManagement.crystalreport.CrystalReport1();
         CrystalReportViewer crv = new CrystalReportViewer();
                TextObject tiNo = (TextObject)objRpt.ReportDefinition.Sections["Section2"].ReportObjects["Text2"];
                tiNo.Text = "Text1";
                TextObject tiNo1 = (TextObject)objRpt.ReportDefinition.Sections["Section2"].ReportObjects["Text3"];
                tiNo1.Text = "Text2";
                TextObject tiNo2 = (TextObject)objRpt.ReportDefinition.Sections["Section2"].ReportObjects["Text4"];
                tiNo2.Text = "Text3";

crv.ReportSource = objRpt;

                objRpt.SetDataSource(ds);
                crystalReportViewer1.ReportSource = objRpt;
                crystalReportViewer1.Refresh();

Friday, 18 March 2016

Serialization and Deserialization


Serialization: Serialization is a process to converting an object to linear sequence of byte streams for either storage or transmission it to another location.
If we want to make an object serializable, then decorate the class with [Serializable] attribute.


Deserialization:  Deserialization is the process of taking the stored information or taking the received byte stream and convert it them again into the object.

Diffenrence between class and structure


 (1) A class is a reference type whereas a structure is a value type.
 (2)While creating an object for a Class , CLR allocates memory for object in Heap ,  whereas while creating an instance of Structure ,    CLR creates memory in Stack.
  (3) Classes support  Inheritance whereas Structure do not support Inheritance.
    (4)Variables of a Class can have a NULL values but variables of Structure can not have a NULL value.
    (5)Class can contain Constructor and Destructor when initialized an object where as Structure members initialized automatically without Constructor.

Wednesday, 16 March 2016

Advantages of external JavaScript over inline JavaScript


Advantages of external JavaScript over inline JavaScript : Here are some of the general advantages of  external JavaScript over inline JavaScript

Maintainability : JavaScript in external files can be referenced on multiple pages without having to
duplicate the code inline on every page. If something has to change, you only have one place to change.
So external JavaScript code can be reused and maintenance will be much easier.

Separation of Concerns : Storing JavaScript in a separate external .js file adheres to Separation of concerns design
principle. In general it is a good practice to separate HTML, CSS and JavaScript as it makes it easier working with them.
Also allows multiple developers to work simultaneously.

Performance : An external JavaScript file can be cached by the browser, where as an inline JavaScript on the page is
loaded every time the page loads. 

How to create a folder on page load ?

 string foldername = "ReportImage";
        private void frmtestreport_Load(object sender, EventArgs e)
        {
            try
            {
                if (!Directory.Exists(@"C:/test/" + foldername))
                {
                    Directory.CreateDirectory(@"C:/test/" + foldername);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

What is Dense Rank Function in SQL Server ?

What  is Dense  Rank Function  in SQL Server ?Dense  Rank  Function  is Used for  provide the Rank  of Rows on the basis  of  any  Column  value either for  Ascending Order or in Descending order.For  Example the table given below


 if we want to provide the Rank of Salary so we use DenseRank function here as shown in Query
select Salary,DENSE_RANK() over(order by Salary Desc) as SalaryCount
from tbl_Employee_Test
Result of above Query is Given in the below Image



In the Above  figure Salary  is  order by Descending and after that we use DENSERANK function for provide the rank to rows as 8000 is the highest Salary  Provides the Rank 1 . Here we use SalaryCount as a Column Name which is the Rank of Salary.

30000 is the Second Highest Salary so here rank is 2 like that Rank for 23000 is 3 and so on.

How to delete duplicate data from table

 firstly create a table named tbl_Employee_DuplicateRow by the script given below.


CREATE TABLE tbl_Employee_DuplicateRow
(
      EmpID int primary key IDENTITY(1,1) NOT NULL,
      DepartmentID int,
      EmpName nvarchar(50) NULL,
      Salary int NULL,

)

 Once table is created after insert the data into the table by the script given below.
insert into tbl_Employee_DuplicateRow(DepartmentID,EmpName,Salary)values('1','Sudhir',10000);
insert into tbl_Employee_DuplicateRow(DepartmentID,EmpName,Salary)values('2','Mark',15000);
insert into tbl_Employee_DuplicateRow(DepartmentID,EmpName,Salary)values('3','Alinaa',23000);
insert into tbl_Employee_DuplicateRow(DepartmentID,EmpName,Salary)values('4','Rajesh',1000);
insert into tbl_Employee_DuplicateRow(DepartmentID,EmpName,Salary)values('5','Daniel',17000);
insert into tbl_Employee_DuplicateRow(DepartmentID,EmpName,Salary)values('6','Micheal',30000);
insert into tbl_Employee_DuplicateRow(DepartmentID,EmpName,Salary)values('7','Ricky',10400);
insert into tbl_Employee_DuplicateRow(DepartmentID,EmpName,Salary)values('8','Amit',80000);
insert into tbl_Employee_DuplicateRow(DepartmentID,EmpName,Salary)values('9','Richard',9000);


Execute the query and check the table...