private void btnEnter1_Click(object sender, EventArgs e)
        {
            this.Hide();
            // creating new window
            frmUpdate frm2 = new frmUpdate();

            // set databinding
            frm2.SetDataAutoFill();
            // get new page for new record
            frm2.employeeBindingNavigator.BindingSource.AddNew();
            frm2.employeeBindingNavigator.Visible = false;

            // set data into comboboxes
            string cn    = "DepartmentName";
            string qDept = "SELECT (DepartmentName) FROM Departments";

            QueryExecution(frm2.cmbdept, qDept, cn);
            string cn1     = "RegionName";
            string qRegion = "SELECT (RegionName) FROM Regions";

            QueryExecution(frm2.cmbstate, qRegion, cn1);
            // end of comboboxes setting

            // display window
            frm2.Show();
            // set combobox data empty
            frm2.cmbdept.Text  = "";
            frm2.cmbstate.Text = "";
            frm2.txtEmpId.Text = "0";
        }
        //When user click item on ListView
        private void lvEmpList_MouseClick(object sender, MouseEventArgs e)
        {
            //hide this window
            this.Hide();
            //create new window
            frmUpdate f4 = new frmUpdate();

            // set data into comboboxes
            string cn    = "DepartmentName";
            string qDept = "SELECT (DepartmentName) FROM Departments";

            QueryExecution(f4.cmbdept, qDept, cn);
            string cn1     = "RegionName";
            string qRegion = "SELECT (RegionName) FROM Regions";

            QueryExecution(f4.cmbstate, qRegion, cn1);
            // end of comboboxes setting

            //set employeebindingnaviator.visible to false since Update form code will be depending on this visibility
            f4.employeeBindingNavigator.Visible = false;
            //get and set f4.form empId from selected item
            f4.txtEmpId.Text = lvEmpList.SelectedItems[0].SubItems[0].Text;
            // new connection to sql
            SqlConnection con = new SqlConnection(conString);

            // open Sql
            con.Open();
            // query
            string     q   = "EXECUTE usp_GetEmpInfo @EmpId ='" + f4.txtEmpId.Text.ToString() + "'";
            SqlCommand cmd = new SqlCommand(q, con);
            // execute command
            SqlDataReader reader = cmd.ExecuteReader();

            while (reader.Read())
            {
                f4.txtfName.Text      = reader.GetValue(1).ToString();
                f4.txtmName.Text      = reader.GetValue(2).ToString();
                f4.txtlName.Text      = reader.GetValue(3).ToString();
                f4.cmbdept.Text       = reader.GetValue(4).ToString();
                f4.txtAddLine1.Text   = reader.GetValue(5).ToString();
                f4.txtAddLine2.Text   = reader.GetValue(6).ToString();
                f4.txtCity.Text       = reader.GetValue(7).ToString();
                f4.cmbstate.Text      = reader.GetValue(8).ToString();
                f4.txtPostalCode.Text = reader.GetValue(9).ToString();
                f4.dtpHireDate.Value  = reader.GetDateTime(10);
            }
            con.Close();
            f4.Show();
        }
        private void btnEnter3_Click(object sender, EventArgs e)
        {
            this.Hide();
            frmUpdate frm2 = new frmUpdate();

            frm2.btnClear.Visible = false;

            // set data into comboboxes
            string cn    = "DepartmentName";
            string qDept = "SELECT (DepartmentName) FROM Departments";

            QueryExecution(frm2.cmbdept, qDept, cn);
            string cn1     = "RegionName";
            string qRegion = "SELECT (RegionName) FROM Regions";

            QueryExecution(frm2.cmbstate, qRegion, cn1);
            // end of comboboxes setting
            //set oldest employee id
            frm2.employeeBindingNavigator.BindingSource.MoveFirst();
            frm2.Show();
        }