コード例 #1
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);
            }
        }
コード例 #2
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);
            }
        }
コード例 #3
0
        public static void Show(GridView gv, HttpSessionState session)
        {
            List <Card> list = new List <Card>();

            //get from session
            if (session["CARD"] != null)
            {
                list = session["CARD"] as List <Card>;
            }

            foreach (var item in list)
            {
                item.Mahsol = Mahsolat.Get(item.MahsolatID);
            }

            string[] t = new string[1];
            t[0]            = "MahsolatID";
            gv.DataKeyNames = t;

            gv.DataSource = list;
            gv.DataBind();
        }
コード例 #4
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);
            }
        }