예제 #1
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (txtNhanVien.Text == "")
            {
                MessageBox.Show("Chưa chọn thông tin!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            NhanVienObjTr ctdObj = new NhanVienObjTr();

            ctdObj.maNV = lblMaNV.Text;


            //nv.Luong = int.Parse(txtLuong.Text);
            //nv.GioiTinh = rdbNam.Checked ? "Nam" : "Nữ";
            //nv.NgaySinh = dtpNgaySinh.Value;
            //nv.MaPhongBan = cmbMaPhongBan.SelectedText;
            if (MessageBox.Show(string.Format("Xóa Nhân Viên có Mã nhân viên {0}", lblMaNV.Text), "Thông Báo", MessageBoxButtons.OKCancel) == DialogResult.OK)
            {
                if (NhanVienCtrlTr.DeleteNhanVien(ctdObj) > 0)
                {
                    MessageBox.Show("Xóa thành công!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    UcNhanVien_Load(sender, e);
                }
                else
                {
                    MessageBox.Show("Không thể xóa bản ghi hiện thời!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
예제 #2
0
 public static int DeleteNhanVien(NhanVienObjTr ctd)
 {
     SqlParameter[] para = new SqlParameter[]
     {
         new SqlParameter("@manv", ctd.maNV)
     };
     return(ConnetctToSQLTr.ExecuteNonQuery("XoaNhanVien", para));
 }
예제 #3
0
 public static int UpdateNhanVien(NhanVienObjTr ctd)
 {
     SqlParameter[] para = new SqlParameter[]
     {
         new SqlParameter("@manv", ctd.maNV),
         new SqlParameter("@hoten", ctd.HoTen),
         new SqlParameter("@ngaysinh", ctd.NgaySinh),
         new SqlParameter("@gioitinh", ctd.GioiTinh),
         new SqlParameter("@socmnd", ctd.SoCMND),
         new SqlParameter("@sdt", ctd.SDT),
         new SqlParameter("@macv", ctd.MaCV),
         new SqlParameter("@mapb", ctd.MaPB),
         new SqlParameter("@mahd", ctd.MaHD)
     };
     return(ConnetctToSQLTr.ExecuteNonQuery("SuaNhanVien", para));
 }
예제 #4
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            this.btnLuu.Visible  = false;
            this.btnHuy.Visible  = false;
            this.btnThem.Visible = true;
            this.btnSua.Visible  = true;
            this.btnXoa.Visible  = true;

            this.btnThoat.Visible = true;
            txtNhanVien.Enabled   = false;
            txtSDT.Enabled        = false;
            txtCMND.Enabled       = false;
            dtpNgaySinh.Enabled   = false;
            cmbChucVu.Enabled     = false;
            cmbHopDong.Enabled    = false;
            cmbPhongBan.Enabled   = false;
            txtTimKiem.Enabled    = true;
            try
            {
                if (m_chucnang == "them")
                {
                    if (txtNhanVien.Text == "")
                    {
                        MessageBox.Show("Chưa chọn thông tin!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    else
                    {
                        NhanVienObjTr ctdObj = new NhanVienObjTr();
                        ctdObj.maNV     = lblMaNV.Text;
                        ctdObj.HoTen    = txtNhanVien.Text.Trim();
                        ctdObj.NgaySinh = dtpNgaySinh.Value;
                        ctdObj.GioiTinh = rbtNam.Checked ? "Nam" : "Nữ";
                        ctdObj.SoCMND   = int.Parse(txtCMND.Text.Trim());
                        ctdObj.SDT      = txtSDT.Text.Trim();
                        ctdObj.MaCV     = cmbChucVu.SelectedValue.ToString();
                        ctdObj.MaHD     = cmbHopDong.SelectedValue.ToString();
                        ctdObj.MaPB     = cmbPhongBan.SelectedValue.ToString();

                        if (MessageBox.Show(string.Format("Thêm  Nhân Viên có Mã nhân viên {0}", lblMaNV.Text), "Thông Báo", MessageBoxButtons.OKCancel) == DialogResult.OK)
                        {
                            if (NhanVienCtrlTr.InsertNhanVien(ctdObj) > 0)
                            {
                                MessageBox.Show("Thêm mới thành công.", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                UcNhanVien_Load(sender, e);
                            }
                            else
                            {
                                MessageBox.Show("Mã Nhân Viên đã có,Vui Lòng Nhập Lại", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                    }
                }
                if (m_chucnang == "sua")
                {
                    if (txtNhanVien.Text == "")
                    {
                        MessageBox.Show("Chưa chọn thông tin!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                    else
                    {
                        NhanVienObjTr ctdObj = new NhanVienObjTr();
                        ctdObj.maNV     = lblMaNV.Text;
                        ctdObj.HoTen    = txtNhanVien.Text.Trim();
                        ctdObj.NgaySinh = dtpNgaySinh.Value;
                        ctdObj.GioiTinh = rbtNam.Checked ? "Nam" : "Nữ";
                        ctdObj.SoCMND   = int.Parse(txtCMND.Text.Trim());
                        ctdObj.SDT      = txtSDT.Text.Trim();
                        ctdObj.MaCV     = cmbChucVu.SelectedValue.ToString();
                        ctdObj.MaHD     = cmbHopDong.SelectedValue.ToString();
                        ctdObj.MaPB     = cmbPhongBan.SelectedValue.ToString();

                        if (MessageBox.Show(string.Format("Sửa Nhân Viên có Mã nhân viên {0}", lblMaNV.Text), "Thông Báo", MessageBoxButtons.OKCancel) == DialogResult.OK)
                        {
                            if (NhanVienCtrlTr.UpdateNhanVien(ctdObj) > 0)
                            {
                                MessageBox.Show("Sửa thành công", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                UcNhanVien_Load(sender, e);
                            }
                            else
                            {
                                MessageBox.Show("Không Sửa Được!", "Thông Báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Lỗi Xảy Ra!", "Thông Báo");
            }
        }
예제 #5
0
 public static int DeleteNhanVien(NhanVienObjTr ctd)
 {
     return(NhanVienModTr.DeleteNhanVien(ctd));
 }
예제 #6
0
 public static int UpdateNhanVien(NhanVienObjTr ctd)
 {
     return(NhanVienModTr.UpdateNhanVien(ctd));
 }
예제 #7
0
 public static int InsertNhanVien(NhanVienObjTr ctd)
 {
     return(NhanVienModTr.InsertNhanVien(ctd));
 }