Beispiel #1
0
 public void InitData(PYC pyc, List <D_PYC_ViewModel> data)
 {
     using (var db = new RestaurantManagerDataEntities())
     {
         var toDay = DateTime.Now;
         lblidpyc.Text      = pyc.idyc.ToString();
         lblFooterDate.Text = string.Format("Ngày {0} tháng {1} năm {2}", toDay.Day, toDay.Month, toDay.Year);
         ///var details = new PYCBll().GetListD_PYC(pyc.idyc);
         objectDataSource1.DataSource = data;
     }
 }
Beispiel #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                using (var db = new RestaurantManagerDataEntities())
                {
                    int idpnhap  = int.Parse(txtid.Text);
                    var ngaynhap = dtngaynhap.Value;
                    int.TryParse(lueDONGIAO.EditValue.ToString(), out int idgiaohang);
                    int.TryParse(lueStorekeeper.EditValue.ToString(), out int thukho);
                    string thukhoName = lueStorekeeper.Text;
                    string nguoigiao  = txtNguoiGiao.Text;
                    string nguoinhap  = txtNguoiNhan.Text;

                    if (ngaynhap == null)
                    {
                        XtraMessageBox.Show("Bạn chưa chọn ngày nhập!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    if (lstD_PNHAP_ViewModel.Count == 0)
                    {
                        XtraMessageBox.Show("Bạn chưa nhập hàng hóa!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }

                    if (lstD_PNHAP_ViewModel.Count() == 0)
                    {
                        XtraMessageBox.Show("Bạn chưa nhập hàng hóa!", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    var model   = new PNHAP_ViewModel();
                    var nameLog = Properties.Settings.Default.NameLog;
                    model.idpnhap       = idpnhap;
                    model.idpgiao       = idgiaohang;
                    model.ngaynhap      = ngaynhap;
                    model.thukho        = thukhoName;
                    model.nguoilapphieu = nameLog;
                    model.nguoigiao     = nameLog;
                    var res = new PNHAPBll().savePNHAP(model, lstD_PNHAP_ViewModel, Properties.Settings.Default.NameLog);
                    if (res != "success")
                    {
                        XtraMessageBox.Show(res, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                    XtraMessageBox.Show("Thêm phiếu giao hàng thành công!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show(ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Beispiel #3
0
        public void InitData(DateTime fromday, DateTime today, List <HOADONTT_ViewModel> data)
        {
            using (var db = new RestaurantManagerDataEntities())
            {
                var toDay = DateTime.Now;
                lblfromday.Text = fromday.ToString("dd/MM/yyyy");
                lbltoday.Text   = today.ToString("dd/MM/yyyy");

                lblFooterDate.Text = string.Format("Ngày {0} tháng {1} năm {2}", toDay.Day, toDay.Month, toDay.Year);
                ///var details = new PYCBll().GetListD_PYC(pyc.idyc);
                objectDataSource3.DataSource = data;
            }
        }
Beispiel #4
0
 public void InitData(DONMH_ViewModel obj, List <D_DONMH_ViewModel> lstDetail)
 {
     using (var db = new RestaurantManagerDataEntities())
     {
         var toDay = DateTime.Now;
         lbliddonmua.Text             = obj.iddonmh.ToString();
         lbldiachi.Text               = obj.diachi;
         lbltenncc.Text               = obj.tenncc;
         lblsdt.Text                  = obj.sdt;
         lblFooterDate.Text           = string.Format("Ngày {0} tháng {1} năm {2}", toDay.Day, toDay.Month, toDay.Year);
         objectDataSource3.DataSource = lstDetail;
     }
 }
Beispiel #5
0
        public HOADONTT AddHOADONTT(HOADONTT_ViewModel model)
        {
            using (var db = new RestaurantManagerDataEntities())
            {
                using (var trans = db.Database.BeginTransaction())
                {
                    try
                    {
                        var check = db.HOADONTTs.FirstOrDefault(x => x.idhoadontt == model.idhoadontt);
                        if (check == null)
                        {
                            var HOADONTT = new HOADONTT
                            {
                                iddondat   = model.iddondat,
                                ngayhd     = model.ngayhd,
                                thoigian   = DateTime.Now,
                                thungan    = model.CreateBy,
                                idkh       = model.idkh,
                                CreateBy   = model.CreateBy,
                                CreateDate = DateTime.Now,
                            };
                            var result = db.HOADONTTs.Add(HOADONTT);
                            db.SaveChanges();

                            foreach (D_HOADONTT_ViewModel item in model.D_HOADONTT)
                            {
                                var D_HOADONTT = new D_HOADONTT
                                {
                                    idhoadontt = HOADONTT.idhoadontt,
                                    idmon      = item.idmon,
                                    slban      = item.slban,
                                    dongiaban  = item.dongiaban,
                                    CreateBy   = model.CreateBy,
                                    CreateDate = DateTime.Now,
                                };
                                db.D_HOADONTT.Add(D_HOADONTT);
                            }
                            db.SaveChanges();
                            trans.Commit();
                            return(result);
                        }
                    }
                    catch
                    {
                        trans.Rollback();
                        return(null);
                    }
                    return(null);
                }
            }
        }
Beispiel #6
0
 public void InitData(DONDATDA_ViewModel obj, List <D_DONDATDA_ViewModel> data)
 {
     using (var db = new RestaurantManagerDataEntities())
     {
         var toDay = DateTime.Now;
         lblid.Text                   = obj.iddondat.ToString();
         lblKhachHang.Text            = obj.tenkh.ToString();
         lblsdt.Text                  = obj.sdt.ToString();
         lblBan.Text                  = obj.ban.ToString();
         lblNgay.Text                 = obj.ngaydat.Value.ToString("dd/MM/yyyy");
         lblFooterDate.Text           = string.Format("Ngày {0} tháng {1} năm {2}", toDay.Day, toDay.Month, toDay.Year);
         objectDataSource2.DataSource = data;
     }
 }
Beispiel #7
0
        public string AddGIAOHANG(GIAOHANG_ViewModel model, List <D_GIAOHANG_ViewModel> lstD_GIAOHANG, string userLogin)
        {
            try
            {
                using (var db = new RestaurantManagerDataEntities())
                {
                    var check = db.GIAOHANGs.FirstOrDefault(x => x.idpgiao == model.idpgiao);
                    if (check == null)
                    {
                        var GIAOHANG = new GIAOHANG
                        {
                            iddonmh       = model.iddonmh,
                            idncc         = model.idncc,
                            diachi        = model.diachi,
                            cuahang       = model.cuahang,
                            ngaygiao      = model.ngaygiao,
                            nguoigiao     = model.nguoigiao,
                            nguoilapphieu = model.nguoilapphieu,
                            nguoinhan     = model.nguoinhan,
                            CreateBy      = userLogin,
                            CreateDate    = DateTime.Now,
                        };
                        var result = db.GIAOHANGs.Add(GIAOHANG);
                        db.SaveChanges();

                        foreach (D_GIAOHANG_ViewModel item in lstD_GIAOHANG)
                        {
                            var D_GIAOHANG = new D_GIAOHANG
                            {
                                idpgiao    = GIAOHANG.idpgiao,
                                idhang     = item.idhang,
                                slgiaohang = item.slgiaohang,
                                slnhanhang = item.slnhanhang,
                                CreateBy   = userLogin,
                                CreateDate = DateTime.Now,
                            };
                            db.D_GIAOHANG.Add(D_GIAOHANG);
                        }
                        db.SaveChanges();
                        return("success");
                    }
                    return("Tạo phiếu giao hàng không thành công!");
                }
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Beispiel #8
0
 //lấy danh sách đơn chưa thanh toán
 public List <DONDATDA_ViewModel> GetOuterOrder()
 {
     try
     {
         using (var db = new RestaurantManagerDataEntities())
         {
             var result = db.Database.SqlQuery <DONDATDA_ViewModel>("EXEC dbo.Proc_GetDonDatDA_OutLeft").ToList();
             return(result);
         }
     }
     catch
     {
         return(null);
     }
 }
Beispiel #9
0
 //lấy danh sách hóa đơn đặt
 public List <DONDATDA> GetLisDONDATDA()
 {
     try
     {
         using (var db = new RestaurantManagerDataEntities())
         {
             var result = db.DONDATDAs.AsNoTracking().ToList();
             return(result);
         }
     }
     catch
     {
         return(null);
     }
 }
Beispiel #10
0
 public List <KHACHHANG> GetListKHACHHANG()
 {
     try
     {
         using (var db = new RestaurantManagerDataEntities())
         {
             var result = db.KHACHHANGs.AsNoTracking().OrderBy(x => x.idkh).ToList();
             return(result);
         }
     }
     catch
     {
         return(null);
     }
 }
Beispiel #11
0
 public void InitData(PNHAP_ViewModel master, List <D_PNHAP_ViewModel> detail)
 {
     using (var db = new RestaurantManagerDataEntities())
     {
         var toDay = DateTime.Now;
         lblidpnhap.Text              = master.idpnhap.ToString();
         lblidgiaohang.Text           = master.idpgiao.ToString();
         lblngaynhap.Text             = string.Format("{0}/{1}/{2}", master.ngaynhap.Value.Day, master.ngaynhap.Value.Month, master.ngaynhap.Value.Year);
         lblnguoigiao.Text            = master.nguoigiao;
         lblnguoilap.Text             = master.nguoilapphieu;
         lblthukho.Text               = master.thukho;
         objectDataSource2.DataSource = detail;
         lblFooterDate.Text           = string.Format("Ngày {0} tháng {1} năm {2}", toDay.Day, toDay.Month, toDay.Year);
     }
 }
Beispiel #12
0
 /// <summary>
 /// lấy id mới đơn mua hàng
 /// </summary>
 /// <returns></returns>
 public string getNewIdDONMH()
 {
     try
     {
         using (var db = new RestaurantManagerDataEntities())
         {
             var result = db.Database.SqlQuery <DONMH_ViewModel>("EXEC dbo.[Proc_GetNewIdDONMH]").FirstOrDefault();
             return((result.iddonmh).ToString());
         }
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
Beispiel #13
0
 public List <DANHMUC> GetListDANHMUC()
 {
     try
     {
         using (var db = new RestaurantManagerDataEntities())
         {
             var result = db.DANHMUCs.AsNoTracking().OrderBy(x => x.iddmuc).ToList();
             return(result);
         }
     }
     catch
     {
         return(null);
     }
 }
Beispiel #14
0
 public List <NLIEU> GetListNLIEU()
 {
     try
     {
         using (var db = new RestaurantManagerDataEntities())
         {
             var result = db.NLIEUx.AsNoTracking().OrderBy(x => x.idhang).ToList();
             return(result);
         }
     }
     catch
     {
         return(null);
     }
 }
Beispiel #15
0
 public List <USER> GetListUsers()
 {
     try
     {
         using (var db = new RestaurantManagerDataEntities())
         {
             var lst = db.USERS.AsNoTracking().ToList();
             return(lst);
         }
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Beispiel #16
0
 //lấy danh sách hóa đơn
 public List <HOADONM> GetLisHOADONM()
 {
     try
     {
         using (var db = new RestaurantManagerDataEntities())
         {
             var result = db.HOADONMs.AsNoTracking().ToList();
             return(result);
         }
     }
     catch
     {
         return(null);
     }
 }
Beispiel #17
0
 /// <summary>
 /// Get danh sachs mon an co cong thuc
 /// </summary>
 /// <returns></returns>
 public List <MONAN_ViewModel> GetListMONAN_OutLeft()
 {
     try
     {
         using (var db = new RestaurantManagerDataEntities())
         {
             var result = db.Database.SqlQuery <MONAN_ViewModel>("EXEC dbo.Proc_GetMONAN_OutLeft").ToList();
             return(result);
         }
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Beispiel #18
0
 public static int getNewId(string table)
 {
     try
     {
         using (var db = new RestaurantManagerDataEntities())
         {
             var _table = new SqlParameter("@table", table);
             var result = db.Database.SqlQuery <int>("EXEC dbo.[Proc_GetNewId] @table", _table).FirstOrDefault();
             return(result);
         }
     }
     catch
     {
         return(1);
     }
 }
Beispiel #19
0
 public List <PYC_ViewModel> GetListPYC()
 {
     using (var db = new RestaurantManagerDataEntities())
     {
         var result = db.PYCs.AsNoTracking()
                      .Select(p => new PYC_ViewModel
         {
             idyc       = p.idyc,
             ngayyc     = p.ngayyc,
             CreateBy   = p.CreateBy,
             CreateDate = p.CreateDate
         })
                      .ToList();
         return(result);
     }
 }
Beispiel #20
0
 public List <USER> GetUsersByPosition(string position, string loginCode, ref string outmess)
 {
     try
     {
         using (var db = new RestaurantManagerDataEntities())
         {
             var lst = db.USERS.AsNoTracking().Where(e => e.ChucVu == position).ToList();
             outmess = "success";
             return(lst);
         }
     }
     catch (Exception ex)
     {
         outmess = ex.Message;
         return(null);
     }
 }
Beispiel #21
0
 private void btnPrint_Click(object sender, EventArgs e)
 {
     //  var obj = lstD_PYC.Current as PYC;
     if (this.idyc > 0)
     {
         using (var db = new RestaurantManagerDataEntities())
         {
             var obj     = db.PYCs.AsNoTracking().FirstOrDefault(x => x.idyc == this.idyc);
             var details = new PYCBll().GetListD_PYC(this.idyc);
             using (frmPrint frm = new frmPrint())
             {
                 frm.PrintPYC(obj, details);
                 frm.ShowDialog();
             }
         }
     }
 }
Beispiel #22
0
 public DONMH_ViewModel GetDONMHById(int id)
 {
     try
     {
         using (var db = new RestaurantManagerDataEntities())
         {
             var master = (from h in db.DONMHs.AsNoTracking()
                           where h.iddonmh == id
                           join k in db.NCCs.AsNoTracking() on h.idncc equals k.idncc
                           select new DONMH_ViewModel
             {
                 iddonmh = h.iddonmh,
                 ngaydonmh = h.ngaydonmh.Value,
                 idncc = h.idncc,
                 tenncc = k.tenncc,
                 diachi = k.diachi,
                 sdt = k.sdt,
                 CreateBy = h.CreateBy,
                 CreateDate = h.CreateDate
             }
                           ).FirstOrDefault();
             if (master != null)
             {
                 master.lstDetail = (from p in db.D_DONMH.AsNoTracking()
                                     join d in db.NLIEUx.AsNoTracking() on p.idhang equals d.idhang
                                     where p.iddonmh == master.iddonmh
                                     select new D_DONMH_ViewModel
                 {
                     idhang = p.idhang,
                     iddonmh = p.iddonmh,
                     slmh = p.slmh.Value,
                     dongiamh = p.dongiamh.Value,
                     totalamount = p.slmh.Value * p.dongiamh.Value,
                     tenhang = d.tenhang,
                     CreateDate = p.CreateDate,
                     CreateBy = p.CreateBy
                 }).ToList();
             }
             return(master);
         }
     }
     catch
     {
         return(null);
     }
 }
Beispiel #23
0
        public List <HOADONM_ViewModel> GetListFullHOADONM(DateTime FromDate, DateTime ToDate)
        {
            try
            {
                using (var db = new RestaurantManagerDataEntities())
                {
                    var _FromDate = new SqlParameter("@FromDate", FromDate);
                    var _ToDate   = new SqlParameter("@ToDate", ToDate);

                    var result = db.Database.SqlQuery <HOADONM_ViewModel>("EXEC dbo.Proc_GetListHOADONM @FromDate,@ToDate", _FromDate, _ToDate).ToList();
                    return(result);
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Beispiel #24
0
        public void InitData(HOADONM_ViewModel obj, List <D_HOADONM_ViewModel> data)
        {
            using (var db = new RestaurantManagerDataEntities())
            {
                var toDay = DateTime.Now;
                lblid.Text         = obj.idhoadonm.ToString();
                lblFooterDate.Text = string.Format("Ngày {0} tháng {1} năm {2}", toDay.Day, toDay.Month, toDay.Year);
                ///var details = new PYCBll().GetListD_PYC(pyc.idyc);

                lblid.Text      = obj.idhoadonm.ToString();
                lblNCC.Text     = obj.tenncc.ToString();
                lblNgayMua.Text = obj.ngaymua.Value.ToString("dd/MM/yyyy");
                lblDiaChi.Text  = obj.diachi;
                lblsdt.Text     = obj.sdt;

                objectDataSource4.DataSource = data;
            }
        }
Beispiel #25
0
 /// <summary>
 /// ds đơn mua
 /// </summary>
 /// <returns></returns>
 public List <DONMH_ViewModel> GetListDONMH()
 {
     using (var db = new RestaurantManagerDataEntities())
     {
         var result = (from p in db.DONMHs.AsNoTracking()
                       join d in db.NCCs.AsNoTracking() on p.idncc equals d.idncc
                       select new DONMH_ViewModel
         {
             iddonmh = p.iddonmh,
             ngaydonmh = p.ngaydonmh.Value,
             idncc = p.idncc.Value,
             tenncc = d.tenncc,
             CreateBy = p.CreateBy,
             CreateDate = p.CreateDate
         }).ToList();
         return(result);
     }
 }
Beispiel #26
0
 public PNHAP_ViewModel GetPNHAPById(int id)
 {
     try
     {
         using (var db = new RestaurantManagerDataEntities())
         {
             var master = (from h in db.PNHAPs.AsNoTracking()
                           where h.idpnhap == id
                           select new PNHAP_ViewModel
             {
                 idpnhap = h.idpnhap,
                 idpgiao = h.idpgiao,
                 ngaynhap = h.ngaynhap,
                 nguoigiao = h.nguoigiao,
                 nguoilapphieu = h.nguoilapphieu,
                 thukho = h.thukho,
             }
                           ).FirstOrDefault();
             if (master != null)
             {
                 master.lstDetail = (from p in db.D_PNHAP.AsNoTracking()
                                     join d in db.NLIEUx.AsNoTracking() on p.idhang equals d.idhang
                                     where p.idpnhap == master.idpnhap
                                     select new D_PNHAP_ViewModel
                 {
                     idhang = p.idhang,
                     idpnhap = p.idpnhap,
                     slnhan = p.slnhan,
                     dongia = d.dongianl,
                     thanhtien = p.slnhan * d.dongianl,
                     slgiao = p.slgiao,
                     tenhang = d.tenhang,
                     CreateDate = p.CreateDate,
                     CreateBy = p.CreateBy
                 }).ToList();
             }
             return(master);
         }
     }
     catch
     {
         return(null);
     }
 }
Beispiel #27
0
        /// <summary>
        /// ds chi tiết phiếu nhập
        /// </summary>
        /// <returns></returns>
        public List <D_PNHAP_ViewModel> GetListD_PNHAP_Full(int idpnhap)
        {
            try
            {
                using (var db = new RestaurantManagerDataEntities())
                {
                    var _idpnhap = new SqlParameter("@idpnhap", idpnhap);

                    var result = db.Database.SqlQuery <D_PNHAP_ViewModel>("EXEC dbo.Proc_GetListD_PNHAP @idpnhap", _idpnhap).ToList();
                    return(result);
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
            //    return result;
            //}
        }
Beispiel #28
0
        public List <DONDATDA_ViewModel> GetListDONDATDA(int iddondat, DateTime FromDate, DateTime ToDate)
        {
            try
            {
                using (var db = new RestaurantManagerDataEntities())
                {
                    var _iddondat = new SqlParameter("@iddondat", iddondat);
                    var _FromDate = new SqlParameter("@FromDate", FromDate);
                    var _ToDate   = new SqlParameter("@ToDate", ToDate);

                    var result = db.Database.SqlQuery <DONDATDA_ViewModel>("EXEC dbo.Proc_GetListDONDATDA @iddondat,@FromDate,@ToDate", _iddondat, _FromDate, _ToDate).ToList();
                    return(result);
                }
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Beispiel #29
0
 public string AddMONAN(MONAN_ViewModel model)
 {
     try
     {
         using (var db = new RestaurantManagerDataEntities())
         {
             var check = db.MONANs.FirstOrDefault(x => x.idmon == model.idmon);
             if (check == null)
             {
                 var MONAN = new MONAN
                 {
                     temon      = model.temon,
                     dongiamon  = model.dongiamon,
                     dvt        = model.dvt,
                     hinhanh    = model.hinhanh,
                     iddmuc     = model.iddmuc,
                     CreateBy   = model.CreateBy,
                     CreateDate = DateTime.Now,
                 };
                 var result = db.MONANs.Add(MONAN);
                 db.SaveChanges();
                 return("Thêm món ăn thành công!");
             }
             else
             {
                 check.temon      = model.temon;
                 check.dongiamon  = model.dongiamon;
                 check.dvt        = model.dvt;
                 check.hinhanh    = model.hinhanh;
                 check.iddmuc     = model.iddmuc;
                 check.ModifyBy   = model.ModifyBy;
                 check.ModifyDate = DateTime.Now;
                 db.SaveChanges();
                 return("Cập nhật món ăn thành công!");
             }
         }
     }
     catch (Exception ex)
     {
         return(ex.Message);
     }
 }
Beispiel #30
0
 public USER Login(string username, string password, ref string outmess)
 {
     try
     {
         using (var db = new RestaurantManagerDataEntities())
         {
             var result = db.USERS.AsNoTracking().FirstOrDefault(x => x.UserName == username && x.Password == password);
             if (result == null)
             {
                 return(null);
             }
             return(result);
         }
     }
     catch (Exception ex)
     {
         outmess = ex.Message;
         return(null);
     }
 }