public static bool Update(Users user) { try { using (FruitShopEntity db = new FruitShopEntity()) { var model = db.Users.Single(x => x.UserID == user.UserID); model.Name = user.Name; model.Family = user.Family; model.Address = user.Address; model.Email = user.Email; model.CodePosti = user.CodePosti; model.Mobile = user.Mobile; model.Phone = user.Phone; db.SaveChanges(); } return(true); } catch (Exception ee) { return(false); } }
public static void Show(ListBox lb) { try { lb.DataTextField = "FullName"; lb.DataValueField = "AshkhasID"; using (FruitShopEntity db = new FruitShopEntity()) { var list = db.Ashkhas .Select(x => new { x.AshkhasID, FullName = x.Name + " " + x.Family, }) .ToList(); lb.DataSource = list; } lb.DataBind(); } catch (Exception) { } }
public static bool Update(Mahsolat mahsolat) { try { using (FruitShopEntity db = new FruitShopEntity()) { var model = db.Mahsolats.Single(x => x.MahsolatID == mahsolat.MahsolatID); model.Name = mahsolat.Name; model.NewPrice = mahsolat.NewPrice; model.OldPrice = mahsolat.OldPrice; model.Description = mahsolat.Description; model.IsDiscount = mahsolat.IsDiscount; if (!string.IsNullOrEmpty(mahsolat.ImageUrl)) { model.ImageUrl = mahsolat.ImageUrl; } db.SaveChanges(); } return(true); } catch (Exception) { return(false); } }
public static void Show(ListBox lb, User_Type type) { try { lb.DataTextField = "FullName"; lb.DataValueField = "UserID"; using (FruitShopEntity db = new FruitShopEntity()) { var list = db.Users.Where(x => x.Type == type) .Select(x => new { x.UserID, FullName = x.Name + " " + x.Family, }) .ToList(); lb.DataSource = list; } lb.DataBind(); } catch (Exception) { } }
public static void Show(ListBox lb, Mahsolat_Type type) { try { lb.DataTextField = "Name"; lb.DataValueField = "MahsolatID"; using (FruitShopEntity db = new FruitShopEntity()) { var list = db.Mahsolats.Where(x => x.Type == type) .Select(x => new { x.MahsolatID, x.Name, }) .ToList(); lb.DataSource = list; } lb.DataBind(); } catch (Exception) { } }
public static Users Get(int id) { try { using (FruitShopEntity db = new FruitShopEntity()) { return(db.Users.Single(x => x.UserID == id)); } } catch (Exception) { return(new Users()); } }
public static List <Users> Get() { try { using (FruitShopEntity db = new FruitShopEntity()) { return(db.Users.ToList()); } } catch (Exception) { return(new List <Users>()); } }
public static List <Mahsolat> Get() { try { using (FruitShopEntity db = new FruitShopEntity()) { return(db.Mahsolats.ToList()); } } catch (Exception) { return(new List <Mahsolat>()); } }
public static Ashkhas Get(int id) { try { using (FruitShopEntity db = new FruitShopEntity()) { return(db.Ashkhas.Single(x => x.AshkhasID == id)); } } catch (Exception) { return(new Ashkhas()); } }
public static Mahsolat Get(int id) { try { using (FruitShopEntity db = new FruitShopEntity()) { return(db.Mahsolats.Single(x => x.MahsolatID == id)); } } catch (Exception) { return(new Mahsolat()); } }
public static BarNameh Get(int id) { try { using (FruitShopEntity db = new FruitShopEntity()) { return(db.BarNamehs.Single(x => x.BarNamehID == id)); } } catch (Exception) { return(new BarNameh()); } }
public static List <BarNameh> Get() { try { using (FruitShopEntity db = new FruitShopEntity()) { return(db.BarNamehs.ToList()); } } catch (Exception) { return(new List <BarNameh>()); } }
public static Users GetLogin(HttpSessionState session) { try { var id = int.Parse(session["LOGIN"].ToString()); using (FruitShopEntity db = new FruitShopEntity()) { return(db.Users.Single(x => x.UserID == id)); } } catch (Exception) { return(new Users()); } }
public static bool Add(Ashkhas shakhs) { try { using (FruitShopEntity db = new FruitShopEntity()) { db.Ashkhas.Add(shakhs); db.SaveChanges(); } return(true); } catch (Exception) { return(false); } }
public static bool Add(BarNameh bar) { try { using (FruitShopEntity db = new FruitShopEntity()) { db.BarNamehs.Add(bar); db.SaveChanges(); } return(true); } catch (Exception) { return(false); } }
public static bool Add(Mahsolat mahsolat) { try { using (FruitShopEntity db = new FruitShopEntity()) { db.Mahsolats.Add(mahsolat); db.SaveChanges(); } return(true); } catch (Exception) { return(false); } }
public static bool Add(Users user) { try { using (FruitShopEntity db = new FruitShopEntity()) { db.Users.Add(user); db.SaveChanges(); } return(true); } catch (Exception ee) { return(false); } }
public static void Show(Repeater rp, Mahsolat_Type type) { try { using (FruitShopEntity db = new FruitShopEntity()) { var list = db.Mahsolats.Where(x => x.Type == type) .OrderByDescending(x => x.MahsolatID) .ToList(); rp.DataSource = list; } rp.DataBind(); } catch (Exception) { } }
public static int GetNextID() { try { using (FruitShopEntity db = new FruitShopEntity()) { var model = db.Ashkhas.ToList() .OrderByDescending(x => x.AshkhasID) .First(); return(model.AshkhasID + 1); } } catch (Exception) { return(-1); } }
public static List <Mahsolat> Get(Mahsolat_Type type, int pageIndex = 1, int pageSize = 4) { try { using (FruitShopEntity db = new FruitShopEntity()) { return(db.Mahsolats.Where(x => x.Type == type) .Distinct() .OrderByDescending(x => x.MahsolatID) .Skip(pageSize * (pageIndex - 1)) .Take(pageSize) .ToList()); } } catch (Exception) { return(new List <Mahsolat>()); } }
public static void Show(GridView gv, User_Type type) { try { string[] t = new string[1]; t[0] = "UserID"; gv.DataKeyNames = t; using (FruitShopEntity db = new FruitShopEntity()) { var list = db.Users.Where(x => x.Type == type).ToList(); gv.DataSource = list; } gv.DataBind(); } catch (Exception ee) { } }
public static void Show(GridView gv) { try { string[] t = new string[1]; t[0] = "AshkhasID"; gv.DataKeyNames = t; using (FruitShopEntity db = new FruitShopEntity()) { var list = db.Ashkhas.ToList(); gv.DataSource = list; } gv.DataBind(); } catch (Exception ee) { } }
public static bool Update(BarNameh bar) { try { using (FruitShopEntity db = new FruitShopEntity()) { var model = db.BarNamehs.Single(x => x.BarNamehID == bar.BarNamehID); model.GhimatKol = bar.GhimatKol; db.SaveChanges(); } return(true); } catch (Exception) { return(false); } }
public static bool IsExistCodeMeli(string code) { try { using (FruitShopEntity db = new FruitShopEntity()) { var model = db.Users.Where(x => x.CodeMeli == code); if (model.Count() > 0) { return(true); } } return(false); } catch (Exception ee) { return(false); } }
public static void Show(GridView gv, Mahsolat_Type type) { try { string[] t = new string[1]; t[0] = "MahsolatID"; gv.DataKeyNames = t; using (FruitShopEntity db = new FruitShopEntity()) { var list = db.Mahsolats.Where(x => x.Type == type) .OrderByDescending(x => x.MahsolatID) .ToList(); gv.DataSource = list; } gv.DataBind(); } catch (Exception ee) { } }
public static bool IsLogin(HttpSessionState session, out Users user) { user = new Users(); try { var id = int.Parse(session["LOGIN"].ToString()); using (FruitShopEntity db = new FruitShopEntity()) { user = db.Users.Single(x => x.UserID == id); if (user.UserID > 0) { return(true); } } return(false); } catch (Exception) { return(false); } }
public static bool Update(Mahsolat mahsol) { try { using (FruitShopEntity db = new FruitShopEntity()) { var model = db.Mahsolats.Single(x => x.MahsolatID == mahsol.MahsolatID); model.Name = mahsol.Name; model.Description = mahsol.Description; model.OldPrice = mahsol.OldPrice; model.NewPrice = mahsol.NewPrice; db.SaveChanges(); } return(true); } catch (Exception) { return(false); } }
public static bool Update(Ashkhas shakhs) { try { using (FruitShopEntity db = new FruitShopEntity()) { var model = db.Ashkhas.Single(x => x.AshkhasID == shakhs.AshkhasID); model.Name = shakhs.Name; model.CodeMeli = shakhs.CodeMeli; model.Family = shakhs.Family; model.Tel = shakhs.Tel; model.Mobile = shakhs.Mobile; model.Address = shakhs.Address; db.SaveChanges(); } return(true); } catch (Exception) { return(false); } }
public static bool Login(string username, string pass, out int userID) { userID = 0; try { using (FruitShopEntity db = new FruitShopEntity()) { var model = db.Users.First(x => x.Username == username && x.Password == pass); if (model.UserID > 0) { userID = model.UserID; return(true); } } return(false); } catch (Exception) { return(false); } }