protected void verifySignButton_Click(object sender, EventArgs e) { //Recuperamos la instancia del cliente ViafirmaClient viafirmaClient = ViafirmaClientFactory.GetInstance(); //Recuperamos el identificador de la firma String signId = Request.Form["signId"]; // Instaciamos la clase encargada de añadir los parámetros verificationSignatureRequest verificationSignatureRequest = VerifyUtil.newVerify(); // Vamos añadiendo los parámetros al listado // SignatureStandard String signatureStandardKey = VerifyParams.SIGNATURE_STANDARD_KEY; String signatureStandardValue = VerifyParams.PADES_SIGNATURE_STANDARD; // Añadimos el parámetro SignatureStandard VerifyUtil.AddParameter(verificationSignatureRequest, signatureStandardKey, signatureStandardValue); // TypeSign String typeSignKey = VerifyParams.TYPE_SIGN_KEY; String typeSignValue = VerifyParams.ENVELOPED_TYPE_SIGN; // Añadimos el parámetro TypeSign VerifyUtil.AddParameter(verificationSignatureRequest, typeSignKey, typeSignValue); // Sign ID String signIdKey = VerifyParams.SIGNATURE_ID_KEY; String signIdValue = signId; // Añadimos el parámetro TypeSign VerifyUtil.AddParameter(verificationSignatureRequest, signIdKey, signIdValue); signatureVerification = viafirmaClient.verifySignature(verificationSignatureRequest); }
public ActionResult ValidEmail(string code = "") { if (string.IsNullOrEmpty(code)) { if (CurrentUserInfo == null)//无用户信息 { return(RedirectToAction("Login")); } else { Session["UserInfo"] = db.FirstOrDefault <TB_User>("where Id=@0", CurrentUserInfo.Id); if (CurrentUserInfo.EmailValid)//刷新页面,重新获取用户信息,已验证邮箱则跳回首页。 { return(Redirect("/Home/Index")); } } return(View()); } else { var message = ""; TB_User user = null; if (!VerifyUtil.CheckEmailVerfyCode(code, out user, out message)) { return(Content(message)); } Session["UserInfo"] = user; return(RedirectToAction("Recharge")); } }
private void SaveBtn_Click(object sender, EventArgs e) { try { CodeProjectInfo codeProjectInfo = FormHelp.GetEntityByControls <CodeProjectInfo>(this.panel1); codeProjectInfo.ID = this.codeProjectInfo.ID; VerifyMessage verifyMessage = VerifyUtil.Verify(codeProjectInfo); if (verifyMessage.ExistError) { MessageBox.Show(verifyMessage.ErrorInfo, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } R r = codeProjectInfoBLL.SaveOrUpdateBySelf(codeProjectInfo, null, false); if (r.Successful) { MessageBox.Show("操作成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadData(); //更新列表页 if (this.Owner is CodeProjectList) { ((CodeProjectList)this.Owner).LoadData(); } } else { MessageBox.Show(r.ResultHint, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show("异常:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void SaveBtn_Click(object sender, EventArgs e) { try { CodeProjectDbConfigInfo saveItem = FormHelp.GetEntityByControls <CodeProjectDbConfigInfo>(this.panel1); saveItem.ID = codeProjectDbConfigInfo.ID; saveItem.ProjectId = codeProjectInfo.ID; VerifyMessage verifyMessage = VerifyUtil.Verify(saveItem); if (verifyMessage.ExistError) { MessageBox.Show(verifyMessage.ErrorInfo, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } R r = codeProjectDbConfigInfoBLL.SaveOrUpdate(saveItem, null, false, null); if (r.Successful) { string msg = saveItem.ID <= 0 ? "新增" : "修改"; MessageBox.Show($"{msg}成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadData(); } else { MessageBox.Show(r.ResultHint, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// Tries to determine whether given type is anonymous type. /// </summary> /// <param name="type">Type to check.</param> /// <returns>True if type is presumably anonymous; false if it's not anonymous for sure.</returns> internal static bool IsAnonymous(this Type type) { VerifyUtil.NotNull(type, "type"); return (!type.IsVisible && type.IsSealed && string.IsNullOrEmpty(type.Namespace) && type.Name.StartsWith("<>f__AnonymousType") && Attribute.IsDefined(type, typeof(CompilerGeneratedAttribute))); }
/// <summary> /// 校验上传的资源 /// </summary> /// <returns></returns> private string VerifyUpload(UploadRes uploadRes) { //校验用户 var userId = base.getUserId(); if (string.IsNullOrEmpty(userId)) { return("没有获取用户信息,请重新登陆"); } if (string.IsNullOrEmpty(uploadRes.refCode)) { return("没有对应的资源Code"); } if (Request.HasFormContentType && string.IsNullOrEmpty(Request.Form["resType"])) { return("没有对应的资源类型"); } if (string.IsNullOrEmpty(uploadRes.fileType)) { return("没有对应的文件类型"); } if (uploadRes.resType == ResType.Book_Url) { var url = uploadRes.outerUrl.ToLower(); if (string.IsNullOrEmpty(uploadRes.outerUrl)) { return("资源缺少Url"); } if (!VerifyUtil.VerifyUrl(url)) { return("不是有效的http/https Url"); } if (!VerifyUtil.VerifyHttp(url)) { return("url地址无法访问,请检查是否已失效"); } } if (!uploadRes.isReset) { if (_resourceServices.IsRepeatRes(userId, uploadRes.refCode, uploadRes.resType, uploadRes.fileType)) { return(uploadRes.resType == ResType.BookOss ? "此书已上传同类型文件,请查看页面下方列表" : $"已上传[{uploadRes.fileType}]文件类型的外部资源,请查看页面下方列表"); } } else { if (string.IsNullOrEmpty(uploadRes.resCode)) { return("没有找到重传的资源"); } } return(null); }
/// <summary> /// 生成配置文件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnCreate_Click(object sender, EventArgs e) { try { CodeProjectInfo codeProjectInfo = FormHelp.GetEntityByControls <CodeProjectInfo>(this.panel1); VerifyMessage verifyMessage = VerifyUtil.Verify(codeProjectInfo); if (verifyMessage.ExistError) { MessageBox.Show(verifyMessage.ErrorInfo, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } Type type = codeProjectInfo.GetType(); System.Reflection.PropertyInfo[] propertyInfos = type.GetProperties(); StringBuilder sbf = new StringBuilder(); for (int i = 0; i < propertyInfos.Length; i++) { if (propertyInfos[i].Name != "ID") { if (propertyInfos[i].Name == "JAVAFODER" || propertyInfos[i].Name == "VIEWFOLDER" || propertyInfos[i].Name == "PRO_SITE") { sbf.Append($"{propertyInfos[i].Name}={propertyInfos[i].GetValue(codeProjectInfo).ToString().Replace("\\","\\\\")}\r\n"); } else if (propertyInfos[i].Name == "TEMPLATE_FOLDER") { sbf.Append($"{propertyInfos[i].Name}={propertyInfos[i].GetValue(codeProjectInfo).ToString().Replace("\\", "\\\\")+"\\\\"}\r\n"); } else { sbf.Append($"{propertyInfos[i].Name}={propertyInfos[i].GetValue(codeProjectInfo)}\r\n"); } } } string configPath = Path.Combine(@System.AppDomain.CurrentDomain.BaseDirectory, autoConfigPath); configPath = Path.Combine(configPath, "basic.properties"); File.WriteAllText(configPath, sbf.ToString()); //调用bat命令 string targetDir = Path.Combine(@System.AppDomain.CurrentDomain.BaseDirectory, autoPath); Process proc = new Process(); proc.StartInfo.WorkingDirectory = targetDir; proc.StartInfo.FileName = "命令.bat"; proc.StartInfo.Arguments = string.Format("30"); //proc.StartInfo.CreateNoWindow = true; //proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;//这里设置DOS窗口不显示,经实践可行 proc.Start(); proc.WaitForExit(); } catch (Exception ex) { MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
protected bool verifyCommitedInfo() { if (VerifyUtil.IsEmpty(name.Text)) { MessageBox.Show("请输入用户名称!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); this.name.Focus(); return(true); } if (VerifyUtil.IsEmpty(this.realName.Text)) { MessageBox.Show("请输入真实姓名!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); this.realName.Focus(); return(true); } if (this.password.Text.Length < 6) { MessageBox.Show(this, "密码不能为空,且最小长度为6位!", "", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign); this.password.Focus(); return(true); } if (!this.password.Text.Equals(this.confirmPassword.Text)) { MessageBox.Show("两次输入的密码不一致!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); this.password.Focus(); return(true); } if (VerifyUtil.IsEmpty(this.mail.Text)) { MessageBox.Show("邮件地址不能为空!", "", MessageBoxButtons.OK, MessageBoxIcon.Error); this.mail.Focus(); return(true); } if (!VerifyUtil.VerifyInput(this.name.Text)) { MessageBox.Show(this, "用户名" + VerifyUtil.NameLimitInfo, "", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign); this.name.Focus(); return(true); } if (!VerifyUtil.VerifyMailInput(this.mail.Text)) { MessageBox.Show(this, VerifyUtil.MailLimitInfo, "", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign); this.mail.Focus(); return(true); } return(false); }
private void commit(object sender, EventArgs e) { if (VerifyUtil.IsEmpty(name.Text)) { MessageBox.Show("请输入群组名称", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //if (!VerifyUtil.VerifyInput(this.name.Text)) //{ // MessageBox.Show(this, "群组名称" + VerifyUtil.NameLimitInfo, "", MessageBoxButtons.OK, // MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, // MessageBoxOptions.RightAlign); // this.name.Focus(); // return; //} Group group = new Group(); group.NameProperty = name.Text; group.DescribeProperty = describe.Text; group.OSTypeProperty = OSType.SelectedIndex; string message; if (insertGroup(group)) { message = "添加群组成功!是否继续?"; } else { message = "添加群组失败!是否继续?"; } DialogResult result = MessageBox.Show(this, message, "", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.RightAlign); if (result == DialogResult.Yes) { this.reset(); } else { cancel(sender, e); } }
override protected FocusFlags validing() { string username = this.LoginForm.UserNameText; string pwd = this.LoginForm.UserPwdText; if (VerifyUtil.IsEmpty(username)) { return(FocusFlags.FocusName); } if (VerifyUtil.IsEmpty(pwd)) { return(FocusFlags.FocusPwd); } return(FocusFlags.NONE); }
/// <summary> /// Creates verifier which checks object public properties. /// </summary> /// <typeparam name="TVerifier">Verifier type.</typeparam> /// <param name="propertyFilter">Object public properties filter; can be null to generate code for all the properties.</param> /// <param name="checkExpr">Property value check lambda expression; if returns true then check is failed.</param> /// <param name="createExceptionExpr">New exception creation expression used when check is failed.</param> /// <returns>Verifier instance.</returns> public static TVerifier Create <TVerifier>( Func <Type, bool> propertyFilter, LambdaExpression checkExpr, LambdaExpression createExceptionExpr) where TVerifier : class { VerifyUtil.NotNull(checkExpr, "checkExpr"); var valueParam = checkExpr.Parameters[0]; return(Create <TVerifier>( propertyFilter, (valueVar, additionalParams) => checkExpr .ReplaceParams(additionalParams) .Replace(valueParam, valueVar.ConvertIfNeeded(valueParam.Type)), createExceptionExpr)); }
private void commit(object sender, EventArgs e) { if (VerifyUtil.IsEmpty(name.Text)) { MessageBox.Show("请输入群组名称", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //if (!VerifyUtil.VerifyInput(this.name.Text)) //{ // MessageBox.Show(this, "群组名称" + VerifyUtil.NameLimitInfo, "", MessageBoxButtons.OK, // MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, // MessageBoxOptions.RightAlign); // this.name.Focus(); // return; //} Group group = new Group(); group.NameProperty = this.name.Text; group.DescribeProperty = this.describe.Text; group.OSTypeProperty = this.OSType.SelectedIndex; string message; if (this.updateGroup(group)) { message = "更新群组成功!"; } else { message = "更新群组失败!"; } string caption = ""; MessageBoxButtons buttons = MessageBoxButtons.OK; DialogResult result; // Displays the MessageBox. result = MessageBox.Show(this, message, caption, buttons, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1); cancel(sender, e); }
public ActionResult ValidEmail() { if (CurrentUserInfo == null) { return(RedirectToAction("Login")); } Result data = new Result(); try { var url = Request.Url.ToString().TrimEnd(Request.Url.PathAndQuery.ToArray()); data.success = VerifyUtil.SendEmailValidCode(CurrentUserInfo.Email, url); } catch (Exception ex) { data.success = false; data.msg = "Error sending mail!Please contact the administrator."; } return(Json(data)); }
public ActionResult Create(string accountEmail, string accountPassword, string recommendBy) { using (var db = new Database("DefaultConnection")) { var user = db.FirstOrDefault <TB_User>("where Email=@0", accountEmail); if (user != null) { return(Content("The email is registered!")); } user = new TB_User(); user.UserName = accountEmail; user.Email = accountEmail; user.Password = accountPassword; if (string.IsNullOrEmpty(recommendBy)) { if (Session["recommendBy"] != null) { recommendBy = Session["recommendBy"].ToString(); } } if (!string.IsNullOrEmpty(recommendBy)) { var recommend = db.FirstOrDefault <TB_User>("where Email=@0 Or Id=@0", recommendBy); if (recommend != null) { user.RecommendBy = recommend.Id; } } user.CreateAt = DateTime.Now; user.Insert(); Session["UserInfo"] = user; var url = Request.Url.ToString().Replace(Request.Url.PathAndQuery, ""); VerifyUtil.SendEmailValidCode(user.Email, url); return(RedirectToAction("ValidEmail")); } }
private void txButton1_Click(object sender, EventArgs e) { try { OsZbPurchaseProjectInfo projectInfo = FormHelp.GetEntityByControls <OsZbPurchaseProjectInfo>(this.groupBox2); osZbPurchaseProjectInfo = osZbPurchaseProjectInfo ?? new OsZbPurchaseProjectInfo(); ObjectUtil.CopyPop(projectInfo, ref osZbPurchaseProjectInfo, "Id"); VerifyMessage verifyMessage = VerifyUtil.Verify(osZbPurchaseProjectInfo); if (!string.IsNullOrWhiteSpace(verifyMessage.ErrorInfo)) { MessageBox.Show(verifyMessage.ErrorInfo, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else if (!string.IsNullOrWhiteSpace(verifyMessage.PromptInfo)) { MessageBox.Show(verifyMessage.PromptInfo, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } R result = osZbPurchaseProjectInfoBLL.SaveOrUpdate(osZbPurchaseProjectInfo, null, true, null); if (!result.Successful) { MessageBox.Show(result.ResultHint, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { MessageBox.Show("操作成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); if (RefeshParentWindow != null) { RefeshParentWindow.Invoke(); } this.Hide(); this.Close(); } } catch (Exception ex) { log.AddLog(ex.Message, null); MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
/// <summary> /// Determines whether given type has public property. /// </summary> /// <param name="type">Type to check.</param> /// <param name="propertyName">Public property name.</param> /// <returns>True if type has <paramref name="propertyName" /> property; false otherwise.</returns> public static bool HasProperty(this Type type, string propertyName) { VerifyUtil.NotNull(type, "type"); VerifyUtil.NotNull(propertyName, "propertyName"); return(type.GetProperty(propertyName) != null); }
/// <summary> /// Determines whether given type has "Length" or "Count" public property. /// </summary> /// <param name="type">Type to check.</param> /// <returns>True if type has "Length" and/or "Count" property; false otherwise.</returns> public static bool HasLengthProperty(this Type type) { VerifyUtil.NotNull(type, "type"); return(type.HasProperty("Length") || type.HasProperty("Count")); }
/// <summary> /// Creates verifier which checks object public properties. /// </summary> /// <typeparam name="TVerifier">Verifier type.</typeparam> /// <param name="propertyFilter">Object public properties filter; can be null to generate code for all the properties.</param> /// <param name="checkExprFunc">Function which generates property value check expression (if returns true then check is failed). /// Function obtains variable which holds property value and additional arguments.</param> /// <param name="createExceptionExpr">New exception creation expression used when check is failed.</param> /// <returns>Verifier instance.</returns> public static TVerifier Create <TVerifier>( Func <Type, bool> propertyFilter, Func <Expression, IList <ParameterExpression>, Expr> checkExprFunc, LambdaExpression createExceptionExpr) where TVerifier : class { VerifyUtil.NotNull(checkExprFunc, "checkExprFunc"); VerifyUtil.NotNull(createExceptionExpr, "createExceptionExpr"); Type argumentsType = typeof(TVerifier).GetGenericArguments()[0]; Type type = argumentsType.GetGenericArguments()[0]; // Prepare lambda action parameters - first is Argument<T>, others are additionalParamTypes var objectParam = Expr.Parameter(argumentsType); var objectVar = Expr.Parameter(type); var genericArguments = typeof(TVerifier).GetGenericArguments(); var additionalParams = genericArguments.Skip(1).Take(genericArguments.Length - 2).Select(Expr.Parameter).ToList(); Expr lambdaBody; if (type.IsAnonymous()) { // Take createExceptionExpr lambda, extract first parameter from it and replace additional parameters in body var exceptionNameParam = createExceptionExpr.Parameters[0]; var exceptionObjectParam = createExceptionExpr.Parameters[1]; var exceptionBody = createExceptionExpr.ReplaceParams(additionalParams); // Obtain type public properties to check propertyFilter = propertyFilter ?? (_ => true); var properties = type.GetProperties().OrderBy(pi => pi.Name).Where(pi => propertyFilter(pi.PropertyType)); // Obtain argument values from fields since it's faster var fields = type.GetFields(BindingFlags.NonPublic | BindingFlags.Instance).OrderBy(fi => fi.Name).Where(fi => propertyFilter(fi.FieldType)).ToList(); // Generate "if (checkExpr) then throw createExceptionExpr;" for each of the properties var propertyChecks = properties .Select( (pi, i) => { var valueVar = Expr.Field(objectVar, fields[i]); return((Expr)Expr.IfThen( checkExprFunc(valueVar, additionalParams), Expr.Throw( exceptionBody .Replace(exceptionNameParam, Expr.Constant(pi.Name)) .Replace(exceptionObjectParam, valueVar.ConvertIfNeeded(exceptionObjectParam.Type))))); }) .ToList(); // Prepare null check - if null is supplied then all checks are passed since nothing to check var checksBody = propertyChecks.Any() ? Expr.IfThen( Expr.ReferenceNotEqual(objectVar, Expr.Constant(null, type)), propertyChecks.Count > 1 ? Expr.Block(propertyChecks) : propertyChecks[0]) : null; lambdaBody = propertyChecks.Any() ? (Expr)Expr.Block( new[] { objectVar }, new Expr[] { Expr.Assign(objectVar, Expr.Field(objectParam, "Holder")) } .Concat(new[] { checksBody }) .Concat(new[] { objectParam })) : objectParam; } else { // Not anonymous type - throw an exception lambdaBody = Expr.Block( Expr.Throw( Expr.New( VerifyArgsExceptionCtor, Expr.Constant(string.Format(ErrorMessages.NotAnonymousType, type)))), objectParam); } // Pull it all together, execute checks only if supplied object is not null var lambda = Expr.Lambda <TVerifier>( lambdaBody, new[] { objectParam }.Concat(additionalParams)); return(lambda.Compile()); }
/// <summary> /// 密码加密 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SaveBtn_Click(object sender, EventArgs e) { try { AppAccountMgn saveItem = FormHelp.GetEntityByControls <AppAccountMgn>(this.panel1); if (!string.IsNullOrEmpty(appAccountMgn.MGNPWD)) { DialogResult dialogResult = MessageBox.Show("是否以原管理密码保存", "温馨提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); if (dialogResult == DialogResult.OK) { saveItem.MGNPWD = appAccountMgn.MGNPWD; } } VerifyMessage verifyMessage = VerifyUtil.Verify(saveItem); if (saveItem.JiaoyanPwd != saveItem.InputPwd) { verifyMessage.ExistError = true; verifyMessage.ErrorInfo += "\n两次输入密码不一致,请重新输入"; } if (verifyMessage.ExistError) { MessageBox.Show(verifyMessage.ErrorInfo, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //string iv = saveItem.ACCOUNT.ToString().PadLeft(8, 'u'); string enc = DesHelper.DESEncrypt(saveItem.InputPwd, key, iv); this.ENCPWD.Text = enc; //真实密码 saveItem.ENCPWD = enc; //真实密码 saveItem.PSEUDOCODE = Md5Util.Md5(enc); //掩码 this.PSEUDOCODE.Text = saveItem.PSEUDOCODE; R r = appAccountMgnBLL.SaveOrUpdateBySelf(saveItem, null, false); if (r.Successful) { string msg = saveItem.ID <= 0 ? "新增" : "修改"; MessageBox.Show($"{msg}成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadData(); //更新列表页 if (this.Owner is AccoutEncFrmList) { ((AccoutEncFrmList)this.Owner).LoadData(); } this.Hide(); this.Dispose(true); } else { MessageBox.Show(r.ResultHint, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch (Exception ex) { MessageHelper.ShowError(ex); } }
private void commitButton_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(this.userNameTextBox.Text)) { MessageBox.Show("请填写用户名!"); this.userNameTextBox.Focus(); return; } if (!VerifyUtil.VerifyName(this.userNameTextBox.Text)) { MessageBox.Show("用户名格式不正确请重新输入!,正确的格式应该是长度4-10,可以是数字或英文字母."); this.userNameTextBox.Text = string.Empty; this.userNameTextBox.Focus(); return; } string userName = this.userNameTextBox.Text; if (string.IsNullOrEmpty(this.oldPasswdTextBox.Text)) { MessageBox.Show("请填写旧密码!"); this.oldPasswdTextBox.Focus(); return; } if (!VerifyUtil.VerifyPwd(this.oldPasswdTextBox.Text)) { MessageBox.Show("旧密码格式不正确请重新输入!,正确的格式应该是长度6-20,可以是数字或英文字母."); this.oldPasswdTextBox.Text = string.Empty; this.oldPasswdTextBox.Focus(); return; } string oldPasswd = this.oldPasswdTextBox.Text; string newPasswd = this.newPasswdTextBox.Text; string verifyPasswd = this.verifyTextBox.Text; if (!string.IsNullOrEmpty(newPasswd)) { if (!VerifyUtil.VerifyPwd(newPasswd)) { MessageBox.Show("新密码格式不正确请重新输入!,正确的格式应该是长度6-20,可以是数字或英文字母."); this.newPasswdTextBox.Text = string.Empty; this.newPasswdTextBox.Focus(); return; } if (string.IsNullOrEmpty(verifyPasswd)) { MessageBox.Show("请填写确认密码!"); this.verifyTextBox.Focus(); return; } } else { newPasswd = oldPasswd; verifyPasswd = oldPasswd; } if (string.IsNullOrEmpty(mailTextBox.Text)) { MessageBox.Show("请填写邮件地址!"); this.mailTextBox.Focus(); return; } string mail = this.mailTextBox.Text; if (!VerifyUtil.VerifyMailInput(mail)) { MessageBox.Show("邮件地址格式错误,请填写正确的邮件地址!"); this.mailTextBox.Focus(); return; } if (string.IsNullOrEmpty(roleComboBox.Text)) { MessageBox.Show("请选择角色!"); this.roleComboBox.Focus(); return; } int roleID = (int)this.roleComboBox.SelectedValue; if (newPasswd != verifyPasswd) { MessageBox.Show("两次输入的密码不符,请重新输入!"); this.newPasswdTextBox.Text = string.Empty; this.verifyTextBox.Text = string.Empty; this.newPasswdTextBox.Focus(); } else { IDataLayer dataLayer = (IDataLayer)Settings.Default.Context["datalayer"]; SysguardWS.UserInfo info = new sysguard.SysguardWS.UserInfo(); userInfo.name = userName; userInfo.realName = realNameTextBox.Text; userInfo.passwd = newPasswd; userInfo.mail = mail; userInfo.msn = this.msnTextBox.Text; userInfo.skype = this.skypeTextBox.Text; userInfo.roleId = roleID; userInfo.updateTime = DateTime.Now; userInfo.updateTimeSpecified = true; this.cancelButton.Enabled = false; DataLayerResult result = dataLayer.ModifyUserInfo(userInfo, oldPasswd); if (result == DataLayerResult.Success) { DialogResult dialoResult = MessageBox.Show("更新成功是否退出?", "是否退出", MessageBoxButtons.YesNo); if (dialoResult == DialogResult.Yes) { this.DialogResult = DialogResult.OK; this.Close(); } else { this.cancelButton.Enabled = true; userControl.Flush(); } } else if (result == DataLayerResult.OldPasswdError) { MessageBox.Show("旧密码无效,请重新输入!"); this.oldPasswdTextBox.Text = string.Empty; this.oldPasswdTextBox.Focus(); } } }
/// <summary> /// Determines whether given type is numeric. /// </summary> /// <param name="type">Type to check.</param> /// <returns>True if type is numeric; false otherwise.</returns> public static bool IsNumeric(this Type type) { VerifyUtil.NotNull(type, "type"); return(NumericTypes.Contains(type)); }