示例#1
0
 /// <summary>
 /// 添加基本信息
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static int Insert(MemberInfo model)
 {
     string strSQL = "INSERT INTO Members(UserName,[Password],Email,RealName,Mobile,Phone,[Type],CreateDateTime,LastLoginDateTime,ModifyDateTime,Address,Province,City,Industry,Position,Fax,NickName,Company,ZipCode,MagType,PurchaseProducts) VALUES(@UserName,@Password,@Email,@RealName,@Mobile,@Phone,@Type,GETDATE(),GETDATE(),GETDATE(),@Address,@Province,@City,@Industry,@Position,@Fax,@NickName,@Company,@ZipCode,@MagType,@PurchaseProducts);SELECT @@IDENTITY;";
     SqlParameter[] parms = { 
                             new SqlParameter("Id",SqlDbType.Int),
                             new SqlParameter("UserName",SqlDbType.VarChar),
                             new SqlParameter("Password",SqlDbType.VarChar),
                             new SqlParameter("Email",SqlDbType.VarChar),
                             new SqlParameter("RealName",SqlDbType.NVarChar),
                             new SqlParameter("Mobile",SqlDbType.VarChar),
                             new SqlParameter("Phone",SqlDbType.VarChar),
                             new SqlParameter("Address",SqlDbType.NVarChar),
                             new SqlParameter("Province",SqlDbType.NVarChar),
                             new SqlParameter("City",SqlDbType.NVarChar),
                             new SqlParameter("Industry",SqlDbType.NVarChar),
                             new SqlParameter("Fax",SqlDbType.NVarChar),
                             new SqlParameter("Position",SqlDbType.NVarChar),
                             new SqlParameter("NickName",SqlDbType.NVarChar),
                             new SqlParameter("Type",SqlDbType.Int),
                             new SqlParameter("Company",SqlDbType.NVarChar),
                             new SqlParameter("ZipCode",SqlDbType.VarChar),
                             new SqlParameter("MagType",SqlDbType.VarChar),
                             new SqlParameter("PurchaseProducts",SqlDbType.VarChar),
                            };
     parms[0].Value = model.Id;
     parms[1].Value = model.UserName;
     parms[2].Value = model.Password;
     parms[3].Value = model.Email;
     parms[4].Value = string.IsNullOrEmpty(model.RealName) ? string.Empty : model.RealName;
     parms[5].Value = string.IsNullOrEmpty(model.Mobile) ? string.Empty : model.Mobile;
     parms[6].Value = string.IsNullOrEmpty(model.Phone) ? string.Empty : model.Phone;
     parms[7].Value = string.IsNullOrEmpty(model.Address) ? string.Empty : model.Address;
     parms[8].Value = string.IsNullOrEmpty(model.Province) ? string.Empty : model.Province;
     parms[9].Value = string.IsNullOrEmpty(model.City) ? string.Empty : model.City;
     parms[10].Value = string.IsNullOrEmpty(model.Industry) ? string.Empty : model.Industry;
     parms[11].Value = string.IsNullOrEmpty(model.Fax) ? string.Empty : model.Fax;
     parms[12].Value = string.IsNullOrEmpty(model.Position) ? string.Empty : model.Position;
     parms[13].Value = string.IsNullOrEmpty(model.NickName) ? model.UserName : model.NickName;
     parms[14].Value = (int)model.Type;
     parms[15].Value = model.Company ?? string.Empty;
     parms[16].Value = model.ZipCode ?? string.Empty;
     parms[17].Value = model.MagType ?? string.Empty;
     parms[18].Value = model.PurchaseProducts ?? string.Empty;
     return Convert.ToInt32(SQLPlus.ExecuteScalar(CommandType.Text, strSQL, parms));
 }
示例#2
0
 /// <summary>
 /// 更新基本信息
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static int Update(MemberInfo model)
 {
     string strSQL = "UPDATE Members SET Email = @Email,RealName = @RealName,Mobile = @Mobile,Phone = @Phone,[Address] = @Address,Province = @Province,City = @City,Industry = @Industry,Position = @Position,Fax = @Fax,ModifyDateTime = GETDATE(),NickName = @NickName ,Company = @Company,ZipCode = @ZipCode,MagType = @MagType,PurchaseProducts = @PurchaseProducts WHERE Id = @Id";
     SqlParameter[] parms = { 
                             new SqlParameter("Id",SqlDbType.Int),
                             new SqlParameter("UserName",SqlDbType.VarChar),
                             new SqlParameter("Password",SqlDbType.VarChar),
                             new SqlParameter("Email",SqlDbType.VarChar),
                             new SqlParameter("RealName",SqlDbType.NVarChar),
                             new SqlParameter("Mobile",SqlDbType.VarChar),
                             new SqlParameter("Phone",SqlDbType.VarChar),
                             new SqlParameter("Address",SqlDbType.NVarChar),
                             new SqlParameter("Province",SqlDbType.NVarChar),
                             new SqlParameter("City",SqlDbType.NVarChar),
                             new SqlParameter("Industry",SqlDbType.NVarChar),
                             new SqlParameter("Fax",SqlDbType.NVarChar),
                             new SqlParameter("Position",SqlDbType.NVarChar),
                             new SqlParameter("NickName",SqlDbType.NVarChar),
                             new SqlParameter("Company",SqlDbType.NVarChar),
                             new SqlParameter("ZipCode",SqlDbType.VarChar),
                             new SqlParameter("MagType",SqlDbType.VarChar),
                             new SqlParameter("PurchaseProducts",SqlDbType.NVarChar),
                            };
     parms[0].Value = model.Id;
     parms[1].Value = model.UserName;
     parms[2].Value = model.Password;
     parms[3].Value = model.Email;
     parms[4].Value = string.IsNullOrEmpty(model.RealName) ? string.Empty : model.RealName;
     parms[5].Value = string.IsNullOrEmpty(model.Mobile) ? string.Empty : model.Mobile;
     parms[6].Value = string.IsNullOrEmpty(model.Phone) ? string.Empty : model.Phone;
     parms[7].Value = string.IsNullOrEmpty(model.Address) ? string.Empty : model.Address;
     parms[8].Value = string.IsNullOrEmpty(model.Province) ? string.Empty : model.Province;
     parms[9].Value = string.IsNullOrEmpty(model.City) ? string.Empty : model.City;
     parms[10].Value = string.IsNullOrEmpty(model.Industry) ? string.Empty : model.Industry;
     parms[11].Value = string.IsNullOrEmpty(model.Fax) ? string.Empty : model.Fax;
     parms[12].Value = string.IsNullOrEmpty(model.Position) ? string.Empty : model.Position;
     parms[13].Value = model.NickName ?? string.Empty;
     parms[14].Value = model.Company ?? string.Empty;
     parms[15].Value = model.ZipCode ?? string.Empty;
     parms[16].Value = model.MagType ?? string.Empty;
     parms[17].Value = model.PurchaseProducts ?? string.Empty;
     return SQLPlus.ExecuteNonQuery(CommandType.Text, strSQL, parms);
 }
