Esempio n. 1
0
        private void btnRegist_Click(object sender, EventArgs e)
        {
            UserInfo ui = new UserInfo()
            {
                uName = txtName.Text,
                uPwd  = txtPwd.Text,
                uType = rbt1.Checked ? 1:0 //老师值为1,学生值为0
            };

            if (txtPwd.Text == txtRePwd.Text)
            {
                if (uiBll.Add(ui))
                {
                    MessageBox.Show("注册成功!");
                }
                else
                {
                    MessageBox.Show("用户名不可用,请重新输入!");
                    txtName.Text  = "";
                    txtPwd.Text   = "";
                    txtRePwd.Text = "";
                }
            }
            else
            {
                MessageBox.Show("两次输入密码不一样,请确认密码!");
                txtPwd.Text   = "";
                txtRePwd.Text = "";
            }
        }
Esempio n. 2
0
        public string QuickReg(UserInfoModel info)
        {
            var error = new ErrorMessage();

            if (string.IsNullOrEmpty(info.username) || string.IsNullOrEmpty(info.userpass))
            {
                error.State = 1;
                error.Msg   = "name can't be empty";
            }
            else if (UserInfoBLL.IsExistUser <UserInfoModel>(info.username))
            {
                error.State = 1;
                error.Msg   = "name already exist";
            }
            else
            {
                info.userpass = Udp.Security.DESEncrypt.DesEncrypt(info.userpass);
                var succ = UserInfoBLL.Add(info, 1);
                if (!succ)
                {
                    error.State = 3;
                    error.Msg   = "Enter name failed,please try again.";
                }
                else
                {
                    error.State = 0;
                    DataTable dt = UserInfoBLL.GetUser(info.username);
                    error.Msg  = dt.Rows[0]["id"].ToString();
                    error.Msg2 = dt.Rows[0]["nickname"].ToString();
                }
            }
            return(Newtonsoft.Json.JsonConvert.SerializeObject(error));
        }
Esempio n. 3
0
        /// <summary>
        /// 添加新用户
        /// </summary>
        private string AddUser(HttpContext context)
        {
            //================必填=====================
            string loginName = context.Request.Params["loginName"];
            string password  = context.Request.Params["password"];
            string nickName  = context.Request.Params["nickName"];

            string headimg        = context.Request.Params["headimg"];
            string mobile         = context.Request.Params["mobile"];
            string companyName    = context.Request.Params["property"];
            string departmentName = context.Request.Params["departmentName"];
            string remark         = context.Request.Params["remark"];
            //角色信息
            string radioRole = context.Request.Params["radio_role"];
            //授权小区
            string authcommunity = context.Request.Params["authcommunity"];

            //新用户
            var newuser = new UserInfoModel()
            {
                loginName      = loginName,
                password       = ConvertHelper.StringToMD5(password),
                nickName       = nickName,
                mobile         = mobile,
                headimg        = headimg,
                companyName    = companyName,
                departmentName = departmentName,
                remark         = remark
            };

            try
            {
                var jr = new JsonResultModel <int>()
                {
                    IsSucceed   = false,
                    Data        = 0,
                    Msg         = "添加用户失败",
                    RedirectUrl = ""
                };
                HttpCookie cook = HttpContext.Current.Request.Cookies["EccmUserinfo"];
                if (cook != null)
                {
                    //解密Cookie
                    HttpCookie decodeCookie = HttpSecureCookie.Decode(cook);
                    string     uid          = decodeCookie.Values["userid"];
                    if (user_bll.Add(newuser, radioRole, authcommunity, int.Parse(uid)))
                    {
                        jr.IsSucceed = true;
                        jr.Msg       = "添加用户成功";
                    }
                }
                return(JsonConvert.SerializeObject(jr));
            }
            catch (Exception err)
            {
                LogHelper.Debug("添加新用户(AddUser)---" + err.Message);
                throw err;
            }
        }
 public ActionResult Add(UserInfo userInfo)
 {
     userInfo.SubTime   = DateTime.Now;
     userInfo.ModfiedOn = DateTime.Now;
     userInfo.DelFlag   = (short)DelFlagEnum.Normal;
     UserInfoBLL.Add(userInfo);
     return(Content("ok"));
 }
Esempio n. 5
0
        public string Reg(UserInfoModel info, string code)
        {
            var error = new ErrorMessage();

            if (string.IsNullOrEmpty(info.username) || string.IsNullOrEmpty(info.userpass))
            {
                error.State = 1;
                error.Msg   = "用户名或者昵称不可以为空";
            }
            else if (UserInfoBLL.IsExistUser <UserInfoModel>(info.username))
            {
                error.State = 1;
                error.Msg   = "用户名已经存在";
            }
            else if (UserInfoBLL.IsExistNickName <UserInfoModel>(info.nickname))
            {
                error.State = 2;
                error.Msg   = "昵称已经存在";
            }
            else
            {
                if (string.IsNullOrEmpty(code) || !dicCode.ContainsKey(code))
                {
                    error.State = 2;
                    error.Msg   = "验证码错误";
                }
                else
                {
                    dicCode.Remove(code);
                    info.userpass = Udp.Security.DESEncrypt.DesEncrypt(info.userpass);
                    var succ = UserInfoBLL.Add(info);
                    if (!succ)
                    {
                        error.State = 3;
                        error.Msg   = "注册失败,请检查填写的信息是否正确";
                    }
                    else
                    {
                        error.State = 0;
                    }
                }
            }
            return(Newtonsoft.Json.JsonConvert.SerializeObject(error));
        }
