private void frmAddStaff_Load(object sender, EventArgs e) { cmbGender.DataSource = Enum.GetValues(typeof(Gender)); cmbDesignation.DataSource = DesignationsHelper.GetDesignationsNameList(); FillGrid(); SetColumnsWidth(); }
private void FillGrid() { dgvDesignationList.Rows.Clear(); foreach (var designation in DesignationsHelper.GetDesignationsModelList()) { int row = dgvDesignationList.Rows.Add(); dgvDesignationList.Rows[row].Cells[0].Value = designation.DesignationID; dgvDesignationList.Rows[row].Cells[1].Value = designation.Name; row++; } }
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 btnAdd_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 (txtTcNo.Text.Trim().Length != 11) { MessageBox.Show("TC No 11 hanali olmalıdır.", "Library Management System", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (txtContactNo.Text.Trim().Length < 9 || txtContactNo.Text.Trim().Length > 14) { MessageBox.Show("Lütfen geçerli bir telefon numarası giriniz!", "Library Management System", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (check1 && check2 && check3 && check4) { if (!StaffsHelper.HaveTCNO(txtTcNo.Text.Trim()) && !StaffsHelper.HaveContactNo(txtContactNo.Text)) { Staffs s = new Staffs(); 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; s.Status = 1; StaffsHelper.Add(s); MessageBox.Show("Staff Ekleme Başarılı", "Library Management System", MessageBoxButtons.OK, MessageBoxIcon.Information); FillGrid(); } else { MessageBox.Show("Girdiğiniz TC veya Telefon numarası sistemde kayıtlıdır.", "Library Management System", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void btnAdd_Click(object sender, EventArgs e) { if (txtDesignation.Text.Trim().Length == 0) { MessageBox.Show("Lütfen Designation ismini giriniz!", "Library Management System", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Designations d = new Designations(); d.Name = txtDesignation.Text; DesignationsHelper.Add(d); MessageBox.Show("Designation ekleme başarılı", "Library Management System", MessageBoxButtons.OK, MessageBoxIcon.Information); FillGrid(); }
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(); } }