コード例 #1
0
        /// <summary>
        /// 用户中心 修改基础信息
        /// </summary>
        /// <param name="info"></param>
        /// <param name="errmsg"></param>
        /// <returns></returns>
        internal static bool PutUserInfo(base_users info, out string errmsg)
        {
            MySqlTransactionHelper tran = new MySqlTransactionHelper();

            if (!tran.TransactionBegin(out errmsg))
            {
                return(false);
            }

            List <DataParameter> pars = new List <DataParameter>();

            pars.Add(new DataParameter("@userid", info.userid));
            pars.Add(new DataParameter("@nickname", info.nickname));
            pars.Add(new DataParameter("@sex", info.sex));
            pars.Add(new DataParameter("@birthday", info.birthday));
            pars.Add(new DataParameter("@phone", info.phone));
            pars.Add(new DataParameter("@email", info.email));
            pars.Add(new DataParameter("@realname", info.realname));            //pars.Add(new DataParameter("@realname", info.degree));

            pars.Add(new DataParameter("@photo", info.photo));

            string sqlstr = "update base_users set nickname=@nickname,sex=@sex,birthday=@birthday,phone=@phone,email=@email,realname=@realname,photo=@photo where userid=@userid";

            tran.TransactionExecuteCommand(sqlstr, out errmsg, pars);
            if (!string.IsNullOrEmpty(errmsg))
            {
                string err;
                tran.TransactionRollback(out err);
                return(false);
            }
            return(tran.TransactionCommit(out errmsg));
        }
コード例 #2
0
        internal static base_users GetUserInfo(int userid, out string errmsg)
        {
            base_users info = DAL.UserAccountDAL.GetUserInfo(userid, out errmsg);

            //info.usertypename = BaseBLL.GetDicOptions("usertype",info.usertype.ToString());
            return(info);
        }
コード例 #3
0
        internal static bool UserFindPasswd(base_users userinfo, out string errmsg)
        {
            List <DataParameter> pars = new List <DataParameter>();
            string sqlstr             = "select * from base_users where status>0 ";

            if (!string.IsNullOrEmpty(userinfo.phone))
            {
                sqlstr += " and phone=@phone";
                pars.Add(new DataParameter("phone", userinfo.phone));
            }
            else if (!string.IsNullOrEmpty(userinfo.email))
            {
                sqlstr += " and email=@email";
                pars.Add(new DataParameter("email", userinfo.email));
            }
            base_users user = MySqlHelper.GetDataInfo <base_users>(sqlstr, out errmsg, pars.ToArray());

            if (!string.IsNullOrEmpty(errmsg))
            {
                return(false);
            }
            if (user == null)
            {
                errmsg = "手机号码或邮件账号不存在";
                return(false);
            }
            sqlstr = "update base_users set passwd=@passwd where userid=@userid ";
            pars.Clear();
            pars.Add(new DataParameter("passwd", userinfo.passwd));
            pars.Add(new DataParameter("userid", user.userid));
            return(MySqlHelper.ExecuteCommand(sqlstr, out errmsg, pars.ToArray()) > 0);
        }
コード例 #4
0
        public object PutUserInfo([FromBody] base_users info)
        {
            string errmsg = null;

            if (userLoginManager.LoginUser == null || userLoginManager.LoginUser.UserID < 1)
            {
                return new { Rcode = 0, Rmsg = "未登录" }
            }
            ;
            info.userid = userLoginManager.LoginUser.UserID;
            bool success = BLL.UserLoginManager.PutUserInfo(info, out errmsg);

            if (!success || !string.IsNullOrEmpty(errmsg))
            {
                return new { Rcode = -1, Rmsg = "修改失败" }
            }
            ;
            UserInfoViewModel user = userLoginManager.LoginUser;

            if (!string.IsNullOrEmpty(info.nickname))
            {
                user.NickName = info.nickname;
            }
            if (!string.IsNullOrEmpty(info.nickname))
            {
                user.Photo = info.photo;
            }
            new  BLL.UserLoginManager().WriteCookie(user, ref errmsg);

            return(new { Rcode = 1, Rmsg = "修改成功" });
        }
コード例 #5
0
        public object GetUserInfo()
        {
            string errmsg = null;

            if (userLoginManager.LoginUser == null || userLoginManager.LoginUser.UserID < 1)
            {
                return new { Rcode = -2, Rmsg = "未登录" }
            }
            ;
            int userid = userLoginManager.LoginUser.UserID;

            base_users info = BLL.UserLoginManager.GetUserInfo(userid, out errmsg);

            if (!string.IsNullOrEmpty(errmsg))
            {
                return new { Rcode = -1, Rmsg = "获取数据错误" }
            }
            ;
            else if (info == null || info.userid < 1)
            {
                return new { Rcode = 0, Rmsg = "用户不存在" }
            }
            ;
            return(new { Rcode = 1, Rdata = info });
        }