Esempio n. 6
0
        public ActionResult Add(string UserName, string TrueName, string Role, string Password, string Pic)
        {
            T_UserInfo model = new T_UserInfo();

            model.id         = StringHelper.GetGuid();
            model.PassWord   = BaseSecurity.Md5Hash("111111");
            model.UserName   = UserName;
            model.TrueName   = TrueName;
            model.pic        = Pic;
            model.CreateDate = DateTime.Now;
            model.Role       = Role;
            try
            {
                userbll.Add(model);
                return(Json(new { success = true, msg = "操作成功" }));
            }
            catch
            {
                return(Json(new { success = false, msg = "操作失败" }));
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 保存(新增、修改)
        /// </summary>
        /// <returns></returns>
        public ActionResult Save()
        {
            string AccountID = Request.Form["AccountID"]; //账套
            string UserCode  = Request.Form["UserCode"];  //用户编号
            string UserName  = Request.Form["UserName"];  //用户名
            string Pwd       = Request.Form["Pwd"];       //密码

            if (!string.IsNullOrWhiteSpace(Pwd))
            {
                DES des = new DES();
                Pwd = des.Encrypt(Pwd);
            }
            string   Employee   = Request.Form["Employee"];                      //员工编号
            string   Position   = Request.Form["Position"];                      //岗位
            string   Department = Request.Form["Department"];                    //部门
            string   Phone      = Request.Form["Phone"];                         //电话
            DateTime BeginDate  = Convert.ToDateTime(Request.Form["BeginDate"]); //生效日期
            DateTime EndDate    = Convert.ToDateTime(Request.Form["EndDate"]);   //失效日期
            string   IsAdmin    = Request.Form["IsAdmin"];                       //管理员
            string   IsEnable   = Request.Form["IsEnable"];                      //生效

            string actionType = Request.Form["actiontype"];                      //新增或者修改状态

            UserInfo userInfo = new UserInfo();

            userInfo.AccountID  = AccountID;
            userInfo.UserCode   = UserCode;
            userInfo.UserName   = UserName;
            userInfo.Pwd        = Pwd;
            userInfo.Employee   = Employee;
            userInfo.Phone      = Phone;
            userInfo.Department = Department;
            userInfo.Position   = Position;
            userInfo.BeginDate  = BeginDate;
            userInfo.EndDate    = EndDate;
            userInfo.IsAdmin    = Convert.ToInt32(IsAdmin);
            userInfo.IsEnable   = Convert.ToInt32(IsEnable);

            bool   sucesss = false;
            string message = "";

            if (actionType == "add")
            {
                if (UserInfoBLL.CheckObjIsExist(userInfo))
                {
                    sucesss = false;
                    message = "该用户已经存在,不能重复录入!";
                }
                else
                {
                    if (UserInfoBLL.Add(userInfo))
                    {
                        sucesss = true;
                    }
                }
            }
            else
            {
                int KeyID = Convert.ToInt32(Request.Form["KeyID"]);//主键
                userInfo.KeyID = KeyID;
                if (UserInfoBLL.Update(userInfo))
                {
                    sucesss = true;
                }
            }

            return(Content(new JsonMessage {
                Success = sucesss, Message = message
            }.ToString()));
        }
    private void Save()
    {
        AjaxResult result = new AjaxResult();

        result.IsSuccess = false;
        result.Msg       = "保存失败!";
        int?id = null;

        if (!string.IsNullOrEmpty(Request.Form["id"]))
        {
            id = Convert.ToInt32(Request.Form["id"]);
        }
        UserInfo model = null;

        if (!id.HasValue)//新增
        {
            var entiy = userBll.Get(Request.Form["UserName"]);
            if (entiy != null)
            {
                result.Msg = "用户名存在!";
            }
            else
            {
                model = new UserInfo()
                {
                    UserName          = Request.Form["UserName"],
                    Password          = CryptTools.HashPassword(Request.Form["Password"]),
                    Mobile            = Request.Form["Mobile"],
                    Status            = byte.Parse(Request.Form["Status"] ?? "0"),
                    IsGeneralAviation = byte.Parse(Request.Form["IsGeneralAviation"]),
                    CompanyCode3      = byte.Parse(Request.Form["IsGeneralAviation"]) == 1 ? Request.Form["CompanyCode3"] : "",
                    CreateTime        = DateTime.Now
                };
                if (userBll.Add(model))
                {
                    result.IsSuccess = true;
                    result.Msg       = "增加成功!";
                }
            }
        }
        else//编辑
        {
            model = userBll.Get(id.Value);
            if (model != null)
            {
                model.UserName = Request.Form["UserName"];
                //  model.Password = CryptTools.HashPassword(Request.Form["Password"]);
                model.Mobile            = Request.Form["Mobile"];
                model.Status            = byte.Parse(Request.Form["Status"] ?? "0");
                model.IsGeneralAviation = byte.Parse(Request.Form["IsGeneralAviation"] ?? "0");
                model.CompanyCode3      = model.IsGeneralAviation == 1 ? Request.Form["CompanyCode3"] : "";

                if (userBll.Update(model))
                {
                    result.IsSuccess = true;
                    result.Msg       = "更新成功!";
                }
            }
        }

        Response.Clear();
        Response.Write(result.ToJsonString());
        Response.ContentType = "application/json";
        Response.End();
    }