예제 #1
0
 public CManageError Validate(string name, string address, string email,string mobile,int idPos)
 {
     CValidate testValue = new CValidate();
     CManageError errors = new CManageError();
     int numErr = 0;
     if (name.Length == 0 || address.Length == 0 || email.Length==0 || mobile.Length==0)
     {
         numErr++;
         errors.AddError(terrcommon);
         return errors;
     }
     if (idPos==0)
     {
         numErr++;
         errors.AddError(tPleaseChoiceWhere);
         return errors;
     }
     if (!testValue.TestAddressEmail(email))
     {
         numErr++;
         errors.AddError(terrmail);
         return errors;
     }
     return errors;
 }
예제 #2
0
    public CManageError Validate(string title, string mailfrom, string mailto, string code)
    {
        CManageError errors = new CManageError();
        CValidate TestValue=new CValidate();
        int numErr = 0;
        if ((title.Length == 0) || (mailfrom.Length == 0) || (mailto.Length == 0) || (code.Length == 0))
        {
            errors.AddError(terror);
            numErr++;
            return errors;
        }
        if (!TestValue.TestAddressEmail(mailfrom) || !TestValue.TestAddressEmail(mailto))
        {
            errors.AddError(terrEmail);
            numErr++;
            return errors;
        }
        if (Session["RamDomCodeRegister"] != null)
        {
            if(!code.Equals(Session["RamDomCodeRegister"].ToString()))
            {
                errors.AddError(terrcode);
                numErr++;
                Session["RamDomCodeRegister"] = DataCommon.CreateCodeRanDom(5);
                return errors;

            }
        }
        return errors;
    }
예제 #3
0
    public CManageError ValidateForm(string username,string pass1,string pass2,string fullname,string jobtitle,string address,string email,string mobile,string homephone,string code)
    {
        CManageError errors = new CManageError();
        int numErr = 0;
        CValidate validate = new CValidate();
        if (username.Length > 0)
        {
            if (validate.TestUserName(username) > 0)
            {
                numErr++;
                errors.AddError(merruser);
                return errors;
            }
        }
        else
        {
            numErr++;
            errors.AddError(merr);
            return errors;
        }
        if (pass1.Length > 0)
        {
            if (pass1.Length < 4)
            {
                numErr++;
                errors.AddError(mpass);
                return errors;
            }
        }
        else
        {
            numErr++;
            errors.AddError(merr);
            return errors;
        }
        if (pass2.Length > 0)
        {
        }
        else
        {
            numErr++;
            errors.AddError(merr);
            return errors;
        }
        if (fullname.Length == 0)
        {
            numErr++;
            errors.AddError(merr);
            return errors;
        }
        if (address.Length == 0)
        {
            numErr++;
            errors.AddError(merr);
            return errors;
        }
        if (email.Length > 0)
        {

        }
        else
        {
            numErr++;
            errors.AddError(merr);
            return errors;
        }
        if (!pass1.Equals(pass2))
        {
            numErr++;
            errors.AddError(mpasserr);
            return errors;
        }
        if (code.Length > 0)
        {
            string subcode = Session["RamDomCodeRegister"].ToString();
            if (!subcode.Equals(code))
            {
                numErr++;
                errors.AddError(mcode);
                subcode = GetCodeRandom.CreateCodeRanDom(5);
                Session["RamDomCodeRegister"] = subcode;
                return errors;
            }
        }
        else
        {
            numErr++;
            errors.AddError(merr);
            return errors;
        }
        if (!validate.TestAddressEmail(email))
        {
            numErr++;
            errors.AddError(merremail);
            return errors;
        }
        //TestExsit Username, or Email:
        DataSet Ds = new UserManagerSystem().UserSelectUsernameandEmail(username, email);
        if (Ds.Tables.Count > 0)
        {
            if (Ds.Tables[0].Rows.Count > 0)
            {
                if (!Ds.Tables[0].Rows[0]["count"].ToString().Equals("0"))
                {
                    numErr++;
                    errors.AddError(muser);
                }
                if (!Ds.Tables[1].Rows[0]["count"].ToString().Equals("0"))
                {
                    numErr++;
                    errors.AddError(memail);
                }
            }
        }
        return errors;
    }