コード例 #6
0
ファイル: usersDAL.cs プロジェクト: xiaosachuchen/-version2
        /// <summary>
        /// 用户管理 更新数据
        /// </summary>
        /// <param name="base_users">要更新的用户管理对象</param>
        /// <param name="errmsg">错误信息</param>
        /// <returns>返回对象</returns>
        public static bool Update(base_users info, out string errmsg)
        {
            List <DataParameter> pars = new List <DataParameter>();

            pars.Add(new DataParameter("username", info.username));
            pars.Add(new DataParameter("passwd", info.passwd));
            pars.Add(new DataParameter("nickname", info.nickname));
            pars.Add(new DataParameter("realname", info.realname));
            pars.Add(new DataParameter("usertype", info.usertype));
            pars.Add(new DataParameter("userlevel", info.userlevel));
            pars.Add(new DataParameter("balance", info.balance));
            pars.Add(new DataParameter("score", info.score));
            pars.Add(new DataParameter("photo", info.photo));
            pars.Add(new DataParameter("phone", info.phone));
            pars.Add(new DataParameter("email", info.email));
            pars.Add(new DataParameter("country", info.country));
            pars.Add(new DataParameter("areacode", info.areacode));
            pars.Add(new DataParameter("sex", info.sex));
            pars.Add(new DataParameter("birthday", info.birthday));
            pars.Add(new DataParameter("createdtime", info.createdtime));
            pars.Add(new DataParameter("sourcetype", info.sourcetype));
            pars.Add(new DataParameter("sourceremarks", info.sourceremarks));
            pars.Add(new DataParameter("customerid", info.customerid));
            pars.Add(new DataParameter("status", info.status));
            string sqlstr = "update base_users set username=@username,passwd=@passwd,nickname=@nickname,realname=@realname,usertype=@usertype,userlevel=@userlevel,balance=@balance,score=@score,photo=@photo,phone=@phone,email=@email,country=@country,areacode=@areacode,sex=@sex,birthday=@birthday,createdtime=@createdtime,sourcetype=@sourcetype,sourceremarks=@sourceremarks,customerid=@customerid,status=@status where userid=@userid ";

            pars.Add(new DataParameter("userid", info.userid));
            return(MySqlHelper.ExecuteCommand(sqlstr, out errmsg, pars) > 0);
        }
コード例 #7
0
 /// <summary>
 /// 验证登录
 /// </summary>
 /// <returns></returns>
 public ActionResult CheckLogin()
 {
     try
     {
         // string aa=Request["userid"] == null ? "" : Request["userid"].ToString();
         string userid   = Request["userid"] == null ? "" : Request["userid"].ToString();
         string password = Request["password"] == null ? "" : Request["password"].ToString();
         if (string.IsNullOrEmpty(userid) || string.IsNullOrEmpty(password))
         {
             return(View("LoginErrorEmpty"));//返回验证失败视图
         }
         //登录验证
         base_users userinfo = _service.CheckLogin(userid, EncodeHepler.GetMD5(password));
         if (userinfo == null)
         {
             return(RedirectToAction("LoginError")); //用户名或者密码错误
         }
         else
         {
             SetCookie("userinfo", JsonHelper.SerializeObject(userinfo));
             Session.Add("userinfo", userinfo); //用户信息存入session
             ViewData["userid"] = userinfo.real_name;
             return(View("MainMenu"));
         }
     }
     catch (Exception ex)
     {
         ViewData["errorinfo"] = ex.Message.ToString();
         return(View("ComErrorView"));
     }
 }
コード例 #8
0
        internal UserInfoViewModel GetUserInfoByOther(base_users user, out string errmsg)
        {
            base_users userInfo = DAL.UserAccountDAL.GetUserInfoByOther(user, out errmsg);

            if (!string.IsNullOrEmpty(errmsg))
            {
                return(null);
            }
            if (userInfo == null || userInfo.userid == 0)
            {
                errmsg = "用户名或密码错误";
                return(null);
            }
            UserInfoViewModel uservm = new UserInfoViewModel()
            {
                UserID        = (int)userInfo.userid,
                UserName      = userInfo.username,
                NickName      = !string.IsNullOrEmpty(userInfo.nickname) ? userInfo.nickname : (!string.IsNullOrEmpty(userInfo.realname) ? userInfo.realname : userInfo.username),
                RealName      = userInfo.realname,
                UserType      = (int)userInfo.usertype,
                Customerid    = (int)userInfo.customerid,
                SourceType    = (int)userInfo.sourcetype,
                SourceRemarks = userInfo.sourceremarks,
                Photo         = userInfo.photo,
                LastLoginTime = DateTime.Now
            };

            if (!WriteCookie(uservm, ref errmsg) || !string.IsNullOrEmpty(errmsg))
            {
                return(null);
            }
            return(uservm);
        }
