public User SelectSingleUserById(int id) { using (var db = new ShopTPTDataContext()) { return(db.Users.SingleOrDefault(x => x.UserID == id)); } }
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 List <Role> View() { using (var db = new ShopTPTDataContext()) { return(db.Roles.Select(x => x).ToList()); } }
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 List <BillDetail> View() { using (var db = new ShopTPTDataContext()) { return(db.BillDetails.Select(x => x).ToList()); } }
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 Product SelectSingleProduct(string productCode) { using (var db = new ShopTPTDataContext()) { return(db.Products.SingleOrDefault(x => x.ProductCode == productCode)); } }
public double?GetPrice(int id) { using (var db = new ShopTPTDataContext()) { return(db.Products.SingleOrDefault(p => p.ProductID == id).Price); } }
public List <Product> ListProductByCategory(int id) { using (var db = new ShopTPTDataContext()) { return(db.Products.Select(x => x).Where(p => p.PCCode == id).ToList()); } }
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(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 int GetLastBillID() { using (var db = new ShopTPTDataContext()) { return(db.Bills.OrderByDescending(x => x.BillID).FirstOrDefault().BillID); } }
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 List <ProductCategory> View() { using (var db = new ShopTPTDataContext()) { return(db.ProductCategories.Select(x => x).ToList()); } }
public ProductCategory SelectSingleProductCategory(int?productCategoryId) { using (var db = new ShopTPTDataContext()) { return(db.ProductCategories.SingleOrDefault(x => x.PCCode == productCategoryId)); } }
public User FindSingleUser(string userName, string password) { using (var db = new ShopTPTDataContext()) { var user = db.Users.SingleOrDefault(x => x.UserName == userName && x.Password == password); return(user); } }
public List <Product> FindProduct(string key) { List <Product> lpd; using (var db = new ShopTPTDataContext()) { lpd = db.Products.Select(p => p).Where(x => x.ProductCode.Contains(key) || x.ProductName.Contains(key)).ToList(); } return(lpd); }
public List <User> View() { List <User> lnv; using (var db = new ShopTPTDataContext()) { lnv = db.Users.Select(x => x).ToList(); } return(lnv); }
public List <Product> View() { List <Product> lProduct; using (var db = new ShopTPTDataContext()) { lProduct = db.Products.Select(x => x).ToList(); } return(lProduct); }
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(User nv) { using (var db = new ShopTPTDataContext()) { db.Users.InsertOnSubmit(nv); 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 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 List <User> FindUser(string strFind) { int userId; try { userId = int.Parse(strFind); } catch (Exception) { userId = 0; } List <User> lUser; using (var db = new ShopTPTDataContext()) { lUser = db.Users.Select(x => x) .Where(p => p.UserID == userId || p.FullName.Contains(strFind) || p.UserName.Contains(strFind)).ToList(); } return(lUser); }
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); } } }