Esempio n. 1
0
 private void btnLuu_Click(object sender, EventArgs e)
 {
     if (Them)
     {
         try
         {
             BLNhanVien blNv = new BLNhanVien();
             blNv.ThemNhanVien(this.txtMaNV.Text.Trim(), this.txtHoTen.Text.Trim(), this.dtpNgaySinh.Value,
                               this.cbxGioiTinh.Text, this.txtCMND.Text.Trim(), this.txtDiaChi.Text.Trim(), this.cbxMaChucVu.Text.Trim(), ref err);
             LoadData();
             MessageBox.Show("Đã Thêm Xong");
         }
         catch (SqlException)
         {
             MessageBox.Show("ko thêm đc. Lỗi r!.");
         }
     }
     else
     {
         BLNhanVien blNv = new BLNhanVien();
         blNv.CapNhatNhanVien(this.txtMaNV.Text.Trim(), this.txtHoTen.Text.Trim(), this.dtpNgaySinh.Value,
                              this.cbxGioiTinh.Text, this.txtCMND.Text.Trim(), this.txtDiaChi.Text.Trim(), this.cbxMaChucVu.Text.Trim(), ref err);
         LoadData();
         MessageBox.Show("Đã sửa xong");
     }
 }
Esempio n. 2
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (Them == true)
            {
                //try
                //{
                // Thực hiện lệnh
                BLNhanVien blTp = new BLNhanVien();
                blTp.ThemNV(txtMaNV.Text, txtTenNV.Text, txtNgaySinh.Text, txtDiaChi.Text, txtGioiTinh.Text, txtPhong.Text, ref err);
                // Load lại dữ liệu trên DataGridView
                LoadData();
                // Thông báo
                MessageBox.Show("Đã thêm xong!");
                //}
                //catch (SqlException)
                //{
                //    MessageBox.Show("Không thêm được. Lỗi rồi!");
                //}
            }
            else
            {
                // Thực hiện lệnh
                BLNhanVien blTp = new BLNhanVien();
                blTp.CapNhatNhanVien(txtMaNV.Text, txtTenNV.Text, txtNgaySinh.Text, txtDiaChi.Text, txtGioiTinh.Text, txtPhong.Text, ref err);

                // Load lại dữ liệu trên DataGridView
                LoadData();
                // Thông báo
                MessageBox.Show("Đã sửa xong!");
            }
        }
Esempio n. 3
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (Them)
     {
         try
         {
             if (dbNV.ThemNhanVien(this.txtMaNV.Text.Trim(), this.txtHovalotNV.Text.Trim(), this.txtTenNV.Text.Trim(), cbbMaCV.Text, int.Parse(nmrSoGioLam.Value.ToString()), NQL, cbChiNhanh.SelectedValue.ToString(), ref err))
             {
                 MessageBox.Show("Đã thêm xong!");
                 dbDangNhap.TaoTaiKhoan(txtMaNV.Text.Trim(), "1", ref err);
                 dbDangNhap.Encrypt(txtMaNV.Text.Trim());
             }
             LoadData();
         }
         catch (SqlException)
         {
             MessageBox.Show("Không thêm được. Lỗi rồi!");
         }
     }
     else
     {
         dbNV.CapNhatNhanVien(this.txtHovalotNV.Text.Trim(), this.txtTenNV.Text.Trim(), this.cbbMaCV.Text, this.txtMaNV.Text, int.Parse(nmrSoGioLam.Value.ToString()), NQL, cbChiNhanh.SelectedValue.ToString(), ref err);
         LoadData();
         MessageBox.Show("Đã sửa xong!");
     }
 }
Esempio n. 4
0
        private void btnLuu_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            if (them)
            {
                try
                {
                    BLNhanVien blNV = new BLNhanVien();
                    if (pic1.Image == null)
                    {
                        blNV.ThemNhanVien(MaNV, TenNV, GioiTinh, NgaySinh, CMND, DiaChi, SDT, NgayNhapLam, null, ref err);
                    }
                    else
                    {
                        blNV.ThemNhanVien(MaNV, TenNV, GioiTinh, NgaySinh, CMND, DiaChi, SDT, NgayNhapLam, imageToByteArray(pic1.Image), ref err);
                    }

                    LoadData();

                    XtraMessageBox.Show("Đã thêm xong!");
                }
                catch
                {
                    XtraMessageBox.Show("Không thêm được. Lỗi rồi!");
                }
            }
            else
            {
                BLNhanVien blNV = new BLNhanVien();
                if (pic1.Image == null)
                {
                    blNV.CapNhatNhanVien(MaNV, TenNV, GioiTinh, NgaySinh, CMND, DiaChi, SDT, NgayNhapLam, null, ref err);
                }
                else
                {
                    blNV.CapNhatNhanVien(MaNV, TenNV, GioiTinh, NgaySinh, CMND, DiaChi, SDT, NgayNhapLam, imageToByteArray(pic1.Image), ref err);
                }

                LoadData();

                XtraMessageBox.Show("Đã sửa xong!");
            }
        }
Esempio n. 5
0
 private void btnLuu_Click(object sender, EventArgs e)
 {
     BLNV = new BLNhanVien();
     if (Them)
     {
         if (this.txtTenDangNhap.Text == "")
         {
             MessageBox.Show("Bạn chưa nhập ID!", "Thông báo",
                             MessageBoxButtons.OK, MessageBoxIcon.Warning);
             this.txtTenDangNhap.Focus();
         }
         else
         {
             try
             {
                 if (BLNV.ThemNhanVien(this.txtTenDangNhap.Text, this.txtMatKhau.Text, this.txtHoVaTen.Text, this.txtDiaChi.Text, this.txtSDT.Text, this.txtEmail.Text, this.txtPhanQuyen.Text, ref err))
                 {
                     LoadData();
                     MessageBox.Show("Đã thêm xong!");
                     Default_Button();
                 }
                 else
                 {
                     MessageBox.Show(err, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
             catch (SqlException)
             {
                 MessageBox.Show("Không thêm được. Lỗi rồi!");
             }
         }
     }
     else
     {
         try
         {
             if (BLNV.CapNhatNhanVien(this.txtTenDangNhap.Text, this.txtMatKhau.Text, this.txtHoVaTen.Text, this.txtDiaChi.Text, this.txtSDT.Text, this.txtEmail.Text, this.txtPhanQuyen.Text, ref err))
             {
                 LoadData();
                 MessageBox.Show("Đã sửa xong!");
                 Default_Button();
                 this.txtTenDangNhap.Enabled = true;
             }
             else
             {
                 MessageBox.Show(this.err);
             }
         }
         catch (SqlException)
         {
             MessageBox.Show("Không sửa được. Lỗi rồi!");
         }
     }
 }
Esempio n. 6
0
 private void saveToolStripMenuItem_Click(object sender, EventArgs e)
 {
     dgvNHANVIEN.Enabled = true;
     if (isThem == true)
     {
         try
         {
             BLNhanVien blNV = new BLNhanVien();
             blNV.ThemNhanVien(txtMaNV.Text, txtHo.Text, txtTenLot.Text,
                               txtTen.Text, dtpNgaySinh.Value, cbbGioiTinh.Text,
                               cbbTenPhong.Text, txtLuongCB.Text, txtDienThoai.Text,
                               pcbHinhAnh.Image, ref err);
             LoadData();
             MessageBox.Show("Đã thêm xong!");
         }
         catch
         {
             MessageBox.Show("Đã xảy ra lỗi! Không thêm được mẫu tin!");
         }
     }
     else
     {
         try
         {
             BLNhanVien blNV = new BLNhanVien();
             blNV.CapNhatNhanVien(txtMaNV.Text, txtHo.Text, txtTenLot.Text,
                                  txtTen.Text, dtpNgaySinh.Value, cbbGioiTinh.Text,
                                  cbbTenPhong.Text, txtLuongCB.Text, txtDienThoai.Text,
                                  pcbHinhAnh.Image, ref err);
             LoadData();
             MessageBox.Show("Đã sửa xong!");
         }
         catch
         {
             MessageBox.Show("Đã xảy ra lỗi! Không sửa được mẫu tin!");
         }
     }
 }
 private void btnSave_Click(object sender, EventArgs e)
 {
     if (Them)
     {
         try
         {
             BLNhanVien blNV = new BLNhanVien();
             blNV.ThemNhanVien(this.txtMaNV.Text.Trim(), this.txtHovalotNV.Text.Trim(), this.txtTenNV.Text.Trim(), cbbMaCV.Text, 0, 0, ref err);
             LoadData();
             MessageBox.Show("Đã thêm xong!");
         }
         catch (SqlException)
         {
             MessageBox.Show("Không thêm được. Lỗi rồi!");
         }
     }
     else
     {
         BLNhanVien blNV = new BLNhanVien();
         blNV.CapNhatNhanVien(this.txtHovalotNV.Text.Trim(), this.txtTenNV.Text.Trim(), this.cbbMaCV.Text, Int32.Parse(lblNghiThang.Text), Int32.Parse(lblNghiNam.Text), this.txtMaNV.Text, ref err);
         LoadData();
         MessageBox.Show("Đã sửa xong!");
     }
 }