コード例 #9
0
        public ActionResult AddUserInfo(string user_name, string real_name, string user_pwd, bool isAdmin)
        {
            base_users model = new base_users()
            {
                user_name = user_name,
                real_name = real_name,
                user_pwd  = EncodeHepler.GetMD5(user_pwd)
            };
            var result = _userService.AddOrUpdateUserInfo(model, 3);

            if (isAdmin && result.State == 1)
            {
                //如果是管理员则添加所有权限
                var usermenus = _userService.GetAllUserMenu();
                var relList   = new List <base_user_menu_rel>();
                usermenus.ForEach(a =>
                {
                    var rel = new base_user_menu_rel()
                    {
                        create_time    = DateTime.Now,
                        edit_time      = DateTime.Now,
                        create_user_id = LoginUser.Current.user_id,
                        user_id        = result.DataResult.ObjToInt(),
                    };
                    relList.Add(rel);
                });
                _userService.AddUserMenu(relList);
            }
            return(Json(result));
        }
コード例 #10
0
ファイル: usersDAL.cs プロジェクト: xiaosachuchen/-version2
        /// <summary>
        /// 用户管理 添加数据
        /// </summary>
        /// <param name="base_users">要添加的用户管理对象</param>
        /// <param name="errmsg">错误信息</param>
        /// <returns>返回对象</returns>
        public static bool Add(base_users info, out string errmsg)
        {
            List <DataParameter> pars = new List <DataParameter>();

            pars.Add(new DataParameter("username", info.username));
            pars.Add(new DataParameter("passwd", info.passwd));
            pars.Add(new DataParameter("nickname", info.nickname));
            pars.Add(new DataParameter("realname", info.realname));
            pars.Add(new DataParameter("usertype", info.usertype));
            pars.Add(new DataParameter("userlevel", info.userlevel));
            pars.Add(new DataParameter("balance", info.balance));
            pars.Add(new DataParameter("score", info.score));
            pars.Add(new DataParameter("photo", info.photo));
            pars.Add(new DataParameter("phone", info.phone));
            pars.Add(new DataParameter("email", info.email));
            pars.Add(new DataParameter("country", info.country));
            pars.Add(new DataParameter("areacode", info.areacode));
            pars.Add(new DataParameter("sex", info.sex));
            pars.Add(new DataParameter("birthday", info.birthday));
            pars.Add(new DataParameter("createdtime", info.createdtime));
            pars.Add(new DataParameter("sourcetype", info.sourcetype));
            pars.Add(new DataParameter("sourceremarks", info.sourceremarks));
            pars.Add(new DataParameter("customerid", info.customerid));
            pars.Add(new DataParameter("status", info.status));
            string sqlstr = "insert into base_users (username,passwd,nickname,realname,usertype,userlevel,balance,score,photo,phone,email,country,areacode,sex,birthday,createdtime,sourcetype,sourceremarks,customerid,status) values (@username,@passwd,@nickname,@realname,@usertype,@userlevel,@balance,@score,@photo,@phone,@email,@country,@areacode,@sex,@birthday,@createdtime,@sourcetype,@sourceremarks,@customerid,@status) ";

            return(MySqlHelper.ExecuteCommand(sqlstr, out errmsg, pars) > 0);
        }
コード例 #11
0
        /// <summary>
        /// 拆包确认配货
        /// </summary>
        /// <returns></returns>
        public ActionResult DispartConfirmDistrbuilt()                                                            //
        {
            base_users   Userinfo   = JsonHelper.DeserializeJsonToObject <base_users>(GetCookie("userinfo"));     //得到用户信息
            RFTDistrView peihuoinfo = JsonHelper.DeserializeJsonToObject <RFTDistrView>(GetCookie("peihuoinfo")); //得到配货信息

            try
            {
                bool isok = _service.DispartConfirmDistruit(peihuoinfo, Userinfo); //真正在数据库中拆分掉包裹
                if (isok)                                                          //配货成功
                {
                    //ViewData["userid"] = Userinfo.real_name;
                    return(RedirectToAction("DistrubulitSucc"));
                }
                else
                {
                    ViewData["errorinfo"] = "配货失败!";
                    return(View("ComErrorView"));
                }
            }
            catch (Exception ex)
            {
                ViewData["errorinfo"] = "配货程序出错!" + ex.Message;
                return(View("ComErrorView"));
            }
            finally //删除之前的配货信息
            {
                peihuoinfo = null;
                DelCookie("peihuoinfo");
            }
        }
コード例 #12
0
        /// <summary>
        /// 用户管理 详情查询
        /// </summary>
        public object Get(int id)
        {
            base_users info = usersBLL.GetInfo(id, out errmsg)
            ;                        if (!string.IsNullOrEmpty(errmsg))

            {
                return(new { Rcode = -1, Rmsg = "获取数据失败" });
            }
            return(new { Rcode = 1, Rdata = info });
        }
