예제 #1
0
 private void btnCapNhat_Click(object sender, EventArgs e)
 {
     if (KiemTraDuLieuHopLe())
     {
         if (DialogResult.Yes == MessageBox.Show("Cập nhật tài khoản có mã " + txtMaDangNhap.Text, "Cập nhật nhân viên", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
         {
             TaiKhoan_BUS    bus = new TaiKhoan_BUS();
             clsTaiKhoan_DTO TK  = TaoDoiTuongTaiKhoan();
             try
             {
                 if (bus.ThaoTacVoiTaiKhoan(TK, "Update"))
                 {
                     //MessageBox.Show("Cập nhật thành công");
                     HienThiDSTaiKhoan();
                 }
                 else
                 {
                     MessageBox.Show("Cập nhật thất bại");
                 }
             }
             catch (Exception)
             {
                 throw;
             }
             TrangThaiBanDau();
         }
     }
     else
     {
         MessageBox.Show(strError, "Lỗi nhập liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     strError = "";
 }
예제 #2
0
        string strWarning   = ""; // Cảnh báo trường dữ liệu nhập có thể sai. Nhưng vẫn thêm được vào cơ sở dữ liệu.
        private void btnDongY_Click(object sender, EventArgs e)
        {
            if (KiemTraDuLieuHopLe())
            {
                string         strThongBao = "Thêm mới nhân viên " + txtHoTen.Text + "\n";
                MessageBoxIcon MBIcon      = MessageBoxIcon.Question;
                if (strWarning != "")
                {
                    strThongBao = strWarning + "\n Vẫn muốn tiếp tục?";
                    MBIcon      = MessageBoxIcon.Warning;
                }

                if (DialogResult.Yes == MessageBox.Show(strThongBao, "Xác nhận thêm", MessageBoxButtons.YesNo, MBIcon))
                {
                    NhanVien_BUS busNhanVien = new NhanVien_BUS();
                    TaiKhoan_BUS busTaiKhoan = new TaiKhoan_BUS();

                    destFileName = TaoDuongDanAnh(); // Lưu đường dẫn ảnh trước khi TaoNhanVien

                    clsNhanVien_DTO NV = TaoDoiTuongNhanVien();
                    clsTaiKhoan_DTO TK = TaoDoiTuongTaiKhoanNhanVien();

                    try
                    {
                        if (busNhanVien.ThaoTacVoiDoiTuongNhanVien(NV, "Add") && busTaiKhoan.ThaoTacVoiTaiKhoan(TK, "Add"))
                        {
                            if (KiemTraHinhAnh())
                            {
                                File.Copy(fd.FileName, destFileName);
                            }
                            //MessageBox.Show("Đã thên nhân viên mới");
                            TuPhatSinhMaNhanVien();
                            TrangThaiBanDau();
                        }
                        else
                        {
                            MessageBox.Show("Thêm thất bại");
                        }
                    }
                    catch (Exception) { }
                    //TrangThaiBanDau();
                }
                else
                {
                    //MessageBox.Show("Hủy thao tác");
                }
            }
            else
            {
                MessageBox.Show(strError, "Lỗi nhập liệu", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            strError     = "";
            destFileName = "";
            strWarning   = "";
        }