public bool Update(Bill bill) { using (var db = new ShopTPTDataContext()) { var tmp = db.Bills.SingleOrDefault(x => x.BillID == bill.BillID); if (tmp != null) { tmp.BillID = bill.BillID; tmp.CreateDate = bill.CreateDate; tmp.UserCode = bill.UserCode; try { db.SubmitChanges(); return(true); } catch (Exception) { return(false); } } else { return(false); } } }
public bool Update(BillDetail bd) { using (var db = new ShopTPTDataContext()) { var tmp = db.BillDetails.SingleOrDefault(x => x.BillID == bd.BillID && x.ProductID == bd.ProductID); if (tmp != null) { tmp.BillID = bd.BillID; tmp.ProductID = bd.ProductID; tmp.Quantity = bd.Quantity; tmp.Total = bd.Total; try { db.SubmitChanges(); return(true); } catch (Exception) { return(false); } } else { return(false); } } }
public bool Update(Product pd) { using (var db = new ShopTPTDataContext()) { Product tmp = db.Products.SingleOrDefault(x => x.ProductCode == pd.ProductCode); if (tmp != null) { tmp.ProductCode = pd.ProductCode; tmp.Image = pd.Image; tmp.Color = pd.Color; tmp.PCCode = pd.PCCode; tmp.Price = pd.Price; tmp.Size = pd.Size; tmp.Quantity = pd.Quantity; tmp.ProductName = pd.ProductName; tmp.Trademark = pd.Trademark; try { db.SubmitChanges(); return(true); } catch (Exception) { return(false); } } else { return(false); } } }
public bool Delete(int bID, int pID) { using (var db = new ShopTPTDataContext()) { var tmp = db.BillDetails.SingleOrDefault(x => x.BillID == bID && x.ProductID == pID); if (tmp != null) { db.BillDetails.DeleteOnSubmit(tmp); try { db.SubmitChanges(); return(true); } catch (Exception) { return(false); } } else { return(false); } } }
public bool Update(ProductCategory pc) { using (var db = new ShopTPTDataContext()) { var tmp = db.ProductCategories.SingleOrDefault(x => x.PCCode == pc.PCCode); if (tmp != null) { tmp.PCCode = pc.PCCode; tmp.PCName = pc.PCName; try { db.SubmitChanges(); return(true); } catch (Exception) { return(false); } } else { return(false); } } }
public bool Update(int maNv, User nv) { using (var db = new ShopTPTDataContext()) { var user = db.Users.SingleOrDefault(x => x.UserID == maNv); if (user != null) { user.UserID = nv.UserID; user.Address = nv.Address; user.DayOfBirth = nv.DayOfBirth; user.Email = nv.Email; user.Gender = nv.Gender; user.Password = Helper.Md5Encrypt(nv.Password); user.Phone = nv.Phone; user.FullName = nv.FullName; user.RoleID = nv.RoleID; } try { db.SubmitChanges(); return(true); } catch (Exception) { // ignored } } return(false); }
public void Delete(string pID) { using (var db = new ShopTPTDataContext()) { var pd = db.Products.SingleOrDefault(x => x.ProductCode == pID); if (pd != null) { db.Products.DeleteOnSubmit(pd); } db.SubmitChanges(); } }
public bool Add(BillDetail billDetail) { using (var db = new ShopTPTDataContext()) { db.BillDetails.InsertOnSubmit(billDetail); try { db.SubmitChanges(); return(true); } catch (Exception) { return(false); } } }
public bool Add(ProductCategory pc) { using (var db = new ShopTPTDataContext()) { db.ProductCategories.InsertOnSubmit(pc); try { db.SubmitChanges(); return(true); } catch (Exception) { return(false); } } }
public bool Add(Product product) { using (var db = new ShopTPTDataContext()) { db.Products.InsertOnSubmit(product); try { db.SubmitChanges(); return(true); } catch (Exception) { //ig } } return(false); }
public bool Add(User nv) { using (var db = new ShopTPTDataContext()) { db.Users.InsertOnSubmit(nv); try { db.SubmitChanges(); return(true); } catch (Exception) { // } } return(false); }
public bool Delete(int id) { using (var db = new ShopTPTDataContext()) { var user = db.Users.SingleOrDefault(x => x.UserID == id); if (user != null) { db.Users.DeleteOnSubmit(user); } try { db.SubmitChanges(); return(true); } catch (Exception) { return(false); } } }
public int Add(int userId) { Bill bill = new Bill() { UserCode = userId }; using (var db = new ShopTPTDataContext()) { db.Bills.InsertOnSubmit(bill); try { db.SubmitChanges(); return(bill.BillID); } catch (Exception) { return(-1); } } }
public bool Delete(int bID) { using (var db = new ShopTPTDataContext()) { var bill = db.Bills.SingleOrDefault(x => x.BillID == bID); if (bill != null) { db.Bills.DeleteOnSubmit(bill); try { db.SubmitChanges(); return(true); } catch (Exception) { return(false); } } else { return(false); } } }
public bool Delete(int pcID) { using (var db = new ShopTPTDataContext()) { var pc = db.ProductCategories.SingleOrDefault(x => x.PCCode == pcID); if (pc != null) { db.ProductCategories.DeleteOnSubmit(pc); try { db.SubmitChanges(); return(true); } catch (Exception) { return(false); } } else { return(false); } } }