private void btnAddEmployee_Click(object sender, EventArgs e) { if (ck.checkNullTextbox(txtName.Text.ToString()) && ck.checkNullTextbox(txtAddress.Text.ToString()) && ck.checkNullTextbox(txtPhone.Text.ToString())) { if (ck.numberPhone(txtPhone.Text.ToString())) { if (ck.IsNaturalNumber(txtPhone.Text.ToString())) { DTO.NhanVien nv = new DTO.NhanVien(); nv.name = txtName.Text; nv.phone = txtPhone.Text; nv.address = txtAddress.Text; nv.salaryperday = int.Parse(cbSalaryPerDay.Text); bll.insertNV(nv); reset(); loadDgv(); } else { lbErrorPhone.Text = "Định dạng phải là số!"; } } else { lbErrorPhone.Text = "Số điện thoại không đủ!"; } } else { lbErrorName.Text = "Thông tin bắt buộc!"; lbErrorPhone.Text = "Thông tin bắt buộc!"; lbErrorAddress.Text = "Thông tin bắt buộc!"; } }
private void btnDetele_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("Xác nhận xóa nhân viên", "THÔNG BÁO", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (result == DialogResult.Yes) { DTO.NhanVien nv = new DTO.NhanVien(); nv.id_nv = id; bll.deleteNV(nv); loadDgv(); reset(); } else { MessageBox.Show("Hủy xóa nhân viên", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void btnUpdate_Click(object sender, EventArgs e) { if (ck.checkNullTextbox(txtName.Text.ToString()) && ck.checkNullTextbox(txtPhone.Text.ToString()) && ck.checkNullTextbox(txtAddress.Text.ToString())) { if (ck.numberPhone(txtPhone.Text.ToString())) { if (ck.IsNaturalNumber(txtPhone.Text.ToString())) { DialogResult result = MessageBox.Show("Xác nhận thay đổi thông tin nhân viên.", "THÔNG BÁO", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); if (result == DialogResult.Yes) { DTO.NhanVien nv = new DTO.NhanVien(); nv.id_nv = id; nv.name = txtName.Text; nv.address = txtAddress.Text; nv.phone = txtPhone.Text; nv.salaryperday = int.Parse(cbSalaryPerDay.Text); bll.updateNV(nv); loadDgv(); reset(); } } else { lbErrorPhone.Text = "Định dạng phải là số!"; } } else { lbErrorPhone.Text = "Số điện thoại không đủ!"; } } else { MessageBox.Show("Thiếu thông tin nhân viên", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }