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...



Clear multiple text boxes with a button in

 void ClearAllText(Control con)
        {
            foreach (Control c in con.Controls)
            {
                if (c is TextBox)
                    ((TextBox)c).Clear();
                else
                    ClearAllText(c);
            }
        }


To use the above code, simply do this:
ClearAllText(this);

Tuesday, 15 March 2016

Get Cell Value On DataGridView Cell Leave Event

private void dataGridView1_CellLeave(object sender, DataGridViewCellEventArgs e)
 {

    if (e.ColumnIndex== 1)
    {
        string name= dataGridView1.CurrentCell.EditedFormattedValue.ToString();
}
}

How to Change DatagridView Header Color

 dataGridView1.ColumnHeadersDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#D7E2E4");
            dataGridView1.EnableHeadersVisualStyles = false;

Saturday, 12 March 2016

How to Set Text on Image MouseHover in C#

 private void pictureBox1_MouseHover(object sender, EventArgs e)
        {
            ToolTip tt = new ToolTip();
            tt.SetToolTip(this.pictureBox1, "Your Text");
        }

How to Change DataGrideView Header Color in C#

dataGridView1.ColumnHeadersDefaultCellStyle.BackColor = ColorTranslator.FromHtml("#D7E2E4");
            dataGridView1.EnableHeadersVisualStyles = false;

Friday, 11 March 2016

send value from one form to another

1.on First Form
      
             New_POS.frm_updatetax fc = new frm_updatetax();
            fc.Tax_Id = TextBox1.Text;
            fc.Show();

2. On Second Form

            Public string Tax_Id ;
           TextBox1.Text=Tax_Id ;

Wednesday, 9 March 2016

programatically generate a click on a DataGridView Row in C#

  dataGridView1_CellClick(dataGridView1, new DataGridViewCellEventArgs(0, 0));

change the datagridview selected row background color

dataGridView1.DefaultCellStyle.SelectionBackColor = ColorTranslator.FromHtml("#FFC0BE");
            dataGridView1.DefaultCellStyle.SelectionForeColor = ColorTranslator.FromHtml("#FFFFFF"); 

Disable default cell selection in datagridView

DataGridView1.Rows[1].Cells[0].Selected = false;

select a complete dataGridView Row when the user clicks a cell

 private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex < 0)
            {
                return;
            }

            int index = e.RowIndex;
            dataGridView1.Rows[index].Selected = true;
        }

Notification in C#

the following control will be added (notiyicon) to the application:



 Add the following code to the form:

                             notifyIcon1.Text = "Notification";
                            notifyIcon1.Visible = true;
                            notifyIcon1.BalloonTipTitle = "You Have  Application Pending ";
                            notifyIcon1.BalloonTipText = "Click Here to see details";

                            notifyIcon1.ShowBalloonTip(100);

Tuesday, 8 March 2016

How to check Testbox is empty or not

 if (Textbox.Text != "")
{
Do Somting Here.
}

Change Date Formate

String Date=Convert.ToDateTime(System.DateTime.Now).ToString("yyyy/MM/dd");

Fill Combobox From DataBase in C#


            MySqlCommand cmd = new MySqlCommand("select * from tbl_categorie", con.getcon());
            MySqlDataAdapter da = new MySqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            cmb_categorie.DataSource = dt;
            cmb_categorie.ValueMember = "Ctegory_Id";
            cmb_categorie.DisplayMember = "categorie";

Fill Combobox From DatBase In c#


            MySqlCommand cmd = new MySqlCommand("select * from tbl_categorie", con.getcon());
            MySqlDataAdapter da = new MySqlDataAdapter(cmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            cmb_categorie.DataSource = dt;
            cmb_categorie.ValueMember = "Ctegory_Id";
            cmb_categorie.DisplayMember = "categorie";
            

Count dataGridView Row Count

 int count = dataGridView1.Rows.Count - 1;

Monday, 22 February 2016

How to get Opning Closing Balance from given Table


How to get total Creadit,total Debit, Opning Amount And Closing Amount
Group By Date

Thanks In Advanced

Monday, 15 February 2016

TextView in Android

 <TextView
     
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello"
       
        />

how To Set Text Color of TextView In Android


             android:textColor="#000000"

Splash Screen in Android


Splash.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/spalsh"
    android:weightSum="1"
    android:orientation="vertical" >
</LinearLayout>


Splash.Java

import java.io.File;
import java.io.IOException;
import android.content.Intent;
import android.content.res.AssetFileDescriptor;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;

public class Splash extends ActionBarActivity {
private ActionBar ab;
MediaPlayer ourSong;
private static int SPLASH_TIME_OUT = 3000;
final MediaPlayer mp=new MediaPlayer();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.splash_screen);
ab = getSupportActionBar();
ab.hide();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
Intent i = new Intent(Splash.this, MainActivity.class);
startActivity(i);
finish();
}
}, SPLASH_TIME_OUT);
}
}

