Пример #1
0
        protected void BtnSubmit_Click(object sender, EventArgs e)
        {
            bool canCreateItem = true;

            foreach (String s in _reservationDAO.GetAvailableItems())
            {
                if (s == TxtItemName.Text)
                {
                    canCreateItem = false;
                }
            }

            if (String.IsNullOrEmpty(TxtItemDesc.Text))
            {
                ErrDesc.Text  = "Description cannot be empty";
                canCreateItem = false;
            }

            if (canCreateItem)
            {
                _reservationDAO.AddItem(TxtItemName.Text,
                                        (Category)Enum.Parse(typeof(Category), DDCategory.SelectedValue),
                                        (Course)Enum.Parse(typeof(Course), DDCourse.SelectedValue),
                                        TxtItemDesc.Text);
                Response.Redirect("~/Admin/ViewItems.aspx");
            }
            else
            {
                ErrName.Text = "Item name in use";
            }
        }
        protected void TableNumber_SelectedIndexChanged(object sender, EventArgs e)
        {
            Appetizer.DataSource = _reservationDao.GetAvailableItems(Course.Appetizer);
            Appetizer.DataBind();
            Appetizer.Visible = true;
            Main.DataSource   = _reservationDao.GetAvailableItems(Course.Main);
            Main.DataBind();
            Main.Visible       = true;
            Dessert.DataSource = _reservationDao.GetAvailableItems(Course.Dessert);
            Dessert.DataBind();
            Dessert.Visible        = true;
            TxtNumOfGuests.Visible = true;
            List <int> nums = new List <int>();

            for (int i = 0; i < 8; i++)
            {
                nums.Add(i + 1);
            }
        }
Пример #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _reservationDao = new ReservationDAO();
            for (int i = 0; i < 3; i++)
            {
                foreach (String itemName in _reservationDao.GetAvailableItems((Course)i))
                {
                    Item item = _reservationDao.GetItemByName(itemName);
                    HtmlGenericControl div = new HtmlGenericControl("div");
                    div.Attributes.Add("class", "itemDiv");
                    HtmlGenericControl name = new HtmlGenericControl("p");
                    name.Attributes.Add("class", "item");
                    name.InnerText = item.Name;
                    HtmlGenericControl category = new HtmlGenericControl("p");
                    category.Attributes.Add("class", "category");
                    category.InnerText = item.Category.ToString();
                    HtmlGenericControl desc = new HtmlGenericControl("p");
                    desc.Attributes.Add("class", "desc");
                    desc.InnerText = item.Description;
                    div.Controls.Add(name);
                    div.Controls.Add(category);
                    div.Controls.Add(desc);
                    switch (i)
                    {
                    case 0:
                        appCont.Controls.Add(div);
                        break;

                    case 1:
                        mainCont.Controls.Add(div);
                        break;

                    case 2:
                        dessCont.Controls.Add(div);
                        break;

                    default:
                        break;
                    }
                }
            }
        }