コード例 #1
0
ファイル: Users.cs プロジェクト: abnnajaf/FruitShop
        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);
            }
        }
コード例 #2
0
ファイル: Ashkhas.cs プロジェクト: abnnajaf/FruitShop
        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)
            {
            }
        }
コード例 #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);
            }
        }
コード例 #4
0
ファイル: Users.cs プロジェクト: abnnajaf/FruitShop
        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)
            {
            }
        }
コード例 #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)
            {
            }
        }
コード例 #6
0
ファイル: Users.cs プロジェクト: abnnajaf/FruitShop
 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());
     }
 }
コード例 #7
0
ファイル: Users.cs プロジェクト: abnnajaf/FruitShop
 public static List <Users> Get()
 {
     try
     {
         using (FruitShopEntity db = new FruitShopEntity())
         {
             return(db.Users.ToList());
         }
     }
     catch (Exception)
     {
         return(new List <Users>());
     }
 }
コード例 #8
0
 public static List <Mahsolat> Get()
 {
     try
     {
         using (FruitShopEntity db = new FruitShopEntity())
         {
             return(db.Mahsolats.ToList());
         }
     }
     catch (Exception)
     {
         return(new List <Mahsolat>());
     }
 }
コード例 #9
0
ファイル: Ashkhas.cs プロジェクト: abnnajaf/FruitShop
 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());
     }
 }
コード例 #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());
     }
 }
コード例 #11
0
ファイル: BarNameh.cs プロジェクト: abnnajaf/FruitShop
 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());
     }
 }
コード例 #12
0
ファイル: BarNameh.cs プロジェクト: abnnajaf/FruitShop
 public static List <BarNameh> Get()
 {
     try
     {
         using (FruitShopEntity db = new FruitShopEntity())
         {
             return(db.BarNamehs.ToList());
         }
     }
     catch (Exception)
     {
         return(new List <BarNameh>());
     }
 }
コード例 #13
0
ファイル: Users.cs プロジェクト: abnnajaf/FruitShop
 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());
     }
 }
コード例 #14
0
ファイル: Ashkhas.cs プロジェクト: abnnajaf/FruitShop
        public static bool Add(Ashkhas shakhs)
        {
            try
            {
                using (FruitShopEntity db = new FruitShopEntity())
                {
                    db.Ashkhas.Add(shakhs);
                    db.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
コード例 #15
0
ファイル: BarNameh.cs プロジェクト: abnnajaf/FruitShop
        public static bool Add(BarNameh bar)
        {
            try
            {
                using (FruitShopEntity db = new FruitShopEntity())
                {
                    db.BarNamehs.Add(bar);
                    db.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
コード例 #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);
            }
        }
コード例 #17
0
ファイル: Users.cs プロジェクト: abnnajaf/FruitShop
        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);
            }
        }
コード例 #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)
            {
            }
        }
コード例 #19
0
ファイル: Ashkhas.cs プロジェクト: abnnajaf/FruitShop
        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);
            }
        }
コード例 #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>());
     }
 }
コード例 #21
0
ファイル: Users.cs プロジェクト: abnnajaf/FruitShop
        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)
            {
            }
        }
コード例 #22
0
ファイル: Ashkhas.cs プロジェクト: abnnajaf/FruitShop
        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)
            {
            }
        }
コード例 #23
0
ファイル: BarNameh.cs プロジェクト: abnnajaf/FruitShop
        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);
            }
        }
コード例 #24
0
ファイル: Users.cs プロジェクト: abnnajaf/FruitShop
        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);
            }
        }
コード例 #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)
            {
            }
        }
コード例 #26
0
ファイル: Users.cs プロジェクト: abnnajaf/FruitShop
        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);
            }
        }
コード例 #27
0
ファイル: Miveh.cs プロジェクト: abnnajaf/FruitShop
        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);
            }
        }
コード例 #28
0
ファイル: Ashkhas.cs プロジェクト: abnnajaf/FruitShop
        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);
            }
        }
コード例 #29
0
ファイル: Users.cs プロジェクト: abnnajaf/FruitShop
        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);
            }
        }