protected override void BtnOK_Click(object sender, EventArgs e) { int iFlag = cbFlag.SelectedIndex - 1; string strUserName = txtUserName.Text.Trim(); string strPassword = txtPassword.Text.Trim(); string strMemo = txtMemo.Text.Trim(); if (iFlag == -1 || strUserName.Equals("") || strPassword.Equals("")) { CMessageBox.ShowError("角色、用户名和密码都必须输入!", Config.DialogTitle); return; } if (MessageBox.Show("确定要保存吗?", Config.DialogTitle, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { return; } Model.UserInfo objModel = new Model.UserInfo() { Flag = iFlag, ID = this._CurrentID, UserName = strUserName, UserPwd = (this._CurrentAction.Equals(EAction.Create)) ? Functions.Md5_32(strPassword) : ((strPassword.Equals(this._OriginalPassword) ? this._OriginalPassword : Functions.Md5_32(strPassword))), Memo = strMemo }; string strErrorInfo = ""; IDAL.IUserInfo objDAL = DALFactory.DALFactory.UserInfo(); if (this._CurrentAction.Equals(EAction.Create)) { int iNewID = objDAL.Add(objModel, out strErrorInfo); if (iNewID <= 0) { CMessageBox.ShowError(string.Format("创建用户失败,错误如下:\r\n{0}!", strErrorInfo), Config.DialogTitle); return; } } else { bool bIfSucc = objDAL.Update(objModel, out strErrorInfo); if (!bIfSucc) { CMessageBox.ShowError(string.Format("修改用户失败,错误如下:\r\n{0}!", strErrorInfo), Config.DialogTitle); return; } } this.DialogResult = DialogResult.OK; }