示例#3
0
 /// <summary>
 /// 更新用户基本信息
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static int Update(MemberInfo model) {
     return MemberManage.Update(model);
 }
示例#4
0
 /// <summary>
 /// 添加用户基本信息
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static int Insert(MemberInfo model) {
     //取消密码MD5
     //model.Password = Controleng.Common.Utils.MD5(model.Password);
     return MemberManage.Insert(model);
 }
示例#5
0
        public ActionResult Edit(MemberInfo oldModel, FormCollection fc)
        {
            //检查Email是否重复
            bool errors = false;
            if (MemberService.EmailExists(oldModel.Email, oldModel.Id))
            {
                errors = true;
                ModelState.AddModelError("EMAILEXISTS", "Email已存在,请选择其他Email");
            }
            if (!errors && ModelState.IsValid)
            {
                oldModel.Province = fc["Province"];
                oldModel.City = fc["City"];
                oldModel.Industry = fc["Industry"] ?? string.Empty;
                oldModel.MagType = fc["MagType"];


                MemberService.Update(oldModel);

                ViewBag.Msg = "更新成功!";
            }
            return View(oldModel);
        }
示例#6
0
 private void _Login(MemberInfo userInfo) {
     ILoginAdapter login = new LoginAdapter();
     login.WriteLoginCookie(new LoginUserInfo() { 
         Email  = userInfo.Email,
         UserId = userInfo.Id,
         RoleId = (int)userInfo.Type,
         UserName = userInfo.UserName,
         Password = userInfo.Password
     });
 }
示例#7
0
        public ActionResult Register(MemberInfo oldModel, FormCollection fc)
        {
            #region == 验证合法性 ==
            bool errors = false;
            if (string.IsNullOrEmpty(oldModel.UserName))
            {
                ModelState.AddModelError("USERNAME", "用户名不能为空");
                errors = true;
            }
            if (string.IsNullOrEmpty(oldModel.Email))
            {
                ModelState.AddModelError("EMAIL", "Email不能为空");
                errors = true;
            }
            if (string.IsNullOrEmpty(oldModel.Password) || string.IsNullOrEmpty(fc["confirmpassword"]))
            {
                ModelState.AddModelError("PASSWORD", "密码不能为空");
                errors = true;
            }
            if (oldModel.Password != fc["confirmpassword"])
            {
                ModelState.AddModelError("PASSWORD2", "两次密码不一致,请重新输入");
                errors = true;
            }
            if (string.IsNullOrEmpty(oldModel.RealName))
            {
                ModelState.AddModelError("REALNAME", "真实姓名不能为空");
                errors = true;
            }
            //判断用户名是否存在
            if (!string.IsNullOrEmpty(oldModel.UserName))
            {
                //检查用户是否在黑名单中
                if (CheckBlockUser(oldModel.UserName) || MemberService.UserNameExists(oldModel.UserName))
                {
                    ModelState.AddModelError("USERNAMEEXISTS", "用户名已经存在,请选择其他用户名");
                    errors = true;
                }
            }
            //判断Email是否存在
            if (!string.IsNullOrEmpty(oldModel.Email))
            {
                if (MemberService.EmailExists(oldModel.Email))
                {
                    ModelState.AddModelError("EMAILEXISTS", "Email已经存在,请选择其他Email");
                    errors = true;
                }
            }
            #endregion

            if (!errors && ModelState.IsValid)
            {
                //行业
                oldModel.Industry = fc["Industry"];
                oldModel.Province = fc["Province"];
                oldModel.City = fc["City"];
                oldModel.Position = fc["Position"];
                oldModel.MagType = fc["MagType"];
                oldModel.Type = MemberType.Common;      //一般用户
                oldModel.Id = MemberService.Insert(oldModel);

                //登录
                _Login(oldModel);

                Response.Redirect("/registersuccess");
            }

            return View();
        }