Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int        item_id = Convert.ToInt32(RouteData.Values["item_id"]);
            MenuItemCS test    = new MenuItemCS(item_id);

            lblTest.Text = String.Concat(test.Item_ID + " has been updated").ToString();
        }
Exemple #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Request.IsAuthenticated)
            {
                Response.Redirect("~/Home");
            }

            else
            {
                if (!IsPostBack)
                {
                    item_id = Convert.ToInt32(RouteData.Values["item_id"]);

                    if (item_id > 0)
                    {
                        MenuItemCS mt = new MenuItemCS(item_id);

                        txtName.Text              = mt.Item_Name;
                        txtDescription.Text       = mt.Item_Desc;
                        txtAllergens.Text         = mt.Item_Allergens;
                        txtPrice.Text             = mt.Item_Price.ToString();
                        ddlMenu.SelectedValue     = mt.Menu_Id.ToString();
                        ddlCategory.SelectedValue = mt.Cat_Id.ToString();
                        cbIsActive.Checked        = mt.Item_Active;

                        lbtnUpdate.Text = "Update";
                    }
                    else
                    {
                        txtName.Text              = String.Empty;
                        txtDescription.Text       = String.Empty;
                        txtAllergens.Text         = String.Empty;
                        txtPrice.Text             = String.Empty;
                        ddlMenu.SelectedValue     = null;
                        ddlCategory.SelectedValue = null;
                        cbIsActive.Checked        = false;

                        lbtnUpdate.Text = "Add";
                    }
                }
            }
        }
Exemple #3
0
        protected void lbtnUpdate_Click(object sender, EventArgs e)
        {
            MenuItemCS sr = new MenuItemCS();

            if (RouteData.Values["item_id"] != null)
            {
                sr.Item_ID          = Convert.ToInt32(RouteData.Values["item_id"]);
                sr.Menu_Id          = Convert.ToInt32(ddlMenu.SelectedValue);
                sr.Cat_Id           = Convert.ToInt32(ddlCategory.SelectedValue);
                sr.Item_Name        = txtName.Text.Trim();
                sr.Item_Desc        = txtDescription.Text.Trim();
                sr.Item_Allergens   = txtAllergens.Text.Trim();
                sr.Item_Price       = Convert.ToDecimal(txtPrice.Text);
                sr.Item_Gluten_Free = false;
                sr.Item_Active      = cbIsActive.Checked;
                MenuItemCS.UpdateMenuItems(sr);

                Response.Redirect("~/Admin/Menu-Items");
            }

            else
            {
                sr.Menu_Id          = Convert.ToInt32(ddlMenu.SelectedValue);
                sr.Cat_Id           = Convert.ToInt32(ddlCategory.SelectedValue);
                sr.Item_Name        = txtName.Text.Trim();
                sr.Item_Desc        = txtDescription.Text.Trim();
                sr.Item_Allergens   = txtAllergens.Text.Trim();
                sr.Item_Price       = Convert.ToDecimal(txtPrice.Text);
                sr.Item_Gluten_Free = false;
                sr.Item_Active      = cbIsActive.Checked;

                MenuItemCS.InsertMenuItem(sr);

                Response.Redirect("~/Admin/Menu-Items");
            }
        }