Exemplo n.º 1
0
 private void Management_Load(object sender, EventArgs e)
 {
     try
     {
         this.toolStripSave.Enabled = false;
         dgv_User();
         if (ClsCommon.userName != "超级管理员")
         {
             UD_Permissions.Minimum = 2;
             DataTable dt = User_BLL.GetUserPower(ClsCommon.userName);
             if (dt.Rows[0]["h_Permissions"].Equals("1"))
             {
                 label4.Visible         = true;
                 UD_Permissions.Visible = true;
             }
             else
             {
                 label4.Visible         = false;
                 UD_Permissions.Visible = false;
             }
         }
         else
         {
             UD_Permissions.Minimum = 1;
             label4.Visible         = true;
             UD_Permissions.Visible = true;
         }
     }
     catch (Exception ex)
     {
         MessageBoxEx.Show("用户管理载入失败!");
         MyLog.Log.InformationLog.Error("用户管理载入失败!" + ex.Message);
     }
 }
Exemplo n.º 2
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            try
            {
                // asc.controllInitializeSize(this);
                #region >>>>>系统初始化
                foreach (XmlNode lineNode in ClsCommon.InfoRootNode.ChildNodes)
                {
                    LineName = lineNode.Attributes["name"].Value;
                    foreach (XmlNode _mNode in lineNode.SelectNodes("station"))
                    {
                        StationName = _mNode.Attributes["name"].Value;
                    }
                }
                #endregion
                #region >>>>>权限管理
                toolStripStatusName.Text = ClsCommon.userName;//显示登录角色
                if (ClsCommon.userName == "超级管理员")
                {
                    buttonItem2.Visible       = true;
                    buttonItem22.Visible      = true;
                    sideBarPanelItem1.Visible = true;
                    for (int i = 0; i < sideBarPanelItem1.SubItems.Count; i++)
                    {
                        sideBarPanelItem1.SubItems[i].Visible = true;
                    }
                    sideBarPanelItem2.Visible = true;
                    for (int i = 0; i < sideBarPanelItem2.SubItems.Count; i++)
                    {
                        sideBarPanelItem2.SubItems[i].Visible = true;
                    }
                    sideBarPanelItem3.Visible = true;
                    for (int i = 0; i < sideBarPanelItem3.SubItems.Count; i++)
                    {
                        sideBarPanelItem3.SubItems[i].Visible = true;
                    }
                    sideBarPanelItem4.Visible = true;
                    for (int i = 0; i < sideBarPanelItem4.SubItems.Count; i++)
                    {
                        sideBarPanelItem4.SubItems[i].Visible = true;
                    }
                    sideBarPanelItem5.Visible = true;
                    for (int i = 0; i < sideBarPanelItem5.SubItems.Count; i++)
                    {
                        sideBarPanelItem5.SubItems[i].Visible = true;
                    }
                    sideBarPanelItem6.Visible = true;
                    for (int i = 0; i < sideBarPanelItem6.SubItems.Count; i++)
                    {
                        sideBarPanelItem6.SubItems[i].Visible = true;
                    }
                }
                else
                {
                    sideBarPanelItem7.Visible = false;
                    #region >>>初始化用户权限
                    Dictionary <string, List <Dictionary <int, string> > > dic = LoadXmlConfig();
                    DataTable dt_user     = User_BLL.GetUserPower(ClsCommon.userName);
                    string    user_powerX = dt_user.Rows[0]["Power"].ToString();

                    string user_power = EncryPtForMy.Class1.DecryptDES(user_powerX);

                    Dictionary <string, List <int> > dic_split_power = Split_Power(user_power);

                    // Lookup<string, string> lookup = ;
                    Dictionary <string, string> dicX = new Dictionary <string, string>();//放置循环结果
                    for (int i = 0; i < dic_split_power.Count; i++)
                    {
                        for (int j = 0; j < dic.Count; j++)
                        {
                            if (dic_split_power.Keys.ToList()[i] == dic.Keys.ToList()[j])
                            {
                                List <int> listX = dic_split_power[dic_split_power.Keys.ToList()[i]];
                                List <Dictionary <int, string> > listC = dic[dic.Keys.ToList()[j]];
                                Dictionary <int, string>         dicCX = new Dictionary <int, string>();
                                for (int m = 0; m < listC.Count; m++)
                                {
                                    for (int w = 0; w < (listC[m] as Dictionary <int, string>).Keys.Count; w++)
                                    {
                                        dicCX.Add((listC[m] as Dictionary <int, string>).Keys.ToList()[w], (listC[m] as Dictionary <int, string>).Values.ToList()[w]);
                                    }
                                }
                                for (int n = 0; n < listX.Count; n++)
                                {
                                    for (int p = 0; p < dicCX.Count; p++)
                                    {
                                        if (listX[n] == dicCX.Keys.ToList()[p])
                                        {
                                            if (dic_split_power.Keys.ToList()[i] == "basis")
                                            {
                                                sideBarPanelItem1.Visible = true;
                                                SideBar sb = this.Controls["sideBar1"] as SideBar;
                                                sb.GetItem("sideBarPanelItem1").SubItems[dicCX.Values.ToList()[p]].Visible = true;
                                                if (dicCX.Values.ToList()[p].ToString().Equals("buttonItem7"))
                                                {
                                                    buttonItem2.Visible = true;
                                                }
                                                if (dicCX.Values.ToList()[p].ToString().Equals("buttonItem8"))
                                                {
                                                    buttonItem22.Visible = true;
                                                }
                                            }
                                            if (dic_split_power.Keys.ToList()[i] == "plan")
                                            {
                                                sideBarPanelItem4.Visible = true;
                                                SideBar sb = this.Controls["sideBar1"] as SideBar;
                                                sb.GetItem("sideBarPanelItem4").SubItems[dicCX.Values.ToList()[p]].Visible = true;
                                            }
                                            if (dic_split_power.Keys.ToList()[i] == "formula")
                                            {
                                                sideBarPanelItem2.Visible = true;
                                                SideBar sb = this.Controls["sideBar1"] as SideBar;
                                                sb.GetItem("sideBarPanelItem2").SubItems[dicCX.Values.ToList()[p]].Visible = true;
                                            }
                                            if (dic_split_power.Keys.ToList()[i] == "table")
                                            {
                                                sideBarPanelItem5.Visible = true;
                                                SideBar sb = this.Controls["sideBar1"] as SideBar;
                                                sb.GetItem("sideBarPanelItem5").SubItems[dicCX.Values.ToList()[p]].Visible = true;
                                            }
                                            if (dic_split_power.Keys.ToList()[i] == "tool")
                                            {
                                                sideBarPanelItem3.Visible = true;
                                                SideBar sb = this.Controls["sideBar1"] as SideBar;
                                                sb.GetItem("sideBarPanelItem3").SubItems[dicCX.Values.ToList()[p]].Visible = true;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    #endregion
                }

                //if (ClsCommon.userName != "Administrator" && ClsCommon.userName != "超级管理员")
                //{
                //    buttonItem5.Visible = false;
                //    sideBarPanelItem6.Visible = false;
                //}
                //if (ClsCommon.userName != "管理员" && ClsCommon.userName != "Administrator" && ClsCommon.userName != "超级管理员")
                //{
                //    buttonItem6.Visible = false;
                //    buttonItem7.Visible = false;
                //    labelItem1.Visible = false;
                //    buttonItem2.Visible = false;
                //    sideBarPanelItem6.Visible = false;
                //}
                //if (ClsCommon.userName != "Administrator")
                //{
                //    buttonItem5.Visible = false;
                //}
                //if (ClsCommon.userName != "管理员"&& ClsCommon.userName != "Administrator")
                //{
                //    buttonItem6.Visible = false;
                //    buttonItem7.Visible = false;
                //    labelItem1.Visible = false;
                //    buttonItem2.Visible = false;
                //}
                #endregion
                #region >>>>>初始化板卡
                //if (Function_BLL.getStationAttribute(LineName, StationName, "adamOrNot") == "1")
                //{
                //    ab = new Adam_BLL();
                //    ab.LineName = LineName;
                //    ab.StationName = StationName;
                //    ab.recodeAdamMessage += new Adam_BLL.recodeAdamLog(recordMessage);
                //    ab.AdamalarmType += new Adam_BLL.AdamAlarm(AlarmFormBusiness);
                //    ab.Run();
                //}
                #endregion
                #region >>>>>初始化打印
                //if (Function_BLL.getStationAttribute(LineName, StationName, "printOrNot") == "1")
                //{
                //    print = new Print_BLL();
                //    print.recodePrintMessage += new Print_BLL.recodePrintLog(recordMessage);
                //    print.printalarmType += new Print_BLL.printAlarm(AlarmFormBusiness);
                //    Thread printworkThread = new Thread(new ThreadStart(print.Run));
                //    printworkThread.Start();
                //}
                #endregion
                recordMessage("系统初始化成功!! " + ClsCommon.userName + "  欢迎你!", 0);
            }
            catch (Exception ex)
            {
                recordMessage("系统初始化失败,请重启......" + ex.Message, 1);
                Application.Restart();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 保存(包括新增用户、修改用户保存)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripSave_Click(object sender, EventArgs e)
        {
            #region       等级为1的用户进行修改
            if (ClsCommon.userName != "超级管理员")
            {
                //TODO:添加
                if (this.h_UserName.Text.Trim() == string.Empty || this.h_UserPwd.Text.Trim() == string.Empty)
                {
                    MessageBoxEx.Show("用户名或密码不能为空!");
                    this.h_UserName.Focus();
                    return;
                }
                else if (this.h_UserPwd.Text.Length < 6)
                {
                    MessageBoxEx.Show("账户密码不能小于6位数字!");
                    this.h_UserPwd.Focus();
                    return;
                }
                DataTable dtX = User_BLL.GetUserPower(this.h_UserName.Text.Trim());
                if (this.toolStripEdit.Enabled == false)    //添加帐户数据判断
                {
                    if (dtX.Rows.Count > 0)
                    {
                        MessageBox.Show("数据库中已存在相同的用户名!");
                        return;
                    }
                    string str_permisssion = UD_Permissions.Value.ToString();
                    string Power_establish = "";      //放置现创建用户的权限

                    DataTable dt = User_BLL.GetUserPower(ClsCommon.userName);
                    if (ClsCommon.userName != "超级管理员")
                    {
                        if (dt.Rows[0]["h_Permissions"].Equals("1"))
                        {
                            string   Power_Now_user       = EncryPtForMy.Class1.DecryptDES(dt.Rows[0]["Power"].ToString()); //当前登录用户权限
                            string[] Power_Now_user_group = Power_Now_user.Split(';');
                            //2类用户权限分配
                            if (str_permisssion.Equals("2"))
                            {
                                string PowerX = "basis:;";
                                for (int i = 1; i < Power_Now_user_group.Length; i++)
                                {
                                    PowerX += Power_Now_user_group[i] + ";";
                                }
                                string power = PowerX.Substring(0, PowerX.Length - 1);
                                Power_establish = EncryPtForMy.Class1.EncryptDES(power);
                            }

                            //3类用户权限分配
                            if (str_permisssion.Equals("3"))
                            {
                                string PowerX = "basis:;";
                                PowerX += "plan:;";
                                //第三等级人员只能有查看权限不能创建(建立在他的第一等级是否拥有该权限)
                                string[] Power_Now_user_group_limit = Power_Now_user_group[1].Split(':');
                                if (Power_Now_user_group_limit[1] != "" && Power_Now_user_group_limit[1] != null)
                                {
                                    string Power_Now_user_group_limit_again = Power_Now_user_group_limit[1];
                                    if (Power_Now_user_group_limit_again.Length > 1)
                                    {
                                        string[] power_choice = Power_Now_user_group_limit_again.Split(',');
                                        for (int i = 0; i < power_choice.Length; i++)
                                        {
                                            if (power_choice[i] != "0" && power_choice[i] != "3")
                                            {
                                                PowerX += power_choice[i] + ",";
                                            }
                                        }
                                        PowerX  = PowerX.Substring(0, PowerX.Length - 1);
                                        PowerX += ";";
                                    }
                                    else
                                    {
                                        PowerX += ";";
                                    }
                                }
                                PowerX += "formula:;";
                                for (int i = 3; i < 4; i++)
                                {
                                    PowerX += Power_Now_user_group[i] + ";";
                                }
                                PowerX += "tool:";
                                //第三等级人员不能导入配方(建立在他的第一等级是否拥有该权限)
                                string[] Power_Now_user_group_limit_4 = Power_Now_user_group[4].Split(':');
                                if (Power_Now_user_group_limit_4[1] != "" && Power_Now_user_group_limit[1] != null)
                                {
                                    string Power_Now_user_group_limit_again = Power_Now_user_group_limit_4[1];
                                    if (Power_Now_user_group_limit_again.Length > 1)
                                    {
                                        string[] power_choice = Power_Now_user_group_limit_again.Split(',');
                                        for (int i = 0; i < power_choice.Length; i++)
                                        {
                                            if (power_choice[i] != "0")
                                            {
                                                PowerX += power_choice[i] + ",";
                                            }
                                        }
                                        PowerX  = PowerX.Substring(0, PowerX.Length - 1);
                                        PowerX += ";";
                                    }
                                    else
                                    {
                                        PowerX += ";";
                                    }
                                }
                                string power = PowerX.Substring(0, PowerX.Length - 1);
                                Power_establish = EncryPtForMy.Class1.EncryptDES(power);
                            }
                        }
                    }
                    else
                    {
                        string PowerX = "";
                        Dictionary <string, List <string> > dic = LoadXmlConfig();
                        for (int i = 0; i < dic.Keys.Count; i++)
                        {
                            PowerX += dic.Keys.ToList()[i].ToString() + ":;";
                        }
                        string power = PowerX.Substring(0, PowerX.Length - 1);
                        Power_establish = EncryPtForMy.Class1.EncryptDES(power);
                    }
                    string str_pwd = EncryPtForMy.Class1.EncryptDES(h_UserPwd.Text);

                    string sql = "insert into Users(h_UserName,h_yUserPwd,Power,h_Permissions,h_Status) values('"
                                 + h_UserName.Text + "','"
                                 + str_pwd + "','"
                                 + Power_establish + "','"
                                 + str_permisssion + "','"
                                 + Convert.ToInt32(h_Status.Checked) + "')";
                    int res = ClsCommon.dbSql.ExecuteNonQuery(sql);
                    if (res > 0)
                    {
                        MessageBoxEx.Show("系统用户添加成功!");
                        dgv_User();
                    }
                }
                else if (this.toolStripAdd.Enabled == false)    //修改帐户数据判断
                {
                    string    str_permisssion = UD_Permissions.Value.ToString();
                    string    Power_establish = "";                                                                  //放置现创建用户的权限
                    DataTable dt                   = User_BLL.GetUserPower(ClsCommon.userName);
                    string    Power_Now_user       = EncryPtForMy.Class1.DecryptDES(dt.Rows[0]["Power"].ToString()); //当前登录用户权限
                    string[]  Power_Now_user_group = Power_Now_user.Split(';');
                    //2类用户权限分配
                    if (str_permisssion.Equals("2"))
                    {
                        string PowerX = "basis:;";
                        for (int i = 1; i < Power_Now_user_group.Length; i++)
                        {
                            PowerX += Power_Now_user_group[i] + ";";
                        }
                        string power = PowerX.Substring(0, PowerX.Length - 1);
                        Power_establish = EncryPtForMy.Class1.EncryptDES(power);
                    }
                    //3类用户权限分配
                    if (str_permisssion.Equals("3"))
                    {
                        string PowerX = "basis:;";
                        PowerX += "plan:;";
                        //第三等级人员只能有查看权限不能创建(建立在他的第一等级是否拥有该权限)
                        string[] Power_Now_user_group_limit = Power_Now_user_group[1].Split(':');
                        if (Power_Now_user_group_limit[1] != "" && Power_Now_user_group_limit[1] != null)
                        {
                            string Power_Now_user_group_limit_again = Power_Now_user_group_limit[1];
                            if (Power_Now_user_group_limit_again.Length > 1)
                            {
                                string[] power_choice = Power_Now_user_group_limit_again.Split(',');
                                for (int i = 0; i < power_choice.Length; i++)
                                {
                                    if (power_choice[i] != "0" && power_choice[i] != "3")
                                    {
                                        PowerX += power_choice[i] + ",";
                                    }
                                }
                                PowerX  = PowerX.Substring(0, PowerX.Length - 1);
                                PowerX += ";";
                            }
                            else
                            {
                                PowerX += ";";
                            }
                        }
                        PowerX += "formula:;";
                        for (int i = 3; i < 4; i++)
                        {
                            PowerX += Power_Now_user_group[i] + ";";
                        }
                        PowerX += "tool:";
                        //第三等级人员不能导入配方(建立在他的第一等级是否拥有该权限)
                        string[] Power_Now_user_group_limit_4 = Power_Now_user_group[4].Split(':');
                        if (Power_Now_user_group_limit_4[1] != "" && Power_Now_user_group_limit[1] != null)
                        {
                            string Power_Now_user_group_limit_again = Power_Now_user_group_limit_4[1];
                            if (Power_Now_user_group_limit_again.Length > 1)
                            {
                                string[] power_choice = Power_Now_user_group_limit_again.Split(',');
                                for (int i = 0; i < power_choice.Length; i++)
                                {
                                    if (power_choice[i] != "0")
                                    {
                                        PowerX += power_choice[i] + ",";
                                    }
                                }
                                PowerX  = PowerX.Substring(0, PowerX.Length - 1);
                                PowerX += ";";
                            }
                            else
                            {
                                PowerX += ";";
                            }
                        }
                        string power = PowerX.Substring(0, PowerX.Length - 1);
                        Power_establish = EncryPtForMy.Class1.EncryptDES(power);
                    }

                    string str_pwd  = EncryPtForMy.Class1.EncryptDES(h_UserPwd.Text);
                    int    rowIndex = int.Parse(this.dataGridView_user.SelectedRows[0].Cells[0].Value.ToString());
                    string sql      = "update Users set h_UserName='******',h_yUserPwd='" + str_pwd
                                      + "',h_Status='" + Convert.ToInt32(h_Status.Checked)
                                      + "',Power='" + Power_establish
                                      + "',h_Permissions='" + str_permisssion
                                      + "' where h_ID='" + rowIndex + "'";
                    int res = ClsCommon.dbSql.ExecuteNonQuery(sql);
                    if (res > 0)
                    {
                        MessageBoxEx.Show("用户帐号修改成功!");
                        dgv_User();
                    }
                }
                toolStripAdd.Enabled  = true;
                toolStripDel.Enabled  = true;
                toolStripEdit.Enabled = true;
                toolStripSave.Enabled = false;
            }
            #endregion

            #endregion

            #region   超级用户进行新增、修改
            //TODO:添加
            if (ClsCommon.userName == "超级管理员")
            {
                if (this.h_UserName.Text.Trim() == string.Empty || this.h_UserPwd.Text.Trim() == string.Empty)
                {
                    MessageBoxEx.Show("用户名或密码不能为空!");
                    this.h_UserName.Focus();
                    return;
                }
                else if (this.h_UserPwd.Text.Length < 6)
                {
                    MessageBoxEx.Show("账户密码不能小于6位数字!");
                    this.h_UserPwd.Focus();
                    return;
                }
                DataTable dtX_super = User_BLL.GetUserPower(this.h_UserName.Text.Trim());
                if (this.toolStripEdit.Enabled == false)        //添加帐户数据判断
                {
                    if (dtX_super.Rows.Count > 0)
                    {
                        MessageBox.Show("数据库中已存在相同的用户名!");
                        return;
                    }
                    string    str_permisssion = UD_Permissions.Value.ToString();
                    string    Power_establish = "";       //放置现创建用户的权限
                    DataTable dt = User_BLL.GetUserPower(ClsCommon.userName);

                    string   power_all            = Handle_ID_XML();
                    string   Power_Now_user       = power_all;         //当前登录用户权限
                    string[] Power_Now_user_group = Power_Now_user.Split(';');
                    //1类用户分配权限
                    if (str_permisssion.Equals("1"))
                    {
                        string power = Power_Now_user;
                        Power_establish = EncryPtForMy.Class1.EncryptDES(power);
                    }
                    //2类用户权限分配
                    if (str_permisssion.Equals("2"))
                    {
                        string PowerX = "basis:;";
                        for (int i = 1; i < Power_Now_user_group.Length; i++)
                        {
                            PowerX += Power_Now_user_group[i] + ";";
                        }
                        string power = PowerX.Substring(0, PowerX.Length - 1);
                        Power_establish = EncryPtForMy.Class1.EncryptDES(power);
                    }

                    //3类用户权限分配
                    if (str_permisssion.Equals("3"))
                    {
                        string PowerX = "basis:;";
                        PowerX += "plan:";
                        //第三等级人员只能有查看权限不能创建(建立在他的第一等级是否拥有该权限)
                        string[] Power_Now_user_group_limit = Power_Now_user_group[1].Split(':');
                        if (Power_Now_user_group_limit[1] != "" && Power_Now_user_group_limit[1] != null)
                        {
                            string Power_Now_user_group_limit_again = Power_Now_user_group_limit[1];
                            if (Power_Now_user_group_limit_again.Length > 1)
                            {
                                string[] power_choice = Power_Now_user_group_limit_again.Split(',');
                                for (int i = 0; i < power_choice.Length; i++)
                                {
                                    if (power_choice[i] != "0" && power_choice[i] != "3")
                                    {
                                        PowerX += power_choice[i] + ",";
                                    }
                                }
                                PowerX  = PowerX.Substring(0, PowerX.Length - 1);
                                PowerX += ";";
                            }
                            else
                            {
                                PowerX += ";";
                            }
                        }
                        PowerX += "formula:;";
                        for (int i = 3; i < 4; i++)
                        {
                            PowerX += Power_Now_user_group[i] + ";";
                        }
                        PowerX += "tool:";
                        //第三等级人员不能导入配方(建立在他的第一等级是否拥有该权限)
                        string[] Power_Now_user_group_limit_4 = Power_Now_user_group[4].Split(':');
                        if (Power_Now_user_group_limit_4[1] != "" && Power_Now_user_group_limit[1] != null)
                        {
                            string Power_Now_user_group_limit_again = Power_Now_user_group_limit_4[1];
                            if (Power_Now_user_group_limit_again.Length > 1)
                            {
                                string[] power_choice = Power_Now_user_group_limit_again.Split(',');
                                for (int i = 0; i < power_choice.Length; i++)
                                {
                                    if (power_choice[i] != "0")
                                    {
                                        PowerX += power_choice[i] + ",";
                                    }
                                }
                                PowerX  = PowerX.Substring(0, PowerX.Length - 1);
                                PowerX += ";";
                            }
                            else
                            {
                                PowerX += ";";
                            }
                        }
                        string power = PowerX.Substring(0, PowerX.Length - 1);
                        Power_establish = EncryPtForMy.Class1.EncryptDES(power);
                    }


                    string str_pwd = EncryPtForMy.Class1.EncryptDES(h_UserPwd.Text);

                    string sql = "insert into Users(h_UserName,h_yUserPwd,Power,h_Permissions,h_Status) values('"
                                 + h_UserName.Text + "','"
                                 + str_pwd + "','"
                                 + Power_establish + "','"
                                 + str_permisssion + "','"
                                 + Convert.ToInt32(h_Status.Checked) + "')";
                    int res = ClsCommon.dbSql.ExecuteNonQuery(sql);
                    if (res > 0)
                    {
                        MessageBoxEx.Show("系统用户添加成功!");
                        dgv_User();
                    }
                }
                else if (this.toolStripAdd.Enabled == false)        //修改帐户数据判断
                {
                    string    str_permisssion = UD_Permissions.Value.ToString();
                    string    Power_establish = "";                    //放置现创建用户的权限
                    DataTable dt                   = User_BLL.GetUserPower(ClsCommon.userName);
                    string    Power_Now_user       = Handle_ID_XML();; //当前登录用户权限
                    string[]  Power_Now_user_group = Power_Now_user.Split(';');

                    //1类用户分配权限
                    if (str_permisssion.Equals("1"))
                    {
                        string power = Power_Now_user;
                        Power_establish = EncryPtForMy.Class1.EncryptDES(power);
                    }

                    //2类用户权限分配
                    if (str_permisssion.Equals("2"))
                    {
                        string PowerX = "basis:;";
                        for (int i = 1; i < Power_Now_user_group.Length; i++)
                        {
                            PowerX += Power_Now_user_group[i] + ";";
                        }
                        string power = PowerX.Substring(0, PowerX.Length - 1);
                        Power_establish = EncryPtForMy.Class1.EncryptDES(power);
                    }
                    //3类用户权限分配
                    if (str_permisssion.Equals("3"))
                    {
                        string PowerX = "basis:;";
                        PowerX += "plan:";
                        //第三等级人员只能有查看权限不能创建(建立在他的第一等级是否拥有该权限)
                        string[] Power_Now_user_group_limit = Power_Now_user_group[1].Split(':');
                        if (Power_Now_user_group_limit[1] != "" && Power_Now_user_group_limit[1] != null)
                        {
                            string Power_Now_user_group_limit_again = Power_Now_user_group_limit[1];
                            if (Power_Now_user_group_limit_again.Length > 1)
                            {
                                string[] power_choice = Power_Now_user_group_limit_again.Split(',');
                                for (int i = 0; i < power_choice.Length; i++)
                                {
                                    if (power_choice[i] != "0" && power_choice[i] != "3")
                                    {
                                        PowerX += power_choice[i] + ",";
                                    }
                                }
                                PowerX  = PowerX.Substring(0, PowerX.Length - 1);
                                PowerX += ";";
                            }
                            else
                            {
                                PowerX += ";";
                            }
                        }
                        PowerX += "formula:;";
                        for (int i = 3; i < 4; i++)
                        {
                            PowerX += Power_Now_user_group[i] + ";";
                        }
                        PowerX += "tool:";
                        //第三等级人员不能导入配方(建立在他的第一等级是否拥有该权限)
                        string[] Power_Now_user_group_limit_4 = Power_Now_user_group[4].Split(':');
                        if (Power_Now_user_group_limit_4[1] != "" && Power_Now_user_group_limit[1] != null)
                        {
                            string Power_Now_user_group_limit_again = Power_Now_user_group_limit_4[1];
                            if (Power_Now_user_group_limit_again.Length > 1)
                            {
                                string[] power_choice = Power_Now_user_group_limit_again.Split(',');
                                for (int i = 0; i < power_choice.Length; i++)
                                {
                                    if (power_choice[i] != "0")
                                    {
                                        PowerX += power_choice[i] + ",";
                                    }
                                }
                                PowerX  = PowerX.Substring(0, PowerX.Length - 1);
                                PowerX += ";";
                            }
                            else
                            {
                                PowerX += ";";
                            }
                        }
                        string power = PowerX.Substring(0, PowerX.Length - 1);
                        Power_establish = EncryPtForMy.Class1.EncryptDES(power);
                    }

                    string str_pwd  = EncryPtForMy.Class1.EncryptDES(h_UserPwd.Text);
                    int    rowIndex = int.Parse(this.dataGridView_user.SelectedRows[0].Cells[0].Value.ToString());
                    string sql      = "update Users set h_UserName='******',h_yUserPwd='" + str_pwd
                                      + "',h_Status='" + Convert.ToInt32(h_Status.Checked)
                                      + "',Power='" + Power_establish
                                      + "',h_Permissions='" + str_permisssion
                                      + "' where h_ID='" + rowIndex + "'";
                    int res = ClsCommon.dbSql.ExecuteNonQuery(sql);
                    if (res > 0)
                    {
                        MessageBoxEx.Show("用户帐号修改成功!");
                        dgv_User();
                    }
                }
                toolStripAdd.Enabled  = true;
                toolStripDel.Enabled  = true;
                toolStripEdit.Enabled = true;
                toolStripSave.Enabled = false;
            }
            #endregion
        }