protected void btnGuardar_Click(object sender, EventArgs e) { if (txbFechaInicio.Text.Length > 0) { fechaini = DateTime.Parse(txbFechaInicio.Text); } if (txbFechaFin.Text.Length > 0) { fechafin = DateTime.Parse(txbFechaFin.Text); } try { var numCon = Convert.ToInt32(Request.QueryString["NUM"]); CONVENIO convenioModificado = ConvenioControlador.BuscarConvenioPorNumero(numCon); convenioModificado.inicioConvenio = fechaini; convenioModificado.finConvenio = fechafin; convenioModificado.plazoConvenio = txbPlazo.Text; CompareValidator1.Validate(); ConvenioControlador.ModificarFechaConvenio(convenioModificado); mensaje.Visible = true; string javaScript = "OcultarMensaje();"; ScriptManager.RegisterStartupScript(this, this.GetType(), "script", javaScript, true); } catch (Exception ex) { var datos = "<script> alert('" + ex.Message + "') </script>"; Response.Write(datos); } }
private bool validateall() { RequiredFieldValidator1.Validate(); RequiredFieldValidator2.Validate(); RequiredFieldValidator3.Validate(); RequiredFieldValidator4.Validate(); RequiredFieldValidator5.Validate(); RequiredFieldValidator6.Validate(); RequiredFieldValidator7.Validate(); RequiredFieldValidator8.Validate(); RequiredFieldValidator9.Validate(); RegularExpressionValidator1.Validate(); RegularExpressionValidator2.Validate(); RegularExpressionValidator3.Validate(); RegularExpressionValidator4.Validate(); RegularExpressionValidator5.Validate(); RegularExpressionValidator6.Validate(); RegularExpressionValidator7.Validate(); CompareValidator1.Validate(); CompareValidator2.Validate(); CompareValidator3.Validate(); if (!RequiredFieldValidator1.IsValid || !RequiredFieldValidator2.IsValid || !RequiredFieldValidator3.IsValid || !RequiredFieldValidator4.IsValid || !RequiredFieldValidator5.IsValid || !RequiredFieldValidator6.IsValid || !RequiredFieldValidator7.IsValid || !RequiredFieldValidator8.IsValid || !RequiredFieldValidator9.IsValid || !RegularExpressionValidator1.IsValid || !RegularExpressionValidator2.IsValid || !RegularExpressionValidator3.IsValid || !RegularExpressionValidator4.IsValid || !RegularExpressionValidator5.IsValid || !RegularExpressionValidator6.IsValid || !RegularExpressionValidator7.IsValid || !CompareValidator1.IsValid || !CompareValidator2.IsValid || !CompareValidator3.IsValid) { return(false); } return(true); }
protected void Page_Load(object sender, EventArgs e) { RequiredFieldValidator1.Validate(); CompareValidator1.Validate(); RegularExpressionValidator1.Validate(); RequiredFieldValidator2.Validate(); RequiredFieldValidator3.Validate(); }
protected void Button1_Click(object sender, EventArgs e) { CompareValidator1.Validate(); if (CompareValidator1.IsValid) { Label3.Text = "valid"; } else { Label3.Text = "not valid"; } }
//******************************************************* // // AddEntry_Click server event handler on this page is used to // saves a time entry and adds it to the system. // //******************************************************* protected void AddEntry_Click(object sender, System.EventArgs e) { // check validation. Requiredfieldvalidator1.Validate(); RequiredFieldValidator2.Validate(); RangeValidator1.Validate(); CompareValidator1.Validate(); // proceeds if data is valid then create an obejct and save it. if (Requiredfieldvalidator1.IsValid && RequiredFieldValidator2.IsValid && CompareValidator1.IsValid && RangeValidator1.IsValid) { BusinessLogicLayer.TimeEntry te = new BusinessLogicLayer.TimeEntry(0, Convert.ToInt32(UserList.SelectedItem.Value), Convert.ToInt32(ProjectList.SelectedItem.Value), Convert.ToInt32(CategoryList.SelectedItem.Value), Convert.ToDateTime(Days.SelectedItem.Value), ITSecurity.CleanStringRegex(Description.Text), Convert.ToDecimal(Hours.Text)); te.Save(); ClearEntryFields(); } }
protected void BtReg_Click(object sender, EventArgs e) { RequiredFieldValidator1.Validate(); RequiredFieldValidator2.Validate(); RequiredFieldValidator3.Validate(); RequiredFieldValidator4.Validate(); RequiredFieldValidator5.Validate(); RequiredFieldValidator6.Validate(); RequiredFieldValidator7.Validate(); CompareValidator1.Validate(); RegularExpressionValidator1.Validate(); RegularExpressionValidator2.Validate(); RegularExpressionValidator3.Validate(); RequiredFieldValidator8.Validate(); RequiredFieldValidator9.Validate(); if (!RequiredFieldValidator8.IsValid || !RequiredFieldValidator9.IsValid || !RequiredFieldValidator1.IsValid || !RequiredFieldValidator2.IsValid || !RequiredFieldValidator3.IsValid || !RequiredFieldValidator4.IsValid || !RequiredFieldValidator5.IsValid || !RequiredFieldValidator6.IsValid || !RequiredFieldValidator7.IsValid || !CompareValidator1.IsValid || !RegularExpressionValidator1.IsValid || !RegularExpressionValidator2.IsValid || !RegularExpressionValidator3.IsValid) { eMessage.Message("请仔细检查输入!", UpdatePanel1, this); return; } if (!this.SerialNumber1.CheckSN(txtCheck.Text) || txtCheck.Text == null || txtCheck.Text == "") { eMessage.Message("请输入正确的验证码", UpdatePanel1, this); this.SerialNumber1.Create(); return; } if (!Regex.IsMatch(txtIdReg.Text, "^\\d{10}$")) { eMessage.Message("不正确的ID", UpdatePanel1, this); SerialNumber1.Create(); return; } if (!Regex.IsMatch(txtNameReg.Text, "^[\u4E00-\u9FA5]{0,}$")) { eMessage.Message("请输入正确的姓名", UpdatePanel1, this); SerialNumber1.Create(); return; } if (txtPawReg.Text != txtPawRegCnf.Text) { eMessage.Message("您两次输入的密码不同", UpdatePanel1, this); SerialNumber1.Create(); return; } var cn = new SqlConnection(); cn.ConnectionString = DealData.constring; SqlCommand cmd = new SqlCommand("usp_VaUserName", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@username", SqlDbType.NVarChar, 50)).Value = txtUsrReg.Text; try { cn.Open(); if ((string)cmd.ExecuteScalar() != null) { eMessage.Message("该用户名已被注册!", UpdatePanel1, this); SerialNumber1.Create(); return; } } catch (Exception e1) { eMessage.Message("系统发生问题,请稍后重试或联系管理员", UpdatePanel1, this); SerialNumber1.Create(); eMessage.Message(e1); } finally { cn.Close(); } int state = 0; var cn2 = new SqlConnection(); cn2.ConnectionString = DealData.constring; SqlCommand cmd2 = new SqlCommand("usp_CreateUser", cn2); cmd2.CommandType = CommandType.StoredProcedure; cmd2.Parameters.Add(new SqlParameter("@username", SqlDbType.NVarChar, 50)).Value = txtUsrReg.Text; cmd2.Parameters.Add(new SqlParameter("@studentid", SqlDbType.NVarChar, 50)).Value = txtIdReg.Text; cmd2.Parameters.Add(new SqlParameter("@password", SqlDbType.NVarChar, 50)).Value = txtPawReg.Text; cmd2.Parameters.Add(new SqlParameter("@email", SqlDbType.NVarChar, 50)).Value = txtEmailReg.Text; cmd2.Parameters.Add(new SqlParameter("@question", SqlDbType.NVarChar, 50)).Value = txtQueReg.Text; cmd2.Parameters.Add(new SqlParameter("@key", SqlDbType.NVarChar, 50)).Value = txtAnsReg.Text; cmd2.Parameters.Add(new SqlParameter("@RealName", SqlDbType.NVarChar, 50)).Value = txtNameReg.Text; try { cn2.Open(); if (cmd2.ExecuteNonQuery() > 0) { eMessage.Message("注册成功,请等待老师的审核!", UpdatePanel1, this); SerialNumber1.Create(); state = 1; } else { eMessage.Message("注册失败,请稍后再试", UpdatePanel1, this); SerialNumber1.Create(); state = -1; } } catch (Exception e2) { eMessage.Message("系统发生错误请稍后再试", UpdatePanel1, this); SerialNumber1.Create(); eMessage.Message(e2); } finally { cn2.Close(); if (state == 1) { Response.Redirect("~/Default.aspx"); } } }
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { CompareValidator1.Operator = (ValidationCompareOperator)DropDownList1.SelectedIndex; CompareValidator1.Validate(); }
protected void TextBox5_TextChanged(object sender, EventArgs e) { CompareValidator1.Validate();//유효성 검사 }
protected void lnlNext_Click(object sender, EventArgs e) { CompareValidator1.Validate(); lblMsgs.Text = ""; dt = new DataTable(); dt = (DataTable)ViewState["UserDetails"]; if (txtUname.Text.Trim().Replace("'", "''") == "") { return; } if (txtFirstName.Text.Trim().Replace("'", "''") == "" || txtFirstName.Text.Trim().Replace("'", "''") == "First Name") { lblMsgs.Text = "First name is required."; return; } if (txtLastName.Text.Trim().Replace("'", "''") == "" || txtLastName.Text.Trim().Replace("'", "''") == "Last Name") { lblMsgs.Text = "Last name is required."; return; } if (txtPassword.Text.Trim() == "") { return; } if (txtConPassword.Text.Trim() == "") { lblMsgs.Text = "Confirm password is required."; return; } if (chkIAgree.Checked == false) { lblMsgs.Text = "Please check Terms & Conditions."; return; } if (txtConPassword.Text.Trim() != txtPassword.Text.Trim()) { lblMsgs.Text = "Passwords do not match."; return; } objLogin.Username = txtUname.Text.Trim().Replace("'", "''"); dt = objLoginDB.GetDataSet(objLogin, DA_SKORKEL.DA_Login.Login_1.GmailFBLogin); if (dt.Rows.Count > 0) { lblMsgs.Text = "Email id already exist."; txtUname.Text = ""; return; } CryptoGraphy objEncrypt = new CryptoGraphy(); string Password = objEncrypt.Encrypt(txtPassword.Text.Trim()); string middleName = ""; BindDataTable(); row = dt.NewRow(); //Defect #9 Validate HTML Input row["FirstName"] = Validations.validateHtmlInput(txtFirstName.Text.Trim()); row["MiddleName"] = middleName; row["LastName"] = Validations.validateHtmlInput(txtLastName.Text.Trim()); row["UserName"] = txtUname.Text.Trim(); row["Password"] = Password; row["ConPassword"] = txtConPassword.Text.Trim(); row["UserTypeId"] = 1; // For students dt.Rows.Add(row); Session.Add("UserDetails", dt); Response.Redirect("~/SignUp2.aspx"); }
protected void Button1_Click(object sender, EventArgs e) { bool IsPwSame = false; // 현재 비밀번호 CompareValidator1.Validate(); CompareValidator2.Validate(); RegularExpressionValidator2.Validate(); RegularExpressionValidator3.Validate(); RegularExpressionValidator4.Validate(); if (CompareValidator1.IsValid && CompareValidator2.IsValid && RegularExpressionValidator2.IsValid && RegularExpressionValidator3.IsValid && RegularExpressionValidator4.IsValid) { string connectionString = @"server=(local)\SQLExpress;Integrated Security=true;database=db_user";//서버 연결 SqlConnection Con = new SqlConnection(connectionString); // SQL COMMAND OBJECT를 만들고 SQL COMMAND 넣기 SqlCommand Cmd = new SqlCommand(); Cmd.Connection = Con; try { // SQL COMMAND 수행하기 Con.Open(); // 현재 비밀번호가 맞는지 체크 Cmd.CommandText = "SELECT pw FROM db_user WHERE id = \'" + Application["id"].ToString().TrimEnd() + "\'"; SqlDataReader reader = Cmd.ExecuteReader(); if (reader.Read()) { string pw = reader["pw"].ToString().TrimEnd(); if (pw == TextBox1.Text) { IsPwSame = true; } } reader.Close(); if (IsPwSame) // 현재 비밀번호가 맞으면 { //새 비밀번호를 DB에 업데이트 Cmd.CommandText = "UPDATE db_user SET pw = \'" + TextBox2.Text + "\' WHERE id = \'" + Application["id"].ToString().TrimEnd() + "\'"; // ExecuteNonQuery()문은 CREATE, ALTER, DROP, INSERT, UPDATE, DELETE 문을 수행할때 사용 int rowsAffected = Cmd.ExecuteNonQuery(); //편집구문에따라 영향받는 줄은 몇줄인가? if (rowsAffected == 1) //영향받는 줄은 1줄 { Response.Redirect(".\\pwchanged.aspx"); //비밀번호 변경후로 이동 } } else // 현재 비밀번호가 아니라면 다시 입력 { Label1.Text = "비밀번호가 다릅니다!"; } Con.Close(); } catch { // 예외 처리 Label1.Text = "안되는대?"; } } }