Esempio n. 1
0
        public ActionResult Index(DeductMoney DeductMoney, EFPagingInfo <DeductMoney> p, int IsFirst = 0, string Mobile = "")
        {
            if (!DeductMoney.TState.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.TState == DeductMoney.TState);
            }
            if (!DeductMoney.UserName.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.UserName.Contains(DeductMoney.UserName));
            }
            if (!Mobile.IsNullOrEmpty())
            {
                Users Users = Entity.Users.FirstOrDefault(n => n.Mobile == Mobile);
                if (Users != null)
                {
                    p.SqlWhere.Add(f => f.UId == Users.Id);
                }
            }
            p.OrderByList.Add("Id", "DESC");
            IPageOfItems <DeductMoney> DeductMoneyList = null;

            if (IsFirst == 0)
            {
                DeductMoneyList = new PageOfItems <DeductMoney>(new List <DeductMoney>(), 0, 10, 0, new Hashtable());
            }
            else
            {
                DeductMoneyList = Entity.Selects <DeductMoney>(p);
            }
            List <int> UId = DeductMoneyList.Select(o => o.UId).Distinct().ToList();

            ViewBag.UsersList = Entity.Users.Where(n => n.State == 1 && UId.Contains(n.Id)).ToList();

            ViewBag.DeductMoneyList = DeductMoneyList;
            ViewBag.DeductMoney     = DeductMoney;
            ViewBag.Info            = this.checkPower("Info");
            ViewBag.IsInfo          = this.checkPower("Info");
            ViewBag.IsAudit         = this.checkPower("Audit");
            ViewBag.ExcelExport     = this.checkPower("ExcelExport");
            ViewBag.MobileSelect    = Mobile;
            return(View());
        }
Esempio n. 2
0
        /// <summary>
        /// 导出
        /// </summary>
        /// <returns></returns>
        public FileResult ExcelExport(DeductMoney DeductMoney, EFPagingInfo <DeductMoney> p, int IsFirst = 0, string Mobile = "")
        {
            if (!DeductMoney.TState.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.TState == DeductMoney.TState);
            }
            if (!DeductMoney.UserName.IsNullOrEmpty())
            {
                p.SqlWhere.Add(f => f.UserName.Contains(DeductMoney.UserName));
            }
            if (!Mobile.IsNullOrEmpty())
            {
                Users Users = Entity.Users.FirstOrDefault(n => n.Mobile == Mobile);
                if (Users != null)
                {
                    p.SqlWhere.Add(f => f.UId == Users.Id);
                }
            }
            p.PageSize = 99999999;
            p.OrderByList.Add("Id", "DESC");
            IPageOfItems <DeductMoney> DeductMoneyList = null;

            if (IsFirst == 0)
            {
                DeductMoneyList = new PageOfItems <DeductMoney>(new List <DeductMoney>(), 0, 10, 0, new Hashtable());
            }
            else
            {
                DeductMoneyList = Entity.Selects <DeductMoney>(p);
            }

            List <int>    UId       = DeductMoneyList.Select(o => o.UId).Distinct().ToList();
            IList <Users> UsersList = Entity.Users.Where(n => n.State == 1 && UId.Contains(n.Id)).ToList();


            DataTable table = new DataTable();
            DataRow   row   = null;

            // 创建 datatable
            table.Columns.Add(new DataColumn("真实姓名", typeof(string)));
            table.Columns.Add(new DataColumn("金额", typeof(string)));
            table.Columns.Add(new DataColumn("状态", typeof(string)));
            table.Columns.Add(new DataColumn("手机号", typeof(string)));
            table.Columns.Add(new DataColumn("发起人", typeof(string)));
            table.Columns.Add(new DataColumn("发起时间", typeof(string)));
            table.Columns.Add(new DataColumn("审核人", typeof(string)));
            table.Columns.Add(new DataColumn("审核时间", typeof(string)));

            // 填充数据
            foreach (var item in DeductMoneyList)
            {
                Users Users = UsersList.FirstOrNew(n => n.Id == item.UId);
                row    = table.NewRow();
                row[0] = item.UserName;
                row[1] = item.Amoney.ToString("f2");

                string TState = "待审核";
                switch (item.TState)
                {
                case 1:
                    TState = "待审核";
                    break;

                case 2:
                    TState = "审核通过";
                    break;

                case 3:
                    TState = "审核不通过";
                    break;
                }

                row[2] = TState;
                row[3] = Users.Mobile;
                row[4] = item.CreateAdminName;
                row[5] = item.AddTime;
                row[6] = item.AuditAdminName;
                row[7] = (item.AuditTime.HasValue ? item.AuditTime.Value.ToString() : "");
                table.Rows.Add(row);
            }
            string Time = DateTime.Now.ToString("yyyyMMddHHmmss") + new Random().Next(10, 99);

            return(this.ExportExcelBase(table, "扣款管理-" + Time));
        }