Exemple #1
0
        public async Task <IActionResult> LoadFinaceStatement(string searchText, int?stationId, string timeRange = "Today", int pageIndex = 1, int pageSize = 20)
        {
            DateTime?sTime = null, eTime = null;

            base.initialData_TimeRange(ref sTime, ref eTime, timeRange: timeRange); //时间初始化
            if (!stationId.HasValue)
            {
                stationId = UserSelf.StationId;
            }

            var dal = new CHIS.DAL.Staticstics_Finatial();
            var ds  = await dal.FinanceStatementAsync(searchText, stationId.Value, sTime.Value, eTime.Value, pageIndex, pageSize);

            var total = await dal.PayTotalAmountAsync(searchText, stationId.Value, sTime.Value, eTime.Value);

            ViewBag.TotalAmount = total;
            return(PartialView("_pvFinanceStatementList", new Ass.Mvc.PageListInfoDs(ds)));
        }
Exemple #2
0
        public async Task <IActionResult> ExportExcel_FinaceStatement(string searchText, int?stationId, int?supplierId, string timeRange = "Today")
        {
            DateTime?sTime = null, eTime = null;

            base.initialData_TimeRange(ref sTime, ref eTime, timeRange: timeRange); //时间初始化
            if (!stationId.HasValue)
            {
                stationId = UserSelf.StationId;
            }
            if (!supplierId.HasValue)
            {
                supplierId = MPS.DefaultSupplierId;
            }
            var dal = new CHIS.DAL.Staticstics_Finatial();
            var ds  = await dal.FinanceStatementAsync(searchText, stationId.Value, sTime.Value, eTime.Value, 0, 0);


            var    sName    = _db.CHIS_Code_WorkStation.FirstOrDefault(m => m.StationID == stationId).StationName;
            var    sTimeStr = sTime?.ToString("yyyyMMdd");
            var    eTimeStr = eTime?.AddDays(-1).ToString("yyyyMMdd");
            string fname    = $"{sName}收款记录_{sTimeStr}_{eTimeStr}.xlsx";

            string tableTitle = string.Format("{0:yyyy-MM-dd}至{1:yyyy-MM-dd} {2}收款记录", sTimeStr, eTimeStr, sName);

            //表头设置
            List <ExcelColumnFormat> tmap = new List <ExcelColumnFormat>
            {
                new ExcelColumnFormat("TotalAmount", "金额", null, "#.00", System.Drawing.ContentAlignment.BottomRight, "Price")
                , new ExcelColumnFormat("PayedTime", "支付时间", 18, "yyyy-MM-dd HH:mm:ss", null, "DateTime")
                , new ExcelColumnFormat("DoctorName", "医生", null)
                , new ExcelColumnFormat("CustomerName", "患者", null)
                , new ExcelColumnFormat("Gender", "性别", null)
                , new ExcelColumnFormat("StationName", "接诊工作站", 26)
                , new ExcelColumnFormat("FeeTypeCode", "支付方式")
                , new ExcelColumnFormat("sysOpMan", "操作人")
            };
            //显示的字段
            string cols = "PayedTime,StationName,TotalAmount,DoctorName,CustomerName,Gender,FeeTypeCode,sysOpMan";
            //字段的值的处理
            Func <object, string, object> tranfunc = (object val, string colKeyName) =>
            {
                switch (colKeyName)
                {
                case "Gender": return(Ass.P.PIntV(val, 2).ToGenderString());

                case "SendTime": return(Ass.P.PDateTimeV(val)?.ToStdString());
                }
                return(val);
            };
            // var fs = Code.Utility.FileUtils.DataTableToExcel(fname, ds.Tables[0], tmap, cols, tranfunc, true, "三方发药收款记录", tableTitle);
            var fs = Ass.ExcelHelper.DataTableToExcel(fname, ds.Tables[0], tmap, cols, tranfunc, true, "收款记录", tableTitle);

            if (fs != null)
            {
                return(File(fs, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fname));
            }
            else
            {
                return(Content("没有数据"));
            }
        }