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