Example #1
0
        /// <summary>
        /// 保存按钮监听
        /// </summary>
        public void Save_Power(object sender, EventArgs e)
        {
            bool             set_admin = false; //标识当前保存用户是否为管理员
            string           ListText  = "";
            Button           button    = (Button)sender;
            CheckBoxComboBox cbcb      = panel2.Controls["panel_" + button.Name].Controls["cbcb0"] as CheckBoxComboBox;
            CheckBoxComboBox cbcb1     = panel2.Controls["panel_" + button.Name].Controls["cbcb1"] as CheckBoxComboBox;
            CheckBoxComboBox cbcb2     = panel2.Controls["panel_" + button.Name].Controls["cbcb2"] as CheckBoxComboBox;
            CheckBoxComboBox cbcb3     = panel2.Controls["panel_" + button.Name].Controls["cbcb3"] as CheckBoxComboBox;
            CheckBoxComboBox cbcb4     = panel2.Controls["panel_" + button.Name].Controls["cbcb4"] as CheckBoxComboBox;

            #region   保存
            string     str0       = cbcb.Text.Trim();
            string[]   strX0      = str0.Split('&');
            List <int> a0         = Split_string_Save(strX0, "basis");
            string     str_power0 = "basis:";
            for (int i = 0; i < a0.Count; i++)
            {
                if (a0.Count - 1 == i)
                {
                    str_power0 += a0[i];
                }
                else
                {
                    str_power0 += a0[i] + ",";
                    //if (a0[i] == 0)//设置为管理员  并在数据库赋值标识
                    //{
                    //    User_BLL.SetUserAdmin(button.Name);
                    //    set_admin = true;
                    //}
                }
            }
            //if (set_admin == false)
            //     User_BLL.SetUserNormal(button.Name);

            str_power0 = str_power0 + ";";

            string     str1       = cbcb1.Text.Trim();
            string[]   strX1      = str1.Split('&');
            List <int> a1         = Split_string_Save(strX1, "plan");
            string     str_power1 = "plan:";
            for (int i = 0; i < a1.Count; i++)
            {
                if (a1.Count - 1 == i)
                {
                    str_power1 += a1[i];
                }
                else
                {
                    str_power1 += a1[i] + ",";
                }
            }
            str_power1 = str_power1 + ";";

            string     str2       = cbcb2.Text.Trim();
            string[]   strX2      = str2.Split('&');
            List <int> a2         = Split_string_Save(strX2, "formula");
            string     str_power2 = "formula:";
            for (int i = 0; i < a2.Count; i++)
            {
                if (a2.Count - 1 == i)
                {
                    str_power2 += a2[i];
                }
                else
                {
                    str_power2 += a2[i] + ",";
                }
            }
            str_power2 = str_power2 + ";";

            string     str3       = cbcb3.Text.Trim();
            string[]   strX3      = str3.Split('&');
            List <int> a3         = Split_string_Save(strX3, "table");
            string     str_power3 = "table:";
            for (int i = 0; i < a3.Count; i++)
            {
                if (a3.Count - 1 == i)
                {
                    str_power3 += a3[i];
                }
                else
                {
                    str_power3 += a3[i] + ",";
                }
            }
            str_power3 = str_power3 + ";";

            string     str4       = cbcb4.Text.Trim();
            string[]   strX4      = str4.Split('&');
            List <int> a4         = Split_string_Save(strX4, "tool");
            string     str_power4 = "tool:";
            for (int i = 0; i < a4.Count; i++)
            {
                if (a4.Count - 1 == i)
                {
                    str_power4 += a4[i];
                }
                else
                {
                    str_power4 += a4[i] + ",";
                }
            }
            str_power4 = str_power4 + ";";
            string str_power = str_power0 + str_power1 + str_power2 + str_power3 + str_power4;
            string Power     = EncryPtForMy.Class1.EncryptDES(str_power.Substring(0, str_power.Length - 1));
            User_BLL.Save_Power(button.Name, Power);

            #endregion

            cbcb.Enabled  = false;
            cbcb1.Enabled = false;
            cbcb2.Enabled = false;
            cbcb3.Enabled = false;
            cbcb4.Enabled = false;
        }