コード例 #1
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (dgvDepartments.SelectedRows[0] == null)
            {
                MessageBox.Show("Please select a department");
                return;
            }
            else
            {
                Department department = new Department();
                using (DBManager dm = new DBManager())
                {
                    int id = (int)dgvDepartments.SelectedRows[0].Cells[0].Value;

                    department.Find(dm, id);
                }

                frmEditDepartment frm = new frmEditDepartment();
                frm.department = department;
                frm.ShowDialog();
                loadGrid();
            }

            //dgvDepartments.SelectedRows[0].Cells[0].Value;
        }
コード例 #2
0
        private void btnNew_Click(object sender, EventArgs e)
        {
            frmEditDepartment frm = new frmEditDepartment();

            frm.department = null;
            frm.ShowDialog();
            loadGrid();
        }