protected void IsAvailablePass(object source, ServerValidateEventArgs args)
        {
            var hashre = new PasswordHasher();

            args.IsValid = (hashre.VerifyHashedPassword(Context.User.Identity.GetUserInfo().PasswordHash, args.Value)) ==
                           PasswordVerificationResult.Success;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Validates the line thickness
        /// </summary>
        /// <param name="source">Validator object</param>
        /// <param name="args">Validation arguments</param>
        public void ValidateLineThickness(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            CustomValidator val      = (CustomValidator)source;
            string          errorKey = "";


            if (InputValidation.ValidateMandatoryPositiveInteger(source, args, out errorKey) == false)
            {
                SetValidationError(val, args, errorKey);
                return;
            }

            if (txtMaxLineThickness.Text.Length == 0)
            {
                SetValidationError(val, args, "PxWebAdminSettingsValidationBiggerThanMaxSetting", Master.GetLocalizedString("PxWebAdminFeaturesChartsGeneralMaxLineThickness"));
                return;
            }

            int value;

            if (int.TryParse(txtMaxLineThickness.Text, out value) == false)
            {
                SetValidationError(val, args, "PxWebAdminSettingsValidationBiggerThanMaxSetting", Master.GetLocalizedString("PxWebAdminFeaturesChartsGeneralMaxLineThickness"));
                return;
            }

            if (int.Parse(txtLineThickness.Text) > int.Parse(txtMaxLineThickness.Text))
            {
                SetValidationError(val, args, "PxWebAdminSettingsValidationBiggerThanMaxSetting", Master.GetLocalizedString("PxWebAdminFeaturesChartsGeneralMaxLineThickness"));
                return;
            }
        }
Exemplo n.º 3
0
 protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
 {
     if (CheckBoxRegulamin.Checked)
         args.IsValid = true;
     else
         args.IsValid = false;
 }
Exemplo n.º 4
0
        /// <summary>
        /// Validates that value is a integer >= 0.
        /// </summary>
        /// <param name="source">Validator object</param>
        /// <param name="args">Validator arguments</param>
        /// <param name="keyErrorMessage">Contains key for error message if value is not valid</param>
        /// <returns>True if value is valid, else false</returns>
        public static bool ValidatePositiveInteger(object source, System.Web.UI.WebControls.ServerValidateEventArgs args, out string keyErrorMessage)
        {
            CustomValidator val = (CustomValidator)source;
            int             value;
            long            lvalue;

            if (!int.TryParse(args.Value, out value))
            {
                if (long.TryParse(args.Value, out lvalue))
                {
                    keyErrorMessage = "PxWebAdminSettingsValidationTooLargeIntegerValue";
                    return(false);
                }
                else
                {
                    keyErrorMessage = "PxWebAdminSettingsValidationIntegerValue";
                    return(false);
                }
            }

            if (value < 0)
            {
                keyErrorMessage = "PxWebAdminSettingsValidationGreaterThanZero";
                return(false);
            }


            keyErrorMessage = "";
            return(true);
        }
Exemplo n.º 5
0
 protected void OnServerLengthValidator(object sender, ServerValidateEventArgs e)
 {
     if (e.Value.Length > 5)
         e.IsValid = true;
     else
         e.IsValid = false;
 }
 protected void CvUserName_ServerValidate(object source, ServerValidateEventArgs args)
 {
     if (args.Value.Length >= 6)
         args.IsValid = true;
     else
         args.IsValid = false;
 }
Exemplo n.º 7
0
        private void ValidateComisiones(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            if (this.rbtImporteFijo.Checked == false && this.rbtPorcentaje.Checked == false)
            {
                args.IsValid = false;
                ((CustomValidator)source).ErrorMessage = this.TraducirTexto("Errores.Obligatorios.PorcentajeImporteFijo");
                return;
            }

            if (this.rbtImporteFijo.Checked == true && this.txtImporteFijo.Text == "")
            {
                args.IsValid = false;
                ((CustomValidator)source).ErrorMessage = this.TraducirTexto("Errores.Obligatorios.ImporteFijo");
                return;
            }

            if (this.rbtPorcentaje.Checked == true && this.txtPorcentaje.Text == "")
            {
                args.IsValid = false;
                ((CustomValidator)source).ErrorMessage = this.TraducirTexto("Errores.Obligatorios.Porcentaje");
                return;
            }

            args.IsValid = true;
        }
 protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
 {
     if (Description.Text.Length > 200)
         args.IsValid = false;
     else
         args.IsValid = true;
 }
        protected void CMSLocationGroup_Validate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            if (args.Value.Length >= 1)
            {
                int cms_location_group_id = int.Parse(args.Value);
                //Check if country already exists

                int result = MappingsCMSLocations.CheckCMSLocationGroupExists(cms_location_group_id);

                if (result == 0)
                {
                    //Does not exist continue
                    args.IsValid = true;
                }
                else
                {
                    //Does exist cancel
                    args.IsValid = false;
                }
            }
            else
            {
                //Not valid
                args.IsValid = false;
            }
        }
