Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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)
            {
            }
        }
Exemple #3
0
        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);
            }
        }
Exemple #4
0
        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)
            {
            }
        }
Exemple #5
0
        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)
            {
            }
        }
Exemple #6
0
 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());
     }
 }
Exemple #7
0
 public static List <Users> Get()
 {
     try
     {
         using (FruitShopEntity db = new FruitShopEntity())
         {
             return(db.Users.ToList());
         }
     }
     catch (Exception)
     {
         return(new List <Users>());
     }
 }
Exemple #8
0
 public static List <Mahsolat> Get()
 {
     try
     {
         using (FruitShopEntity db = new FruitShopEntity())
         {
             return(db.Mahsolats.ToList());
         }
     }
     catch (Exception)
     {
         return(new List <Mahsolat>());
     }
 }
Exemple #9
0
 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());
     }
 }
Exemple #10
0
 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());
     }
 }
Exemple #11
0
 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());
     }
 }
Exemple #12
0
 public static List <BarNameh> Get()
 {
     try
     {
         using (FruitShopEntity db = new FruitShopEntity())
         {
             return(db.BarNamehs.ToList());
         }
     }
     catch (Exception)
     {
         return(new List <BarNameh>());
     }
 }
Exemple #13
0
 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());
     }
 }
Exemple #14
0
        public static bool Add(Ashkhas shakhs)
        {
            try
            {
                using (FruitShopEntity db = new FruitShopEntity())
                {
                    db.Ashkhas.Add(shakhs);
                    db.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemple #15
0
        public static bool Add(BarNameh bar)
        {
            try
            {
                using (FruitShopEntity db = new FruitShopEntity())
                {
                    db.BarNamehs.Add(bar);
                    db.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemple #16
0
        public static bool Add(Mahsolat mahsolat)
        {
            try
            {
                using (FruitShopEntity db = new FruitShopEntity())
                {
                    db.Mahsolats.Add(mahsolat);
                    db.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemple #17
0
        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);
            }
        }
Exemple #18
0
        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)
            {
            }
        }
Exemple #19
0
        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);
            }
        }
Exemple #20
0
 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>());
     }
 }
Exemple #21
0
        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)
            {
            }
        }
Exemple #22
0
        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)
            {
            }
        }
Exemple #23
0
        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);
            }
        }
Exemple #24
0
        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);
            }
        }
Exemple #25
0
        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)
            {
            }
        }
Exemple #26
0
        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);
            }
        }
Exemple #27
0
        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);
            }
        }
Exemple #28
0
        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);
            }
        }
Exemple #29
0
        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);
            }
        }