/// <summary> /// 添加范围 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void lvOwernRoles_MouseDoubleClick(object sender, MouseEventArgs e) { /* *说明: *角色的使用范围一般是只有,护士帐号和医生帐号才有,其他帐号暂无。 */ try { /* * 获取已经有的范围配置 */ ArrayList currentRanges = new ArrayList(); for (int i = 0; i < trvRoleRange.Nodes.Count; i++) { currentRanges.Add(trvRoleRange.Nodes[i].Text); } Class_Role temp = (Class_Role)lvOwernRoles.SelectedItems[0].Tag; frmRoleRange fm = new frmRoleRange("0", temp.Role_type, currentRanges); App.FormStytleSet(fm, false); fm.ShowDialog(); if (trvTempRoleRange != null) { temp.Rnages = new Class_Rnage[trvTempRoleRange.Nodes.Count]; trvRoleRange.Nodes.Clear(); for (int i = 0; i < temp.Rnages.Length; i++) { temp.Rnages[i] = new Class_Rnage(); temp.Rnages[i] = (Class_Rnage)trvTempRoleRange.Nodes[i].Tag; Node tn = new Node(); tn.Tag = temp.Rnages[i]; tn.Text = temp.Rnages[i].Rnagename; tn.ImageIndex = 2; trvRoleRange.Nodes.Add(tn); } lvOwernRoles.SelectedItems[0].Tag = temp; } if (ucSectionkeep.trvTempRoleRange != null) { temp = (Class_Role)lvOwernRoles.SelectedItems[0].Tag; temp.Rnages = new Class_Rnage[ucSectionkeep.trvTempRoleRange.Nodes.Count]; trvRoleRange.Nodes.Clear(); for (int i = 0; i < temp.Rnages.Length; i++) { temp.Rnages[i] = new Class_Rnage(); temp.Rnages[i] = (Class_Rnage)ucSectionkeep.trvTempRoleRange.Nodes[i].Tag; Node tn = new Node(); tn.Tag = temp.Rnages[i]; tn.Text = temp.Rnages[i].Rnagename; trvRoleRange.Nodes.Add(tn); } lvOwernRoles.SelectedItems[0].Tag = temp; } } catch (Exception ex) { App.MsgErr("错误信息:" + ex.Message); } }
/// <summary> /// 加载选择项 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnChoseone_Click(object sender, EventArgs e) { for (int i = 0; i < lvRoles.Items.Count; i++) { if (lvRoles.Items[i].Checked) { bool flag = false; for (int j = 0; j < lvOwernRoles.Items.Count; j++) { Class_Role temp1 = (Class_Role)lvRoles.Items[i].Tag; Class_Role temp2 = (Class_Role)lvOwernRoles.Items[j].Tag; if (temp1.Role_id == temp2.Role_id) { flag = true; } } if (!flag) { lvOwernRoles.Items.Add((ListViewItem)lvRoles.Items[i].Clone()); } } } App.RemoveSelectNodes(lvRoles); }
private void toolMenuUseful_Click(object sender, EventArgs e) { Class_Role temp = (Class_Role)trvRoles.SelectedNode.Tag; App.ExecuteSQL("update t_role set ENABLE_FLAG='Y' where id=" + temp.Role_id + ""); temp.Enable = "Y"; trvRoles.SelectedNode.Tag = temp; trvRoles.SelectedNode.ForeColor = Color.Black; }
private void btnAdd_Click(object sender, EventArgs e) { EditState(true); IsSave = true; txtRoleName.Text = ""; txtRoleName.Focus(); cboRoleState.SelectedIndex = 0; CurrentRole = null; AllCheckFalse(trvPerssions.Nodes); AllCheckFalse(trvPerssionsButton.Nodes); }
/// <summary> /// 菜单删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void toolMenuDelete_Click(object sender, EventArgs e) { if (trvRoles.SelectedNode != null) { if (App.Ask("该权限可能已经在使用确定要删除吗?")) { if (trvRoles.SelectedNode.Nodes.Count == 0) { ArrayList Slqs = new ArrayList(); Class_Role temp = (Class_Role)trvRoles.SelectedNode.Tag; //删除权限 Slqs.Add("delete from t_role where role_id=" + temp.Role_id + ""); //删除权限所对应的菜单功能项 Slqs.Add("delete from t_role_permission where ROLE_ID=" + temp.Role_id + ""); //删除帐号权限所对应的使用范围 Slqs.Add("delete from t_acc_role_range where acc_role_id in (select id from T_ACC_ROLE where role_id=" + temp.Role_id + ")"); //删除帐号所对应的该权限项 Slqs.Add("delete from t_acc_role where ROLE_ID=" + temp.Role_id + ""); string[] Sqls = new string[Slqs.Count]; for (int i = 0; i < Slqs.Count; i++) { Sqls[i] = Slqs[i].ToString(); } if (App.ExecuteBatch(Sqls) > 0) { App.Msg("删除已经成功"); temp.Enable = "N"; trvRoles.SelectedNode.Tag = temp; trvRoles.SelectedNode.ForeColor = Color.Red; trvRoles.Nodes.Remove(trvRoles.SelectedNode); } else { App.MsgErr("删除操作失败"); } } else { App.MsgErr("请先删除该菜单的子项!"); return; } } } }
private void toolMenuUnUseful_Click(object sender, EventArgs e) { if (trvRoles.SelectedNode != null) { if (App.Ask("该权限可能已经在使用确定要停用吗?")) { Class_Role temp = (Class_Role)trvRoles.SelectedNode.Tag; App.ExecuteSQL("update t_role set ENABLE_FLAG='N' where id=" + temp.Role_id + ""); temp.Enable = "N"; trvRoles.SelectedNode.Tag = temp; trvRoles.SelectedNode.ForeColor = Color.Red; } } }
/// <summary> /// 初始化角色 /// </summary> private void IniRoles() { DataSet ds = App.GetDataSet("select * from t_role g where g.role_name='普通医师' or g.role_name='内科值班医生' or g.role_name='外科值班医生'"); AllRoles = new Class_Role[ds.Tables[0].Rows.Count]; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { AllRoles[i] = new Class_Role(); AllRoles[i].Role_id = ds.Tables[0].Rows[i]["ROLE_ID"].ToString(); AllRoles[i].Role_name = ds.Tables[0].Rows[i]["ROLE_NAME"].ToString(); AllRoles[i].Enable = ds.Tables[0].Rows[i]["ENABLE_FLAG"].ToString(); AllRoles[i].Role_type = ds.Tables[0].Rows[i]["ROLE_TYPE"].ToString(); } }
/// <summary> /// 根据角色初始化所拥有的权限列表 /// </summary> /// <param name="SelectRole">当前角色</param> private void IniOwnerPersions(Class_Role SelectRole) { if (SelectRole != null) { if (SelectRole.Permissions.Length > 0) { for (int i = 0; i < SelectRole.Permissions.Length; i++) { TreeNode tn = new TreeNode(); tn.Tag = SelectRole.Permissions[i]; tn.Text = SelectRole.Permissions[i].Perm_name; trvPerssions.Nodes.Add(tn); } } } }
private void contextMenuStrip1_Opening(object sender, CancelEventArgs e) { if (trvRoles.SelectedNode != null) { Class_Role temp = (Class_Role)trvRoles.SelectedNode.Tag; if (temp.Enable == "Y") { toolMenuUseful.Enabled = false; toolMenuUnUseful.Enabled = true; } else { toolMenuUseful.Enabled = true; toolMenuUnUseful.Enabled = false; } } }
/// <summary> /// 初始化已经拥有的权限树 /// </summary> /// <param name="Account">当前帐号</param> private void IniTrvOwner(Class_Account Account) { lvOwernRoles.Items.Clear(); if (Account != null) { if (Account.Roles != null) { for (int i = 0; i < Account.Roles.Length; i++) { Class_Role temp = (Class_Role)Account.Roles[i]; ListViewItem tempitem = new ListViewItem(); tempitem.Tag = temp; tempitem.Text = temp.Role_name; tempitem.ImageIndex = 1; lvOwernRoles.Items.Add(tempitem); } } } }
/// <summary> /// 当前帐号拥有的角色的选择 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void lvOwernRoles_SelectedIndexChanged(object sender, EventArgs e) { try { trvRoleRange.Nodes.Clear(); Class_Role temp = (Class_Role)lvOwernRoles.SelectedItems[0].Tag; if (temp.Rnages != null) { trvRoleRange.Nodes.Clear(); for (int i = 0; i < temp.Rnages.Length; i++) { Node tn = new Node(); tn.Tag = temp.Rnages[i]; tn.Text = temp.Rnages[i].Rnagename; tn.ImageIndex = 2; trvRoleRange.Nodes.Add(tn); } } } catch { } }
private void trvRoles_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) { if (trvRoles.SelectedNode != null) { IsChoseAllChildNodes = false; CurrentRole = (Class_Role)trvRoles.SelectedNode.Tag; txtRoleName.Text = CurrentRole.Role_name; if (CurrentRole.Enable == "Y") { cboRoleState.SelectedIndex = 0; } else { cboRoleState.SelectedIndex = 1; } /* * 加载界面控件的值 */ if (CurrentRole.Role_type == "D") { cboRoleType.Text = "医生"; } else if (CurrentRole.Role_type == "N") { cboRoleType.Text = "护士"; } else if (CurrentRole.Role_type == "H") { cboRoleType.Text = "护理部"; } else if (CurrentRole.Role_type == "Y") { cboRoleType.Text = "医务处"; } else if (CurrentRole.Role_type == "B") { cboRoleType.Text = "病案室"; } else if (CurrentRole.Role_type == "M") { cboRoleType.Text = "管理员"; } else if (CurrentRole.Role_type == "O") { cboRoleType.Text = "其他"; } else { } /* * 加载所有的菜单权限 */ AllCheckFalse(trvPerssions.Nodes); ALLCheckByCode(CurrentRole.Permissions, trvPerssions.Nodes); /* * 加载所有的按钮权限 */ AllCheckFalse(trvPerssionsButton.Nodes); ALLCheckByCode(CurrentRole.Permissions, trvPerssionsButton.Nodes); /* * 加载文书权限 */ AllCheckFalse(trvTextRole.Nodes); if (CurrentRole.Texts != null) { ALLCheckByID(CurrentRole.Texts, trvTextRole.Nodes); } IsChoseAllChildNodes = true; } }
string Role_Type = ""; //角色类型 private void btnSure_Click(object sender, EventArgs e) { SqlStrs = new ArrayList(); PID = 0; if (cboRoleType.Text == "医生") { Role_Type = "D"; } else if (cboRoleType.Text == "护士") { Role_Type = "N"; } else if (cboRoleType.Text == "护理部") { Role_Type = "H"; } else if (cboRoleType.Text == "医务处") { Role_Type = "Y"; } else if (cboRoleType.Text == "病案室") { Role_Type = "B"; } else if (cboRoleType.Text == "管理员") { Role_Type = "M"; } else if (cboRoleType.Text == "院感科") { Role_Type = "U"; } else if (cboRoleType.Text == "质控科") { Role_Type = "Z"; } else if (cboRoleType.Text == "其他") { Role_Type = "O"; } else { Role_Type = ""; } if (txtRoleName.Text.Trim() == "") { App.MsgErr("角色名称不能为空!"); return; } string IsUserful = "Y"; int ID = 0; if (cboRoleState.SelectedIndex == 0) { IsUserful = "Y"; } else { IsUserful = "N"; } if (IsSave) { //添加操作 if (IsExitRole(txtRoleName.Text)) { App.MsgErr("权限名称已经存在!"); return; } ID = App.GenId("T_ROLE", "ROLE_ID"); //保存角色 string Sql = ""; Sql = "insert into T_ROLE(ROLE_ID,ROLE_NAME,ENABLE_FLAG,ROLE_TYPE)values(" + ID.ToString() + ",'" + txtRoleName.Text + "','" + IsUserful + "','" + Role_Type + "')"; SqlStrs.Add(Sql); } else { //修改操作 if (trvRoles.SelectedNode != null) { Class_Role TempRole = (Class_Role)trvRoles.SelectedNode.Tag; ID = Convert.ToInt32(TempRole.Role_id); //更新角色 string Sql = ""; Sql = "update T_ROLE set ROLE_NAME='" + txtRoleName.Text + "',ENABLE_FLAG='" + IsUserful + "',ROLE_TYPE='" + Role_Type + "' where ROLE_ID=" + TempRole.Role_id + ""; SqlStrs.Add(Sql); } } /* * 保存与角色相关的权限 */ SqlStrs.Add("delete from T_ROLE_PERMISSION where ROLE_ID=" + ID + ""); SqlStrs.Add("delete from T_ROLE_TEXT where ROLE_ID=" + ID + ""); //保存菜单权限 SavePerssions(ID.ToString(), trvPerssions.Nodes); //保存按钮权限 SavePerssions(ID.ToString(), trvPerssionsButton.Nodes); //保存文书权限 SaveTexts(ID.ToString(), trvTextRole.Nodes); 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("操作已成功"); btnCancel_Click(sender, e); } //更新角色树 IniRoles(); //返回添加状态 if (IsSave) { btnAdd_Click(sender, e); } }
/// <summary> /// 初始化角色树结点 /// </summary> private void IniRoles() { trvRoles.Nodes.Clear(); Class_Table[] tabSqls = new Class_Table[2]; tabSqls[0] = new Class_Table(); tabSqls[0].Sql = "select * from t_role"; tabSqls[0].Tablename = "role"; tabSqls[1] = new Class_Table(); tabSqls[1].Sql = "select * from T_PERMISSION a inner join T_ROLE_PERMISSION b on a.perm_code=b.perm_code"; tabSqls[1].Tablename = "permission"; DataSet ds = App.GetDataSet(tabSqls); if (ds != null) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { TreeNode tn = new TreeNode(); Class_Role tempRole = new Class_Role(); tempRole.Role_id = ds.Tables["role"].Rows[i]["ROLE_ID"].ToString();//App.GenId("t_role", "ROLE_ID") tempRole.Role_name = ds.Tables["role"].Rows[i]["ROLE_NAME"].ToString(); tempRole.Enable = ds.Tables["role"].Rows[i]["ENABLE_FLAG"].ToString(); tempRole.Section_Id = ds.Tables["role"].Rows[i]["SECTION_ID"].ToString(); tempRole.Sickarea_Id = ds.Tables["role"].Rows[i]["SICKAREA_ID"].ToString(); tempRole.Role_type = ds.Tables["role"].Rows[i]["ROLE_TYPE"].ToString(); //绑定角色所对应的权限 DataRow[] rows = ds.Tables["permission"].Select("ROLE_ID = " + tempRole.Role_id + ""); if (rows != null) { tempRole.Permissions = new Class_Permission[rows.Length]; for (int j = 0; j < rows.Length; j++) { tempRole.Permissions[j] = new Class_Permission(); tempRole.Permissions[j].Id = rows[j]["ID"].ToString(); tempRole.Permissions[j].Perm_code = rows[j]["PERM_CODE"].ToString(); tempRole.Permissions[j].Perm_name = rows[j]["PERM_NAME"].ToString(); tempRole.Permissions[j].Perm_kind = rows[j]["PERM_KIND"].ToString(); tempRole.Permissions[j].Num = rows[j]["NUM"].ToString(); } } //绑定角色所对应的文书权限 DataSet ds_textrole = App.GetDataSet("select * from t_text where id in(select text_id from t_role_text where role_id=" + tempRole.Role_id + ") "); if (ds_textrole != null) { tempRole.Texts = GetTextDs(ds_textrole.Tables[0]); } tn.Tag = tempRole; tn.Text = tempRole.Role_name; if (tempRole.Enable == "Y") { tn.ForeColor = Color.Black; } else { tn.ForeColor = Color.Red; } trvRoles.Nodes.Add(tn); } } }
/// <summary> /// 进行添加或修改操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSure_Click(object sender, EventArgs e) { /* * 说明: * 1、添加操作: * 手动生成一个帐号的ID,然后再插入帐号,已经相关的角色和以及角色所对应使用范围。 * 2、修改操作: * 对帐号表信息进行修改,然后再对“帐号角色关系表”,“角色和使用范围表”进行删除 * 操作,然后再添加新的角色和相关使用范围。 */ try { int Account_Id = 0; //帐号表的主键 Account_Id = Convert.ToInt32(CurrentAccount.Account_id); ArrayList SqlStrs = new ArrayList(); //保存帐号的权限 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() + ")"); int 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 (App.UserAccount.CurrentSelectRole.Rnages != null) { for (int i1 = 0; i1 < App.UserAccount.CurrentSelectRole.Rnages.Length; i1++) { string Section_id = "0"; string Area_id = "0"; if (App.UserAccount.CurrentSelectRole.Rnages[i1].Isbelonge == "0") { Section_id = App.UserAccount.CurrentSelectRole.Rnages[i1].Section_id; } else { Area_id = App.UserAccount.CurrentSelectRole.Rnages[i1].Sickarea_id; } SqlStrs.Add("insert into T_ACC_ROLE_RANGE(ACC_ROLE_ID,SICKAREA_ID,SECTION_ID,ISBELONGTO)values(" + ACC_ROLE_ID + "," + Area_id + "," + Section_id + ",'" + App.UserAccount.CurrentSelectRole.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("操作已成功"); } IniTrvAccount(txtAccountCheck.Text); btnCancel_Click(sender, e); } catch (Exception ex) { App.MsgErr("操作失败!原因:" + ex.Message); } }
/// <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); } }