Exemplo n.º 1
0
        private void btXoa_Click(object sender, EventArgs e)
        {
            try
            {
                frmXacNhanXoaNV xn = new frmXacNhanXoaNV();
                xn.ShowDialog();

                string MaNhanVien;
                MaNhanVien = txtMaNV.Text;
                NhanVienDTO quantri = new NhanVienDTO(MaNhanVien);


                if (string.IsNullOrEmpty(txtMaNV.Text))
                {
                    return;
                }

                int numOfRows = quantriBUS.Delete(quantri);
                if (numOfRows == 0)
                {
                    MessageBox.Show("Xóa thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("Xóa thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                GridNhanVien.DataSource = quantriBUS.GetNhanVien();
            }
            catch (SqlException ex)
            {
                MessageBox.Show("Lỗi hệ thống\n" + ex.Message);
            }
        }
Exemplo n.º 2
0
        private void btXoa_Click(object sender, EventArgs e)
        {
            frmXacNhanXoaNV xn = new frmXacNhanXoaNV();

            xn.ShowDialog();
            string        cnsql = "Data Source=.;Initial Catalog=QLPetMarket;Integrated Security=True";
            SqlConnection cn    = new SqlConnection(cnsql);

            cn.Open();
            string     sql = "DELETE FROM NhanVien WHERE MaNhanVien = '" + txtMaNV.Text + "'";
            SqlCommand cmd = new SqlCommand(sql, cn);

            if (string.IsNullOrEmpty(txtMaNV.Text))
            {
                return;
            }

            int numOfRows = cmd.ExecuteNonQuery();

            if (numOfRows == 0)
            {
                MessageBox.Show("Xóa thất bại", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                MessageBox.Show("Xóa thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            GridNhanVien.DataSource = GetNhanVien();
            cn.Close();
        }
Exemplo n.º 3
0
        private void button4_Click(object sender, EventArgs e)
        {
            frmXacNhanXoaNV xc = new frmXacNhanXoaNV();

            xc.ShowDialog();
            frmXemAccountList xem = new frmXemAccountList();

            xem.Show();
        }