Exemplo n.º 1
0
        }                                                          //系统管理_用户类别管理_新增页面
        public void btnSave_Click(object sender, System.EventArgs e)
        {
            UserType newUserType = new UserType();
            string   userType    = txtUserType.Text.Trim();

            byte[] sarr = System.Text.Encoding.GetEncoding("gb2312").GetBytes(userType);
            if (sarr.Length > 2)
            {
                YSWL.Common.MessageBox.ShowFailTip(this, "输入的用户类型不能超过两个字符");
                return;
            }
            string description = txtDescription.Text.Trim();

            if (string.IsNullOrWhiteSpace(userType) || string.IsNullOrWhiteSpace(description))
            {
                return;
            }

            string  strErr  = "";
            DataSet dataSet = newUserType.GetList("UserType='" + YSWL.Common.InjectionFilter.SqlFilter(userType) + "'");

            if (dataSet != null && dataSet.Tables[0].Rows.Count > 0)
            {
                strErr += Resources.Site.TooltipUserTypeExist;
            }
            if (strErr != "")
            {
                YSWL.Common.MessageBox.ShowSuccessTip(this, strErr);
                return;
            }
            newUserType.Add(userType, description);
            LogHelp.AddUserLog(CurrentUser.UserName, CurrentUser.UserType, string.Format("新增用户类别用户类别:【{0}】", userType), this);
            YSWL.Common.MessageBox.ResponseScript(this, "parent.location.href='UserTypeAdmin.aspx'");
            //Response.Redirect("UserTypeAdmin.aspx");
        }
Exemplo n.º 2
0
        public async Task Seed(IApplicationBuilder app)
        {
            var _userManager = app.ApplicationServices.GetRequiredService <UserManager <ApplicationUser> >();

            var Admin = await this.UserType.SingleOrDefaultAsync(t => t.IsAdmin == true);

            if (Admin == null)
            {
                Admin = new UserType
                {
                    IsAdmin      = true,
                    Arg          = 1,
                    UserTypeName = "系统默认"
                };
                UserType.Add(Admin);
                await SaveChangesAsync();
            }

            var Part = await this.Part.SingleOrDefaultAsync(t => t.PartName == "其它");

            if (Part == null)
            {
                Part = new Part
                {
                    PartName = "其它"
                };
                this.Part.Add(Part);
                await this.SaveChangesAsync();
            }

            var wang = new ApplicationUser
            {
                Email      = "*****@*****.**",
                UserName   = "******",
                StaffNo    = "08608",
                Name       = "王蓓蕾",
                UserTypeId = Admin.UserTypeId,
                PartId     = Part.PartId
            };

            var currentWang = await this.Users.SingleOrDefaultAsync(t => t.Name == "王蓓蕾");

            if (currentWang == null)
            {
                await _userManager.CreateAsync(wang, "123456");
            }
            else
            {
                wang = currentWang;
            }

            await this.SaveChangesAsync();
        }