Exemplo n.º 10
0
 protected void csvEname_ServerValidate(object sender, System.Web.UI.WebControls.ServerValidateEventArgs e)
 {
     if (!UserManag.IsUniqueUserName() && hf_update.Value == "0")
     {
         e.IsValid = false;
     }
 }
Exemplo n.º 11
0
 private void ValidateSiniestro(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
 {
     if ((rbtDecomisada.Checked || rbtExtraviada.Checked || rbtAnuladaWeb.Checked) && txtSiniestro.Text != "")
     {
         args.IsValid = true;
         return;
     }
     else if ((rbtDecomisada.Checked || rbtExtraviada.Checked || rbtAnuladaWeb.Checked) && txtSiniestro.Text == "")
     {
         args.IsValid = false;
         ((CustomValidator)source).ErrorMessage = "Debe ingresar un número de siniestro o acta de infracción, es obligatorio";
         return;
     }
     else if (rbtObservacion.Checked && (Observacion1.ObservacionID != "" || Observacion1.Codigo != "" || Observacion1.ObsDescrip != ""))
     {
         args.IsValid = true;
         return;
     }
     else if (rbtObservacion.Checked && (Observacion1.ObservacionID == "" || Observacion1.Codigo == "" || Observacion1.ObsDescrip == ""))
     {
         args.IsValid = false;
         ((CustomValidator)source).ErrorMessage = "Debe ingresar una observación tipificada, es obligatorio";
         return;
     }
 }
Exemplo n.º 12
0
 private void ValidateSupervisor(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
 {
     if (this.busqSupervisor.VendedorID == "" || this.busqSupervisor.ApellidoNombre == "")
     {
         this.busqSupervisor.VendedorID = "0";
     }
 }
Exemplo n.º 13
0
 protected void cvEventDate_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
 {
     if (!myHelpers.DateIsValid(txtEventDate.Text))
     {
         args.IsValid = false;
     }
 }
Exemplo n.º 14
0
        protected void RACFID_Validate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            if (args.Value.Length >= 1)
            {
                string racfid = Convert.ToString(args.Value);
                //Check if racfid already exists

                int result = Users.CheckRACFIDExits(racfid);

                if (result == 0)
                {
                    //Does not exist continue
                    args.IsValid = true;
                }
                else
                {
                    //Does exist cancel
                    args.IsValid = false;
                    this.CustomValidatorRACFID.Text = Resources.lang.ErrorMessageUniqueRACFID;
                }
            }
            else
            {
                //Not valid
                args.IsValid = false;
                this.CustomValidatorRACFID.Text = Resources.lang.ErrorMessageRACFID;
            }
        }
Exemplo n.º 15
0
 protected void CustomValidator1_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
 {
     if (!this.check_Acepto.Checked)
     {
         args.IsValid = false;
     }
 }
Exemplo n.º 16
0
/*
 */
        public void CheckPrice(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            double tempVal;

            args.IsValid = true;

            //strip out dollar sign if present
            if (txtPrice.Text.IndexOf("$") != -1)
            {
                txtPrice.Text = Global.StrReplace(txtPrice.Text, @"\$");
            }

            if (!IsNumeric(txtPrice.Text))
            {
                args.IsValid = false;
                CustomValidator5.ErrorMessage = "!";
            }

            try
            {
                tempVal = Convert.ToDouble(txtPrice.Text);
            }

            catch
            {
                CustomValidator5.ErrorMessage = "!";
                args.IsValid = false;
            }
        }
Exemplo n.º 17
0
    protected void CustomValidator1_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
    {
        int zip;

        if (Int32.TryParse(address.Text, out zip))
        {
            if (address.Text.Length != 5)
            {
                args.IsValid = false;
                CustomValidator1.ErrorMessage = "Please enter a 5 digit zipcode";
            }
            else
            {
                args.IsValid = true;
            }
        }
        else
        {
            string cityandstate = address.Text;
            if (cityandstate.Contains(","))
            {
                args.IsValid = true;
            }
            else
            {
                args.IsValid = false;
            }
        }
    }
Exemplo n.º 18
0
 protected void cvMaterialName_ServerValidate(object source, ServerValidateEventArgs args)
 {
     //供应商名称控件
     var txtSupplierName = (TextBox)fvMaterialReturnAdd.FindControl("txtSupplierName");
     //检测是否存在物料名称
     args.IsValid = ydPublicMethod.IsExistMaterialName(txtSupplierName, source, args);
 }
Exemplo n.º 19
0
 /// <summary>
 /// 验证数据是否满足图片类型.
 /// </summary>
 protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
 {
     if (args.Value != null && args.Value != "")
     {
         args.IsValid = imgytpes.IndexOf(System.IO.Path.GetExtension(args.Value).ToUpper()) >= 0;
     }
 }
Exemplo n.º 20
0
        protected void CustomValidator_ServerValidate(object source, ServerValidateEventArgs args)
        {
            //string imageName = Guid.NewGuid().ToString().Substring(0, 8);
            //string geocacheImageTemp = imageName + ".bmp";
            //System.Drawing.Bitmap bmpPostedImage = new System.Drawing.Bitmap(imageFileUpload.PostedFile.InputStream);
            //bmpPostedImage.Save(Server.MapPath(@"temp\") + imageName + ".bmp");
            ////bmpPostedImage.Save("C:\\Users\\Juliana\\Documents\\GitHub\\ASECPJ\\ASECPJ\\geocache\\temp\\" + imageName + ".bmp");

            //Stegano decryptStegano = new Stegano();
            //string message = decryptStegano.RetrieveMessage(Server.MapPath(@"temp\") + imageName + ".bmp");
            ////string message = decryptStegano.RetrieveMessage("C:\\Users\\Juliana\\Documents\\GitHub\\ASECPJ\\ASECPJ\\geocache\\temp\\3a902149.bmp");

            //if (message.Equals(""))
            //{
            //    Response.Redirect("true");
            //    args.IsValid = true;

            //}
            //else
            //{
            //    Response.Redirect("false");
            //    args.IsValid = false;
            //}

            args.IsValid = true;
        }
 protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
 {
     if (Image1.ImageUrl == "Images/icon_visa.png")
     {
         if ((txtCard.Text).Count() == 16 || (txtCard.Text).Count() == 13)
             args.IsValid = true;
         else
             args.IsValid = false;
     }
     else
         if (Image1.ImageUrl =="Images/apps_mastercard.png")
         {
             if ((txtCard.Text).Count() == 16)
                 args.IsValid = true;
             else
                 args.IsValid = false;
         }
         else
             if (Image1.ImageUrl =="Images/download.jpg")
             {
                 if ((txtCard.Text).Count() == 15)
                     args.IsValid = true;
                 else
                     args.IsValid = false;
             }
             else args.IsValid = false;
 }
        private void ValidarEntidad(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            if (this.rbtAgencias.Checked)
            {
                string AgenciaID = this.busqAgencia.AgenciaID;
                if (AgenciaID == "")
                {
                    args.IsValid = false;
                    ((CustomValidator)source).ErrorMessage = this.TraducirTexto("Errores.Obligatorios.Agencia");
                    return;
                }
            }
            if (this.rbtCliente.Checked)
            {
                string ClienteID = this.busqCliente.ClienteID;
                if (ClienteID == "")
                {
                    args.IsValid = false;
                    ((CustomValidator)source).ErrorMessage = this.TraducirTexto("Errores.Obligatorios.Cliente");
                    return;
                }
            }

            args.IsValid = true;
        }
Exemplo n.º 23
0
 protected void cvIsActive_ServerValidate(object source, ServerValidateEventArgs args)
 {
     if (chkDone.Checked != true)
         args.IsValid = false;
     else
         args.IsValid = true;
 }
Exemplo n.º 24
0
 protected void cvUserEmail_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
 {
     if (!myHelpers.UserEmailIsValid("", Email.Text.Trim()))
     {
         args.IsValid = false;
     }
 }
Exemplo n.º 25
0
        /// <summary>
        /// Validates that a entered value is a integer
        /// </summary>
        /// <param name="source">Validator object</param>
        /// <param name="args">Validator arguments</param>
        public void ValidateMandatoryInteger(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            CustomValidator val = (CustomValidator)source;
            int value;

            if (args.Value.Length == 0)
            {
                args.IsValid = false;
                val.ErrorMessage = Master.GetLocalizedString("PxWebAdminSettingsValidationMandatorySetting");
                return;
            }

            if (!int.TryParse(args.Value, out value))
            {
                args.IsValid = false;
                val.ErrorMessage = Master.GetLocalizedString("PxWebAdminSettingsValidationIntegerValue");
                return;
            }

            if (value < 1)
            {
                args.IsValid = false;
                val.ErrorMessage = Master.GetLocalizedString("PxWebAdminSettingsValidationGreaterThanZero");
                return;
            }

            args.IsValid = true;
            return;
        }
Exemplo n.º 26
0
 protected void LogoValidator_ServerValidate(object sender, ServerValidateEventArgs e)
 {
     if (e.Value.Length > 0)
     {
         e.IsValid = FileType.IsImageFile(e.Value);
     }
 }
        protected void cvGrdUnassignedServiceRequests_ServerValidate(object source, ServerValidateEventArgs args)
        {
            if ((hdfOriginBtn.Value == "Assign") || (hdfOriginBtn.Value == "Manager"))
            {
                CustomValidator cvSelectedServices = (CustomValidator)source;
                args.IsValid = false;

                if (grdUnassignedServiceRequests.Rows.Count > 0)
                {
                    foreach (GridViewRow row in grdUnassignedServiceRequests.Rows)
                    {
                        if (((CheckBox)row.FindControl("cbxSelected")).Checked)
                        {
                            args.IsValid = true;
                        }
                    }

                    if (!args.IsValid)
                    {
                        cvSelectedServices.ErrorMessage = "At least one item must be selected.";
                    }
                }
            }
            else
            {
                args.IsValid = true;
            }
        }
Exemplo n.º 28
0
        protected void Country_Validate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            if (args.Value.Length >= 1)
            {
                string country = Convert.ToString(args.Value);
                //Check if country already exists

                int result = MappingsCountry.CheckIfCountryExists(country);

                if (result == 0)
                {
                    //Does not exist continue
                    args.IsValid = true;
                }
                else
                {
                    //Does exist cancel
                    args.IsValid = false;
                    this.CustomValidatorCountry.Text = Resources.lang.MappingDetailsErrorMessageCountryDuplicate;
                }
            }
            else
            {
                //Not valid
                args.IsValid = false;
                this.CustomValidatorCountry.Text = Resources.lang.MappingDetailsErrorMessageCountry;
            }
        }
