Exemplo n.º 1
0
        internal void XacNhanDaGiao(int hopDongId, bool tt)
        {
            var lsp = db.HopDongNccs.Find(hopDongId);

            if (lsp.TinhTrang == false && tt == true)
            {
                var sp = new SanPhamModel();
                sp.UpdateSL(lsp.SanPhamId, lsp.SLCungCap, lsp.IsBuy);
            }

            lsp.TinhTrang       = tt;
            db.Entry(lsp).State = EntityState.Modified;
            db.SaveChanges();
        }
Exemplo n.º 2
0
 internal bool UpdateTinhTrang(int madh, int?tt)
 {
     if (tt == null)
     {
         return(false);
     }
     try
     {
         var db = new MainContext();
         var dh = db.DonHangKHs.Find(madh);
         if (dh.TinhTrangDH == 4 || dh.TinhTrangDH == 3)
         {
             return(false);
         }
         if (dh.TinhTrangDH == 1)
         {
             if (tt == 2 || tt == 3)
             {
                 foreach (var item in dh.ChiTietDonHangs)
                 {
                     var spm = new SanPhamModel();
                     spm.UpdateSL(item.SanPhamId, item.SoLuong, false);
                 }
             }
         }
         if (dh.TinhTrangDH == 2)
         {
             if (tt == 4)
             {
                 foreach (var item in dh.ChiTietDonHangs)
                 {
                     var spm = new SanPhamModel();
                     spm.UpdateSL(item.SanPhamId, item.SoLuong, true);
                 }
             }
             if (tt == 1)
             {
                 return(false);
             }
         }
         var query = "update DonHangKH set TinhTrangDH = " + tt + " where Id ='" + madh + "'";
         db.Database.ExecuteSqlCommand(query);
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }