protected void Button1_Click(object sender, EventArgs e) { // читаем название группы в переменную name String name = TextBox1.Text; // значение названия группы обязательно должно быть введено if (name == "") { return; } // строка запроса на добавление данных String query = "INSERT INTO groups (name) VALUES ('" + name + "')"; // выполнение запроса на добавление данных SqlDataSource1.InsertCommand = query; SqlDataSource1.Insert(); // очистка поля ввода TextBox1.Text = ""; }
protected void Insertdatabtn_click(object sender, EventArgs e) { SqlDataSource1.InsertCommandType = SqlDataSourceCommandType.Text; SqlDataSource1.InsertCommand = "Insert into Schedule (Pro_id, Tournament, Location, StartDate, EndDate, Time, Team) VALUES (@Pro_id, @Tournament, @Location, @StartDate, @EndDate, @Time, @Team )"; SqlDataSource1.InsertParameters.Add("Pro_id", Convert.ToString(Request.QueryString["Pro_Id"])); SqlDataSource1.InsertParameters.Add("Tournament", TmentTxt.Text); SqlDataSource1.InsertParameters.Add("Location", LocationTxt.Text); SqlDataSource1.InsertParameters.Add("StartDate", StartDateTxt.Text); SqlDataSource1.InsertParameters.Add("EndDate", EndDateTxt.Text); SqlDataSource1.InsertParameters.Add("Time", TimeTxt.Text); SqlDataSource1.InsertParameters.Add("Team", TeamTxt.Text); SqlDataSource1.Insert(); TmentTxt.Text = ""; LocationTxt.Text = ""; StartDateTxt.Text = ""; EndDateTxt.Text = ""; TimeTxt.Text = ""; TeamTxt.Text = ""; AddSchTbl.Visible = false; GridView2.DataBind(); }
protected void btnAdd_Click(object sender, EventArgs e) { lblError.Text = ""; if (!Page.IsValid) { return; } txbSite.Text.Trim(); txbPhone.Text.Trim(); txbName.Text.Trim(); txbMail.Text.Trim(); if (txbMail.Text.Equals("") || txbName.Text.Equals("") || txbPhone.Text.Equals("") || txbSite.Text.Equals("")) { lblError.Text = "Вы заполнили не все поля"; return; } try { SqlDataSource1.Insert(); GridView1.DataBind(); txbMail.Text = ""; txbName.Text = ""; txbPhone.Text = ""; txbSite.Text = ""; } catch (SqlException ex) { lblError.Text = ex.Message; } }
protected void btncatadd_Click(object sender, EventArgs e) { DataView dv = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty); bool flag = false; string maincat = Ddlcategory.SelectedItem.Text; string brandname = TBbrandname.Text; for (int i = 0; i <= dv.Table.Rows.Count - 1; i++) { if (dv.Table.Rows[i]["maincategory"].ToString() == maincat && dv.Table.Rows[i]["brandname"].ToString().ToLower() == brandname) { flag = true; } else { flag = false; } } if (flag == true) { Lblmessage.Text = "Brand already exits!!"; } else { SqlDataSource1.Insert(); Lblmessage.Text = "Brand added successfully"; } }
protected void Button1_Click(object sender, EventArgs e) { if (IsValid) { var parameters = SqlDataSource1.InsertParameters; parameters["CD_ID"].DefaultValue = TextBox1.Text; parameters["CD_Name"].DefaultValue = TextBox2.Text; parameters["Artist_ID"].DefaultValue = TextBox3.Text; parameters["Genre"].DefaultValue = TextBox4.Text; parameters["Status"].DefaultValue = DropDownList1.Text; parameters["Release_Date"].DefaultValue = TextBox5.Text; try { SqlDataSource1.Insert(); TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = ""; TextBox4.Text = ""; TextBox5.Text = ""; } catch (Exception ex) { lblError.Text = DatabaseErrorMessage(ex.Message); } } }
protected void lbInsert_Click(object sender, EventArgs e) { SqlDataSource1.InsertParameters["Username"].DefaultValue = ((TextBox)GridView1.FooterRow.FindControl("txtUsername")).Text; SqlDataSource1.InsertParameters["Password"].DefaultValue = ((TextBox)GridView1.FooterRow.FindControl("txtPassword")).Text; SqlDataSource1.InsertParameters["Email"].DefaultValue = ((TextBox)GridView1.FooterRow.FindControl("txtEmail")).Text; SqlDataSource1.Insert(); }
protected void Button1_Click(object sender, EventArgs e) { string xibuname = TextBox1.Text.Trim(); bool kejian = true; //检查系部名称是否存在 SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["kecheng2012ConnectionString"].ConnectionString); SqlCommand comm = conn.CreateCommand(); comm.CommandText = "select xibuid from tb_xibu where xibuname='" + xibuname + "'"; conn.Open(); SqlDataReader sdr = comm.ExecuteReader(); if (sdr.Read()) { kejian = false; Label1.Text = "该系部名称已存在,请使用其他名称。"; } sdr.Close(); conn.Close(); if (kejian) { try { SqlDataSource1.InsertParameters[0].DefaultValue = TextBox1.Text.Trim(); SqlDataSource1.Insert(); Label1.Text = "创建系部成功!"; GridView1.DataBind(); } catch (Exception e1) { Label1.Text = e1.Message; } } }
protected void btnAdd_Click(object sender, EventArgs e) { if (IsValid) { var parameters = SqlDataSource1.InsertParameters; parameters["Disk_Status"].DefaultValue = Disk_Status_DropDownList.SelectedValue; parameters["Disk_Genre"].DefaultValue = Disk_Genre_DropDownList.SelectedValue; parameters["Disk_Type"].DefaultValue = Disk_Type_DropDownList.SelectedValue; parameters["Disk_Name"].DefaultValue = txtDisk_Name.Text; parameters["release_date"].DefaultValue = Disk_Calendar.SelectedDate.ToString(); try { SqlDataSource1.Insert(); Disk_Status_DropDownList.SelectedValue = null; Disk_Genre_DropDownList.SelectedValue = null; Disk_Type_DropDownList.SelectedValue = null; txtDisk_Name.Text = ""; } catch (Exception ex) { lblError.Text = DatabaseErrorMessage(ex.Message); } } }
protected void Button1_Click(object sender, EventArgs e) { try { //1350 500 if (FileUpload1.HasFile) { System.Drawing.Image img = System.Drawing.Image.FromStream(FileUpload1.PostedFile.InputStream); int height = img.Height; int width = img.Width; decimal size = Math.Round(((decimal)FileUpload1.PostedFile.ContentLength / (decimal)1024), 2); FileUpload1.SaveAs(Server.MapPath("~/DynamicImage/" + Path.GetFileName(FileUpload1.FileName))); SqlDataSource1.InsertParameters.Add("Image", "~/DynamicImage/" + FileUpload1.FileName); SqlDataSource1.Insert(); lblMessage.Visible = true; savediv.Visible = true; GridView1.DataBind(); } } catch (Exception ex) { lblMessage.Visible = true; lblMessage.Text = ex.Message; } }
protected void btnCadastrar_Click(object sender, EventArgs e) { Usuarios User = new Usuarios(); User = (Usuarios)Session["usuario"]; string ope = Request.QueryString["ope"]; if (ope != "E") { SqlDataSource1.InsertParameters["Nome"].DefaultValue = txtProjeto.Text; SqlDataSource1.InsertParameters["Responsavel"].DefaultValue = txtResponsavel.Text; SqlDataSource1.InsertParameters["Tipo"].DefaultValue = txtTipo.Text; SqlDataSource1.InsertParameters["Orcamento"].DefaultValue = txtOrcamento.Text; SqlDataSource1.InsertParameters["Periodo"].DefaultValue = txtDias.Text; SqlDataSource1.InsertParameters["Descricao"].DefaultValue = txtDescricao.Text; SqlDataSource1.InsertParameters["IDCond"].DefaultValue = Convert.ToString(User.Cond); SqlDataSource1.InsertParameters["Login"].DefaultValue = User.Login; SqlDataSource1.Insert(); } else { SqlDataSource1.UpdateParameters["Nome"].DefaultValue = txtProjeto.Text; SqlDataSource1.UpdateParameters["Responsavel"].DefaultValue = txtResponsavel.Text; SqlDataSource1.UpdateParameters["Tipo"].DefaultValue = txtTipo.Text; SqlDataSource1.UpdateParameters["Orcamento"].DefaultValue = txtOrcamento.Text; SqlDataSource1.UpdateParameters["Periodo"].DefaultValue = txtDias.Text; SqlDataSource1.UpdateParameters["Descricao"].DefaultValue = txtDescricao.Text; SqlDataSource1.Update(); } }
protected void btnCadastrar_Click(object sender, EventArgs e) { Usuarios User = new Usuarios(); User = (Usuarios)Session["usuario"]; string ope = Request.QueryString["ope"]; if (ope != "E") { SqlDataSource1.InsertParameters["IDUnit"].DefaultValue = ddlApart.SelectedItem.Value; SqlDataSource1.InsertParameters["IDCond"].DefaultValue = Convert.ToString(User.Cond); SqlDataSource1.InsertParameters["ConsNome"].DefaultValue = txtNome.Text; SqlDataSource1.InsertParameters["ConsTelefone"].DefaultValue = txtTelefone.Text; SqlDataSource1.InsertParameters["ConsGestao"].DefaultValue = txtGestao.Text; SqlDataSource1.InsertParameters["ConsEmail"].DefaultValue = txtEmail.Text; SqlDataSource1.InsertParameters["IDBloco"].DefaultValue = ddlBloco.SelectedItem.Value; SqlDataSource1.Insert(); } else { SqlDataSource1.UpdateParameters["IDUnit"].DefaultValue = ddlApart.SelectedItem.Value; SqlDataSource1.UpdateParameters["IDCond"].DefaultValue = Convert.ToString(User.Cond); SqlDataSource1.UpdateParameters["ConsNome"].DefaultValue = txtNome.Text; SqlDataSource1.UpdateParameters["ConsTelefone"].DefaultValue = txtTelefone.Text; SqlDataSource1.UpdateParameters["ConsGestao"].DefaultValue = txtGestao.Text; SqlDataSource1.UpdateParameters["ConsEmail"].DefaultValue = txtEmail.Text; SqlDataSource1.UpdateParameters["IDBloco"].DefaultValue = ddlBloco.SelectedItem.Value; SqlDataSource1.Update(); } }
protected void btnsaveProduct_Click(object sender, EventArgs e) { if (FileUpload1.HasFile) { FileUpload1.SaveAs(Server.MapPath("Uploadedpix/") + FileUpload1.FileName); lblFullSizeImage.Text = FileUpload1.FileName; } if (FileUpload2.HasFile) { FileUpload2.SaveAs(Server.MapPath("Thumbnails/") + FileUpload2.FileName); } lblThumbSizeImage.Text = FileUpload2.FileName; btnsaveProduct.Visible = true; SqlDataSource1.Insert(); this.lblAddingNewItem.Text = "Item Has Been Added into the Database"; btnsaveProduct.Visible = false; btnInsert.Visible = true; txtPrice.Enabled = false; txtShortDescription.Enabled = false; txtProductDescription.Enabled = false; txtProductName.Enabled = false; dropCatInsert.Enabled = false; }
protected void btnAddRecord_Click(object sender, EventArgs e) { if (IsValid) { var parameters = SqlDataSource1.InsertParameters; // ([ChuDe], [MoTa], [NoiDung], [Video], [HinhAnh], [FileDinhKem], [ID_CT]) parameters["ChuDe"].DefaultValue = txtChuDe.Text; parameters["MoTa"].DefaultValue = txtMoTa.Text; parameters["NoiDung"].DefaultValue = txtNoiDung.Text; parameters["Video"].DefaultValue = txtVideo.Text; parameters["HinhAnh"].DefaultValue = txtHinhAnh.Text; parameters["FileDinhKem"].DefaultValue = txtFileDinhKem.Text; parameters["ID_CT"].DefaultValue = ddlID_CT.SelectedValue; try { if (txtChuDe.Text == "") { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Các trường (*) không được bỏ trống.');", true); } else if (txtMoTa.Text == "") { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Các trường (*) không được bỏ trống.');", true); } else if (txtNoiDung.Text == "") { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Các trường (*) không được bỏ trống.');", true); } else if (txtHinhAnh.Text == "") { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Các trường (*) không được bỏ trống.');", true); } else { SqlDataSource1.Insert(); txtChuDe.Text = ""; txtMoTa.Text = ""; txtNoiDung.Text = ""; txtVideo.Text = ""; txtHinhAnh.Text = ""; txtFileDinhKem.Text = ""; StringBuilder sb = new StringBuilder(); sb.Append(@"<script type='text/javascript'>"); sb.Append("alert('Record Added Successfully');"); sb.Append("$('#addModal').modal('hide');"); sb.Append(@"</script>"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "AddHideModalScript", sb.ToString(), false); } } catch (Exception) { ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Vui lòng kiểm tra lại.');", true); } } }
protected void btnAdd_Click(object sender, EventArgs e) { if (!Page.IsValid) { return; } string name = txtName.Text; if (name.Length < 2) { //Response.Write("<script>alert('Name must be at least 2 characters long');</script>"); txtName.Text = ""; return; } int age; if (!Int32.TryParse(txtAge.Text, out age) || age < 0 || age > 150) { //Response.Write("<script>alert('Please enter a valid number between 0 and 150');</script>"); txtAge.Text = ""; return; } SqlDataSource1.InsertCommandType = SqlDataSourceCommandType.Text; SqlDataSource1.InsertCommand = "INSERT INTO Persons VALUES(@Name, @Age)"; SqlDataSource1.InsertParameters.Add("Name", name); SqlDataSource1.InsertParameters.Add("Age", age.ToString()); SqlDataSource1.Insert(); txtName.Text = ""; txtAge.Text = ""; }
protected void Button1_Click(object sender, EventArgs e) { Label10.Visible = false; if (RadioButton1.Checked) { if (IsValid) { SqlDataSource1.InsertParameters["nom"].DefaultValue = TextBox1.Text; SqlDataSource1.InsertParameters["apell"].DefaultValue = TextBox2.Text; SqlDataSource1.InsertParameters["telf"].DefaultValue = TextBox4.Text; SqlDataSource1.InsertParameters["clave"].DefaultValue = TextBox6.Text; SqlDataSource1.Insert(); Label10.Text = "Se efectuó el registro"; TextBox1.Text = ""; TextBox2.Text = ""; TextBox3.Text = ""; TextBox4.Text = ""; TextBox5.Text = ""; TextBox6.Text = ""; } } else { Label10.Visible = true; } Label10.Text = "Debe aceptar los términos y condiciones"; }
//button that inserts into the database protected void BtnSubmit_Click(object sender, EventArgs e) { SqlDataSource1.InsertParameters["datetime"].DefaultValue = DateTime.Now.ToString(); SqlDataSource1.Insert(); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert ('Successfully created an incident!')", true); Clear(); }
protected void submit_Click(object sender, EventArgs e) { DataView x; Boolean flag = false; x = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty); for (Int32 i = 0; i <= x.Table.Rows.Count - 1; i++) { if (email.Text.ToLower() == x.Table.Rows[i]["email"].ToString().ToLower()) { flag = true; break; } } if (flag == true) { name.Focus(); Response.Redirect("inf.aspx"); } else { SqlDataSource1.Insert(); Response.Redirect("info/City table.aspx"); } }
protected void btnCadastrar_Click(object sender, EventArgs e) { Usuarios User = new Usuarios(); User = (Usuarios)Session["usuario"]; string ope = Request.QueryString["ope"]; if (ope != "E") { SqlDataSource1.InsertParameters["EmpresaNome"].DefaultValue = ddlEmpresa.SelectedItem.Value; SqlDataSource1.InsertParameters["NumeroNf"].DefaultValue = ddlNf.SelectedItem.Value; SqlDataSource1.InsertParameters["CtaDescricao"].DefaultValue = txtDescricao.Text; SqlDataSource1.InsertParameters["CtaBoletoNumero"].DefaultValue = txtBoleto.Text; SqlDataSource1.InsertParameters["CtaDtBoleto"].DefaultValue = txtRecebimento.Text; SqlDataSource1.InsertParameters["CtaVencimentoBoleto"].DefaultValue = txtVencimento.Text; SqlDataSource1.InsertParameters["CtaValor"].DefaultValue = txtValor.Text; SqlDataSource1.InsertParameters["IDCond"].DefaultValue = Convert.ToString(User.Cond); SqlDataSource1.Insert(); } else { SqlDataSource1.UpdateParameters["EmpresaNome"].DefaultValue = ddlEmpresa.SelectedItem.Value; SqlDataSource1.UpdateParameters["NumeroNf"].DefaultValue = ddlNf.SelectedItem.Value; SqlDataSource1.UpdateParameters["CtaDescricao"].DefaultValue = txtDescricao.Text; SqlDataSource1.UpdateParameters["CtaBoletoNumero"].DefaultValue = txtBoleto.Text; SqlDataSource1.UpdateParameters["CtaDtBoleto"].DefaultValue = txtRecebimento.Text; SqlDataSource1.UpdateParameters["CtaVencimentoBoleto"].DefaultValue = txtVencimento.Text; SqlDataSource1.UpdateParameters["CtaValor"].DefaultValue = txtValor.Text; SqlDataSource1.UpdateParameters["IDCond"].DefaultValue = Convert.ToString(User.Cond); SqlDataSource1.Update(); } }
protected void btnAdd_Click(object sender, EventArgs e) { if (IsValid) { var parameters = SqlDataSource1.InsertParameters; parameters["name"].DefaultValue = txtName.Text; parameters["shortDescription"].DefaultValue = txtShortDescription.Text; parameters["description"].DefaultValue = txtDescription.Text; parameters["price"].DefaultValue = txtPrice.Text; parameters["image"].DefaultValue = txtImage.Text; try { SqlDataSource1.Insert(); txtName.Text = ""; txtShortDescription.Text = ""; txtDescription.Text = ""; txtPrice.Text = ""; txtImage.Text = ""; } catch (Exception ex) { lblError.Text = DatabaseErrorMessage(ex.Message); } } }
protected void Button1_Click(object sender, EventArgs e) { SqlDataSource1.InsertParameters["descripcion"].DefaultValue = TextBox1.Text; SqlDataSource1.Insert(); Label1.Text = "Se efectuó la carga"; TextBox1.Text = ""; }
protected void Page_Load(object sender, EventArgs e) { UnobtrusiveValidationMode = UnobtrusiveValidationMode.None; if (IsPostBack) { // If check email is true, that means that the email is already in the User table. // So if it is false, we can safely insert and move on to the Log In page. if (!CheckEmail(txtEmail.Text)) { SqlDataSource1.Insert(); Response.Redirect("Login.aspx"); } else { lblMessage.Text = "That email is already in use!"; } } else { // Bind all of the fields! txtFirstName.DataBind(); txtLastName.DataBind(); txtAddress.DataBind(); txtCity.DataBind(); txtState.DataBind(); txtZipCode.DataBind(); ddlCountry.DataBind(); txtEmail.DataBind(); txtPhoneNumber.DataBind(); txtPassword.DataBind(); } }
protected void btn1_Click(object sender, EventArgs e) { try { int n = SqlDataSource1.Insert(); if (n == 1) { string SignOfGuide = Server.MapPath("RashtrapatiGuideAwardFormSignatureOfGuide"); string SignOfGuideCaptain = Server.MapPath("RashtrapatiGuideAwardForm2SignatureOfGuideCaptain"); fuSignatureOfGuide.SaveAs(SignOfGuide + "\\" + fuSignatureOfGuide.FileName); fuSignatureOfGuideCaptain.SaveAs(SignOfGuideCaptain + "\\" + fuSignatureOfGuideCaptain.FileName); // Session.Add("NameOfGuide", txtNameofGuide.Text); Response.Write("<script>alert('Data Inserted Successfully')</script>"); Server.Transfer("RashtrapatiScoutAwardForm2.aspx"); } else { Response.Write("<script>alert('Please fill the form Correctly')</script>"); } } catch (Exception er) { Response.Write(er.Message); } }
protected void btadd_Click(object sender, EventArgs e) { //判断信息输入完整 if (!HaveUty(txtuty.Text)) { if (txtrdays.Text.Trim() == "" || txtnum.Text.Trim() == "" || txtbdays.Text.Trim() == "") { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "", "alert('请输入完整信息!');", true); } else { SqlDataSource1.InsertParameters["utid"].DefaultValue = GenId(); SqlDataSource1.InsertParameters["user_class"].DefaultValue = txtuty.Text.Trim(); SqlDataSource1.InsertParameters["number_limit"].DefaultValue = txtnum.Text.Trim(); SqlDataSource1.InsertParameters["borrow_days"].DefaultValue = txtbdays.Text.Trim(); SqlDataSource1.InsertParameters["reserve_days"].DefaultValue = txtrdays.Text.Trim(); SqlDataSource1.InsertParameters["renew_times"].DefaultValue = txtrenew_times.Text.Trim(); SqlDataSource1.InsertParameters["renew_days"].DefaultValue = txtrenew_days.Text.Trim(); SqlDataSource1.Insert(); } } else { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "", "alert('该用户类别已存在!');", true); } }
protected void InsertMedicine(object sender, EventArgs e) { if (medicineID.Text == "") { Response.Write("<script>alert('請輸入藥品編號!');</script>"); } if (medicineName.Text == "") { Response.Write("<script>alert('請輸入藥品名稱!');</script>"); } else { SqlDataSource1.InsertParameters["MCategoryID"].DefaultValue = category_select.Value.Substring(0, 4); SqlDataSource1.InsertParameters["MSubCategoryID"].DefaultValue = (subcategory_select.Value == "") ? "0" : subcategory_select.Value.Substring(0, 4); SqlDataSource1.InsertParameters["ID"].DefaultValue = medicineID.Text; SqlDataSource1.InsertParameters["IDNote"].DefaultValue = medicineIDNote.Text; SqlDataSource1.InsertParameters["Name"].DefaultValue = medicineName.Text; SqlDataSource1.InsertParameters["Name2"].DefaultValue = medicineName2.Text; SqlDataSource1.InsertParameters["DF_mID"].DefaultValue = (medicineMID.Text == "") ? " " : medicineMID.Text; SqlDataSource1.InsertParameters["DF_subname"].DefaultValue = (medicineSubName1.Text == "") ? " " : medicineSubName1.Text; SqlDataSource1.InsertParameters["DF_subname2"].DefaultValue = (medicineSubName2.Text == "") ? " " : medicineSubName2.Text; SqlDataSource1.InsertParameters["DF_dosage"].DefaultValue = (medicineDosage.Text == "") ? " " : medicineDosage.Text; SqlDataSource1.InsertParameters["DF_form"].DefaultValue = (medicineForm.Text == "") ? " " : medicineForm.Text; SqlDataSource1.InsertParameters["DF_note"].DefaultValue = (medicineDFNote.Text == "") ? " " : medicineDFNote.Text; SqlDataSource1.InsertParameters["DosFormNote"].DefaultValue = DosageFormNote.Text; SqlDataSource1.InsertParameters["UsualDose"].DefaultValue = (UsualDose.Text == "") ? " " : UsualDose.Text; SqlDataSource1.InsertParameters["Category"].DefaultValue = medicineCategory.Value; SqlDataSource1.InsertParameters["CategoryNote"].DefaultValue = medicineCategoryNote.Text; SqlDataSource1.InsertParameters["Note"].DefaultValue = medicineNote.Text; SqlDataSource1.InsertParameters["ImagePaths"].DefaultValue = ""; SqlDataSource1.Insert(); Response.Write("<script>alert('資料新增成功!');window.location.replace('NewMedicine.aspx');</script>"); } }
protected void btnAddCake_Click(object sender, EventArgs e) { // Manager can add cake to DB SqlDataSource1.InsertParameters["ProductId"].DefaultValue = txtID.Text; SqlDataSource1.InsertParameters["Name"].DefaultValue = txtName.Text; SqlDataSource1.InsertParameters["Description"].DefaultValue = txtDescript.Text; SqlDataSource1.InsertParameters["Image"].DefaultValue = txtImageFile.Text; SqlDataSource1.InsertParameters["UnitPrice"].DefaultValue = txtPrice.Text; SqlDataSource1.InsertParameters["OnHand"].DefaultValue = txtOnHand.Text; try { // insert to Products table in database SqlDataSource1.Insert(); // clear textboxes txtID.Text = ""; txtName.Text = ""; txtDescript.Text = ""; txtImageFile.Text = ""; txtPrice.Text = ""; txtOnHand.Text = ""; } catch (Exception ex) { lblError.Text = "A database error has occurred. " + "Message: " + ex.Message; } }
protected void OnClick_Insert(object sender, EventArgs e) { if (Password.Text.Length < 8) { Label2.Text = "Password can't be less then 8 character"; Password.Text = ""; } else if (Password.Text.Length > 12) { Label2.Text = "Password can't be more then 12 character"; Password.Text = ""; } else if (Password.Text.Contains(User_Name.Text)) { Label2.Text = "Password can't contain User Name"; Password.Text = ""; } else { Encryption enc = new Encryption(User_Name.Text, Password.Text); Password.Text = enc.Get_Encrypted_Value(); SqlDataSource1.Insert(); empid.Text = ""; User_Name.Text = ""; Password.Text = ""; Designation.Text = ""; Role.Text = ""; Label2.Text = "User Created"; } }
protected void btnAddProduct_Click(object sender, EventArgs e) { if (IsValid) { var parameters = SqlDataSource1.InsertParameters; parameters["ProductCode"].DefaultValue = txtProductCode.Text; parameters["Name"].DefaultValue = txtName.Text; parameters["Version"].DefaultValue = txtVersion.Text; parameters["ReleaseDate"].DefaultValue = txtReleaseDate.Text; try { SqlDataSource1.Insert(); txtProductCode.Text = ""; txtName.Text = ""; txtVersion.Text = ""; txtReleaseDate.Text = "mm/dd/yy"; } catch (Exception ex) { string errorMsg = DatabaseErrorMessage(ex.Message); lblAddError.Text = errorMsg; Session["ErrorMessage"] = errorMsg; Session["ReturnUrl"] = Request.Url.ToString(); Response.Redirect("~/ErrorMessage"); } } }
protected void BtnSubmit_Click(object sender, EventArgs e) { //SqlDataSource1.InsertParameters["user_id"].DefaultValue = selectedCustomer.user_id; SqlDataSource1.InsertParameters["datetime"].DefaultValue = DateTime.Now.ToString(); SqlDataSource1.Insert(); clear(); }
protected void LinkButton1_Click(object sender, EventArgs e) { SqlDataSource1.InsertParameters["NUMBER"].DefaultValue = (GridView1.FooterRow.FindControl("txtInsertNumber") as TextBox).Text; SqlDataSource1.InsertParameters["NAME"].DefaultValue = (GridView1.FooterRow.FindControl("txtInsertName") as TextBox).Text; SqlDataSource1.InsertParameters["AMOUNT"].DefaultValue = (GridView1.FooterRow.FindControl("txtInsertAmount") as TextBox).Text; SqlDataSource1.Insert(); string SecName = (GridView1.FooterRow.FindControl("txtInsertName") as TextBox).Text; SecName = SecName.Replace(" ", ""); con = new SqlConnection(ConfigurationManager.ConnectionStrings["UniversityDatabaseConnectionString"].ToString()); SqlCommand cmd = new SqlCommand("alter table SAVINGS$ add " + SecName + " nvarchar(50);", con); //cmd.Parameters.AddWithValue("@NAME", SecName); con.Open(); cmd.ExecuteNonQuery(); con.Close(); SqlCommand cmd1 = new SqlCommand("update SAVINGS$ set " + SecName + "=0", con); //cmd.Parameters.AddWithValue("@NAME", SecName); con.Open(); cmd1.ExecuteNonQuery(); con.Close(); Response.Write("<script>alert('Data Saved Successfully!!');</script>"); }
protected void btnCadastrar_Click(object sender, EventArgs e) { Usuarios User = new Usuarios(); User = (Usuarios)Session["usuario"]; string ope = Request.QueryString["ope"]; if (ope != "E") { SqlDataSource1.InsertParameters["Data"].DefaultValue = txtData.Text; SqlDataSource1.InsertParameters["Local"].DefaultValue = txtLocal.Text; SqlDataSource1.InsertParameters["Hora"].DefaultValue = txtHora.Text; SqlDataSource1.InsertParameters["Assunto"].DefaultValue = txtAssunto.Text; SqlDataSource1.InsertParameters["IDCond"].DefaultValue = Convert.ToString(User.Cond); SqlDataSource1.Insert(); } else { SqlDataSource1.UpdateParameters["Data"].DefaultValue = txtData.Text; SqlDataSource1.UpdateParameters["Local"].DefaultValue = txtLocal.Text; SqlDataSource1.UpdateParameters["Hora"].DefaultValue = txtHora.Text; SqlDataSource1.UpdateParameters["Assunto"].DefaultValue = txtAssunto.Text; SqlDataSource1.Update(); } }