Exemplo n.º 29
0
 protected void CustomValidator4_ServerValidate(object source, ServerValidateEventArgs args)
 {
     if (CheckBox1.Checked && TextBox1.Text == "")
     {
         args.IsValid = false;
     }
 }
Exemplo n.º 30
0
 protected void IsAvailableEmail(object source, ServerValidateEventArgs args)
 {
     using (_repository)
     {
         args.IsValid = !_repository.Users.Select(s => s.Email).Contains(this.EmailTexbox.Text);
     }
 }
Exemplo n.º 31
0
 private void cvDate2_Validate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
 {
     if (dtcDateStart.SelectedDate > dtcDateEnd.SelectedDate)
     {
         args.IsValid = false;
     }
 }
Exemplo n.º 32
0
 protected void cvTitle_ServerValidate(object source, ServerValidateEventArgs args)
 {
     SqlDataAdapter da = new SqlDataAdapter("", connection);
     DataTable dt = new DataTable();
     DataTable dl = new DataTable();
     da.SelectCommand.CommandText = "SELECT * FROM Skills WHERE ID = @sxid";
     da.SelectCommand.Parameters.AddWithValue("@sxid", Request.QueryString["Sid"]);
     da.Fill(dl);
     //Consept : Check if TextBox' value has changed or not
     //If This part doesn't Exist -> the page won't be valid Because of the next part of Validation. WHY? ...
     //if the title isn't changed the next part cause invalidation beacuse the Title has already Exist
     if (dl.Rows[0]["Title"].ToString() != txtTitle.Text)
     {
         da.SelectCommand.CommandText = "SELECT * FROM Skills WHERE Title=@t AND Cat_ID=@scid";
         da.SelectCommand.Parameters.AddWithValue("@t", txtTitle.Text);
         da.SelectCommand.Parameters.AddWithValue("@scid", ddlSkillCat.SelectedValue);
         da.Fill(dt);
         //If the TextBox' Value has changed ...
         //So , Now Check if The New Value has already Exist in Table or not
         if (dt.Rows.Count == 0)
         {
             args.IsValid = true;
         }
         else
             args.IsValid = false;
     }
 }
Exemplo n.º 33
0
/*
 *      //Here we check the file type and size.
 */
        public void CheckFileType(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            args.IsValid = true;

            HttpFileCollection uploadFilCol = Request.Files;
            int count = uploadFilCol.Count;

            for (int i = 0; i < count; i++)
            {
                //get handle to file
                HttpPostedFile file = uploadFilCol[i];

                //get file name & ext
                string fileName    = Path.GetFileName(file.FileName);
                string fileExt     = Path.GetExtension(file.FileName).ToLower();
                int    IntFileSize = file.ContentLength;

                if (fileName != string.Empty)
                {
                    if ((!Regex.IsMatch(file.ContentType, "(.gif|.jpg|.jpeg|.bmp|.png)")))
                    {
                        args.IsValid = false;
                        CustomValidator6.ErrorMessage = "Wrong file type!";
                        return;
                    }
                    //check for 4mb max
                    if (IntFileSize <= 0 || IntFileSize >= 2621440)
                    {
                        args.IsValid          = false;
                        CustomValidator6.Text = "File too big!";
                        return;
                    }
                }
            }
        }
        protected void cvCaptcha_ServerValidate(object source, ServerValidateEventArgs args)
        {
            bool isValid = false;

            if (ViewState["captchaToken"] != null)
            {
                Guid captchaToken = (Guid)ViewState["captchaToken"];
                using (CSSDataContext db = new CSSDataContext())
                {
                    var captcha = db.Captchas.FirstOrDefault(p => p.Id == captchaToken);

                    //args.Value
                    //CustomValidator cvCaptcha = (CustomValidator)source;
                    //TextBox txtValidationCode = (TextBox) cvCaptcha.ControlToValidate;
                    if (captcha != null && args.Value.Equals(captcha.Answer, StringComparison.InvariantCultureIgnoreCase) == true)
                    {
                        isValid = true;
                    }
                }
            }

            if (isValid == false)
                ViewState["captchaToken"] = null;

            args.IsValid = isValid;
        }