コード例 #13
0
ファイル: UserService.cs プロジェクト: chrgu000/2017lecheng
        /// <summary>
        /// 添加或者更新用户信息
        /// </summary>
        /// <param name="model"></param>
        /// <param name="state">0代表修改密码1代表删除用户2代表禁用启用用户3代表添加</param>
        /// <returns></returns>
        public ComResult AddOrUpdateUserInfo(base_users model, int state)
        {
            ComResult result = new ComResult();

            using (var db = SugarDao.GetInstance(LoginUser.GetConstr()))
            {
                if (model.user_id > 0)
                {    //判断用户名是否存在
                    var userModel = db.Queryable <base_users>().Where(a => a.user_id == model.user_id).ToList();
                    if (userModel == null || userModel.Count() <= 0)
                    {
                        result.State = 0;
                        result.Msg   = "用户不存在";
                        return(result);
                    }
                    switch (state)
                    {
                    case 0:
                        db.Update <base_users>(new { user_pwd = model.user_pwd, real_name = model.real_name }, a => a.user_id == model.user_id);
                        break;

                    case 1:
                        db.Update <base_users>(new { del_flag = model.del_flag }, a => a.user_id == model.user_id);
                        break;

                    case 2:
                        db.Update <base_users>(new { user_status = model.user_status }, a => a.user_id == model.user_id);
                        break;;
                    }
                    result.State = 1;
                    return(result);
                }
                else
                {
                    //判断用户名是否存在
                    var userModel = db.Queryable <base_users>().Where(a => a.user_name == model.user_name).ToList();
                    if (userModel != null && userModel.Count() > 0)
                    {
                        result.State = 0;
                        result.Msg   = "用户已经存在";
                        return(result);
                    }
                    model.create_time    = DateTime.Now;
                    model.edit_time      = DateTime.Now;
                    model.del_flag       = true;
                    model.user_status    = true;
                    model.create_user_id = LoginUser.Current.user_id;
                    model.net_no         = 1;
                    model.emp_no         = 1;
                    result.State         = 1;
                    result.DataResult    = db.InsertOrUpdate <base_users>(model);
                    return(result);
                }
            }
        }
コード例 #14
0
        public ActionResult SetUserStateById(int user_id, bool user_state)
        {
            base_users model = new base_users()
            {
                user_id     = user_id,
                user_status = user_state
            };
            var result = _userService.AddOrUpdateUserInfo(model, 2);

            return(Json(result));
        }
コード例 #15
0
        public ActionResult DelUserById(int user_id)
        {
            base_users model = new base_users()
            {
                user_id  = user_id,
                del_flag = false
            };
            var result = _userService.AddOrUpdateUserInfo(model, 1);

            return(Json(result));
        }
コード例 #16
0
        public ActionResult UpdateUserInfoById(string real_name, string user_pwd, int user_id)
        {
            base_users model = new base_users()
            {
                user_id   = user_id,
                real_name = real_name,
                user_pwd  = user_pwd
            };
            var result = _userService.AddOrUpdateUserInfo(model, 0);

            return(Json(result));
        }
