Exemplo n.º 1
0
        public ActionResult MyFunds(BillsSearchModel info)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToRoute(new { controller = "Login", action = "LogOut" }));
            }
            int   user = PageValidate.FilterParam(User.Identity.Name);
            Bills dal  = new Bills(db);

            if (!RoleCheck.CheckHasAuthority(user, db, "经费管理"))
            {
                info.userId = user;
            }
            info.PageSize = 0;
            info.userId   = user;
            var bills = dal.GetApplyList(info).ToList();

            foreach (var bill in bills)
            {
                bill.contents         = dal.getContents(bill.reimbursementCode, 0).ToList();
                bill.attachmentsCount = dal.getAttachments(bill.reimbursementCode, 0).Count();
            }
            ViewData["Bills"] = bills;
            List <SelectOption> options = DropDownList.RespondStateSelect();

            ViewData["RState"] = DropDownList.SetDropDownList(options);
            return(View(info));
        }
        public ActionResult Responded(BillsSearchModel info)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToRoute(new { controller = "Login", action = "Index" }));
            }
            ApplyManager dal    = new ApplyManager(db);
            int          userId = PageValidate.FilterParam(User.Identity.Name);

            if (!RoleCheck.CheckHasAuthority(userId, db, "批复管理", "批复"))
            {
                return(RedirectToRoute(new { controller = "Error", action = "Index", err = "没有权限。" }));
            }
            if (RoleCheck.CheckHasAuthority(userId, db, "批复管理"))
            {
                if (info.userId == null)
                {
                    info.userId = 0;
                }
            }
            else
            {
                info.userId = userId;
            }
            SetSelect();
            var list = getResponseDetail((int)info.userId, 1, 2, 3, 4);

            ViewData["Bills"] = list;
            return(View(info));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取主报帐单列表
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public List <ApplyListModel> GetApplyList(BillsSearchModel search)
        {
            StringBuilder sql = new StringBuilder();

            sql.Append("select r_add_user_id as userId,r_bill_amount as amount,reimbursement_code as reimbursementCode,r_bill_state as state,drs_state_name as strState,r_add_date as time,f_code as  fundsCode,f_name as fundsName,reimbursement_info as info,");
            sql.Append("(select COUNT(attachment_id) from Reimbursement_Attachment where atta_reimbursement_code=reimbursement_code) as attachmentsCount");
            sql.Append(" from Reimbursements");
            sql.Append(" inner join Dic_Respond_State on drs_state_id=r_bill_state");
            sql.Append(" inner join Funds on f_id=r_funds_id");
            sql.Append(" where 1=1");
            if (search.fid != 0)
            {
                sql.Append(" and r_funds_id=").Append(search.fid);
            }
            if (search.userId != 0)
            {
                sql.Append(" and r_add_user_id=").Append(search.userId);
            }
            if (search.state != null)
            {
                sql.Append(" and r_bill_state=").Append(search.state);
            }
            if (!string.IsNullOrEmpty(search.reimbursementCode))
            {
                sql.Append(" and reimbursement_code='").Append(search.reimbursementCode).Append("'");
            }
            if (search.beginDate != null)
            {
                sql.Append(" and r_add_date>'").Append(((DateTime)search.beginDate).ToString()).Append("'");
            }
            if (search.endDate != null)
            {
                sql.Append(" and r_add_date<'").Append(((DateTime)search.endDate).ToString()).Append("'");
            }
            if (!string.IsNullOrEmpty(search.KeyWord))
            {
                sql.Append(" and reimbursement_info like '%").Append(search.KeyWord).Append("%'");
            }
            if (search.PageSize > 0)
            {
                return(db.Database.SqlQuery <ApplyListModel>(sql.ToString()).Skip(search.PageSize * (search.PageIndex - 1)).Take(search.PageSize).ToList());
            }
            else
            {
                return(db.Database.SqlQuery <ApplyListModel>(sql.ToString()).ToList());
            }
        }
Exemplo n.º 4
0
        // GET: FundsManager
        public ActionResult Index(BillsSearchModel info)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(RedirectToRoute(new { controller = "Login", action = "LogOut" }));
            }
            int  user    = PageValidate.FilterParam(User.Identity.Name);
            bool isAdmin = RoleCheck.CheckHasAuthority(user, db, "经费管理", "添加经费");

            if (!isAdmin)
            {
                return(RedirectToRoute(new { controller = "Error", action = "Index", err = "没有权限。" }));
            }
            ApplyManager dal = new ApplyManager(db);

            if (info.userId != 0)
            {
                if (!RoleCheck.CheckHasAuthority(user, db, "经费管理"))
                {
                    info.userId = user;
                }
            }
            info.PageSize = 0;
            //管理的经费
            var mfunds = from funds in db.Funds
                         join u in db.User_Info on funds.f_manager equals u.user_id
                         select new mFundsListModel
            {
                manager     = funds.f_manager,
                code        = funds.f_code,
                amount      = funds.f_amount,
                balance     = funds.f_balance,
                id          = funds.f_id,
                name        = funds.f_name,
                managerName = u.real_name,
                strState    = funds.f_state == 0 ? "未启用" : (funds.f_state == 1 ? "正常" : "锁定"),
                userCount   = (from bill in db.Reimbursement
                               where bill.r_funds_id == funds.f_id && bill.r_bill_state == 1
                               select bill
                               ).Count(),
                applyamount = (
                    from bill in db.Reimbursement
                    where bill.r_funds_id == funds.f_id && bill.r_bill_state == 1
                    select bill.r_fact_amount
                    ).DefaultIfEmpty(0).Sum()
            };

            if (info.userId > 0)
            {
                mfunds = mfunds.Where(x => x.manager == info.userId);
            }
            var list = mfunds.ToList();

            foreach (var item in list)
            {
                item.managerName = Common.DEncrypt.AESEncrypt.Decrypt(item.managerName);
            }
            ViewData["Funds"] = list;
            List <SelectOption> options = DropDownList.FundsManagerSelect(user);

            ViewData["ViewUsers"] = DropDownList.SetDropDownList(options);
            return(View(info));
        }