Exemplo n.º 35
0
        protected void OwnArea_Validate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            if (args.Value.Length >= 1)
            {
                string ownarea = Convert.ToString(args.Value);
                //Check if areacode already exists

                int result = MappingsAreaCodes.CheckAreaCodeExists(ownarea);

                if (result == 0)
                {
                    //Does not exist continue
                    args.IsValid = true;
                }
                else
                {
                    //Does exist cancel
                    args.IsValid = false;
                    this.CustomValidatorOwnArea.Text = Resources.lang.MappingDetailsErrorMessageOwnAreaDuplicate;
                }
            }
            else
            {
                //Not valid
                args.IsValid = false;
                this.CustomValidatorOwnArea.Text = Resources.lang.MappingDetailsErrorMessageOwnArea;
            }
        }
Exemplo n.º 36
0
        protected void cvDiskSpace_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            // Get value in txtDiskSpace
            string strDiskSpace = this.txtDiskSpace.Text;

            // If empty then return validation message
            if (strDiskSpace.Equals(String.Empty))
            {
                this.lblMessage.Text     = ResourceManager.GetString("rfvDiskSpace");
                this.lblMessage.CssClass = "WarningMessage";
                //((CustomValidator)source).ErrorMessage = ResourceManager.GetString("rfvDiskSpace");
                args.IsValid = false;
                return;
            }

            // If not numeric then return validation message
            if (!IsIntNumeric(strDiskSpace))
            {
                this.lblMessage.Text     = ResourceManager.GetString("revDiskSpace");
                this.lblMessage.CssClass = "WarningMessage";
                //((CustomValidator)source).ErrorMessage = ResourceManager.GetString("revDiskSpace");
                args.IsValid = false;
                return;
            }
        }
Exemplo n.º 37
0
 protected void password_validate(object source, ServerValidateEventArgs args)
 {
     if (args.Value.Contains("$") || args.Value.Contains("\\"))
         args.IsValid = false;
     else
         args.IsValid = true;
 }
 protected void cvEmail_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
 {
     if (!myHelpers.UserEmailIsValid("", myHelpers.CleanInput(txtEmail.Text)))
     {
         args.IsValid = false;
     }
 }
    protected void validateDOB_ServerValidate(object source,
                                              System.Web.UI.WebControls.ServerValidateEventArgs args)
    {
        args.IsValid = false;
        DateTime dob;
        TimeSpan sp;

        try
        {
            dob = DateTime.Parse(txtDob.Text);
            sp  = DateTime.Now - dob;
        }
        catch (Exception ex)
        {
            validateDOB.ErrorMessage = "Invalid Date Format";
            return;
        }
        if (sp.Days < 12 * 365)
        {
            validateDOB.ErrorMessage = "You must be above 12 years ";
            return;
        }
        else
        {
            args.IsValid = true;
        }
    }
 protected void CheckDate(object sender, ServerValidateEventArgs e)
 {
     DateTime date;
     bool IsDate = DateTime.TryParse(e.Value, out date);
     if (IsDate) e.IsValid = true;
     else e.IsValid = false;
 }
Exemplo n.º 41
0
        protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
        {
            string connectionString = ConfigurationManager.ConnectionStrings["PeopleConnectionString"].ConnectionString;
            _connection = new SqlConnection(connectionString);
            _connection.Open();

            SqlDataReader reader = null;
            SqlCommand commandReadCompare = new SqlCommand("SELECT * FROM People", _connection);

            string result = string.Empty;

            reader = commandReadCompare.ExecuteReader();

            while (reader.Read())
            {
                if ((TextBox1.Text == Convert.ToString(reader["Login"]))&&(TextBox2.Text == Convert.ToString(reader["Password"])))
                {
                    args.IsValid = true;
                    Session["id"] = Convert.ToString(reader["id"]);
                    return;
                }
            }
            args.IsValid = false;

            _connection.Close();
        }
Exemplo n.º 42
0
 protected void CheckPassword(object source, ServerValidateEventArgs args)
 {
     if (WebClient.RevalidatePassword(PasswordField.Text))
         args.IsValid = true;
     else
         args.IsValid = false;
 }
Exemplo n.º 43
0
 protected void validateFile(object sender, ServerValidateEventArgs e)
 {
     if(Path.GetExtension(e.Value) == ".jpg" || Path.GetExtension(e.Value) == ".png" || Path.GetExtension(e.Value) == ".gif")
         e.IsValid = true;
     else
         e.IsValid = false;
 }
Exemplo n.º 44
0
        /// <summary>
        /// Validator cho StringSafe
        /// </summary>
        /// <param name="pSource">CustomValidator object</param>
        /// <param name="args">ServerValidateEventArgs</param>
        /// <param name="pIsStripAllHTML">tùy chọn bỏ hết html hay ko</param>
        /// <author>NHTIN</author>
        public static void StringSafeValidate(ref object pSource, ref System.Web.UI.WebControls.ServerValidateEventArgs pArgs, bool pIsStripAllHTML)
        {
            CustomValidator cv  = (CustomValidator)pSource;
            Control         con = cv.FindControl(cv.ControlToValidate);

            string vValue = pArgs.Value.Trim() + " ";

            vValue = StringSafe(vValue, pIsStripAllHTML);

            if (vValue.Trim() != "")
            {
                pArgs.IsValid = true;
            }
            else
            {
                pArgs.IsValid = false;
            }

            if (typeof(TextBox) == con.GetType())
            {
                ((TextBox)con).Text = vValue.Trim();
            }

            {
                try
                {
                    ((DotNetNuke.UI.UserControls.TextEditor)con).Text = vValue.Trim();
                }
                catch { }
            }
        }
Exemplo n.º 45
0
        protected void CheckPassword(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            args.IsValid = false;

            if (txtPassword1.Text == string.Empty || (txtPassword1.Text.Length < 6))
            {
                CustomValidator1.ErrorMessage = "!";
                pnlError.Visible  = true;
                lblStatus.Text    = "Password needs to be 6 or more characters.";
                lblStatus.Visible = true;
                //lblStatus.CssClass = "errorLabel";
                return;
            }

            //else if
            //{
            //    pnlError.Visible = true;
            //    lblStatus.Text = "Password needs to be 6 or more characters.";
            //    lblStatus.Visible = true;

            //}
            else
            {
                args.IsValid = true;
            }
        }
Exemplo n.º 46
0
        protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
        {
            try
            {
                var connString = ConfigurationManager.ConnectionStrings["CineQuilla"].ConnectionString;
                using (SqlConnection connection = new SqlConnection(connString))
                {
                    connection.Open();
                    using (SqlCommand command = new SqlCommand(null, connection))
                    {
                        command.CommandText = @"SELECT 1 FROM clients WHERE id = @id";
                        SqlParameter idParam = new SqlParameter("@id", SqlDbType.Int);

                        idParam.Value = args.Value;

                        command.Parameters.Add(idParam);

                        var reader = command.ExecuteReader();
                        if (!reader.HasRows)
                            args.IsValid = false;
                    }
                }
            }
            catch (SqlException ex)
            {
                ErrorLabel.Visible = true;
                args.IsValid = false;
            }
        }
Exemplo n.º 47
0
 protected void cvProcName_ServerValidate(object source, ServerValidateEventArgs args)
 {
     //默认不存在该部门
     args.IsValid = false;
     //检测是否存在部门
     args.IsValid = ydPublicMethod.IsExistProc(args.Value);
 }
Exemplo n.º 48
0
 /// <summary>
 /// custom validator for checking the uniqueness of the busines unit number
 /// </summary>
 protected void cvBUNumber_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
 {
     try
     {
         BusinessUnitItem objBusinessUnit = new BusinessUnitItem();
         var buNumber = ValidationHelper.GetLong(txtBUNumber.Text, default(int));
         int itemID   = QueryHelper.GetInteger("itemID", 0);
         if (itemID > 0)
         {
             var buData = CustomTableItemProvider.GetItems <BusinessUnitItem>()
                          .WhereEquals("BusinessUnitNumber", buNumber)
                          .And()
                          .WhereNotEquals("ItemID", itemID)
                          .Columns("BusinessUnitNumber")
                          .FirstOrDefault();
             args.IsValid = DataHelper.DataSourceIsEmpty(buData);
         }
         else
         {
             var buData = CustomTableItemProvider.GetItems <BusinessUnitItem>()
                          .WhereEquals("BusinessUnitNumber", buNumber)
                          .Columns("BusinessUnitNumber")
                          .FirstOrDefault();
             args.IsValid = DataHelper.DataSourceIsEmpty(buData);
         }
     }
     catch (Exception ex)
     {
         EventLogProvider.LogException("BusinessUnit.ascx.cs", "cvBUNumber_ServerValidate()", ex);
     }
 }
Exemplo n.º 49
0
 public void val_email(object source, ServerValidateEventArgs args)
 {
     Regex rgxEmail = new Regex(@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +
                    @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" +
                    @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$");
     args.IsValid = rgxEmail.IsMatch(args.Value);
 }
Exemplo n.º 50
0
 //Validate input service group name
 //Add Option - Validate existence of group naem
 protected void ExistenceCustomValidator_ServerValidate(object source, ServerValidateEventArgs args)
 {
     var inputValue = args.Value.ToString();
     var icdChapters = from element in _dataContext.IcdChapters
                        select element.icdChapterName.ToString().ToLower();
     foreach (var chapter in icdChapters.ToArray())
     {
         if (chapter.ToString().ToLower().Equals(inputValue.ToLower()))
         {
             args.IsValid = true;
             return;
         }
     }
     args.IsValid = false;
     //int editIndex = MedicalServiceList.EditIndex;
     //TextBox textBox = MedicalServiceList.Rows[editIndex].FindControl("EditGroupId") as TextBox;
     //var inputStringData = textBox.Text;
     //var inputIntData = Convert.ToInt64(inputStringData);
     //var idList = from element in _dataContext.MedicalServiceGroups
     //             select element.medicalServiceGroupId;
     //foreach (var id in idList.ToArray())
     //{
     //    if (id == inputIntData)
     //    {
     //        args.IsValid = true;
     //        return;
     //    }
     //}
     //args.IsValid = false;
 }
Exemplo n.º 51
0
// CategoriesGrid CustomIncludes end
//-------------------------------


	public void ValidateNumeric(object source, ServerValidateEventArgs args) {
			try{
				Decimal temp=Decimal.Parse(args.Value);
				args.IsValid=true;
		        }catch{
				args.IsValid=false;	}
		}
Exemplo n.º 52
0
 private void ValidateCuit(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
 {
     //pzambudio 19-02-05 - COMIENZO
     //controlar que se exija el ingreso del cuit, siempre que la condición de IVA del cliente
     // sea RESPONSABLE INSCRIPTO
     if ((NegociosSisPackInterface.SisPack.CondicionIva)Convert.ToInt32(this.ddlCondicionIva.SelectedValue) == NegociosSisPackInterface.SisPack.CondicionIva.ResponsableInscripto)
     {
         if (this.txtCUITTipo.Text == "" && this.txtCUITNro.Text == "" && this.txtCUITDigitoVerificador.Text == "")
         {
             args.IsValid = false;
             ((CustomValidator)source).ErrorMessage = this.TraducirTexto("Errores.Obligatorios.Cuit");
             return;
         }
         if (!Validaciones.CUIT(this.txtCUITTipo.Text + this.txtCUITNro.Text + this.txtCUITDigitoVerificador.Text))
         {
             args.IsValid = false;
             ((CustomValidator)source).ErrorMessage = this.TraducirTexto("Errores.Invalidos.Cuit");
             return;
         }
     }
     else
     {
         if (this.txtCUITTipo.Text != "" || this.txtCUITNro.Text != "" || this.txtCUITDigitoVerificador.Text != "")
         {
             if (!Validaciones.CUIT(this.txtCUITTipo.Text + this.txtCUITNro.Text + this.txtCUITDigitoVerificador.Text))
             {
                 args.IsValid = false;
                 ((CustomValidator)source).ErrorMessage = this.TraducirTexto("Errores.Invalidos.Cuit");
                 return;
             }
         }
     }
     args.IsValid = true;
 }
Exemplo n.º 53
0
        private void ValidateImage(object source, ServerValidateEventArgs args)
        {
            if (FileUploadEdit.HasFile)
            {
                var bytes = FileUploadEdit.FileBytes;

                try
                {
                    var image = System.Drawing.Image.FromStream(new MemoryStream(bytes));
                }
                catch
                {
                    // catch any error when user tries to load a file that 
                    // is not an image recognised by System.Drawing
                    args.IsValid = false;
                    CustomValidator1.ErrorMessage = "Not an Image";
                }
            }
            else
            {
                return;
                // no file to download you decide wether this is a valid error
                // to throw comment out
                if (!FileUploadEdit.HasFile && String.IsNullOrEmpty(ImageEdit.ImageUrl))
                {
                    args.IsValid = false;
                    CustomValidator1.ErrorMessage = "No file to download";
                }
            }
        }
Exemplo n.º 54
0
 protected void Automobile_ServerValidate(object sender, ServerValidateEventArgs e)
 {
     int automobileId;
     string automobileIdTxt = e.Value;
     bool validAutomobile = Int32.TryParse(automobileIdTxt, out automobileId) && (automobileId >= 0);
     e.IsValid = validAutomobile;
 }
Exemplo n.º 55
0
        private void cvMediaType_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            switch (this.radMediaType.SelectedIndex)
            {
            case 0:
                if (string.IsNullOrEmpty(ctlURL.Url))
                {
                    args.IsValid = false;
                }
                break;

            case 1:
                if (string.IsNullOrEmpty(txtEmbed.Text))
                {
                    args.IsValid = false;
                }
                break;

            case 2:
                if (string.IsNullOrEmpty(txtOEmbed.Text))
                {
                    args.IsValid = false;
                }
                break;
            }
        }
Exemplo n.º 56
0
 private void cvStartEndDate_Validate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
 {
     if (TimeStart > TimeEnd)
     {
         args.IsValid = false;
     }
 }
Exemplo n.º 57
0
 protected void cvNextProc_ServerValidate(object source, ServerValidateEventArgs args)
 {
     //默认不存在该部门
     args.IsValid = false;
     //当前验证控件
     var cv = (CustomValidator)source;
     cv.ToolTip = "部门名称不存在";
     //获取当前用户所在部门名称
     object obj = Session["proc_name"];
     if (obj != null && obj.ToString() != args.Value)
     {
         //订单序号文本框
         var txtLotId = (TextBox)fvProductRecordAdd.FindControl("txtLotId");
         //生产板报数下工序不能是样板
         if (!txtLotId.Text.ToUpper().Contains("S") && args.Value == "样板")
         {
             cv.ToolTip = "生产板报数下工序不能是样板";
         }
         else
         {
             //检测是否存在部门
             args.IsValid = ydPublicMethod.IsExistProductProc(args.Value);
         }
     }
 }
Exemplo n.º 58
0
 private void cvWeek_Validate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
 {
     if (Weekdays == 0)
     {
         args.IsValid = false;
     }
 }
        protected void cvDistance_ServerValidate(object source, ServerValidateEventArgs args)
        {
            if (args.Value.Trim() != "")
            {
                // Initialize
                CustomValidator cvDistance = (CustomValidator)source;
                args.IsValid = true;

                // Control of format
                if (!Distance.IsValidDistance(args.Value))
                {
                    cvDistance.Text = "Invalid format. (please use X'Y\", or Xft Yin, or X.Y, or X.Ym, or X.Ymm)";
                    args.IsValid = false;
                }

                // Control of distance > 0
                if (args.IsValid)
                {
                    Distance distance = new Distance(args.Value);
                    if (distance.ToDoubleInEng3() < 0)
                    {
                        cvDistance.Text = "Invalid distance. (must be equal or greater than 0)";
                        args.IsValid = false;
                    }
                }
            }
        }
        private void ServerPhoneValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args)
        {
            Regex           expr    = new Regex(@"^\(?\d{3}\)?(\s|-)\d{3}\-\d{4}$");
            MatchCollection matches = expr.Matches(args.Value, 0);

            args.IsValid = (matches != null && matches[0].Value == args.Value);
        }