コード例 #1
0
 public bool CreateRepast(Repast instance)
 {
     if (instance.RepastId == 0)
     {
         Db.Repasts.InsertOnSubmit(instance);
         Db.Repasts.Context.SubmitChanges();
         return(true);
     }
     return(false);
 }
コード例 #2
0
        public bool UpdateRepast(Repast instance)
        {
            Repast cache = Db.Repasts.FirstOrDefault(p => p.RepastId == instance.RepastId);

            if (instance.RepastId != 0)
            {
                cache.Name = instance.Name;
                Db.Repasts.Context.SubmitChanges();
                return(true);
            }
            return(false);
        }
コード例 #3
0
        public bool RemoveRepast(int RepastId)
        {
            Repast instance = Db.Repasts.FirstOrDefault(p => p.RepastId == RepastId);

            if (instance != null)
            {
                Db.Repasts.DeleteOnSubmit(instance);
                Db.Repasts.Context.SubmitChanges();
                return(true);
            }

            return(false);
        }
コード例 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            stage = Convert.ToInt32(Request.QueryString["stage"]);

            switch (stage)
            {
            case 0:
                Name.Visible   = true; MText.Visible = true;
                Recept.Visible = false; Repast.Visible = false; Button2.Visible = false;
                price.Visible  = false;
                break;

            case 1:
                Name.Visible   = false; MText.Visible = false;
                Recept.Visible = true; Repast.Visible = true; Button2.Visible = true;
                price.Visible  = false;
                break;

            case 2:
                Name.Visible   = false; MText.Visible = false;
                Recept.Visible = false; Repast.Visible = false; Button2.Visible = false;
                price.Visible  = true;
                break;

            case 3:
                Name.Visible   = false; MText.Visible = false;
                Recept.Visible = false; Repast.Visible = false; Button2.Visible = false;
                price.Visible  = false;
                break;

            default:

                break;
            }

            List <MenuDish> pAdd  = new List <MenuDish>();
            List <DMclass>  pAddd = new List <DMclass>();

            pAdd = (List <MenuDish>)Session["ListMenuDish"];
            if (pAdd != null)
            {
                foreach (MenuDish asd in pAdd)
                {
                    DMclass assf = new DMclass();
                    assf.Dish   = Repository.Dishs.Where(p => p.DishId == asd.DishId).FirstOrDefault().Name;
                    assf.Repast = Repository.Repasts.Where(p => p.RepastId == asd.RepastId).FirstOrDefault().Name;
                    pAddd.Add(assf);
                }
            }

            decimal priceAdd = 0;

            if (Session["MenusAdd"] != null)
            {
                priceAdd = ((DbClassesBell.Menu)Session["MenusAdd"]).Price > 0 ? (decimal)((DbClassesBell.Menu)Session["MenusAdd"]).Price : priceAdd;
            }
            if (stage == 2 && price.Text == "")
            {
                if (pAdd != null)
                {
                    foreach (MenuDish asd in pAdd)
                    {
                        priceAdd += (decimal)Repository.Dishs.Where(p => p.DishId == asd.DishId).FirstOrDefault().Price;
                    }
                }
                price.Text = Convert.ToString(Math.Round(priceAdd, 2));
            }

            DbClassesBell.Menu dAdd = (DbClassesBell.Menu)Session["MenusAdd"];
            if (dAdd != null)
            {
                MenuLabel.Text = "Наименование меню: " + dAdd.Name + "<br/>" +
                                 "Описание: " + dAdd.Text + "<br/>" +
                                 "Стоимость: " + priceAdd;
            }

            List <String> ListMenq = new List <string>();

            foreach (Repast sd in Repository.Repasts)
            {
                ListMenq.Add(sd.Name);
            }

            List <String> ListDish = new List <string>();

            foreach (Dish sd in Repository.Dishs)
            {
                ListDish.Add(sd.Name);
            }

            Recept.DataSource = ListDish.OrderBy(p => p);
            Recept.DataBind();

            Repast.DataSource = ListMenq;
            Repast.DataBind();

            Repeater1.DataSource = pAddd;
            Repeater1.DataBind();
        }