protected void BtnThem_Click(object sender, EventArgs e) { FoodType f = new FoodType(); if (!f.exist(txtName.Text)) { f.Type_name = txtName.Text; f.Type_post = Convert.ToInt32(txtPost.Text); int lastIndex = hfImgReview.Value.LastIndexOf("/"); f.Type_img = hfImgReview.Value.Substring(lastIndex + 1).ToString(); f.Status = Convert.ToInt32(ddlStatus.SelectedValue); f.Username = Session["username"].ToString(); if (f.add()) { lblMessage.Text = "Thêm Thành Công"; ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "showModal();", true); Btn_cancel_Click(sender, e); } else { Response.Write("<script>alert('Thất Bại') </script>"); } } else { lblMessage.Text = "Đã Tồn Tại"; ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "showModal();", true); } }