Ejemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         string    id   = Request.QueryString["foodID"];
         Food_List food = oneDB.Food_Lists.SingleOrDefault(
             s => s.foodID == id
             );
         if (food != null)
         {
             txtfoodname.Text = food.foodName;
             txtprice.Text    = food.foodPrice.ToString();
             lblStatus.Text   = food.foodStatus;
         }
     }
 }
Ejemplo n.º 2
0
        protected void btnInsert_Click(object sender, EventArgs e)
        {
            string  foodname  = txtfood.Text;
            decimal foodprice = decimal.Parse(txtfoodprice.Text);
            string  id;
            int     randomId;
            bool    repeatId = false;
            Random  random   = new Random();

            string path     = MapPath("~/Photos/");
            string filename = Guid.NewGuid().ToString("N") + ".jpeg";

            do
            {
                randomId = random.Next(10000, 999999);
                id       = "F" + randomId;
                var p = OneDB.Food_Lists.SingleOrDefault(
                    b => b.foodID == id);
                if (p == null)
                {
                    repeatId = true;
                }
            } while (repeatId == false);

            var img = new SimpleImage(FileUpload1.FileContent);

            img.Square();
            img.Resize(150);
            img.SaveAs(path + filename);

            Food_List fl = new Food_List
            {
                foodID     = id,
                foodName   = foodname,
                foodPrice  = foodprice,
                foodPhoto  = filename,
                foodStatus = "available"
            };

            OneDB.Food_Lists.InsertOnSubmit(fl);
            OneDB.SubmitChanges();

            displaystatus.Text = "The food has been added to food menu";
        }
Ejemplo n.º 3
0
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                string    foodname = txtfoodname.Text;
                string    price    = txtprice.Text;
                string    id       = Request.QueryString["foodID"];
                string    status   = ddlStatus.SelectedValue;
                Food_List food     = oneDB.Food_Lists.SingleOrDefault(
                    f => f.foodID == id
                    );
                if (food != null)
                {
                    food.foodName   = foodname;
                    food.foodPrice  = decimal.Parse(price);
                    food.foodStatus = status;

                    oneDB.SubmitChanges();
                }
                Response.Redirect("~/StaffOnly/foodmenu.aspx");
            }
        }