Beispiel #1
0
        protected void update_click(object sender, EventArgs e)
        {
            int      id        = int.Parse(Request.QueryString["id"].ToString());
            string   sTypeName = typename.Text;
            int      sTypePost = Int32.Parse(typepos.Text);
            string   sTypeImg  = type_img.FileName;
            int      sStatus   = Convert.ToInt32(listStatus.SelectedValue);
            string   sUsername = Username.Text;
            DateTime modified  = DateTime.Parse(DateTime.Now.ToString());

            FoodType foodtype = new FoodType(id, sTypeName, sTypePost, sTypeImg, sStatus, sUsername, modified);

            if (foodtype.updateTypeFood())
            {
                if (type_img.HasFile)
                {
                    string path = Server.MapPath("~/admin/img/" + type_img.FileName);
                    type_img.SaveAs(path);
                }
                Session["update_typefood"] = "success";
                Response.Redirect("DSTypeFood.aspx");
            }
            else
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMess", "swal.fire({title: 'Update type food fail!',type: 'warning'});", true);
            }
        }