How to Fill DataGridview in C#

            s = "select     * from tablename";
            MySqlDataAdapter da = new MySqlDataAdapter(s, getcon());
            DataTable dt = new DataTable();
            da.Fill(dt);   
          dataGridView1.DataSource = dt;

Auto Complete Text Box in C#

AutoCompleteStringCollection namesCollection = new AutoCompleteStringCollection();
 void AutoCompleteItems()
        {
            try
            {
                AutoCompleteStringCollection namesCollection = new AutoCompleteStringCollection();
                s = "Select EmpName from tablename ";
                dt = cnn.DataTable(s);
                if (dt.Rows.Count > 0)
                {
                    for (int i = 0; i <= dt.Rows.Count - 1; i++)
                    {
                        namesCollection.Add(dt.Rows[i][0].ToString());
                    }
                }
                else
                {
                   
                }

                txt_empName.AutoCompleteMode = AutoCompleteMode.SuggestAppend;
                txt_empName.AutoCompleteSource = AutoCompleteSource.CustomSource;
                txt_empName.AutoCompleteCustomSource = namesCollection;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }

Programatically Save an Image From a URL in C#

WebClient webClient = new WebClient();
webClient.DownloadFile(FileUrl, Location);

How to split String using a back slash

String[] breakApart = strname.Split('\\');

How to Fill ComboBox From Database in C#

  s = "select * from tablename ";
           MySqlDataAdapter da = new MySqlDataAdapter(s, getcon());
            DataTable dt = new DataTable();
            da.Fill(dt);
            cmb_serchcategorie.DataSource = dt;
            cmb_serchcategorie.ValueMember = "ID";
            cmb_serchcategorie.DisplayMember = "ColumnName";

What is Asp.net MVC ?

MVC stands for Model View Controller is a web application development framework mainly used for developing application in three layers like Data Layer also called Model, Presentation Layer also called View and Business Layer called as Controller.
We use MVC pattern to reduce complexity of code and provide seperation of codes.
Model is used as class it contains the Database entity logics and provides manupulation of data to write code here.
View is used as presentation layer .it presents the data in desired format that user wants to present.
Controller is collection of methods defined business logic of an application.

How to Get Value From Datagridview in C#

  str = gdvrequisition.Rows[0].Cells[0].Value.ToString();

Programmatically Set the ForeColor of a label in C#

 lblExample.ForeColor = System.Drawing.Color.Red;

How to Get Value From Datatable in C#

lbl_available.Text = datatable.Rows[0][0].ToString();

Difference Between Memory Stream and file Stream.

Serialization is a process of converting object into byte streams for storing Data in any Backing Device.
During the Serialization we can use either file stream or Memory stream.
Memory Stream is representation of data in byte stream format in memory because there is no any backing store for Byte stream . Memory Stream reduce the need for temporary buffers and files in an application. where as File stream is used for read data from disk or file .
a memory stream can be used to read data that is  mapped in the computer's internal memory (RAM). You are basically reading/writing streams of bytes from memory.
There are two ways to create a MemoryStream.
You can initialize one  from an unsigned byte array or we can create an empty one. Empty memory streams are resizable.
Advantage of a memory stream is that there is no need to create temporary bufers and files in an application.
File stream and memory stream both are classes in C# and it derives from System.IO namespace.

button Click Event In Android

login.setOnClickListener(new View.OnClickListener() {

  @Override
  public void onClick(View view) {

  }
});

Convert String To Int C#.Net

int Test = Convert.ToInt32(str); 

Access Modifier in C#

Access Modifiers in C# :-access modifiers are used to define the scope of data and methods in the restricted manner. It protect data members of a class to outside interference.There are five types of access modifies in C# listed below:
(1). Public
(2).Private
(3). Protected
(4). Internal
(5). Protected internal Modifiers
(1)    Public :- Public modifier allows public access to members both inside and outside the class.
(2)    Private :- Private modifier allows the access of data members and member functions only inside the class in which they are declared , outside of class access is not allowed.
(3)    Internal :- Internal modifier allows data access only to the current assembly , if a member is accessed outside the assembly in which it has been defined a error gets generated.
(4)    Protected :- you can access the protected members inside the class in which they are declared or a class derived from that class in which they are declared.

(5)    Protected Internal :- allows access to members containing in current assembly , containing class and the class derived from that class.