public int?capnhattrangthai(int madh, int masp, int kc, int?huy) { int?check = -1; var ct = db.CTDHs.Where(c => c.MADH == madh && c.MASP == masp && c.MAKICHCO == kc).SingleOrDefault(); if (huy != null) { ct.TINHTRANG = 0; db.SaveChanges(); } else { if (ct.TINHTRANG == 1) { ct.TINHTRANG = 2; } else if (ct.TINHTRANG == 2) { ct.TINHTRANG = 3; } db.SaveChanges(); } check = ct.TINHTRANG; if (check == 0 || check == 3) { RATINGDAL r = new RATINGDAL(); r.capnhattinhtrangrating(madh, masp); } return(check); }
public bool themcsp(CUNGSANPHAM csp) { bool check = false; db.CUNGSANPHAMs.Add(csp); db.SaveChanges(); check = true; return(check); }
public void luudonhang(DONHANG dh, List <CTDH> ctdh) { DONHANG donhang = new DONHANG { MACUSTOMER = dh.MACUSTOMER, NGAYMUA = dh.NGAYMUA, DIACHI = dh.DIACHI, SDT = dh.SDT, TONGTIEN = dh.TONGTIEN, GHICHU = dh.GHICHU }; db.DONHANGs.Add(donhang); db.SaveChanges(); int iddonhang = donhang.MADH; List <CTDH> listct = new List <CTDH>(); listct = ctdh; var listrating = new List <RATING>(); foreach (var item in listct) { CTDH ct = new CTDH(); ct.MADH = iddonhang; ct.MASP = item.MASP; ct.MAMERCHANT = item.MAMERCHANT; ct.SOLUONG = item.SOLUONG; ct.THANHTIEN = item.THANHTIEN; ct.TINHTRANG = item.TINHTRANG; ct.MAKICHCO = item.MAKICHCO; ct.GIAGIAM = item.GIAGIAM; db.CTDHs.Add(ct); db.SaveChanges(); if (listrating.Exists(x => x.MADH == item.MADH) && listrating.Exists(x => x.MASP == item.MASP)) { } else { listrating.Add(new RATING() { MADH = item.MADH, MASP = item.MASP }); RATING rating = new RATING(); rating.MADH = iddonhang; rating.MASP = item.MASP; rating.MAMERCHANT = item.MAMERCHANT; rating.MACUSTOMER = dh.MACUSTOMER; rating.RATING_M = null; rating.RATING_C = null; rating.NGAYRATING = null; rating.TRANGTHAI = 0; RATINGDAL ratingdal = new RATINGDAL(); ratingdal.addrating(rating); db.SaveChanges(); } } }
public bool themsp(SANPHAM sp) { bool check = false; db.SANPHAMs.Add(sp); db.SaveChanges(); check = true; return(check); }
public bool thaydoitrangthai(int idcustomer) { var c = db.CUSTOMERS.Find(idcustomer); if (c != null) { c.TINHTRANG = 1; db.SaveChanges(); return(true); } return(false); }
public int AddCustomer(CUSTOMER c) { db = new WEBGIAYEntities(); db.CUSTOMERS.Add(c); db.SaveChanges(); return(c.MACUSTOMER); }
public int AddMerchant(MERCHANT c) { db = new WEBGIAYEntities(); db.MERCHANTS.Add(c); db.SaveChanges(); return(c.MAMERCHANT); }
public bool themact(ANHCHITIET a) { bool check = false; db.ANHCHITIETs.Add(a); db.SaveChanges(); check = true; return(check); }
public void addlichsumuatin(LICHSUMUATIN l) { db.LICHSUMUATINs.Add(l); db.SaveChanges(); }
public void addrating(RATING r) { db.RATINGs.Add(r); db.SaveChanges(); }
public int newme(MERCHANT m) { db.MERCHANTS.Add(m); db.SaveChanges(); return(m.MAMERCHANT); }