示例#1
0
        private void btn_registered_Click(object sender, EventArgs e)
        {
            if (!checkUserName)
            {
                MessageBox.Show("用户名已存在!");
                return;
            }
            if (!checkPassword)
            {
                MessageBox.Show("密码不一致");
                return;
            }
            List <Users> list = new List <Users>();

            list.Add(new Users()
            {
                UserName     = txt_UserName.Text.Trim(),
                UserPassword = ub.GetMd5(txt_Password.Text),
                systemAdimin = false,
                Limite       = false,
                Department   = comb_Department.Text.Trim() == "无"?"":comb_Department.Text.Trim(),
                AddUser      = false
            });
            try
            {
                if (ub.insertUsersBll(list, "insertUsers"))
                {
                    foreach (PFunctionMenu item in PFmenuBll.selectPFunctionMenuFID0Bll("selectPFunctionMenuFID0"))//次级功能权限名
                    {
                        Guid guid = Guid.NewGuid();
                        List <PUsers_Function> pufList = new List <PUsers_Function>();
                        pufList.Add(new PUsers_Function
                        {
                            UserName             = list[0].UserName,
                            FunctionName         = item.FunctionName,
                            FunctionJurisdiction = false,
                            FunctionGUID         = guid.ToString()
                        });
                        if (!pufb.insertPUsers_FunctionBll(pufList, "insertPUsers_Function"))
                        {
                        }
                        foreach (PFunctionMenu item1 in PFmenuBll.selectPFunctionMenuFID0Bll("selectPFunctionMenuFID01"))//最下级功能权限名
                        {
                            if (item1.FID == item.ID)
                            {
                                List <PUsers_Function_Detailed> pufdList = new List <PUsers_Function_Detailed>();
                                pufdList.Add(new PUsers_Function_Detailed()
                                {
                                    UserName             = list[0].UserName,
                                    FunctionName         = item1.FunctionName,
                                    FunctionJurisdiction = false,
                                    FunctionGUID         = guid.ToString()
                                });
                                if (pufdb.insertPUsers_Function_DetailedBll(pufdList, "insertPUsers_Function_Detailed"))
                                {
                                }
                            }
                        }
                    }

                    MessageBox.Show("注册成功!");
                    this.ClearTxt();
                }
                else
                {
                    MessageBox.Show("注册失败!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }