/// <summary> /// modelID=-1:表示验证账户 /// </summary> /// <param name="modelID"></param> /// <param name="curIndex"></param> /// <param name="dataLength"></param> /// <param name="pars"></param> /// <returns></returns> public override object ModelOptionLoad(int modelID, int curIndex, int dataLength, params string[] pars) { object res = null; //modelID=-1:表示验证账户 switch (modelID) { case -1: { res = dal.ValidateAccount(pars[0], pars[1]); }; break; default: break; } return(res); }
private void ucBtnExt1_BtnClick(object sender, EventArgs e) { txtValidateCode.InputText = txtValidateCode.InputText.ToLower(); bool accValResult = verAccountValidate.Verification(txtAcc); bool pwdValResult = verPwdValidate.Verification(txtPwd); bool memValCodeResult = verValidateCode.Verification(txtValidateCode); try { if (accValResult && pwdValResult && memValCodeResult) { //输入合法,且验证码正确,此时验证账户密码是否正确 //使用T_UserDAl T_UserDAl dal = new T_UserDAl(); ICreateSha256Pwd createSha256 = new CreateGenericCode(); string sha256PWD = createSha256.CreateSHA256Code(txtPwd.Text); object obj = dal.ValidateAccount(txtAcc.InputText, sha256PWD); //obj!=null;表示返回了用户权限,此时我们可以使用Convert.ToInt32(obj); if (obj != null) { user = new T_User(txtAcc.InputText, Convert.ToInt32(obj)); //打开主界面窗体 FrmMain main = new FrmMain(); Hide(); main.ShowDialog(); Dispose(); return; } else { throw new Exception(); } } else { throw new Exception(); } } catch { ICreateValidateCode genericCode = new CreateGenericCode(); ISetValidateControlConfig setValidateControlConfig = new ControlSet(); var code = genericCode.CreateMemoryValidateCode(); txtMemCode.Text = code; setValidateControlConfig.SetValidateControl(txtValidateCode, verValidateCode, string.Format(@"^({0}|{1})$", code, code.ToLower()), "请输入正确的验证码"); } }