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 BtnSearch_Click(object sender, EventArgs e) { ep.Clear(); if (txtSearchUserName.Text.Trim().Length == 0) { ep.SetError(txtSearchUserName, "Kullacı adı boş bırakılamaz!"); txtSearchUserName.Focus(); return; } if (txtSearchPassword.Text.Trim().Length == 0) { ep.SetError(txtSearchPassword, "Şifre boş bırakılamaz!"); txtSearchPassword.Focus(); return; } var check = UsersHelper.Login(txtSearchUserName.Text, txtSearchPassword.Text).Item1; var staffID = UsersHelper.Login(txtSearchUserName.Text, txtSearchPassword.Text).Item2; if (check) { var userPrivileges = UserPrivilegesHelper.GetByStaffID(staffID); chkConfiguration.Checked = Convert.ToBoolean(userPrivileges.Configuration); chkStaff.Checked = Convert.ToBoolean(userPrivileges.Staff); chkStudent.Checked = Convert.ToBoolean(userPrivileges.Student); chkBook.Checked = Convert.ToBoolean(userPrivileges.Book); chkIssueBook.Checked = Convert.ToBoolean(userPrivileges.IssueBook); chkReturnBook.Checked = Convert.ToBoolean(userPrivileges.ReturnBook); chkReport.Checked = Convert.ToBoolean(userPrivileges.Report); chkGSM.Checked = Convert.ToBoolean(userPrivileges.Gsm); chkEmail.Checked = Convert.ToBoolean(userPrivileges.Email); var staff = StaffsHelper.GetById(staffID); txtUpdateUser.Text = staff.Name; txtContactNo.Text = staff.ContactNo; var designation = DesignationsHelper.GetById(staff.DesignationID); txtDesignation.Text = designation.Name; btnUpdate.Enabled = true; txtSearchUserName.Enabled = false; txtSearchPassword.Enabled = false; btnSearch.Enabled = false; } else { MessageBox.Show("Kullanıcı Adı ve Şifre Eşleşmiyor.", "Library Management System", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btnEdit_Click(object sender, EventArgs e) { if (dgvStaffList.Rows.Count > 0) { if (dgvStaffList.SelectedRows.Count == 1) { int selectIndex = dgvStaffList.CurrentRow.Index; var staffID = dgvStaffList.Rows[selectIndex].Cells[0].Value; var s = StaffsHelper.GetById(Convert.ToInt32(staffID)); var d = DesignationsHelper.GetById(s.DesignationID); cmbDesignation.SelectedItem = d.Name; txtName.Text = s.Name; txtTcNo.Text = s.TCNO; cmbGender.SelectedIndex = s.Gender; txtAddress.Text = s.Address; txtContactNo.Text = s.ContactNo; EnableComponent(); } } }
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(); } }