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(); } } }