Beispiel #1
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            try
            {
                using (DEWSRMEntities db = new DEWSRMEntities())
                {
                    int[]       selRows    = ((GridView)grdEmployees.MainView).GetSelectedRows();
                    DataRowView oEmployeeD = (DataRowView)(((GridView)grdEmployees.MainView).GetRow(selRows[0]));

                    int      nEmployeeID = Convert.ToInt32(oEmployeeD["EmployeeID"]);
                    Employee oEmployee   = db.Employees.FirstOrDefault(p => p.EmployeeID == nEmployeeID);


                    if (oEmployee == null)
                    {
                        MessageBox.Show("select an item to edit", "Item not yet selected", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }

                    fEmployee frm = new fEmployee();
                    frm.ItemChanged = RefreshList;
                    frm.ShowDlg(oEmployee, false);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #2
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            fEmployee frm = new fEmployee();

            frm.ItemChanged = RefreshList;
            frm.ShowDlg(new Employee(), true);
        }