internal void XacNhanDaGiao(string item, bool tt) { HopDongNCC lsp = db.HopDongNCCs.Find(item); if (lsp.TinhTrang == false && tt == true) { SanPhamModel sp = new SanPhamModel(); sp.UpdateSL(lsp.MaSP, lsp.SLCungCap, lsp.IsBuy); } lsp.TinhTrang = tt; db.Entry(lsp).State = EntityState.Modified; db.SaveChanges(); }
internal bool UpdateTinhTrang(string madh, int?tt) { if (tt == null) { return(false); } try { Entities db = new Entities(); DonHangKH 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) { SanPhamModel spm = new SanPhamModel(); spm.UpdateSL(item.MaSP, item.SoLuong, false); } } } if (dh.TinhTrangDH == 2) { if (tt == 4) { foreach (var item in dh.ChiTietDonHangs) { SanPhamModel spm = new SanPhamModel(); spm.UpdateSL(item.MaSP, item.SoLuong, true); } } if (tt == 1) { return(false); } } string query = "update DonHangKH set TinhTrangDH = " + tt + " where MaDH ='" + madh + "'"; db.Database.ExecuteSqlCommand(query); return(true); } catch (Exception e) { return(false); } }