private void btnUpdate_Click(object sender, EventArgs e) { epProgram.Clear(); bool check = DepartmentsHelper.ControlValidate(txtDepartmentName, "Lütfen Department İsmini Giriniz.", epProgram); if (check) { int selectIndex = dgvDepartmentList.CurrentRow.Index; var dDepartmentID = dgvDepartmentList.Rows[selectIndex].Cells[0].Value; var d = DepartmentsHelper.GetById(Convert.ToInt32(dDepartmentID)); d.Name = txtDepartmentName.Text.Trim(); d.EstablishDate = dtpEstablishDate.Value; DepartmentsHelper.Update(d); MessageBox.Show("Department güncelleme başarılı", "Library Management System", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearForm(); FillGrid(); DisableComponent(); } }
private void btnEdit_Click(object sender, EventArgs e) { if (dgvDepartmentList.Rows.Count > 0) { if (dgvDepartmentList.SelectedRows.Count == 1) { int selectIndex = dgvDepartmentList.CurrentRow.Index; var departmentID = dgvDepartmentList.Rows[selectIndex].Cells[0].Value; var d = DepartmentsHelper.GetById(Convert.ToInt32(departmentID)); txtDepartmentName.Text = Convert.ToString(d.Name); dtpEstablishDate.Value = d.EstablishDate; EnableComponent(); } } else { MessageBox.Show("Department listesi boş!", "Library Management System", MessageBoxButtons.OK, MessageBoxIcon.Information); } }