Exemplo n.º 1
0
        protected void ThemTypeFood(object sender, EventArgs e)
        {
            string   sTypeName = type_name.Text;
            int      sTypePost = Int32.Parse(type_pos.Text.ToString());
            string   sTypeImg  = type_img.FileName;
            int      sStatus   = Convert.ToInt32(listStatus.SelectedValue);
            string   sUsername = Username.Text;
            DateTime modified  = DateTime.Parse(DateTime.Now.ToString());

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

            if (foodtype.addTypeFood())
            {
                if (type_img.HasFile)
                {
                    string path = Server.MapPath("~/Admin/img/" + type_img.FileName);
                    type_img.SaveAs(path);
                }

                Session["add_typefood"] = "thành công";
                Response.Redirect("danhsach_loaisp.aspx");
            }
            else
            {
                Session["add_typefood"] = "thất bại";
            }
        }
Exemplo n.º 2
0
 protected void btnAdd_Click(object sender, EventArgs e)
 {
     if (btnAdd.Text == "Thêm Food Type")
     {
         string    sFoodName  = txtName.Text;
         int       sPost      = Convert.ToInt32(txtPos.Text);
         string    sFoodImage = FileUpload1.FileName;
         string    sUserName  = (string)Session["Login"];
         int       sStatus    = Convert.ToInt32(DropDownList_SelectStatus.SelectedValue);
         Food_type food_type  = new Food_type(sFoodName, sPost, sFoodImage, sStatus, sUserName, id);
         if (food_type.AddFood() == true)
         {
             lbmodal.Text = "Thêm loại sản phẩm thành công";
             ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);
         }
         else
         {
             lbmodal.Text = "Thêm loại sản phẩm thất bại";
             ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);
         }
     }
     if (btnAdd.Text == "Update")
     {
         string    sFoodName  = txtName.Text;
         int       sPost      = Convert.ToInt32(txtPos.Text);
         string    sFoodImage = FileUpload1.FileName;
         string    sUserName  = (string)Session["Login"];
         int       sStatus    = Convert.ToInt32(DropDownList_SelectStatus.SelectedValue);
         Food_type food_type  = new Food_type(sFoodName, sPost, sFoodImage, sStatus, sUserName, id);
         if (food_type.CapNhat() == true)
         {
             lbmodal.Text = "Cập nhật thành công";
             ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);
         }
         else
         {
             lbmodal.Text = "Cập nhật thất bại";
             ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openModal();", true);
         }
     }
 }