/// <summary> /// 修改操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSure_Click(object sender, EventArgs e) { if (Encrypt.EncryptStr(txtOldPassword.Text) == App.UserAccount.Password) { if (txtNewPassword.Text == txtNewPasswordAgin.Text) { if (App.UserAccount.CurrentSelectRole != null) { /* * 正式账号修改 */ App.ExecuteSQL("update t_account set PASSWORD='******' where ACCOUNT_ID=" + App.UserAccount.Account_id + ""); App.SynchronizationDataBase(App.CurrentHospitalId.ToString(), "update t_account set PASSWORD='******' where ACCOUNT_ID=" + App.UserAccount.Account_id + ""); } else { /* * 临时账号的修改 */ App.ExecuteSQL("update T_TEMP_ACCOUNT set PASSWORD='******' where ACCOUNT_ID=" + App.UserAccount.Account_id + ""); App.SynchronizationDataBase(App.CurrentHospitalId.ToString(), "update T_TEMP_ACCOUNT set PASSWORD='******' where ACCOUNT_ID=" + App.UserAccount.Account_id + ""); } App.Msg("修改成功!"); } else { App.MsgErr("新密码两次输入不一致!"); txtNewPassword.Text = ""; txtNewPasswordAgin.Text = ""; txtNewPassword.Focus(); } } else { App.MsgErr("原密码不正确!"); txtOldPassword.Text = ""; txtNewPassword.Text = ""; txtNewPasswordAgin.Text = ""; txtOldPassword.Focus(); } }
/// <summary> /// 保存签名 /// </summary> /// <param name="Type">类型</param> /// <param name="account">帐号</param> /// <param name="pass">密码</param> private void SaveSign(string Type, string account, string pass) { if (Type == "S" && Userid != "") { DataSet ds_old_account = App.GetDataSet("select a.account_id from T_ACCOUNT a where a.ACCOUNT_NAME='" + txtAccount.Text.ToUpper() + "' and a.PASSWORD='******'"); if (ds_old_account != null) { if (ds_old_account.Tables[0].Rows.Count < 1) { App.Msg("原密码或帐号不正确!"); return; } } else { App.Msg("原密码或帐号不正确!"); return; } } App.DocSign = null; string sqltype = "select a.role_type,t.kind from T_ROLE a inner join T_ACC_ROLE b on a.role_id=b.role_id inner join T_account t on b.account_id=t.account_id where t.account_name='" + account + "'"; DataSet dsettype = App.GetDataSet(sqltype); if (dsettype.Tables[0].Rows.Count > 0) { if (dsettype.Tables[0].Rows[0][0].ToString().Trim() != "D") { App.MsgWaring("该帐号不是医生帐号!"); return; } } else { if (STYPE == "S") { this.txtNewPassword.Text = ""; this.txtNewAccount.Focus(); } else { this.txtPassword.Text = ""; this.txtAccount.Focus(); } App.Msg("工号或密码不正确!"); return; } string AccountType = dsettype.Tables[0].Rows[0][1].ToString().Trim(); if (Type != "S") { if (AccountType != "52") { if (AccountType == "53") { App.Msg("该帐号是实习生帐号,不能审签他人文书!"); return; } else if (AccountType == "54") { App.Msg("该帐号是进修生帐号,不能审签他人文书!"); return; } else if (AccountType == "70") { App.Msg("该帐号是轮转医生帐号,不能审签他人文书!"); return; } else if (AccountType == "7921") { App.Msg("该帐号是研究生帐号,不能审签他人文书!"); return; } } } Sql = "select c.user_id,c.user_name,c.u_tech_post,d1.name as u_tech_post_name,c.u_position,d2.name as u_position_name from T_ACCOUNT a inner join t_account_user b on a.account_id=b.account_id inner join T_USERINFO c on b.user_id=c.user_id inner join T_DATA_CODE d1 on c.u_tech_post=d1.id inner join T_DATA_CODE d2 on c.u_position=d2.id where a.ACCOUNT_NAME='" + account + "' and a.PASSWORD='******'"; DataSet ds = App.GetDataSet(Sql); if (ds != null) { if (ds.Tables[0].Rows.Count > 0) { App.DocSign = new Class_DocSign(); App.DocSign.Userid = ds.Tables[0].Rows[0]["user_id"].ToString(); App.DocSign.Username = ds.Tables[0].Rows[0]["user_name"].ToString(); App.DocSign.U_tech_post = ds.Tables[0].Rows[0]["u_tech_post"].ToString(); App.DocSign.U_tech_post_name = ds.Tables[0].Rows[0]["u_tech_post_name"].ToString(); App.DocSign.U_position = ds.Tables[0].Rows[0]["u_position"].ToString(); App.DocSign.U_position_name = ds.Tables[0].Rows[0]["u_position_name"].ToString(); App.DocSign.Digtype = cboDigType.Text; this.Close(); } else { if (STYPE == "S") { this.txtNewPassword.Text = ""; this.txtNewAccount.Focus(); } else { this.txtPassword.Text = ""; this.txtAccount.Focus(); } App.Msg("工号或密码不正确!"); } } else { if (STYPE == "S") { this.txtNewPassword.Text = ""; this.txtNewAccount.Focus(); } else { this.txtPassword.Text = ""; this.txtAccount.Focus(); } App.Msg("工号或密码不正确!"); } }
/// <summary> /// 进行添加或修改操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSure_Click(object sender, EventArgs e) { /* * 说明: * 1、添加操作: * 手动生成一个帐号的ID,然后再插入帐号,已经相关的角色和以及角色所对应使用范围。 * 2、修改操作: * 对帐号表信息进行修改,然后再对“帐号角色关系表”,“角色和使用范围表”进行删除 * 操作,然后再添加新的角色和相关使用范围。 */ try { string Sql = ""; //进行操作的SQL语句 int Account_Id = 0; //帐号表的主键 string Account_Enable = "Y"; //帐号状态 string Account_Password = ""; //帐号密码 string TbSql = ""; //同步用的SQL //帐号异动信息 string accountAccountType = ""; //操作类型 string accountInfo = ""; //操作信息 if (IsSave) //新增 { accountAccountType = "新建"; } else { accountAccountType = "修改"; } ArrayList SqlStrs = new ArrayList(); if (cboAccountKind.Text == "") { App.MsgErr("用户性质为必填项!"); return; } //帐号状态 if (!rbtnUserful.Checked) { Account_Enable = "N"; } //查看是否已经设置了所有角色的使用范围 for (int i = 0; i < lvOwernRoles.Items.Count; i++) { Class_Role temprole = (Class_Role)lvOwernRoles.Items[i].Tag; if (temprole.Role_type == "N" || temprole.Role_type == "D") { if (temprole.Rnages == null) { App.MsgErr("该帐号的某个或多个选中的角色没有设置使用范围."); return; } } } if (lvOwernRoles.Items.Count == 0) { App.MsgErr("请为当前帐号选择角色."); return; } if (IsSave) { /* * 进行添加操作 */ if (txtPassword.Text.Trim() == "") { App.MsgErr("密码不能为空!"); return; } else { if (txtPassword.Text != txtPasswordAgin.Text) { App.MsgErr("两次密码设置不一致!"); return; } } if (txtAccount.Text != "") { if (IsExitAccount(txtAccount.Text)) { App.MsgErr("帐号已经存在!"); return; } } else { App.MsgErr("帐号不能为空!"); return; } Account_Password = txtPassword.Text; //Account_Id = App.GenId("T_ACCOUNT", "ACCOUNT_ID"); Account_Id = App.GenAccountId(App.CurrentHospitalId.ToString()); if (Account_Enable == "Y") { Sql = "insert into T_ACCOUNT(ACCOUNT_ID,ACCOUNT_NAME,PASSWORD,ENABLE,ENABLE_START_TIME,KIND,HSID)values(" + Account_Id.ToString() + ",'" + txtAccount.Text + "','" + Encrypt.EncryptStr(Account_Password) + "','" + Account_Enable + "',to_timestamp('" + DateTime.Now.ToShortDateString() + "','syyyy-mm-dd hh24:mi:ss.ff9')," + cboAccountKind.SelectedValue.ToString() + "," + App.CurrentHospitalId.ToString() + ")"; } else { Sql = "insert into T_ACCOUNT(ACCOUNT_ID,ACCOUNT_NAME,PASSWORD,ENABLE,ENABLE_END_TIME,KIND,HSID)values(" + Account_Id.ToString() + ",'" + txtAccount.Text + "','" + Encrypt.EncryptStr(Account_Password) + "','" + Account_Enable + "',to_timestamp('" + DateTime.Now.ToShortDateString() + "','syyyy-mm-dd hh24:mi:ss.ff9')," + cboAccountKind.SelectedValue.ToString() + "," + App.CurrentHospitalId.ToString() + ")"; } } else { /* * 进行修改操作 */ Account_Id = Convert.ToInt32(CurrentAccount.Account_id); if (txtPassword.Text.Trim() != "") { if (txtPassword.Text != txtPasswordAgin.Text) { App.MsgErr("两次密码设置不一致!"); return; } else { Account_Password = txtPassword.Text; if (CurrentAccount.Enable == "Y") { if (Account_Enable == "Y") { Sql = "update T_ACCOUNT set ACCOUNT_NAME='" + txtAccount.Text + "',PASSWORD='******',ENABLE='" + Account_Enable + "',KIND=" + cboAccountKind.SelectedValue.ToString() + " where ACCOUNT_ID='" + CurrentAccount.Account_id + "'"; } else { Sql = "update T_ACCOUNT set ACCOUNT_NAME='" + txtAccount.Text + "',PASSWORD='******',ENABLE='" + Account_Enable + "',ENABLE_END_TIME=to_timestamp('" + DateTime.Now.ToShortDateString() + "','syyyy-mm-dd hh24:mi:ss.ff9'),KIND=" + cboAccountKind.SelectedValue.ToString() + " where ACCOUNT_ID='" + CurrentAccount.Account_id + "'"; } } else { if (Account_Enable == "Y") { Sql = "update T_ACCOUNT set ACCOUNT_NAME='" + txtAccount.Text + "',PASSWORD='******',ENABLE='" + Account_Enable + "',ENABLE_START_TIME=to_timestamp('" + DateTime.Now.ToShortDateString() + "','syyyy-mm-dd hh24:mi:ss.ff9'),KIND=" + cboAccountKind.SelectedValue.ToString() + " where ACCOUNT_ID='" + CurrentAccount.Account_id + "'"; } else { Sql = "update T_ACCOUNT set ACCOUNT_NAME='" + txtAccount.Text + "',PASSWORD='******',ENABLE='" + Account_Enable + "',KIND=" + cboAccountKind.SelectedValue.ToString() + " where ACCOUNT_ID='" + CurrentAccount.Account_id + "'"; } } } } else { Sql = "update T_ACCOUNT set ACCOUNT_NAME='" + txtAccount.Text + "',ENABLE='" + Account_Enable + "',KIND=" + cboAccountKind.SelectedValue.ToString() + " where ACCOUNT_ID='" + CurrentAccount.Account_id + "'"; if (CurrentAccount.Enable == "Y") { if (Account_Enable == "Y") { Sql = "update T_ACCOUNT set ACCOUNT_NAME='" + txtAccount.Text + "',ENABLE='" + Account_Enable + "',KIND=" + cboAccountKind.SelectedValue.ToString() + " where ACCOUNT_ID='" + CurrentAccount.Account_id + "'"; } else { Sql = "update T_ACCOUNT set ACCOUNT_NAME='" + txtAccount.Text + "',ENABLE='" + Account_Enable + "',ENABLE_END_TIME=to_timestamp('" + DateTime.Now.ToShortDateString() + "','syyyy-mm-dd hh24:mi:ss.ff9'),KIND=" + cboAccountKind.SelectedValue.ToString() + " where ACCOUNT_ID='" + CurrentAccount.Account_id + "'"; } } else { if (Account_Enable == "Y") { Sql = "update T_ACCOUNT set ACCOUNT_NAME='" + txtAccount.Text + "',ENABLE='" + Account_Enable + "',ENABLE_START_TIME=to_timestamp('" + DateTime.Now.ToShortDateString() + "','syyyy-mm-dd hh24:mi:ss.ff9'),KIND=" + cboAccountKind.SelectedValue.ToString() + " where ACCOUNT_ID='" + CurrentAccount.Account_id + "'"; } else { Sql = "update T_ACCOUNT set ACCOUNT_NAME='" + txtAccount.Text + "',ENABLE='" + Account_Enable + "',KIND=" + cboAccountKind.SelectedValue.ToString() + " where ACCOUNT_ID='" + CurrentAccount.Account_id + "'"; } } } } //保存帐号基本信息 SqlStrs.Add(Sql); TbSql = Sql; //保存帐号的权限 SqlStrs.Add("delete from T_ACC_ROLE where ACCOUNT_ID=" + Account_Id.ToString() + ""); SqlStrs.Add("delete from T_ACC_ROLE_RANGE where ACC_ROLE_ID in (select ID from T_ACC_ROLE where ACCOUNT_ID=" + Account_Id.ToString() + ")"); long ACC_ROLE_ID = 0; for (int i = 0; i < lvOwernRoles.Items.Count; i++) { if (ACC_ROLE_ID >= App.GenId("T_ACC_ROLE", "ID")) { ACC_ROLE_ID = ACC_ROLE_ID + 1; } else { ACC_ROLE_ID = App.GenId("T_ACC_ROLE", "ID"); } Class_Role temp = (Class_Role)lvOwernRoles.Items[i].Tag; SqlStrs.Add("insert into T_ACC_ROLE(ID,ACCOUNT_ID,ROLE_ID)values(" + ACC_ROLE_ID.ToString() + "," + Account_Id + "," + temp.Role_id + ")"); //保存该帐号权限的使用用范围 if (temp.Rnages != null) { for (int i1 = 0; i1 < temp.Rnages.Length; i1++) { string Section_id = "0"; string Area_id = "0"; if (temp.Rnages[i1].Isbelonge == "0") { Section_id = temp.Rnages[i1].Section_id; } else { Area_id = temp.Rnages[i1].Sickarea_id; } //帐号使用范围异动信息 if (accountInfo == "") { accountInfo = temp.Rnages[i1].Rnagename; } else { if (!accountInfo.Contains(temp.Rnages[i1].Rnagename)) { accountInfo += "," + temp.Rnages[i1].Rnagename; } } SqlStrs.Add("insert into T_ACC_ROLE_RANGE(ACC_ROLE_ID,SICKAREA_ID,SECTION_ID,ISBELONGTO)values(" + ACC_ROLE_ID + ",'" + Area_id + "'," + Section_id + ",'" + temp.Rnages[i1].Isbelonge + "')"); } } } string[] ESQlS = new string[SqlStrs.Count]; for (int i = 0; i < ESQlS.Length; i++) { ESQlS[i] = SqlStrs[i].ToString(); } if (App.ExecuteBatch(ESQlS) > 0) { App.Msg("操作已成功"); App.SynchronizationDataBase(App.CurrentHospitalId.ToString(), TbSql); //记录帐号异动日志 if (accountInfo == "" && IsSave == false) { accountAccountType = "注销"; } LogHelper.Account_SystemLog(Account_Id.ToString(), accountAccountType, accountInfo); } IniTrvAccount(txtAccountCheck.Text); btnCancel_Click(sender, e); } catch (Exception ex) { App.MsgErr("操作失败!原因:" + ex.Message); } }