Ejemplo n.º 1
0
        public void SaveUser(Users user)
        {
            if (db.Users.Where(u => u.user_id != user.user_id && u.user_name == user.user_name).Count() > 0)
            {
                throw new Exception("登录名已存在,保存失败");
            }

            if (user.user_id > 0)
            {
                //修改
                var us = GetUserByUserId(user.user_id);
                if (us == null)
                {
                    throw new Exception("用户不存在,不能编辑");
                }

                us.user_name = user.user_name;
                us.real_name = user.real_name;
                us.email     = user.email;
                us.comment   = user.comment;
                us.user_role = user.user_role;

                //如果供应商在基础资料里面保存了的,也要跟着修改
                if (user.user_role == "供应商")
                {
                    var info = db.SupplierInfo.Where(s => s.supplier_number == us.user_name).ToList();
                    if (info.Count() > 0)
                    {
                        foreach (var i in info)
                        {
                            i.name = user.real_name;
                        }
                    }
                }
            }
            else
            {
                //新增
                user.is_forbit             = false;
                user.continual_error_times = 0;
                user.in_date  = DateTime.Now;
                user.password = MyUtils.getMD5(user.user_name);

                db.Users.InsertOnSubmit(user);

                db.SubmitChanges();

                //根据角色增加到权限组中
                int groupId = new UASv().GetGroupIdByName("auth", user.user_role + "组");
                if (groupId > 0)
                {
                    new UASv().SaveGroupUser(groupId, user.user_id);
                }
            }
            db.SubmitChanges();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 查看我的审核申请,订料员和采购员用
        /// </summary>
        /// <param name="p"></param>
        /// <param name="canCheckAll"></param>
        /// <returns></returns>
        public IQueryable <CheckApplyListModel> SearchMyAuditList(SearchMyApplyParams p, bool canCheckAll)
        {
            var groupUserName = new UASv().GetAuditGroupUsers(p.userId).Select(u => u.user_name).ToList();

            return(SearchApplyListBase(p)
                   .Where(s => (canCheckAll ||
                                s.matOrderNumber == p.userName ||
                                s.buyerNumber == p.userName ||
                                groupUserName.Contains(s.matOrderNumber) ||
                                groupUserName.Contains(s.buyerName))
                          )
                   .OrderBy(s => s.sendDate));
        }