public bool updateHD(string id, string tongtien, string tienkh, string tientra, string tongsl) { try { db = new CMART8Entities(); HOADON hd = db.HOADONs.Single(st => st.SOHD.Equals(id)); hd.TONGTIEN = tongtien; hd.TIENKHACHDUA = tienkh; hd.TIENKHATRA = tientra; hd.TONGSL = int.Parse(tongsl); db.SaveChanges(); return(true); } catch { return(false); } }
public HOADON createHD(string POS, string maTK) { db = new CMART8Entities(); string id = autoID(); HOADON hd = new HOADON(); hd.SOHD = id; hd.NGAYBAN = DateTime.Now; hd.MATK = maTK; hd.POS = POS; hd.TONGSL = 0; hd.TONGTIEN = "0"; hd.TIENKHACHDUA = "0"; hd.TIENKHATRA = "0"; db.HOADONs.Add(hd); db.SaveChanges(); return(hd); }
public bool deleteHD(string sohd) { db = new CMART8Entities(); try { HOADON HD = db.HOADONs.Single(st => st.SOHD.Equals(sohd)); List <CTHOADON> cthd = db.CTHOADONs.Where(st => st.SOHD.Equals(sohd)).ToList(); foreach (CTHOADON tmp in cthd) { db.CTHOADONs.Remove(tmp); } db.SaveChanges(); db.HOADONs.Remove(HD); db.SaveChanges(); return(true); } catch { return(false); } }
public List <CTHOADON> searchCTHD(string sTmp, HOADON HD) { db = new CMART8Entities(); return(db.CTHOADONs.ToList().Where(x => x.SOHD.Equals(HD.SOHD) && x.MASP.Contains(sTmp)).ToList()); }