Beispiel #1
0
 public bool AddTheDocGiaAndUser(TheDocGiaDtos DocGia, UserDtos user)
 {
     try
     {
         using (var db = new QuanLyThuVienEntities())
         {
             int ID = TheDocGiaDAO.Instance.IDPlus();
             db.THEDOCGIAs.Add(new THEDOCGIA()
             {
                 IDDocGia   = ID,
                 HoTenDG    = DocGia.HoTenDG,
                 DiaChiDG   = DocGia.DiaChiDG,
                 EmailDG    = DocGia.EmailDG,
                 NgaySinhDG = DocGia.NgaySinhDG,
                 NgayLapThe = DocGia.NgayLapThe,
                 IDLoaiDG   = DocGia.IDLoaiDocGia,
                 TongNo     = 0,
                 NgayHetHan = TheDocGiaDAO.Instance.countHanThe(DocGia.NgayLapThe),
             });
             db.USERS.Add(new USER()
             {
                 IDDocGia = ID,
                 UserName = user.UserName,
                 Pwd      = user.Password,
             });
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
Beispiel #2
0
 // Add List "THeDocGia" and "User"
 public void AddTheDocGiaAndUser(TheDocGiaDtos DocGia, UserDtos user)
 {
     _TheDocGiaBUS.AddTheDocGiaAndUser(DocGia, user);
 }
Beispiel #3
0
 private void bt_CNDL_Click(object sender, EventArgs e)
 {
     if (string.IsNullOrEmpty(tb_HoTenDG.Text))
     {
         MessageBox.Show("Không được để trống họ tên độc giả.", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Warning); tb_HoTenDG.Focus();
     }
     else if (string.IsNullOrEmpty(tb_User.Text))
     {
         MessageBox.Show("Không được để trống Tài khoản.", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Warning); tb_User.Focus();
     }
     else if (string.IsNullOrEmpty(tb_Passwork.Text))
     {
         MessageBox.Show("Không được để trống Passwork.", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Warning); tb_Passwork.Focus();
     }
     else if (string.IsNullOrEmpty(tb_Diachi.Text))
     {
         MessageBox.Show("Không được để trống địa chỉ.", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Warning); tb_Diachi.Focus();
     }
     else if (string.IsNullOrEmpty(tb_Email.Text))
     {
         MessageBox.Show("Không được để trống Email.", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Warning); tb_Email.Focus();
     }
     else if (HelperGUI.Instance.checkIsMail(tb_Email) == false)
     {
         MessageBox.Show("Email không hợp lệ", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Warning); tb_Email.Focus();
     }
     else if (string.IsNullOrEmpty(cb_LoaiDocGia.Text))
     {
         MessageBox.Show("Không được để trống loại độc giả.", "Chú ý", MessageBoxButtons.OK, MessageBoxIcon.Warning); cb_LoaiDocGia.Focus();
     }
     else
     {
         try
         {
             TheDocGiaService sv   = new TheDocGiaService();
             TheDocGiaDtos    tdg  = new TheDocGiaDtos();
             UserDtos         user = new UserDtos();
             HoTenDG          = HelperGUI.Instance.KiemTraHoTen(tb_HoTenDG.Text);
             UserName         = tb_User.Text;
             Pwd              = tb_Passwork.Text;
             DiaChiDG         = tb_Diachi.Text;
             EmailDG          = tb_Email.Text;
             NgayLapThe       = dt_NgayLT.Value;
             tdg.HoTenDG      = HoTenDG;
             tdg.IDLoaiDocGia = IDLoaiDG;
             tdg.NgayLapThe   = NgayLapThe;
             tdg.NgaySinhDG   = NgaySinhDG;
             tdg.DiaChiDG     = DiaChiDG;
             tdg.EmailDG      = EmailDG;
             user.Password    = Pwd;
             user.UserName    = UserName;
             sv.AddTheDocGiaAndUser(tdg, user);
             MessageBox.Show("Thêm thành công!");
             fillAllDataFromTableTheDocGia();
             HelperGUI.ResetAllControls(groupControl_TTDG);
         }
         catch
         {
         }
     }
 }