Ejemplo n.º 1
0
        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);
            }
        }