Esempio n. 1
0
 private void EmpdataGridView_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Right)
     {
         //tdata is a grid view name
         var hti = EmpdataGridView.HitTest(e.X, e.Y);
         EmpdataGridView.ClearSelection();
         EmpdataGridView.Rows[hti.RowIndex].Selected = true;
     }
 }
Esempio n. 2
0
        private void editToolStripMenuItem_Click(object sender, EventArgs e)
        {
            empedit upe1        = new empedit();
            int     rowToUpdate = EmpdataGridView.Rows.GetFirstRow(DataGridViewElementStates.Selected);
            DataRow row         = dtEmployee.Rows[rowToUpdate];

            upe1.eid               = int.Parse(row["ID"].ToString());
            upe1.eNAME             = row["Name"].ToString();
            upe1.ecnic             = row["CNIC"].ToString();
            upe1.eCONTACTNO        = row["Contact_NO"].ToString();
            upe1.eADDRESS          = row["Address"].ToString();
            upe1.eGENDER           = row["Gender"].ToString();
            upe1.eAGE              = int.Parse(row["Age"].ToString());
            upe1.eSTATUS           = row["Status"].ToString();
            upe1.eDESIGNATION      = row["Designation"].ToString();
            upe1.eEMPQUALIFICATION = row["Qualification"].ToString();
            upe1.eEEXPERIENC       = row["Experience"].ToString();
            upe1.eESALARY          = row["Salary"].ToString();
            upe1.eWORKSCHEDULE     = row["Working_Schedual"].ToString();
            upe1.eJOINDATE         = row["Join_Date"].ToString();


            upe1.IsUpdate = true;
            upe1.ShowDialog();
            if (!upe1.IsCanceled)
            {
                row["ID"]               = upe1.eid;
                row["Name"]             = upe1.eNAME;
                row["CNIC"]             = upe1.ecnic;
                row["Contact_NO"]       = upe1.eCONTACTNO;
                row["Address"]          = upe1.eADDRESS;
                row["Gender"]           = upe1.eGENDER;
                row["Age"]              = upe1.eAGE;
                row["Status"]           = upe1.eSTATUS;
                row["Designation"]      = upe1.eDESIGNATION;
                row["Qualification"]    = upe1.eEMPQUALIFICATION;
                row["Experience"]       = upe1.eEEXPERIENC;
                row["Salary"]           = upe1.eESALARY;
                row["Working_Schedual"] = upe1.eWORKSCHEDULE;
                row["Join_Date"]        = upe1.eJOINDATE;


                upe1.IsUpdate = false;

                SqlCommandBuilder cmdBuilder = new SqlCommandBuilder(adapter);
                adapter.Update(dtEmployee);

                EmpdataGridView.Update();
                MessageBox.Show("Record is updated Successfully!");
            }
        }