private void btnDelete_Click(object sender, EventArgs e) { try { if (dgvStaffList.Rows.Count > 0) { int selectIndex = dgvStaffList.CurrentRow.Index; var staffID = dgvStaffList.Rows[selectIndex].Cells[0].Value; DialogResult dialogResult = MessageBox.Show("Staff'ı silmek istediğinize emin misiniz?", "Library Management System", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { var s = StaffsHelper.GetById(Convert.ToInt32(staffID)); s.Status = 0; StaffsHelper.Update(s); MessageBox.Show("Staff Silme Başarılı", "Library Management System", MessageBoxButtons.OK, MessageBoxIcon.Information); FillGrid(); } } } catch (Exception ex) { MessageBox.Show("Herhangi bir eleman seçmediniz!", "Library Management System", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btnUpdate_Click(object sender, EventArgs e) { epName.Clear(); bool check1 = StaffsHelper.ControlValidate(txtName, "Lütfen Staff İsmini Giriniz.", epName); epTCNO.Clear(); bool check2 = StaffsHelper.ControlValidate(txtTcNo, "Lütfen TC No Giriniz.", epTCNO); epAddress.Clear(); bool check3 = StaffsHelper.ControlValidate(txtAddress, "Lütfen Address İsmini Giriniz.", epAddress); epContactNo.Clear(); bool check4 = StaffsHelper.ControlValidate(txtContactNo, "Lütfen Contact No Giriniz.", epContactNo); if (check1 && check2 && check3 && check4) { int selectIndex = dgvStaffList.CurrentRow.Index; var staffID = dgvStaffList.Rows[selectIndex].Cells[0].Value; var s = StaffsHelper.GetById(Convert.ToInt32(staffID)); s.DesignationID = DesignationsHelper.GetByName(cmbDesignation.SelectedItem.ToString()); s.Name = txtName.Text; s.TCNO = txtTcNo.Text; s.Gender = cmbGender.SelectedIndex; s.Address = txtAddress.Text; s.ContactNo = txtContactNo.Text; StaffsHelper.Update(s); MessageBox.Show("Staff güncelleme başarılı", "Library Management System", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearForm(); FillGrid(); DisableComponent(); } }