private void ButtonAdd_Click(object sender, EventArgs e) { DangKi dk = new DangKi(); string tk = txtTaiKhoan.Text; if (verif() && kiemtra(tk)) { string mk1 = txtMatKhau1.Text; string mk2 = txtMatKhau2.Text; if (kiemtraTaiKhoan(tk) == false) { if (dk.insertTaiKhoan(tk, mk1)) { MessageBox.Show("New TaiKhoan Added"); } else { MessageBox.Show("Error"); } } else { MessageBox.Show("Đăng Kí Không Thành Công"); } } else { MessageBox.Show("Empty Fields"); } }
private void buttonXoa_Click(object sender, EventArgs e) { NguoiLaoDong nguoilaodong = new NguoiLaoDong(); if (radioButton1.Checked == true) { DangKi dk = new DangKi(); try { string ma = Convert.ToString(txtMa.Text); dk.deleteTaiKhoan(ma); if ((MessageBox.Show("Are You Sure You Want To Delete This KySu", "Delete KySu", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)) { if (nguoilaodong.deleteNguoiLaoDong(ma)) { MessageBox.Show("KySu Deleted", "Delete KySu", MessageBoxButtons.OK, MessageBoxIcon.Information); txtMa.Text = null; txtTen.Text = null; txtSDT.Text = null; txtDCtamtru.Text = null; ComboBoxChucVu.Text = null; ComboBoxDVTT.Text = null; ComboBoxTrinhDo.Text = null; ComboBoxChuyenMon.Text = null; radioButtonMale.Checked = true; dateTimeNgaysinh.Value = DateTime.Now; pictureBoxImage.Image = null; } else { MessageBox.Show("KySu Enter A Valid ID", "Delete KySu", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch { MessageBox.Show("Please Enter A Valid ID", "Delete KySu", MessageBoxButtons.OK, MessageBoxIcon.Information); } getdata(); labelNguoiLaoDong.Text = ("Tổng Người Lao Động trong danh sách: " + DataGridView1.RowCount); } if (radioButton2.Checked == true) { try { string ma = Convert.ToString(txtMa.Text); if ((MessageBox.Show("Are You Sure You Want To Delete This NhanVien", "Delete NhanVien", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)) { if (nguoilaodong.deleteNguoiLaoDong(ma)) { MessageBox.Show("NhanVien Deleted", "Delete NhanVien", MessageBoxButtons.OK, MessageBoxIcon.Information); txtMa.Text = null; txtTen.Text = null; txtSDT.Text = null; txtDCtamtru.Text = null; ComboBoxChucVu.Text = null; ComboBoxDVTT.Text = null; ComboBoxTrinhDo.Text = null; ComboBoxChuyenMon.Text = null; radioButtonMale.Checked = true; dateTimeNgaysinh.Value = DateTime.Now; pictureBoxImage.Image = null; } else { MessageBox.Show("NhanVien Enter A Valid ID", "Delete NhanVien", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch { MessageBox.Show("Please Enter A Valid ID", "Delete NhanVien", MessageBoxButtons.OK, MessageBoxIcon.Information); } getdata(); labelNguoiLaoDong.Text = ("Tổng Người Lao Động trong danh sách: " + DataGridView1.RowCount); } if (radioButton3.Checked == true) { try { string ma = Convert.ToString(txtMa.Text); if ((MessageBox.Show("Are You Sure You Want To Delete This CongNhan", "Delete CongNhan", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)) { if (nguoilaodong.deleteNguoiLaoDong(ma)) { MessageBox.Show("CongNhan Deleted", "Delete CongNhan", MessageBoxButtons.OK, MessageBoxIcon.Information); txtMa.Text = null; txtTen.Text = null; txtSDT.Text = null; txtDCtamtru.Text = null; ComboBoxChucVu.Text = null; ComboBoxDVTT.Text = null; ComboBoxTrinhDo.Text = null; ComboBoxChuyenMon.Text = null; radioButtonMale.Checked = true; dateTimeNgaysinh.Value = DateTime.Now; pictureBoxImage.Image = null; } else { MessageBox.Show("CongNhan Enter A Valid ID", "Delete CongNhan", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch { MessageBox.Show("Please Enter A Valid ID", "Delete CongNhan", MessageBoxButtons.OK, MessageBoxIcon.Information); } getdata(); labelNguoiLaoDong.Text = ("Tổng Người Lao Động trong danh sách: " + DataGridView1.RowCount); } }