public void TraHangHoaDon(string idhd, string idch) { using (GalaxyMobileEntities dbs = new GalaxyMobileEntities()) { var ct = dbs.ChiTietHoaDons.Where(p => p.MaHoaDon == idhd && p.MaCuaHang == idch).ToList(); foreach (ChiTietHoaDon c in ct) { dbs.USP_ThayDoiSoLuongChiTietSP(c.MaKieu, c.SoluongSP); dbs.USP_ThemSL_KhoHangByMaKieuByMaCH(c.MaKieu, idch, c.SoluongSP); } } }
public void LuuHoaDonNhap(string id) { using (GalaxyMobileEntities dbs = new GalaxyMobileEntities()) { var p = (from u in dbs.ChiTietHDNhapHangs where u.MaHoaDonNH == id select u).ToList(); foreach (var t in p) { dbs.USP_ThayDoiSoLuongChiTietSP(t.MaKieu, t.SoLuongNhap); } } }
public void ThanhToanHoaDon(string idhd, string idch) { using (GalaxyMobileEntities dbs = new GalaxyMobileEntities()) { var ct = dbs.ChiTietHoaDons.Where(p => p.MaHoaDon == idhd && p.MaCuaHang == idch).ToList(); foreach (ChiTietHoaDon c in ct) { dbs.USP_ThayDoiSoLuongChiTietSP(c.MaKieu, -c.SoluongSP); dbs.USP_ThemSL_KhoHangByMaKieuByMaCH(c.MaKieu, idch, -c.SoluongSP); } var hd = dbs.HoaDons.Where(p => p.MaHoaDon == idhd && p.MaCuaHang == idch).SingleOrDefault(); dbs.HoaDons.Attach(hd); hd.TinhTrang = 1; dbs.Entry(hd).State = System.Data.Entity.EntityState.Modified; dbs.SaveChanges(); } }