コード例 #17
0
ファイル: RFTService.cs プロジェクト: chrgu000/2017lecheng
        private static string conn = "server=112.12.29.172;uid=sa;pwd=jhqn89808980;database=20170717Newlecheng";// "server=122.226.76.100,5433;uid=sa;pwd=123!@#QAZ;database=Newlecheng";

        public DBModel.DBmodel.base_users CheckLogin(string userid, string password)
        {
            using (var db = SugarDao.GetInstance(conn))
            {
                try
                {
                    base_users platlist = db.Queryable <base_users>().Where(s => s.user_id == userid.ObjToInt()).Where(s => s.user_pwd == password).FirstOrDefault();
                    return(platlist);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
コード例 #18
0
        public object Get(string codes, string type, string flig, string userid)
        {
            if (!string.IsNullOrEmpty(type))
            {
                base_users info = usersBLL.selectusername(codes, type, out errmsg);
                if (string.Equals("修改", flig))
                {
                    if (info != null)
                    {
                        return(new { valid = (string.Equals(info.userid.ToString(), userid)) ? true : false });
                    }
                    return(new { valid = true });
                }
                return(new { valid = (info == null) ? true : false });
            }


            return(new { valid = false });
        }
コード例 #19
0
        /// <summary>
        /// 用户管理 更新数据
        /// </summary>
        public object Put(int id, [FromBody] base_users info)
        {
            bool success = false;

            info.userid = id;
            if (info.username == null && info.email == null & info.phone == null)
            {
                success = usersBLL.UpdateCus(info.customerid, info.userid, out errmsg);
            }
            else
            {
                info.createdtime = DateTime.Now;
                success          = usersBLL.Update(info, out errmsg);
            }
            if (!success || !string.IsNullOrEmpty(errmsg))
            {
                return new { Rcode = -1, Rmsg = "更新失败" }
            }
            ;
            return(new { Rcode = 1, Rmsg = "更新成功" });
        }
コード例 #20
0
        public object GetUserPwd(string pwd)
        {
            string errmsg = null;

            if (userLoginManager.LoginUser == null || userLoginManager.LoginUser.UserID < 1)
            {
                return new { Rcode = 0, Rmsg = "未登录" }
            }
            ;
            int userid = userLoginManager.LoginUser.UserID;

            pwd = StrFormatClass.MD5ToDepth(pwd);
            base_users info = BLL.UserLoginManager.GetUserPwd(userid, pwd, out errmsg);

            if (info == null || !string.IsNullOrEmpty(errmsg))
            {
                return new { Rcode = -1, Rmsg = "获取数据错误" }
            }
            ;
            return(new { Rcode = 1 });
        }
コード例 #21
0
        /// <summary>
        /// 用户管理 添加数据
        /// </summary>
        public object Post([FromBody] base_users info)
        {
            info.createdtime = DateTime.Now;
            info.nickname    = info.username;
            info.usertype    = 1;//用户类型
            info.userlevel   = 1;
            info.balance     = 0;
            info.score       = 0;
            info.sourcetype  = 1;//来源类型
            info.passwd      = GlobalParameters.DefaultUserPasswd;
            info.customerid  = 0;

            bool success = usersBLL.Add(info, out errmsg);

            if (!success || !string.IsNullOrEmpty(errmsg))
            {
                return new { Rcode = -1, Rmsg = "添加失败" }
            }
            ;
            return(new { Rcode = 1, Rmsg = "添加成功" });
        }
コード例 #22
0
        internal static base_users UserLogin(string phone, string email, string username, string passwd, string jgid, out string errmsg)
        {
            List <DataParameter> pars = new List <DataParameter>();

            pars.Add(new DataParameter("passwd", passwd));
            string sqlstr = "select * from base_users where status>0 and passwd=@passwd ";

            if (!string.IsNullOrEmpty(phone))
            {
                sqlstr += " and phone=@phone";
                pars.Add(new DataParameter("phone", phone));
            }
            else if (!string.IsNullOrEmpty(email))
            {
                sqlstr += " and email=@email";
                pars.Add(new DataParameter("email", email));
            }
            else if (!string.IsNullOrEmpty(username))
            {
                sqlstr += " and username=@username";
                pars.Add(new DataParameter("username", username));
            }
            else
            {
                errmsg = "参数错误";
                return(null);
            }
            base_users user = MySqlHelper.GetDataInfo <base_users>(sqlstr, out errmsg, pars.ToArray());

            if (!string.IsNullOrEmpty(errmsg))
            {
                return(null);
            }
            if (user == null)
            {
                errmsg = "账号或密码错误";
                return(null);
            }
            return(user);
        }
コード例 #23
0
        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="phone"></param>
        /// <param name="email"></param>
        /// <param name="username"></param>
        /// <param name="passwd"></param>
        /// <param name="errmsg"></param>
        /// <returns></returns>
        public UserInfoViewModel UserLogin(string phone, string email, string username, string passwd, string jgid, out string errmsg)
        {
            if (string.IsNullOrEmpty(phone) && string.IsNullOrEmpty(email) && string.IsNullOrEmpty(username) && string.IsNullOrEmpty(passwd))
            {
                errmsg = "请输入完整的账号密码";
                return(null);
            }
            base_users userInfo = DAL.UserAccountDAL.UserLogin(phone, email, username, passwd, jgid, out errmsg);

            if (!string.IsNullOrEmpty(errmsg))
            {
                return(null);
            }
            if (userInfo == null || userInfo.userid == 0)
            {
                errmsg = "用户名或密码错误";
                return(null);
            }
            UserInfoViewModel user = new UserInfoViewModel()
            {
                UserID        = (int)userInfo.userid,
                UserName      = userInfo.username,
                NickName      = !string.IsNullOrEmpty(userInfo.nickname) ? userInfo.nickname : (!string.IsNullOrEmpty(userInfo.realname) ? userInfo.realname : userInfo.username),
                RealName      = userInfo.realname,
                UserType      = (int)userInfo.usertype,
                Customerid    = (int)userInfo.customerid,
                SourceType    = (int)userInfo.sourcetype,
                SourceRemarks = userInfo.sourceremarks,
                Photo         = userInfo.photo,
                LastLoginTime = DateTime.Now
            };

            if (!WriteCookie(user, ref errmsg) || !string.IsNullOrEmpty(errmsg))
            {
                return(null);
            }
            return(user);
        }
コード例 #24
0
        public object UserFindPasswd(base_users userinfo)
        {
            string errmsg = null;

            if (userinfo.yzmcode == null || userinfo.yzmcode.Length != 6)
            {
                return(new { Rcode = -1, Rmsg = "找回密码失败:请填写验证码" });
            }
            base_identifycode identifycode = BLL.BaseBLL.GetIdentifyCodeInfo(userinfo.phone, userinfo.email, userinfo.yzmcode, out errmsg);

            if (identifycode == null)
            {
                return new { Rcode = 0, Rmsg = "验证码错误" }
            }
            ;
            else if (DateTime.Now > identifycode.endtime)
            {
                return new { Rcode = 0, Rmsg = "验证码超时,请重新获取验证码" }
            }
            ;

            userinfo.passwd = StrFormatClass.MD5ToDepth(userinfo.passwd);

            bool issuc = userLoginManager.UserFindPasswd(userinfo, out errmsg);

            if (!string.IsNullOrEmpty(errmsg))
            {
                return(new { Rcode = -1, Rmsg = "找回密码失败:" + errmsg });
            }
            if (issuc)
            {
                return(new { Rcode = 1, Rmsg = "ok" });
            }
            else
            {
                return(new { Rcode = 0, Rmsg = "找回密码失败" });
            }
        }
コード例 #25
0
        public object UserLoginByOther(base_users userinfo)
        {
            userinfo.passwd        = Models.GlobalParameters.DefaultUserPasswd;
            userinfo.usertype      = 1;
            userinfo.userlevel     = 1;
            userinfo.sourcetype    = 4;
            userinfo.sourceremarks = userinfo.usertypename;
            userinfo.customerid    = 0;
            userinfo.status        = 1;
            userinfo.createdtime   = DateTime.Now;
            UserInfoViewModel userVM = userLoginManager.GetUserInfoByOther(userinfo, out errmsg);

            if (!string.IsNullOrEmpty(errmsg))
            {
                return new { Rcode = -1, Rmsg = "获取数据错误" }
            }
            ;
            else if (userVM == null || userVM.UserID < 1)
            {
                return new { Rcode = -1, Rmsg = "绑定用户出错" }
            }
            ;
            else
            {
                base_userlogs log = new base_userlogs()
                {
                    logtype     = 22,
                    restype     = "0",
                    rescode     = userVM.UserID.ToString(),
                    logcontent  = string.Format("登录用户{0}", userVM.UserName),
                    creator     = 0,
                    createdtime = DateTime.Now
                };

                return(new { Rcode = 1, Rmsg = "登录成功", Rdata = userVM });
            }
        }
コード例 #26
0
 /// <summary>
 /// 拆分包裹
 /// </summary>
 /// <returns></returns>
 public ActionResult Dipartpackge() //
 {
     try
     {
         base_users   Userinfo      = JsonHelper.DeserializeJsonToObject <base_users>(GetCookie("userinfo"));     //得到用户信息
         RFTDistrView peihuoinfo    = JsonHelper.DeserializeJsonToObject <RFTDistrView>(GetCookie("peihuoinfo")); //得到配货信息
         RFTDistrView newpeihuoinfo = _service.Dispartpackge(peihuoinfo);
         //DelCookie("peihuoinfo"); //删除之前的配货cookie信息
         if (newpeihuoinfo == null)
         {
             ViewData["errorinfo"] = "拆分包裹失败";
             return(View("ComErrorView"));
         }
         else
         {
             var useinfo = JsonHelper.DeserializeJsonToObject <base_users>(GetCookie("userinfo"));
             ViewData["userid"] = useinfo.real_name;
             SetCookie("peihuoinfo", JsonHelper.SerializeObject(newpeihuoinfo)); //将数据放入cookie,记得确认配货完删除cookie
             if (newpeihuoinfo.info == "可包装")
             {
                 ViewData["disinfo"] = newpeihuoinfo;
                 return(View("DistrbuiltInfo3"));
             }
             else
             {
                 ViewData["disinfo"] = newpeihuoinfo;
                 return(View("DistrbuiltInfo2"));
             }
         }
     }
     catch (Exception ex)
     {
         ViewData["errorinfo"] = ex.Message.ToString();
         return(View("ComErrorView"));
     }
 }
コード例 #27
0
 internal static bool PutUserInfo(base_users info, out string errmsg)
 {
     return(DAL.UserAccountDAL.PutUserInfo(info, out errmsg));
 }
コード例 #28
0
ファイル: RFTService.cs プロジェクト: chrgu000/2017lecheng
        /// <summary>
        /// 拆分包裹确认配货
        /// </summary>
        /// <param name="peihuoinfo"></param>
        /// <param name="Userinfo"></param>
        /// <returns></returns>
        public bool DispartConfirmDistruit(RFTDistrView peihuoinfo, base_users Userinfo)
        {
            using (var db = SugarDao.GetInstance(conn))
            {
                db.CommandTimeOut = 3000;//设置超时时间
                try
                {
                    db.BeginTran();
                    //1.先设置work_info中已配货的状态
                    bool isok = db.Update <busi_workinfo>(new { is_work = 1, work_type = 2, work_time = DateTime.Now, edit_user_id = Userinfo.user_id, islock = 0 }, it => it.work_id == peihuoinfo.workid);
                    if (isok)
                    {
                        if (peihuoinfo.info == "可包装")//单件的,需要打印
                        {
                            //1.先拆分包裹,先得到原先的包裹号
                            busi_sendorder oldpack = db.Queryable <busi_sendorder>().Where(s => s.order_id == peihuoinfo.packid).FirstOrDefault();
                            if (peihuoinfo.packgecode != GetPackCode().ToString())//再次取新的包裹号,如果不相等说明刚才的包裹号被其他地方占用了
                            {
                                throw new Exception("拆分后的包裹号被占用请重新拆分");
                            }
                            long oldpackid = oldpack.order_id;
                            oldpack.prod_num--;                  //减少原先包裹SKU数量
                            db.Update <busi_sendorder>(oldpack); //先更新原先包裹SKU数量信息

                            oldpack.order_code  = peihuoinfo.packgecode;
                            oldpack.order_id    = 0;
                            oldpack.prod_num    = 1;
                            oldpack.order_tatus = 40;                                     //包裹配货完成
                            int npackid = db.Insert <busi_sendorder>(oldpack).ObjToInt(); //插入新包裹

                            //判断这个包裹中是否买了多个相同的SKU
                            long codeid = db.Queryable <base_prod_code>().Where(s => s.sku_code == peihuoinfo.skucode).FirstOrDefault().code_id;//得到skuid
                            busi_sendorder_detail oldsenddetail = db.Queryable <busi_sendorder_detail>().Where(s1 => s1.order_id == peihuoinfo.packid).Where(s1 => s1.code_id == codeid).FirstOrDefault();
                            long senddetailid = 0;
                            if (Convert.ToInt32(oldsenddetail.prod_num) > 1) //原包裹相同SKU购买多件
                            {
                                oldsenddetail.prod_num--;
                                db.Update <busi_sendorder_detail>(new { prod_num = oldsenddetail.prod_num }, it => it.detail_id == oldsenddetail.detail_id);
                                oldsenddetail.detail_id = 0;
                                oldsenddetail.order_id  = npackid;
                                oldsenddetail.prod_num  = 1;
                                senddetailid            = db.Insert <busi_sendorder_detail>(oldsenddetail).ObjToInt();
                            }
                            else if (Convert.ToInt32(oldsenddetail.prod_num) == 1)//只买了一个,直接更新这条数据
                            {
                                senddetailid = oldsenddetail.detail_id;
                                db.Update <busi_sendorder_detail>(new { order_id = npackid }, it => it.detail_id == oldsenddetail.detail_id);
                            }
                            db.Update <busi_workinfo>(new { packid = npackid, sendorder_detail_id = senddetailid, islock = 0 }, it => it.work_id == peihuoinfo.workid);
                            //==================20171023添加,如果上架过,最后一个拆分包裹,检查原包裹的状态并做相应的更新===================
                            //1.判断已上架的数量和包裹SKU数量是否相等
                            int skunum   = db.Queryable <busi_sendorder>().Where(s => s.order_id == oldpackid).FirstOrDefault().prod_num;
                            var worklist = db.Queryable <busi_workinfo>().Where(s => s.packid == oldpackid && s.is_work == true && s.del_flag == true).ToList();
                            if (skunum == worklist.Count)
                            {
                                db.Update <busi_sendorder>(new { order_tatus = 40 }, it => it.order_id == peihuoinfo.packid);//原先包裹更新状态,全部配货
                            }
                            else
                            {
                                db.Update <busi_sendorder>(new { order_tatus = 30 }, it => it.order_id == peihuoinfo.packid);//原先包裹更新状态,部分配货
                            }
                            //================================================================================================
                            //插入打印数据
                            //插入打印数据,只是包裹号
                            busi_printwork insertinfo = new busi_printwork();
                            insertinfo.p_WorkType = 30;
                            insertinfo.data_1     = peihuoinfo.packgecode;
                            insertinfo.data_4     = DateTime.Now.ToString();
                            insertinfo.p_idPoint  = 1; //测试
                            insertinfo.p_Status   = 1;
                            insertinfo.data_2     = peihuoinfo.packgecode.Substring(8, 4);
                            insertinfo.data_3     = peihuoinfo.packnum.ToString();
                            db.Insert <busi_printwork>(insertinfo);

                            //-------------------20170720减库存--------------------------------------
                            var depotID = db.Queryable <base_wh_warehouse>().Where(s => s.wh_name == "金华仓").FirstOrDefault();
                            if (null == depotID)
                            {
                                throw new Exception("金华仓不存在");
                            }
                            var locationID = db.Queryable <base_location>().Where(s => s.wh_id == depotID.wh_id && s.locat_code == "zz-zz-zz").FirstOrDefault();
                            if (null == locationID)
                            {
                                throw new Exception("金华仓库位zz-zz-zz不存在");
                            }
                            var skuid = db.Queryable <base_prod_code>().Where(s => s.sku_code == peihuoinfo.skucode).FirstOrDefault();
                            var stock = db.Queryable <base_wh_stock>().Where(s => s.location_id == locationID.locat_id && s.code_id == skuid.code_id).FirstOrDefault();
                            if (0 >= stock.stock_qty)
                            {
                                throw new Exception("金华仓临时库库存为零");
                            }
                            stock.stock_qty--;
                            db.Update <base_wh_stock>(stock);
                            //---------------------------------------------------------------------------
                            //3.得到这个订单的所有包裹数目
                            int packges = db.Queryable <busi_sendorder>().Where(s => s.custorder_id == peihuoinfo.orderid).Where(s => s.del_flag == true).ToList().Count;
                            //已配货数量
                            int ispackingnum = db.Queryable <busi_sendorder>().Where(s => s.custorder_id == peihuoinfo.orderid).Where(s => s.del_flag == true).Where(s => s.order_tatus >= 40).ToList().Count;
                            if (packges == ispackingnum)
                            {
                                db.Update <busi_custorder>(new { order_status = 40 }, it => it.order_id == peihuoinfo.orderid);
                            }
                        }
                        db.CommitTran();
                        return(true);
                    }
                    else
                    {
                        db.RollbackTran();
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    db.RollbackTran();
                    throw ex;
                }
            }
        }
コード例 #29
0
 internal bool UserFindPasswd(base_users userinfo, out string errmsg)
 {
     return(DAL.UserAccountDAL.UserFindPasswd(userinfo, out errmsg));
 }
コード例 #30
0
ファイル: LoginService.cs プロジェクト: chrgu000/2017lecheng
        /// <summary>
        /// 从库登入
        /// </summary>
        /// <param name="user"></param>
        /// <param name="connectionStr">从库数据库链接字符串</param>
        /// <returns></returns>
        private ComResult CKlogin(base_users userModel, string connectionStr)
        {
            ComResult result = new ComResult();

            try
            {
                using (var db = SugarDao.GetInstance(connectionStr))
                {
                    //验证公司网点
                    var singlenet_no = db.Queryable <base_users>().SingleOrDefault(c => c.net_no == userModel.net_no && c.user_name == userModel.user_name);
                    if (singlenet_no == null)
                    {
                        result.State = 0;
                        result.Msg   = "公司网点与用户不匹配";

                        return(result);
                    }
                    //验证用户名和密码
                    var singleuser = db.Queryable <base_users>().SingleOrDefault(c => c.user_name == userModel.user_name);
                    if (singleuser == null)
                    {
                        result.State = 0;
                        result.Msg   = "用户不存在";

                        return(result);
                    }
                    //密码校验错误次数,超过5次设置10分钟的缓冲时间
                    //记录登录错误日志
                    var reeoruser = db.Queryable <base_login_error>().SingleOrDefault(c => c.user_id == singleuser.user_id);
                    if (reeoruser != null && reeoruser.check_times > 0 && reeoruser.check_times % 5 == 0 && DateTime.Now <= reeoruser.login_date.AddMinutes(10))
                    {
                        result.State = 0;
                        result.Msg   = "密码校验错误次数超过5次,请10分钟后尝试";
                        return(result);
                    }
                    var usermodel = db.Queryable <base_users>().SingleOrDefault(c => c.user_name == userModel.user_name && c.user_pwd == userModel.user_pwd);
                    if (usermodel == null)
                    {
                        if (reeoruser == null)
                        {
                            db.Insert <base_login_error>(new base_login_error()
                            {
                                user_id = singleuser.user_id, check_times = 1, login_date = DateTime.Now, create_time = DateTime.Now
                            });
                        }
                        else
                        {
                            db.Update <base_login_error>(new base_login_error()
                            {
                                user_id = singleuser.user_id, check_times = (byte)(reeoruser.check_times + 1), login_date = DateTime.Now, login_error_id = reeoruser.login_error_id, create_time = DateTime.Now
                            });
                        }
                        //记录登录日志
                        db.Insert <base_login_log>(Ckinsertlog(singleuser.user_id, false, singleuser.emp_id));
                        result.State = 0;
                        result.Msg   = "密码错误";

                        return(result);
                    }
                    if (!usermodel.user_status)
                    {
                        //记录登录日志
                        db.Insert <base_login_log>(Ckinsertlog(singleuser.user_id, false, singleuser.emp_id));
                        result.State = 0;
                        result.Msg   = "该账号不可用,请联系管理员";

                        return(result);
                    }
                    //记录登录日志
                    //用户登录成功清除登录错误次数
                    if (reeoruser != null)
                    {
                        db.Update <base_login_error>(new base_login_error()
                        {
                            user_id = singleuser.user_id, check_times = 0, login_date = DateTime.Now, login_error_id = reeoruser.login_error_id, create_time = DateTime.Now
                        });
                    }
                    db.Insert <base_login_log>(Ckinsertlog(singleuser.user_id, true, singleuser.emp_id));
                    result.State      = 1;
                    result.DataResult = usermodel;
                    //将登入状态存入缓存
                    SessionHelper.Add(CookieHelper.GetCookieValue("tockenid"), JsonHelper.SerializeObject(usermodel), SystemConfig.loginExpireTime);
                    return(result);
                }
            }
            catch (Exception ex)
            {
                result.State = 0;
                result.Msg   = "系统异常" + ex.Message;
                return(result);

                throw;
            }
        }