Example #1
0
        public void FillData(DateTime startDate, DateTime endDate, string filepath, string filename)
        {
            var table1 = GetMonthDate(startDate, endDate);
            var excel  = new NPOIExcel();

            excel.ToExcel(table1, "1-1预处理部分", filepath, 4, 3);
            var table2 = _waterMObservationApp.GetMonthDate(startDate, endDate);

            excel.ToExcel(table2, "1-2水机", filepath, 5, 3);
        }
        public ActionResult ToExcel()
        {
            ITopClient client = new TopClientDefault();
            Dictionary <string, string> dic = new Dictionary <string, string>();
            string CompanyID = this.CompanyID;

            dic.Add("CompanyID", CompanyID);
            string result      = client.Execute(DepartApiName.DepartApiName_GetList, dic);
            string returnValue = string.Empty;

            if (!result.IsEmpty())
            {
                DataListResult <SysDepartEntity> dataResult = JsonConvert.DeserializeObject <DataListResult <SysDepartEntity> >(result);
                List <SysDepartEntity>           listResult = dataResult.Result;
                if (!listResult.IsNullOrEmpty())
                {
                    DataTable dt = new DataTable();
                    dt.Columns.Add(new DataColumn("部门名"));
                    dt.Columns.Add(new DataColumn("上级部门"));
                    dt.Columns.Add(new DataColumn("创建时间"));
                    dt.Columns.Add(new DataColumn("部门编号"));
                    foreach (SysDepartEntity t in listResult.Remove(item => item.DepartName == "Root"))
                    {
                        DataRow row = dt.NewRow();
                        row[0] = t.DepartName;
                        row[1] = t.ParentName;
                        row[2] = t.CreateTime.To("yyyy-MM-dd");
                        row[3] = t.DepartNum;
                        dt.Rows.Add(row);
                    }
                    string filePath = Server.MapPath("~/UploadFile/");
                    if (!System.IO.Directory.Exists(filePath))
                    {
                        System.IO.Directory.CreateDirectory(filePath);
                    }
                    string    filename = string.Format("部门管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmssfff"));
                    NPOIExcel excel    = new NPOIExcel("部门管理", "部门管理", System.IO.Path.Combine(filePath, filename));
                    excel.ToExcel(dt);
                    returnValue = ("/UploadFile/" + filename).Escape();
                }
            }
            DataResult returnResult = null;

            if (!returnValue.IsEmpty())
            {
                returnResult = new DataResult()
                {
                    Code = 1000, Message = returnValue
                };
            }
            else
            {
                returnResult = new DataResult()
                {
                    Code = 1001, Message = "没有任何数据导出"
                };
            }
            return(Content(JsonHelper.SerializeObject(returnResult)));
        }
Example #3
0
        public ActionResult ToExcel()
        {
            PageInfo pageInfo = new Git.Framework.DataTypes.PageInfo()
            {
                PageIndex = 1, PageSize = Int32.MaxValue
            };
            string               roleName   = WebUtil.GetFormValue <string>("roleName", string.Empty);
            SysRoleProvider      provider   = new SysRoleProvider();
            SysRoleEntity        entity     = new SysRoleEntity();
            List <SysRoleEntity> list       = provider.GetList();
            List <SysRoleEntity> listResult = new List <SysRoleEntity>();

            if (!list.IsNullOrEmpty())
            {
                listResult = list.Where(a => a.RoleNum.Contains(roleName) || a.RoleName.Contains(roleName)).OrderByDescending(a => a.ID).ToList();
            }

            if (!listResult.IsNullOrEmpty())
            {
                DataTable dt = new DataTable();
                dt.Columns.Add(new DataColumn("序号"));
                dt.Columns.Add(new DataColumn("角色编号"));
                dt.Columns.Add(new DataColumn("角色名"));
                dt.Columns.Add(new DataColumn("创建时间"));
                dt.Columns.Add(new DataColumn("备注"));
                int count = 1;
                foreach (SysRoleEntity t in listResult)
                {
                    DataRow row = dt.NewRow();
                    row[0] = count;
                    row[1] = t.RoleNum;
                    row[2] = t.RoleName;
                    row[3] = t.CreateTime;
                    row[4] = t.Remark;
                    count++;
                    dt.Rows.Add(row);
                }
                string filePath = Server.MapPath("~/UploadFiles/");
                if (!System.IO.Directory.Exists(filePath))
                {
                    System.IO.Directory.CreateDirectory(filePath);
                }
                string filename = string.Format("角色管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmss"));

                NPOIExcel excel = new NPOIExcel("角色管理", "角色", System.IO.Path.Combine(filePath, filename));
                excel.ToExcel(dt);
                this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape());
            }
            else
            {
                this.ReturnJson.AddProperty("d", "无数据导出!")
                ;
            }

            return(Content(this.ReturnJson.ToString()));
        }
Example #4
0
        public void ToExcelTest()
        {
            string    _xlsPath     = string.Format(@"D:\Employees_{0}.xls", DateTime.Now.FormatDate(12));
            DataTable _queryResult = sqlHelper.ExecuteDataTable(@"SELECT * FROM [Employees]", null);

            NPOIExcel.ToExcel(_queryResult, "Hello", "Employees", _xlsPath);
            bool _actual = File.Exists(_xlsPath);

            Assert.IsTrue(_actual);
        }
Example #5
0
        public ActionResult XFExcel(string starttime)
        {
            OrganizeApp organizeApp = new OrganizeApp();
            DataTable   dt          = new DataTable();

            dt.Columns.Add("部门");
            dt.Columns.Add("姓名");

            DateTime now = DateTime.Now;

            if (!string.IsNullOrEmpty(starttime))
            {
                now = starttime.ToDate();
            }
            now = new DateTime(now.Year, now.Month, 1);
            for (int i = 1; i <= now.AddMonths(1).AddDays(-1).Day; i++)
            {
                dt.Columns.Add(i + "日");
            }
            foreach (var item in userApp.GetList(new Pagination()
            {
                page = 1, rows = 1000, sord = "asc", sidx = "F_DepartmentId asc,F_CreatorTime desc"
            }, ""))
            {
                DataRow dr = dt.NewRow();
                dr["部门"] = organizeApp.GetForm(item.F_DepartmentId).F_FullName;
                dr["姓名"] = item.F_RealName;
                for (int i = 1; i <= now.AddMonths(1).AddDays(-1).Day; i++)
                {
                    string times = "";
                    if (!string.IsNullOrEmpty(item.F_PosCard))
                    {
                        foreach (var attr in posApp.GetList(item.F_PosCard.Trim(), new DateTime(now.Year, now.Month, i), new DateTime(now.Year, now.Month, i)))
                        {
                            times += attr.PosTime.ToString("HH:mm:ss") + "  \r\n";
                        }
                    }

                    dr[i + "日"] = times;
                }
                dt.Rows.Add(dr);
            }

            NPOIExcel npoiexel = new NPOIExcel();
            string    fileDir  = DateTime.Now.ToString("yyyyMMdd");
            string    fileName = "XF" + Guid.NewGuid().ToString("N") + ".xls";
            string    destDir  = Server.MapPath(@"/XlsTemp") + "\\" + fileDir + "\\";

            if (!Directory.Exists(destDir))
            {
                Directory.CreateDirectory(destDir);
            }
            npoiexel.ToExcel(dt, now.ToString("yyyy年MM月") + "的消费机数据", "Sheet1", destDir + fileName);
            return(Content("/XlsTemp/" + fileDir + "/" + fileName));
        }
Example #6
0
        public ActionResult Excel(DateTime?starttime, DateTime?endtime, bool?status)
        {
            NPOIExcel ex   = new NPOIExcel();
            var       data = customerTranApp.GetList(starttime, endtime, status);

            List <CustomerTransactionSimple> lst = data.Select(t => new CustomerTransactionSimple()
            {
                BillDate = t.BillDate, SourceName = t.Source, CustomerName = t.CustomerName, CustomerTelphone = t.Telphone, CustomerAddress = t.Address, TranStatus = t.TradStatus == true ? "成交" : "未成交", Remark = t.Remark
            }).ToList();

            DataTable dt = ListToDataTable <CustomerTransactionSimple>(lst);

            string filePath = Server.MapPath("~/Temp/客户跟单统计.xls");

            ex.ToExcel(dt, "客户跟单统计", "", filePath);
            return(Success("操作成功"));
        }
        public ActionResult ToCheckExcel()
        {
            string orderNum = WebUtil.GetFormValue <string>("OrderNum", string.Empty);
            List <CheckDataEntity> listResult = new CheckDataProvider().GetCheckOrder(orderNum);

            if (!listResult.IsNullOrEmpty())
            {
                DataTable dt = new DataTable();
                dt.Columns.Add(new DataColumn("库位名称"));
                dt.Columns.Add(new DataColumn("库位编号"));
                dt.Columns.Add(new DataColumn("产品编码"));
                dt.Columns.Add(new DataColumn("产品条码"));
                dt.Columns.Add(new DataColumn("产品名称"));
                dt.Columns.Add(new DataColumn("批次"));
                dt.Columns.Add(new DataColumn("盘点数"));
                foreach (CheckDataEntity t in listResult)
                {
                    DataRow row = dt.NewRow();
                    row[0] = t.LocalName;
                    row[1] = t.LocalNum;
                    row[2] = t.ProductNum;
                    row[3] = t.BarCode;
                    row[4] = t.ProductName;
                    row[5] = t.BatchNum;
                    row[6] = "";
                    dt.Rows.Add(row);
                }
                string filePath = Server.MapPath("~/UploadFiles/");
                if (!System.IO.Directory.Exists(filePath))
                {
                    System.IO.Directory.CreateDirectory(filePath);
                }
                string    filename = string.Format("盘点管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmss"));
                NPOIExcel excel    = new NPOIExcel("盘点管理", "盘点单", System.IO.Path.Combine(filePath, filename));
                excel.ToExcel(dt);
                this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape());
            }
            else
            {
                this.ReturnJson.AddProperty("d", "无数据导出!");
            }
            return(Content(this.ReturnJson.ToString()));
        }
        public ActionResult ToExcel()
        {
            int    Status    = WebUtil.GetFormValue <int>("Status", 0);
            string OrderNum  = WebUtil.GetFormValue <string>("OrderNum", string.Empty);
            string CusName   = WebUtil.GetFormValue <string>("CusName", string.Empty);
            string beginTime = WebUtil.GetFormValue <string>("beginTime", string.Empty);
            string endTime   = WebUtil.GetFormValue <string>("endTime", string.Empty);

            PageInfo pageInfo = new PageInfo()
            {
                PageIndex = 1, PageSize = int.MaxValue
            };
            OutStorageEntity entity = new OutStorageEntity();

            if (Status > 0)
            {
                entity.Where(a => a.Status == Status);
            }
            if (!OrderNum.IsEmpty())
            {
                entity.Where("OrderNum", ECondition.Like, "%" + OrderNum + "%");
            }
            if (!CusName.IsEmpty())
            {
                entity.Begin <OutStorageEntity>()
                .And <OutStorageEntity>("CusNum", ECondition.Like, "%" + CusName + "%")
                .Or <OutStorageEntity>("CusName", ECondition.Like, "%" + CusName + "%")
                .End <OutStorageEntity>()
                ;
            }
            if (!beginTime.IsEmpty() && !endTime.IsEmpty())
            {
                entity.Where("OrderTime", ECondition.Between, ConvertHelper.ToType <DateTime>(beginTime), ConvertHelper.ToType <DateTime>(endTime));
            }
            entity.And(a => a.StorageNum == this.DefaultStore);
            Bill <OutStorageEntity, OutStoDetailEntity> bill = new OutStorageOrder();
            List <OutStorageEntity> listResult = bill.GetList(entity, ref pageInfo);

            listResult = listResult == null ? new List <OutStorageEntity>() : listResult;
            if (listResult.IsNotNull())
            {
                DataTable dt = new DataTable();
                dt.Columns.Add(new DataColumn("序号 "));
                dt.Columns.Add(new DataColumn("出库单编号 "));
                dt.Columns.Add(new DataColumn("出库类型"));
                dt.Columns.Add(new DataColumn("客户名称"));
                dt.Columns.Add(new DataColumn("关联单号"));
                dt.Columns.Add(new DataColumn("总数量"));
                dt.Columns.Add(new DataColumn("总金额"));
                dt.Columns.Add(new DataColumn("状态"));
                dt.Columns.Add(new DataColumn("制单人"));
                dt.Columns.Add(new DataColumn("操作方式"));
                dt.Columns.Add(new DataColumn("创建时间"));
                int count = 1;
                foreach (OutStorageEntity t in listResult)
                {
                    DataRow row = dt.NewRow();
                    row[0]  = count;
                    row[1]  = t.OrderNum;
                    row[2]  = EnumHelper.GetEnumDesc <EOutType>(t.OutType);
                    row[3]  = t.CusName;
                    row[4]  = t.ContractOrder;
                    row[5]  = t.Num;
                    row[6]  = t.Amount;
                    row[7]  = EnumHelper.GetEnumDesc <EAudite>(t.Status);
                    row[8]  = t.CreateUserName;
                    row[9]  = EnumHelper.GetEnumDesc <EOpType>(t.OperateType);
                    row[10] = t.CreateTime.ToString("yyyy-MM-dd");
                    dt.Rows.Add(row);
                    count++;
                }
                string filePath = Server.MapPath("~/UploadFiles/");
                if (!System.IO.Directory.Exists(filePath))
                {
                    System.IO.Directory.CreateDirectory(filePath);
                }
                string    filename = string.Format("出库管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmss"));
                NPOIExcel excel    = new NPOIExcel("出库管理", "出库单", System.IO.Path.Combine(filePath, filename));
                excel.ToExcel(dt);
                this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape());
            }
            else
            {
                this.ReturnJson.AddProperty("d", "无数据导出!");
            }
            return(Content(this.ReturnJson.ToString()));
        }
Example #9
0
        public ActionResult WriteToExcel(Pagination pagination, string keyword, string starttime)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("部门");
            dt.Columns.Add("姓名");
            dt.Columns.Add("报餐情况");
            dt.Columns.Add("上班考勤");
            dt.Columns.Add("下班考勤"); dt.Columns.Add("早晨刷卡"); dt.Columns.Add("中餐刷卡"); dt.Columns.Add("晚餐刷卡"); dt.Columns.Add("扣次数");
            dt.Columns.Add("预计补助");
            DateTime now = DateTime.Now;

            if (!string.IsNullOrEmpty(starttime))
            {
                now = starttime.ToDate();
            }
            var         lists       = new List <DataStatisticsForm>();
            OrganizeApp organizeApp = new OrganizeApp();

            foreach (var item in userApp.GetList(pagination, keyword))
            {
                DataRow dr = dt.NewRow();
                dr["部门"] = organizeApp.GetForm(item.F_DepartmentId).F_FullName;

                dr["姓名"] = item.F_RealName;
                var baocan = reportApp.GetCurrentTime(item.F_Id, now, 1);
                dr["报餐情况"] = "未报";
                if (baocan != null)
                {
                    dr["报餐情况"] = "已报";
                }
                var attl = attlApp.GetCurrentTime(item.F_AttCard, now, true);
                dr["上班考勤"] = "×";
                if (attl != null)
                {
                    dr["上班考勤"] = "√";
                }
                var attl2 = attlApp.GetCurrentTime(item.F_AttCard, now, false);
                dr["下班考勤"] = "×";
                if (attl2 != null)
                {
                    dr["下班考勤"] = "√";
                }
                var pos = posApp.GetCurrentTime(item.F_PosCard, now, 0);
                dr["早晨刷卡"] = "×";
                if (pos != null)
                {
                    dr["早晨刷卡"] = "√";
                }
                var pos1 = posApp.GetCurrentTime(item.F_PosCard, now, 1);
                dr["中餐刷卡"] = "×";
                if (pos1 != null)
                {
                    dr["中餐刷卡"] = "√";
                }
                var pos2 = posApp.GetCurrentTime(item.F_PosCard, now, 2);
                dr["晚餐刷卡"] = "×";
                if (pos2 != null)
                {
                    dr["晚餐刷卡"] = "√";
                }
                int bu  = 0;
                int kou = 0;
                PosT(now, item.F_PosCard, item.F_AttCard, item.F_Id, out bu, out kou);
                dr["预计补助"] = (bu * 15).ToString();
                dr["扣次数"]  = (kou).ToString();
                dt.Rows.Add(dr);
            }
            NPOIExcel npoiexel = new NPOIExcel();
            string    fileDir  = DateTime.Now.ToString("yyyyMMdd");
            string    fileName = "G" + Guid.NewGuid().ToString("N") + ".xls";
            string    destDir  = Server.MapPath(@"/XlsTemp") + "\\" + fileDir + "\\";

            if (!Directory.Exists(destDir))
            {
                Directory.CreateDirectory(destDir);
            }
            npoiexel.ToExcel(dt, "数据", "Sheet1", destDir + fileName);
            return(Content("/XlsTemp/" + fileDir + "/" + fileName));
        }
Example #10
0
        public ActionResult ToSaleReportListExcel()
        {
            string BarCode     = WebUtil.GetFormValue <string>("BarCode");
            string ProductName = WebUtil.GetFormValue <string>("ProductName");
            string CusNum      = WebUtil.GetFormValue <string>("CusNum");
            string CusName     = WebUtil.GetFormValue <string>("CusName");
            string BeginTime   = WebUtil.GetFormValue <string>("BeginTime");
            string EndTime     = WebUtil.GetFormValue <string>("EndTime");
            int    PageIndex   = 1;
            int    PageSize    = Int32.MaxValue;

            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("CompanyID", CompanyID);
            dic.Add("BarCode", BarCode);
            dic.Add("ProductName", ProductName);
            dic.Add("CusNum", CusNum);
            dic.Add("CusName", CusName);
            dic.Add("BeginTime", BeginTime);
            dic.Add("EndTime", EndTime);
            dic.Add("PageIndex", PageIndex.ToString());
            dic.Add("PageSize", PageSize.ToString());

            ITopClient client = new TopClientDefault();

            string result      = client.Execute(SaleApiName.SaleApiName_GetDetailList, dic);
            string returnValue = string.Empty;

            if (!result.IsEmpty())
            {
                DataListResult <SaleDetailEntity> dataResult = JsonConvert.DeserializeObject <DataListResult <SaleDetailEntity> >(result);
                List <SaleDetailEntity>           listResult = dataResult.Result;
                if (!listResult.IsNullOrEmpty())
                {
                    DataTable dt = new DataTable();
                    dt.Columns.Add(new DataColumn("产品名称"));
                    dt.Columns.Add(new DataColumn("产品编号"));
                    dt.Columns.Add(new DataColumn("产品规格"));
                    dt.Columns.Add(new DataColumn("销售单号"));
                    dt.Columns.Add(new DataColumn("数量"));
                    dt.Columns.Add(new DataColumn("单价"));
                    dt.Columns.Add(new DataColumn("总价"));
                    dt.Columns.Add(new DataColumn("客户"));
                    dt.Columns.Add(new DataColumn("销售时间"));
                    foreach (SaleDetailEntity t in listResult)
                    {
                        DataRow row = dt.NewRow();
                        row[0] = t.ProductName;
                        row[1] = t.BarCode;
                        row[2] = t.Size;
                        row[3] = t.OrderNum;
                        row[4] = t.Num.ToString("0.00");
                        row[5] = t.Price.ToString("0.00");
                        row[6] = t.Amount.ToString("0.00");
                        row[7] = t.CusName;
                        row[8] = t.CreateTime.To("yyyy-MM-dd");
                        dt.Rows.Add(row);
                    }
                    string filePath = Server.MapPath("~/UploadFile/");
                    if (!System.IO.Directory.Exists(filePath))
                    {
                        System.IO.Directory.CreateDirectory(filePath);
                    }
                    string    filename = string.Format("销售详细报表{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmssfff"));
                    NPOIExcel excel    = new NPOIExcel("销售详细报表", "销售详细报表", System.IO.Path.Combine(filePath, filename));
                    excel.ToExcel(dt);
                    returnValue = ("/UploadFile/" + filename).Escape();
                }
            }
            DataResult returnResult = null;

            if (!returnValue.IsEmpty())
            {
                returnResult = new DataResult()
                {
                    Code = 1000, Message = returnValue
                };
            }
            else
            {
                returnResult = new DataResult()
                {
                    Code = 1001, Message = "没有任何数据导出"
                };
            }
            return(Content(JsonHelper.SerializeObject(returnResult)));
        }
        public ActionResult ToExcel()
        {
            int              status    = WebUtil.GetFormValue <int>("Status", 0);
            string           orderNum  = WebUtil.GetFormValue <string>("OrderNum", string.Empty);
            string           beginTime = WebUtil.GetFormValue <string>("BeginTime", string.Empty);
            string           endTime   = WebUtil.GetFormValue <string>("EndTime", string.Empty);
            CheckStockEntity entity    = new CheckStockEntity();

            if (status > 0)
            {
                entity.Where(a => a.Status == status);
            }
            if (!orderNum.IsEmpty())
            {
                entity.Where("OrderNum", ECondition.Like, "%" + orderNum + "%");
            }
            if (!beginTime.IsEmpty() && !endTime.IsEmpty())
            {
                entity.Where("CreateTime", ECondition.Between, ConvertHelper.ToType <DateTime>(beginTime, DateTime.Now.AddDays(-1)), ConvertHelper.ToType <DateTime>(endTime, DateTime.Now));
            }
            entity.And(a => a.StorageNum == this.DefaultStore);
            PageInfo pageInfo = new PageInfo()
            {
                PageIndex = 1, PageSize = Int32.MaxValue
            };
            Bill <CheckStockEntity, CheckStockInfoEntity> bill = new CheckOrder();
            List <CheckStockEntity> listResult = bill.GetList(entity, ref pageInfo);

            listResult = listResult.IsNull() ? new List <CheckStockEntity>() : listResult;
            if (!listResult.IsNullOrEmpty())
            {
                DataTable dt = new DataTable();
                dt.Columns.Add(new DataColumn("盘点单号"));
                dt.Columns.Add(new DataColumn("盘点类型"));
                dt.Columns.Add(new DataColumn("关联单号"));
                dt.Columns.Add(new DataColumn("状态"));
                dt.Columns.Add(new DataColumn("制单人"));
                dt.Columns.Add(new DataColumn("操作方式"));
                dt.Columns.Add(new DataColumn("创建时间"));
                foreach (CheckStockEntity t in listResult)
                {
                    DataRow row = dt.NewRow();
                    row[0] = t.OrderNum;
                    row[1] = EnumHelper.GetEnumDesc <ECheckType>(t.Type);
                    row[2] = t.ContractOrder;
                    row[3] = EnumHelper.GetEnumDesc <EAudite>(t.Status);
                    row[4] = t.CreateUserName;
                    row[5] = EnumHelper.GetEnumDesc <EOpType>(t.OperateType);
                    row[6] = t.CreateTime.ToString("yyyy-MM-dd");
                    dt.Rows.Add(row);
                }
                string filePath = Server.MapPath("~/UploadFiles/");
                if (!System.IO.Directory.Exists(filePath))
                {
                    System.IO.Directory.CreateDirectory(filePath);
                }
                string    filename = string.Format("盘点管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmss"));
                NPOIExcel excel    = new NPOIExcel("盘点管理", "盘点单", System.IO.Path.Combine(filePath, filename));
                excel.ToExcel(dt);
                this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape());
            }
            else
            {
                this.ReturnJson.AddProperty("d", "无数据导出!");
            }
            return(Content(this.ReturnJson.ToString()));
        }
        public ActionResult ToExcel()
        {
            ITopClient client = new TopClientDefault();
            Dictionary <string, string> dic = new Dictionary <string, string>();
            string CompanyID = this.CompanyID;
            int    PageIndex = 1;
            int    PageSize  = Int32.MaxValue;

            string BillNum     = WebUtil.GetFormValue <string>("BillNum", string.Empty);
            string CateNum     = WebUtil.GetFormValue <string>("CateNum", string.Empty);
            int    BillType    = (int)EFinanceType.BillReceivable;
            string FromName    = WebUtil.GetFormValue <string>("FromName", string.Empty);
            string ToName      = WebUtil.GetFormValue <string>("ToName", string.Empty);
            string Title       = WebUtil.GetFormValue <string>("Title", string.Empty);
            string ContractNum = WebUtil.GetFormValue <string>("ContractNum", string.Empty);
            string BeginTime   = WebUtil.GetFormValue <string>("BeginTime", string.Empty);
            string EndTime     = WebUtil.GetFormValue <string>("EndTime", string.Empty);
            int    Status      = WebUtil.GetFormValue <int>("Status", 0);

            dic.Add("CompanyID", CompanyID);
            dic.Add("PageIndex", PageIndex.ToString());
            dic.Add("PageSize", PageSize.ToString());
            dic.Add("BillNum", BillNum);
            dic.Add("CateNum", CateNum);
            dic.Add("BillType", BillType.ToString());
            dic.Add("Status", Status.ToString());
            dic.Add("FromName", FromName);
            dic.Add("ToName", ToName);
            dic.Add("Title", Title);
            dic.Add("ContractNum", ContractNum);
            dic.Add("BeginTime", BeginTime);
            dic.Add("EndTime", EndTime);

            string result = client.Execute(FinanceBillApiName.FinanceBillApiName_GetPage, dic);

            string returnValue = string.Empty;

            if (!result.IsEmpty())
            {
                DataListResult <FinanceBillEntity> dataResult = JsonConvert.DeserializeObject <DataListResult <FinanceBillEntity> >(result);
                List <FinanceBillEntity>           listResult = dataResult.Result;
                if (!listResult.IsNullOrEmpty())
                {
                    DataTable dt = new DataTable();
                    dt.Columns.Add(new DataColumn("流水号"));
                    dt.Columns.Add(new DataColumn("名称"));
                    dt.Columns.Add(new DataColumn("分类"));
                    dt.Columns.Add(new DataColumn("付款方"));
                    dt.Columns.Add(new DataColumn("应收金额"));
                    dt.Columns.Add(new DataColumn("实收金额"));
                    dt.Columns.Add(new DataColumn("剩余金额"));
                    dt.Columns.Add(new DataColumn("状态"));
                    dt.Columns.Add(new DataColumn("创建时间"));
                    foreach (FinanceBillEntity t in listResult)
                    {
                        DataRow row = dt.NewRow();
                        row[0] = t.BillNum;
                        row[1] = t.Title;
                        row[2] = t.CateName;
                        row[3] = t.FromName;
                        row[4] = t.Amount.ToString("0.00");
                        row[5] = t.RealPayAmount.ToString("0.00");
                        row[6] = t.LeavAmount.ToString("0.00");
                        row[7] = EnumHelper.GetEnumDesc <EFinanceStatus>(t.Status);
                        row[8] = t.CreateTime.To("yyyy-MM-dd");
                        dt.Rows.Add(row);
                    }
                    string filePath = Server.MapPath("~/UploadFile/");
                    if (!System.IO.Directory.Exists(filePath))
                    {
                        System.IO.Directory.CreateDirectory(filePath);
                    }
                    string    filename = string.Format("应收管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmssfff"));
                    NPOIExcel excel    = new NPOIExcel("应收管理", "应收管理", System.IO.Path.Combine(filePath, filename));
                    excel.ToExcel(dt);
                    returnValue = ("/UploadFile/" + filename).Escape();
                }
            }
            DataResult returnResult = null;

            if (!returnValue.IsEmpty())
            {
                returnResult = new DataResult()
                {
                    Code = 1000, Message = returnValue
                };
            }
            else
            {
                returnResult = new DataResult()
                {
                    Code = 1001, Message = "没有任何数据导出"
                };
            }
            return(Content(JsonHelper.SerializeObject(returnResult)));
        }
        public ActionResult ToExcel()
        {
            string CompanyID = this.CompanyID;

            int    PageIndex     = 1;
            int    PageSize      = Int32.MaxValue;
            string OrderNum      = WebUtil.GetFormValue <string>("OrderNum");
            int    OrderType     = WebUtil.GetFormValue <int>("OrderType", 0);
            string BarCode       = WebUtil.GetFormValue <string>("BarCode");
            string ProductName   = WebUtil.GetFormValue <string>("ProductName");
            string SupNum        = WebUtil.GetFormValue <string>("SupNum", string.Empty);
            string SupName       = WebUtil.GetFormValue <string>("SupName", string.Empty);
            int    Status        = WebUtil.GetFormValue <int>("Status", 0);
            int    AuditeStatus  = WebUtil.GetFormValue <int>("AuditeStatus", -1);
            string ContractOrder = WebUtil.GetFormValue <string>("ContractOrder", string.Empty);
            string BeginTime     = WebUtil.GetFormValue <string>("BeginTime", string.Empty);
            string EndTime       = WebUtil.GetFormValue <string>("EndTime", string.Empty);

            ITopClient client = new TopClientDefault();
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("CompanyID", CompanyID);
            dic.Add("PageIndex", PageIndex.ToString());
            dic.Add("PageSize", PageSize.ToString());
            dic.Add("OrderNum", OrderNum);
            dic.Add("BarCode", BarCode);
            dic.Add("ProductName", ProductName);
            dic.Add("OrderType", OrderType.ToString());
            dic.Add("SupNum", SupNum);
            dic.Add("SupName", SupName);
            dic.Add("Status", Status.ToString());
            dic.Add("AuditeStatus", AuditeStatus.ToString());
            dic.Add("ContractOrder", ContractOrder);
            dic.Add("BeginTime", BeginTime);
            dic.Add("EndTime", EndTime);

            string result = client.Execute(PurchaseApiName.PurchaseApiName_GetDetailList, dic);

            string returnValue = string.Empty;

            if (!result.IsEmpty())
            {
                DataListResult <PurchaseDetailEntity> dataResult = JsonHelper.DeserializeObject <DataListResult <PurchaseDetailEntity> >(result);
                List <PurchaseDetailEntity>           listResult = dataResult.Result;
                if (!listResult.IsNullOrEmpty())
                {
                    DataTable dt = new DataTable();
                    dt.Columns.Add(new DataColumn("订单号"));
                    dt.Columns.Add(new DataColumn("产品名称"));
                    dt.Columns.Add(new DataColumn("产品编号"));
                    dt.Columns.Add(new DataColumn("产品规格"));
                    dt.Columns.Add(new DataColumn("单价"));
                    dt.Columns.Add(new DataColumn("单位"));
                    dt.Columns.Add(new DataColumn("数量"));
                    dt.Columns.Add(new DataColumn("总额"));
                    dt.Columns.Add(new DataColumn("供应商编号"));
                    dt.Columns.Add(new DataColumn("供应商名称"));
                    dt.Columns.Add(new DataColumn("订单总额"));
                    dt.Columns.Add(new DataColumn("状态"));
                    dt.Columns.Add(new DataColumn("是否入账"));
                    dt.Columns.Add(new DataColumn("退货"));
                    dt.Columns.Add(new DataColumn("创建时间"));
                    foreach (PurchaseDetailEntity t in listResult)
                    {
                        DataRow row = dt.NewRow();
                        row[0]  = t.OrderNum;
                        row[1]  = t.ProductName;
                        row[2]  = t.BarCode;
                        row[3]  = t.Size;
                        row[4]  = t.Price;
                        row[5]  = t.UnitName;
                        row[6]  = t.Num;
                        row[7]  = t.Amount;
                        row[8]  = t.SupNum;
                        row[9]  = t.SupName;
                        row[10] = t.OrderAmount;
                        row[11] = EnumHelper.GetEnumDesc <EPurchaseStatus>(t.OrderStatus);
                        row[12] = EnumHelper.GetEnumDesc <EBool>(t.AuditeStatus);
                        row[13] = EnumHelper.GetEnumDesc <EBool>(t.HasReturn);
                        row[14] = t.CreateTime.ToString("yyyy-MM-dd");
                        dt.Rows.Add(row);
                    }
                    string filePath = Server.MapPath("~/UploadFile/");
                    if (!System.IO.Directory.Exists(filePath))
                    {
                        System.IO.Directory.CreateDirectory(filePath);
                    }
                    string    filename = string.Format("采购订单{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmssfff"));
                    NPOIExcel excel    = new NPOIExcel("采购订单", "采购订单", System.IO.Path.Combine(filePath, filename));
                    excel.ToExcel(dt);
                    returnValue = ("/UploadFile/" + filename).Escape();
                }
            }
            DataResult returnResult = null;

            if (!returnValue.IsEmpty())
            {
                returnResult = new DataResult()
                {
                    Code = 1000, Message = returnValue
                };
            }
            else
            {
                returnResult = new DataResult()
                {
                    Code = 1001, Message = "没有任何数据导出"
                };
            }
            return(Content(JsonHelper.SerializeObject(returnResult)));
        }
        public ActionResult ToExcel()
        {
            string CompanyID  = this.CompanyID;
            int    PageIndex  = WebUtil.GetFormValue <int>("PageIndex", 1);
            int    PageSize   = Int32.MaxValue;
            string ReportNum  = WebUtil.GetFormValue <string>("ReportNum");
            string ReportName = WebUtil.GetFormValue <string>("ReportName");
            int    ReportType = WebUtil.GetFormValue <int>("ReportType", 0);

            ITopClient client = new TopClientDefault();
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("CompanyID", CompanyID);
            dic.Add("PageIndex", PageIndex.ToString());
            dic.Add("PageSize", PageSize.ToString());
            dic.Add("ReportNum", ReportNum);
            dic.Add("ReportName", ReportName);
            dic.Add("ReportType", ReportType.ToString());

            string result = client.Execute(ReportApiName.ReportApiName_GetList, dic);

            string returnValue = string.Empty;

            if (!result.IsEmpty())
            {
                DataListResult <ReportsEntity> dataResult = JsonConvert.DeserializeObject <DataListResult <ReportsEntity> >(result);
                List <ReportsEntity>           listResult = dataResult.Result;
                if (!listResult.IsNullOrEmpty())
                {
                    DataTable dt = new DataTable();
                    dt.Columns.Add(new DataColumn("编号"));
                    dt.Columns.Add(new DataColumn("报表名称"));
                    dt.Columns.Add(new DataColumn("报表类型"));
                    dt.Columns.Add(new DataColumn("是否禁用"));
                    dt.Columns.Add(new DataColumn("备注"));
                    dt.Columns.Add(new DataColumn("数据源类型"));
                    dt.Columns.Add(new DataColumn("数据源"));
                    dt.Columns.Add(new DataColumn("文件路径"));
                    foreach (ReportsEntity t in listResult)
                    {
                        DataRow row = dt.NewRow();
                        row[0] = t.ReportNum;
                        row[1] = t.ReportName;
                        row[2] = EnumHelper.GetEnumDesc <EReportType>(t.ReportType);
                        row[3] = EnumHelper.GetEnumDesc <EBool>(t.Status);
                        row[4] = t.Remark;
                        row[5] = EnumHelper.GetEnumDesc <EDataSourceType>(t.DsType);
                        row[6] = t.DataSource;
                        row[7] = t.FileName;
                        dt.Rows.Add(row);
                    }
                    string filePath = Server.MapPath("~/UploadFile/");
                    if (!System.IO.Directory.Exists(filePath))
                    {
                        System.IO.Directory.CreateDirectory(filePath);
                    }
                    string    filename = string.Format("自定义报表{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmssfff"));
                    NPOIExcel excel    = new NPOIExcel("自定义报表", "报表", System.IO.Path.Combine(filePath, filename));
                    excel.ToExcel(dt);
                    returnValue = ("/UploadFile/" + filename).Escape();
                }
            }
            DataResult returnResult = null;

            if (!returnValue.IsEmpty())
            {
                returnResult = new DataResult()
                {
                    Code = 1000, Message = returnValue
                };
            }
            else
            {
                returnResult = new DataResult()
                {
                    Code = 1001, Message = "没有任何数据导出"
                };
            }
            return(Content(JsonHelper.SerializeObject(returnResult)));
        }
        public ActionResult ToExcel()
        {
            string CompanyID = this.CompanyID;

            int    PageIndex = 1;
            int    PageSize  = Int32.MaxValue;
            string CusNum    = WebUtil.GetFormValue <string>("CusNum", string.Empty);
            string CusName   = WebUtil.GetFormValue <string>("CusName", string.Empty);
            string Phone     = WebUtil.GetFormValue <string>("Phone", string.Empty);
            int    CusType   = WebUtil.GetFormValue <int>("CusType", -1);

            ITopClient client = new TopClientDefault();
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("CompanyID", CompanyID);
            dic.Add("PageIndex", PageIndex.ToString());
            dic.Add("PageSize", PageSize.ToString());
            dic.Add("CusNum", CusNum);
            dic.Add("CusName", CusName);
            dic.Add("Phone", Phone);
            dic.Add("CusType", CusType.ToString());

            string result = client.Execute(CustomerApiName.CustomerApiName_GetAddressPage, dic);

            string returnValue = string.Empty;

            if (!result.IsEmpty())
            {
                DataListResult <CusAddressEntity> dataResult = JsonConvert.DeserializeObject <DataListResult <CusAddressEntity> >(result);
                List <CusAddressEntity>           listResult = dataResult.Result;
                if (!listResult.IsNullOrEmpty())
                {
                    DataTable dt = new DataTable();
                    dt.Columns.Add(new DataColumn("客户编号"));
                    dt.Columns.Add(new DataColumn("客户名称"));
                    dt.Columns.Add(new DataColumn("地址"));
                    dt.Columns.Add(new DataColumn("联系人"));
                    dt.Columns.Add(new DataColumn("电话"));
                    dt.Columns.Add(new DataColumn("备注"));
                    dt.Columns.Add(new DataColumn("邮箱"));
                    dt.Columns.Add(new DataColumn("传真"));
                    dt.Columns.Add(new DataColumn("创建时间"));
                    foreach (CusAddressEntity t in listResult)
                    {
                        DataRow row = dt.NewRow();
                        row[0] = t.CusNum;
                        row[1] = t.CusName;
                        row[2] = t.Address;
                        row[3] = t.Contact;
                        row[4] = t.Phone;
                        row[5] = t.Remark;
                        row[6] = t.Email;
                        row[7] = t.Fax;
                        row[8] = t.CreateTime.To("yyyy-MM-dd");
                        dt.Rows.Add(row);
                    }
                    string filePath = Server.MapPath("~/UploadFile/");
                    if (!System.IO.Directory.Exists(filePath))
                    {
                        System.IO.Directory.CreateDirectory(filePath);
                    }
                    string    filename = string.Format("客户管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmssfff"));
                    NPOIExcel excel    = new NPOIExcel("客户管理", "客户", System.IO.Path.Combine(filePath, filename));
                    excel.ToExcel(dt);
                    returnValue = ("/UploadFile/" + filename).Escape();
                }
            }
            DataResult returnResult = null;

            if (!returnValue.IsEmpty())
            {
                returnResult = new DataResult()
                {
                    Code = 1000, Message = returnValue
                };
            }
            else
            {
                returnResult = new DataResult()
                {
                    Code = 1001, Message = "没有任何数据导出"
                };
            }
            return(Content(JsonHelper.SerializeObject(returnResult)));
        }
Example #16
0
        public ActionResult ToExcel()
        {
            ITopClient client = new TopClientDefault();
            Dictionary <string, string> dic = new Dictionary <string, string>();
            string CompanyID = this.CompanyID;
            int    PageIndex = 1;
            int    PageSize  = Int32.MaxValue;
            string CateName  = WebUtil.GetFormValue <string>("CateName", string.Empty);

            dic.Add("CompanyID", CompanyID);
            dic.Add("PageIndex", PageIndex.ToString());
            dic.Add("PageSize", PageSize.ToString());
            dic.Add("CateName", CateName);

            string result = client.Execute(FinanceCateApiName.FinanceCateApiName_GetPage, dic);

            string returnValue = string.Empty;

            if (!result.IsEmpty())
            {
                DataListResult <FinanceCateEntity> dataResult = JsonConvert.DeserializeObject <DataListResult <FinanceCateEntity> >(result);
                List <FinanceCateEntity>           listResult = dataResult.Result;
                if (!listResult.IsNullOrEmpty())
                {
                    DataTable dt = new DataTable();
                    dt.Columns.Add(new DataColumn("类别编号"));
                    dt.Columns.Add(new DataColumn("类别名称"));
                    dt.Columns.Add(new DataColumn("创建时间"));
                    foreach (FinanceCateEntity t in listResult)
                    {
                        DataRow row = dt.NewRow();
                        row[0] = t.CateNum;
                        row[1] = t.CateName;
                        row[2] = t.CreateTime.To("yyyy-MM-dd");
                        dt.Rows.Add(row);
                    }
                    string filePath = Server.MapPath("~/UploadFile/");
                    if (!System.IO.Directory.Exists(filePath))
                    {
                        System.IO.Directory.CreateDirectory(filePath);
                    }
                    string    filename = string.Format("财务分类管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmssfff"));
                    NPOIExcel excel    = new NPOIExcel("财务分类管理", "财务分类", System.IO.Path.Combine(filePath, filename));
                    excel.ToExcel(dt);
                    returnValue = ("/UploadFile/" + filename).Escape();
                }
            }
            DataResult returnResult = null;

            if (!returnValue.IsEmpty())
            {
                returnResult = new DataResult()
                {
                    Code = 1000, Message = returnValue
                };
            }
            else
            {
                returnResult = new DataResult()
                {
                    Code = 1001, Message = "没有任何数据导出"
                };
            }
            return(Content(JsonHelper.SerializeObject(returnResult)));
        }
        public ActionResult ToExcel()
        {
            PageInfo pageInfo = new Git.Framework.DataTypes.PageInfo()
            {
                PageIndex = 1, PageSize = Int32.MaxValue
            };
            string           StorageNum = WebUtil.GetFormValue <string>("StorageName", string.Empty);
            string           LocalName  = WebUtil.GetFormValue <string>("LocalName", string.Empty);
            string           LocalType  = WebUtil.GetFormValue <string>("LocalType", string.Empty);
            LocationProvider provider   = new LocationProvider();
            LocationEntity   entity     = new LocationEntity();

            StorageEntity SEntity = new StorageEntity();

            SEntity.Include(a => new { StorageName = a.StorageName });
            entity.Left <StorageEntity>(SEntity, new Params <string, string>()
            {
                Item1 = "StorageNum", Item2 = "StorageNum"
            });
            if (!StorageNum.IsEmpty())
            {
                entity.Where <LocationEntity>("StorageNum", ECondition.Like, "%" + StorageNum + "%");
            }
            if (!LocalName.IsEmpty())
            {
                entity.Begin <LocationEntity>()
                .Where <LocationEntity>("LocalName", ECondition.Like, "%" + LocalName + "%")
                .Or <LocationEntity>("LocalNum", ECondition.Like, "%" + LocalName + "%")
                .Or <LocationEntity>("LocalBarCode", ECondition.Like, "%" + LocalName + "%")
                .End <LocationEntity>()
                ;
            }
            if (!LocalType.IsEmpty())
            {
                entity.Where <LocationEntity>("LocalType", ECondition.Like, "%" + LocalType + "%");
            }
            List <LocationEntity> listResult = provider.GetList(entity, ref pageInfo);

            listResult = listResult.IsNull() ? new List <LocationEntity>() : listResult;
            if (listResult.IsNotNull())
            {
                DataTable dt = new DataTable();
                dt.Columns.Add(new DataColumn("序号 "));
                dt.Columns.Add(new DataColumn("库位编号 "));
                dt.Columns.Add(new DataColumn("库位名 "));
                dt.Columns.Add(new DataColumn("所在仓库 "));
                dt.Columns.Add(new DataColumn("库位类型"));
                dt.Columns.Add(new DataColumn("是否禁用"));
                dt.Columns.Add(new DataColumn("是否默认"));
                dt.Columns.Add(new DataColumn("创建时间"));
                int count = 1;
                foreach (LocationEntity t in listResult)
                {
                    DataRow row = dt.NewRow();
                    row[0] = count;
                    row[1] = t.LocalNum;
                    row[2] = t.LocalName;
                    row[3] = t.StorageName;
                    row[4] = EnumHelper.GetEnumDesc <ELocalType>(t.LocalType);
                    row[5] = EnumHelper.GetEnumDesc <EBool>(t.IsForbid);
                    row[6] = EnumHelper.GetEnumDesc <EBool>(t.IsDefault);
                    row[7] = t.CreateTime.ToString("yyyy-MM-dd");
                    dt.Rows.Add(row);
                    count++;
                }
                string filePath = Server.MapPath("~/UploadFiles/");
                if (!System.IO.Directory.Exists(filePath))
                {
                    System.IO.Directory.CreateDirectory(filePath);
                }
                string    filename = string.Format("库位管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmss"));
                NPOIExcel excel    = new NPOIExcel("库位管理", "库位", System.IO.Path.Combine(filePath, filename));
                excel.ToExcel(dt);
                this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape());
            }
            else
            {
                this.ReturnJson.AddProperty("d", "无数据导出!");
            }
            return(Content(this.ReturnJson.ToString()));
        }
Example #18
0
        public ActionResult ToExcel()
        {
            string   StorageName = WebUtil.GetFormValue <string>("StorageName", string.Empty);
            int      StorageType = WebUtil.GetFormValue <int>("StorageType", -1);
            int      IsForbid    = WebUtil.GetFormValue <int>("IsForbid", -1);
            PageInfo pageInfo    = new Git.Framework.DataTypes.PageInfo()
            {
                PageIndex = 1, PageSize = Int32.MaxValue
            };
            StorageProvider provider = new StorageProvider();
            StorageEntity   entity   = new StorageEntity();

            if (IsForbid > -1)
            {
                entity.Where <StorageEntity>("IsForbid", ECondition.Eth, IsForbid);
            }
            if (StorageType > -1)
            {
                entity.Where <StorageEntity>("StorageType", ECondition.Eth, StorageType);
            }
            if (!StorageName.IsEmpty())
            {
                entity.Begin <StorageEntity>()
                .Where <StorageEntity>("StorageName", ECondition.Like, "%" + StorageName + "%")
                .Or <StorageEntity>("StorageNum", ECondition.Like, "%" + StorageName + "%")
                .End <StorageEntity>()
                ;
            }
            List <StorageEntity> listResult = provider.GetList(entity, ref pageInfo);

            listResult = listResult.IsNull() ? new List <StorageEntity>() : listResult;
            if (listResult.IsNotNull())
            {
                DataTable dt = new DataTable();
                dt.Columns.Add(new DataColumn("序号 "));
                dt.Columns.Add(new DataColumn("仓库编号 "));
                dt.Columns.Add(new DataColumn("仓库名 "));
                dt.Columns.Add(new DataColumn("仓库类型 "));
                dt.Columns.Add(new DataColumn("是否禁用"));
                dt.Columns.Add(new DataColumn("是否默认"));
                dt.Columns.Add(new DataColumn("备注"));
                dt.Columns.Add(new DataColumn("创建时间"));
                int count = 1;
                foreach (StorageEntity t in listResult)
                {
                    DataRow row = dt.NewRow();
                    row[0] = count;
                    row[1] = t.StorageNum;
                    row[2] = t.StorageName;
                    row[3] = EnumHelper.GetEnumDesc <EStorageType>(t.StorageType);
                    row[4] = EnumHelper.GetEnumDesc <EBool>(t.IsForbid);
                    row[5] = EnumHelper.GetEnumDesc <EBool>(t.IsDefault);
                    row[6] = t.Remark;
                    row[7] = t.CreateTime.ToString("yyyy-MM-dd");
                    dt.Rows.Add(row);
                    count++;
                }
                string filePath = Server.MapPath("~/UploadFiles/");
                if (!System.IO.Directory.Exists(filePath))
                {
                    System.IO.Directory.CreateDirectory(filePath);
                }
                string    filename = string.Format("仓库管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmss"));
                NPOIExcel excel    = new NPOIExcel("仓库管理", "仓库", System.IO.Path.Combine(filePath, filename));
                excel.ToExcel(dt);
                this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape());
            }
            else
            {
                this.ReturnJson.AddProperty("d", "无数据导出!");
            }
            return(Content(this.ReturnJson.ToString()));
        }
        /// <summary>
        /// 导出Excel
        /// </summary>
        /// <returns></returns>
        public ActionResult ToExcel()
        {
            int      status    = WebUtil.GetFormValue <int>("Status", 0);
            string   orderNum  = WebUtil.GetFormValue <string>("OrderNum", string.Empty);
            string   supName   = WebUtil.GetFormValue <string>("SupName", string.Empty);
            string   beginTime = WebUtil.GetFormValue <string>("beginTime", string.Empty);
            string   endTime   = WebUtil.GetFormValue <string>("endTime", string.Empty);
            int      pageSize  = Int32.MaxValue;
            int      pageIndex = 1;
            PageInfo pageInfo  = new PageInfo()
            {
                PageIndex = pageIndex, PageSize = pageSize
            };
            InStorageEntity entity = new InStorageEntity();

            if (status > 0)
            {
                entity.Where(a => a.Status == status);
            }
            if (!orderNum.IsEmpty())
            {
                entity.Where("OrderNum", ECondition.Like, "%" + orderNum + "%");
            }
            if (!supName.IsEmpty())
            {
                entity.AndBegin <InStorageEntity>()
                .And <InStorageEntity>("SupNum", ECondition.Like, "%" + supName + "%")
                .Or <InStorageEntity>("SupName", ECondition.Like, "%" + supName + "%")
                .End <InStorageEntity>()
                ;
            }
            if (!beginTime.IsEmpty() && !endTime.IsEmpty())
            {
                entity.Where("OrderTime", ECondition.Between, ConvertHelper.ToType <DateTime>(beginTime), ConvertHelper.ToType <DateTime>(endTime));
            }
            Bill <InStorageEntity, InStorDetailEntity> bill = new InStorageOrder();
            List <InStorageEntity> listResult = bill.GetList(entity, ref pageInfo);

            listResult = listResult == null ? new List <InStorageEntity>() : listResult;
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("入库单单号"));
            dt.Columns.Add(new DataColumn("入库类型"));
            dt.Columns.Add(new DataColumn("供应商"));
            dt.Columns.Add(new DataColumn("关联单号"));
            dt.Columns.Add(new DataColumn("货品总数"));
            dt.Columns.Add(new DataColumn("总金额"));
            dt.Columns.Add(new DataColumn("状态"));
            dt.Columns.Add(new DataColumn("制单人"));
            dt.Columns.Add(new DataColumn("操作方式"));
            dt.Columns.Add(new DataColumn("创建时间"));
            foreach (InStorageEntity t in listResult)
            {
                DataRow row = dt.NewRow();
                row[0] = t.OrderNum;
                row[1] = EnumHelper.GetEnumDesc <EInType>(t.InType);
                row[2] = t.SupName;
                row[3] = t.ContractOrder;
                row[4] = t.Num;
                row[5] = t.Amount.ToString("0.00") + " 元";
                row[6] = EnumHelper.GetEnumDesc <EAudite>(t.Status);
                row[7] = t.CreateUserName;
                row[8] = EnumHelper.GetEnumDesc <EOpType>(t.OperateType);
                row[9] = t.OrderTime.ToString("yyyy-MM-dd");
                dt.Rows.Add(row);
            }
            string filePath = Server.MapPath("~/UploadFiles/");

            if (!System.IO.Directory.Exists(filePath))
            {
                System.IO.Directory.CreateDirectory(filePath);
            }
            string    filename = string.Format("入库单{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmss"));
            NPOIExcel excel    = new NPOIExcel("入库管理", "入库单", System.IO.Path.Combine(filePath, filename));

            excel.ToExcel(dt);
            this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape());

            return(Content(this.ReturnJson.ToString()));
        }
        public ActionResult ToExcel()
        {
            string CompanyID = this.CompanyID;

            int    PageIndex     = 1;
            int    PageSize      = Int32.MaxValue;
            string OrderNum      = WebUtil.GetFormValue <string>("OrderNum");
            int    Status        = WebUtil.GetFormValue <int>("Status", 0);
            string ContractOrder = WebUtil.GetFormValue <string>("ContractOrder", string.Empty);
            string BeginTime     = WebUtil.GetFormValue <string>("BeginTime", string.Empty);
            string EndTime       = WebUtil.GetFormValue <string>("EndTime", string.Empty);

            ITopClient client = new TopClientDefault();
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("CompanyID", CompanyID);
            dic.Add("PageIndex", PageIndex.ToString());
            dic.Add("PageSize", PageSize.ToString());
            dic.Add("OrderNum", OrderNum);
            dic.Add("StorageNum", this.DefaultStorageNum);
            dic.Add("Status", Status.ToString());
            dic.Add("ContractOrder", ContractOrder);
            dic.Add("BeginTime", BeginTime);
            dic.Add("EndTime", EndTime);

            string result = client.Execute(CheckApiName.CheckApiName_GetOrderList, dic);

            string returnValue = string.Empty;

            if (!result.IsEmpty())
            {
                DataListResult <InventoryOrderEntity> dataResult = JsonConvert.DeserializeObject <DataListResult <InventoryOrderEntity> >(result);
                List <InventoryOrderEntity>           listResult = dataResult.Result;
                if (!listResult.IsNullOrEmpty())
                {
                    DataTable dt = new DataTable();
                    dt.Columns.Add(new DataColumn("盘点单号"));
                    dt.Columns.Add(new DataColumn("盘点类型"));
                    dt.Columns.Add(new DataColumn("关联单号"));
                    dt.Columns.Add(new DataColumn("状态"));
                    dt.Columns.Add(new DataColumn("制单人"));
                    dt.Columns.Add(new DataColumn("制单时间"));
                    foreach (InventoryOrderEntity t in listResult)
                    {
                        DataRow row = dt.NewRow();
                        row[0] = t.OrderNum;
                        row[1] = EnumHelper.GetEnumDesc <ECheckType>(t.Type);
                        row[2] = t.ContractOrder;
                        row[3] = EnumHelper.GetEnumDesc <EAudite>(t.Status);
                        row[4] = t.CreateUserName;
                        row[5] = t.CreateTime.To("yyyy-MM-dd");
                        dt.Rows.Add(row);
                    }
                    string filePath = Server.MapPath("~/UploadFile/");
                    if (!System.IO.Directory.Exists(filePath))
                    {
                        System.IO.Directory.CreateDirectory(filePath);
                    }
                    string    filename = string.Format("盘点管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmssfff"));
                    NPOIExcel excel    = new NPOIExcel("盘点管理", "盘点单", System.IO.Path.Combine(filePath, filename));
                    excel.ToExcel(dt);
                    returnValue = ("/UploadFile/" + filename).Escape();
                }
            }
            DataResult returnResult = null;

            if (!returnValue.IsEmpty())
            {
                returnResult = new DataResult()
                {
                    Code = 1000, Message = returnValue
                };
            }
            else
            {
                returnResult = new DataResult()
                {
                    Code = 1001, Message = "没有任何数据导出"
                };
            }
            return(Content(JsonHelper.SerializeObject(returnResult)));
        }
Example #21
0
        public static bool DataTableToExcel(DataTable dt, string title, string sheetName, string path)
        {
            NPOIExcel excel = new NPOIExcel();

            return(excel.ToExcel(dt, title, sheetName, path));
        }
Example #22
0
        public ActionResult ToExcel()
        {
            PageInfo pageInfo = new Git.Framework.DataTypes.PageInfo()
            {
                PageIndex = 1, PageSize = Int32.MaxValue
            };
            string          ProductName = WebUtil.GetFormValue <string>("ProductName", string.Empty);
            int             pageIndex   = WebUtil.GetFormValue <int>("pageIndex", 0);
            int             pageSize    = WebUtil.GetFormValue <int>("pageSize", 0);
            string          CateNum     = WebUtil.GetFormValue <string>("CateNum", string.Empty);
            ProductProvider provider    = new ProductProvider();
            ProductEntity   entity      = new ProductEntity();

            if (!ProductName.IsEmpty())
            {
                entity.Where <ProductEntity>("ProductName", ECondition.Like, "%" + ProductName + "%");
            }
            if (!CateNum.IsEmpty())
            {
                entity.Where <ProductEntity>("CateNum", ECondition.Eth, CateNum);
            }
            List <ProductEntity> listResult = provider.GetList(entity, ref pageInfo);

            listResult = listResult.IsNull() ? new List <ProductEntity>() : listResult;
            if (listResult.IsNotNull())
            {
                DataTable dt = new DataTable();
                dt.Columns.Add(new DataColumn("序号 "));
                dt.Columns.Add(new DataColumn("产品编号"));
                dt.Columns.Add(new DataColumn("条码编号"));
                dt.Columns.Add(new DataColumn("产品名称"));
                dt.Columns.Add(new DataColumn("类别名称"));
                dt.Columns.Add(new DataColumn("库存数"));
                dt.Columns.Add(new DataColumn("预警值下线"));
                dt.Columns.Add(new DataColumn("预警值上线"));
                dt.Columns.Add(new DataColumn("单位"));
                dt.Columns.Add(new DataColumn("平均价格"));
                dt.Columns.Add(new DataColumn("进口价格"));
                dt.Columns.Add(new DataColumn("出口价格"));
                dt.Columns.Add(new DataColumn("净重"));
                dt.Columns.Add(new DataColumn("毛重"));
                dt.Columns.Add(new DataColumn("备注"));
                int count = 1;
                foreach (ProductEntity t in listResult)
                {
                    DataRow row = dt.NewRow();
                    row[0]  = count;
                    row[1]  = t.SnNum;
                    row[2]  = t.BarCode;
                    row[3]  = t.ProductName;
                    row[4]  = t.CateName;
                    row[5]  = t.Num;
                    row[6]  = t.MinNum;
                    row[7]  = t.MaxNum;
                    row[8]  = t.UnitName;
                    row[9]  = t.AvgPrice;
                    row[10] = t.InPrice;
                    row[11] = t.OutPrice;
                    row[12] = t.NetWeight.ToString();
                    row[13] = t.GrossWeight.ToString();
                    row[14] = t.Remark;
                    dt.Rows.Add(row);
                    count++;
                }
                string filePath = Server.MapPath("~/UploadFiles/");
                if (!System.IO.Directory.Exists(filePath))
                {
                    System.IO.Directory.CreateDirectory(filePath);
                }
                string    filename = string.Format("产品管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmss"));
                NPOIExcel excel    = new NPOIExcel("产品管理", "产品", System.IO.Path.Combine(filePath, filename));
                excel.ToExcel(dt);
                this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape());
            }
            else
            {
                this.ReturnJson.AddProperty("d", "无数据导出!");
            }
            return(Content(this.ReturnJson.ToString()));
        }
Example #23
0
        public ActionResult ToExcel()
        {
            ITopClient client = new TopClientDefault();
            Dictionary <string, string> dic = new Dictionary <string, string>();
            string CompanyID = this.CompanyID;
            int    PageIndex = WebUtil.GetFormValue <int>("PageIndex", 1);
            int    PageSize  = WebUtil.GetFormValue <int>("PageSize", Int32.MaxValue);

            string EquipmentName = WebUtil.GetFormValue <string>("EquipmentName");
            string Remark        = WebUtil.GetFormValue <string>("Remark", string.Empty);
            string EquipmentNum  = WebUtil.GetFormValue <string>("EquipmentNum", string.Empty);
            int    Status        = WebUtil.GetFormValue <int>("Status", 0);

            dic.Add("CompanyID", CompanyID);
            dic.Add("PageIndex", PageIndex.ToString());
            dic.Add("PageSize", PageSize.ToString());
            dic.Add("EquipmentName", EquipmentName);
            dic.Add("Remark", Remark);
            dic.Add("EquipmentNum", EquipmentNum);
            dic.Add("Status", Status.ToString());

            string result = client.Execute(EquipmentApiName.EquipmentApiName_GetPage, dic);

            string returnValue = string.Empty;

            if (!result.IsEmpty())
            {
                DataListResult <EquipmentEntity> dataResult = JsonConvert.DeserializeObject <DataListResult <EquipmentEntity> >(result);
                List <EquipmentEntity>           listResult = dataResult.Result;
                if (!listResult.IsNullOrEmpty())
                {
                    DataTable dt = new DataTable();
                    dt.Columns.Add(new DataColumn("编号"));
                    dt.Columns.Add(new DataColumn("名称"));
                    dt.Columns.Add(new DataColumn("是否授权"));
                    dt.Columns.Add(new DataColumn("授权标识符"));
                    dt.Columns.Add(new DataColumn("状态"));
                    dt.Columns.Add(new DataColumn("备注"));
                    foreach (EquipmentEntity t in listResult)
                    {
                        DataRow row = dt.NewRow();
                        row[0] = t.EquipmentNum;
                        row[1] = t.EquipmentName;
                        row[2] = EnumHelper.GetEnumDesc <EBool>(t.IsImpower);
                        row[3] = t.Flag;
                        row[4] = EnumHelper.GetEnumDesc <EEquipmentStatus>(t.Status);
                        row[5] = t.Remark;
                        dt.Rows.Add(row);
                    }
                    string filePath = Server.MapPath("~/UploadFile/");
                    if (!System.IO.Directory.Exists(filePath))
                    {
                        System.IO.Directory.CreateDirectory(filePath);
                    }
                    string    filename = string.Format("设备管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmssfff"));
                    NPOIExcel excel    = new NPOIExcel("设备管理", "设备管理", System.IO.Path.Combine(filePath, filename));
                    excel.ToExcel(dt);
                    returnValue = ("/UploadFile/" + filename).Escape();
                }
            }
            DataResult returnResult = null;

            if (!returnValue.IsEmpty())
            {
                returnResult = new DataResult()
                {
                    Code = 1000, Message = returnValue
                };
            }
            else
            {
                returnResult = new DataResult()
                {
                    Code = 1001, Message = "没有任何数据导出"
                };
            }
            return(Content(JsonHelper.SerializeObject(returnResult)));
        }
        public ActionResult ToExcel()
        {
            string BarCode     = WebUtil.GetFormValue <string>("BarCode");
            string ProductName = WebUtil.GetFormValue <string>("ProductName");
            string BatchNum    = WebUtil.GetFormValue <string>("BatchNum");
            string StorageNum  = WebUtil.GetFormValue <string>("StorageNum");
            string Day         = WebUtil.GetFormValue <string>("Day");

            int PageIndex = WebUtil.GetFormValue <int>("PageIndex", 1);
            int PageSize  = WebUtil.GetFormValue <int>("PageSize", 10);

            ITopClient client = new TopClientDefault();
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("CompanyID", CompanyID);
            dic.Add("PageIndex", PageIndex.ToString());
            dic.Add("PageSize", PageSize.ToString());
            dic.Add("BarCode", BarCode);
            dic.Add("ProductName", ProductName);
            dic.Add("BatchNum", BatchNum);
            dic.Add("StorageNum", StorageNum);
            dic.Add("Day", Day);

            string result = client.Execute(BalanceBookApiName.BalanceBookApiName_GetList, dic);

            string returnValue = string.Empty;

            if (!result.IsEmpty())
            {
                DataListResult <BalanceBookEntity> dataResult = JsonHelper.DeserializeObject <DataListResult <BalanceBookEntity> >(result);
                List <BalanceBookEntity>           listResult = dataResult.Result;
                if (!listResult.IsNullOrEmpty())
                {
                    DataTable dt = new DataTable();
                    dt.Columns.Add(new DataColumn("日期"));
                    dt.Columns.Add(new DataColumn("产品名称"));
                    dt.Columns.Add(new DataColumn("产品编号"));
                    dt.Columns.Add(new DataColumn("产品规格"));
                    dt.Columns.Add(new DataColumn("产品批次"));
                    dt.Columns.Add(new DataColumn("单位"));
                    dt.Columns.Add(new DataColumn("仓库"));
                    dt.Columns.Add(new DataColumn("期初"));
                    dt.Columns.Add(new DataColumn("入库"));
                    dt.Columns.Add(new DataColumn("出库"));
                    dt.Columns.Add(new DataColumn("期末"));
                    foreach (BalanceBookEntity t in listResult)
                    {
                        DataRow row = dt.NewRow();
                        row[0]  = t.Day;
                        row[1]  = t.ProductName;
                        row[2]  = t.BarCode;
                        row[3]  = t.Size;
                        row[4]  = t.BatchNum;
                        row[5]  = t.UnitName;
                        row[6]  = t.StorageName;
                        row[7]  = t.BeginNum;
                        row[8]  = t.InNum;
                        row[9]  = t.OutNum;
                        row[10] = t.EndNum;
                        dt.Rows.Add(row);
                    }
                    string filePath = Server.MapPath("~/UploadFile/");
                    if (!System.IO.Directory.Exists(filePath))
                    {
                        System.IO.Directory.CreateDirectory(filePath);
                    }
                    string    filename = string.Format("期初期末{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmssfff"));
                    NPOIExcel excel    = new NPOIExcel("期初期末", "期初期末", System.IO.Path.Combine(filePath, filename));
                    excel.ToExcel(dt);
                    returnValue = ("/UploadFile/" + filename).Escape();
                }
            }
            DataResult returnResult = null;

            if (!returnValue.IsEmpty())
            {
                returnResult = new DataResult()
                {
                    Code = 1000, Message = returnValue
                };
            }
            else
            {
                returnResult = new DataResult()
                {
                    Code = 1001, Message = "没有任何数据导出"
                };
            }
            return(Content(JsonHelper.SerializeObject(returnResult)));
        }
        public ActionResult ToExcel()
        {
            int      Status      = WebUtil.GetFormValue <int>("Status", 0);
            string   OrderNum    = WebUtil.GetFormValue <string>("OrderNum", string.Empty);
            string   BadType     = WebUtil.GetFormValue <string>("BadType", string.Empty);
            string   ProductType = WebUtil.GetFormValue <string>("ProductType", string.Empty);
            string   beginTime   = WebUtil.GetFormValue <string>("beginTime", string.Empty);
            string   endTime     = WebUtil.GetFormValue <string>("endTime", string.Empty);
            int      pageSize    = WebUtil.GetFormValue <int>("PageSize", 10);
            int      pageIndex   = WebUtil.GetFormValue <int>("PageIndex", 1);
            PageInfo pageInfo    = new PageInfo()
            {
                PageIndex = pageIndex, PageSize = pageSize
            };
            BadReportEntity entity = new BadReportEntity();

            if (Status > 0)
            {
                entity.Where(a => a.Status == Status);
            }
            if (!OrderNum.IsEmpty())
            {
                entity.Where("OrderNum", ECondition.Like, "%" + OrderNum + "%");
            }
            if (!ProductType.IsEmpty())
            {
                entity.Where("ProductType", ECondition.Eth, ProductType);
            }
            if (!BadType.IsEmpty())
            {
                entity.Where("BadType", ECondition.Eth, BadType);
            }
            if (!beginTime.IsEmpty() && !endTime.IsEmpty())
            {
                entity.Where("CreateTime", ECondition.Between, ConvertHelper.ToType <DateTime>(beginTime), ConvertHelper.ToType <DateTime>(endTime));
            }
            entity.And(a => a.StorageNum == this.DefaultStore);
            Bill <BadReportEntity, BadReportDetailEntity> bill = new BadOrder();
            List <BadReportEntity> listResult = bill.GetList(entity, ref pageInfo);

            if (!listResult.IsNullOrEmpty())
            {
                DataTable dt = new DataTable();
                dt.Columns.Add(new DataColumn("序号 "));
                dt.Columns.Add(new DataColumn("单据编号"));
                dt.Columns.Add(new DataColumn("报损类型"));
                dt.Columns.Add(new DataColumn("关联单号"));
                dt.Columns.Add(new DataColumn("报损数量"));
                dt.Columns.Add(new DataColumn("状态"));
                dt.Columns.Add(new DataColumn("操作方式"));
                dt.Columns.Add(new DataColumn("创建人"));
                dt.Columns.Add(new DataColumn("创建时间"));
                int count = 1;
                foreach (BadReportEntity t in listResult)
                {
                    DataRow row = dt.NewRow();
                    row[0] = count;
                    row[1] = t.OrderNum;
                    row[2] = EnumHelper.GetEnumDesc <EBadType>(t.BadType);
                    row[3] = t.ContractOrder;
                    row[4] = t.Num;
                    row[5] = EnumHelper.GetEnumDesc <EAudite>(t.Status);
                    row[6] = EnumHelper.GetEnumDesc <EOpType>(t.OperateType);
                    row[7] = t.CreateUser;
                    row[8] = t.CreateTime.ToString("yyyy-MM-dd");
                    dt.Rows.Add(row);
                    count++;
                }
                string filePath = Server.MapPath("~/UploadFiles/");
                if (!System.IO.Directory.Exists(filePath))
                {
                    System.IO.Directory.CreateDirectory(filePath);
                }
                string    filename = string.Format("报损管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmss"));
                NPOIExcel excel    = new NPOIExcel("报损管理", "报损单", System.IO.Path.Combine(filePath, filename));
                excel.ToExcel(dt);
                this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape());
            }
            else
            {
                this.ReturnJson.AddProperty("d", "无数据导出!");
            }
            return(Content(this.ReturnJson.ToString()));
        }
        public ActionResult ToExcel()
        {
            ITopClient client = new TopClientDefault();
            Dictionary <string, string> dic = new Dictionary <string, string>();
            string CompanyID = this.CompanyID;
            int    PageIndex = WebUtil.GetFormValue <int>("PageIndex", 1);
            int    PageSize  = WebUtil.GetFormValue <int>("PageSize", 10);

            string BarCode      = WebUtil.GetFormValue <string>("BarCode");
            string ProductName  = WebUtil.GetFormValue <string>("ProductName");
            string UnitNum      = WebUtil.GetFormValue <string>("UnitNum");
            string CateNum      = WebUtil.GetFormValue <string>("CateNum");
            string Size         = WebUtil.GetFormValue <string>("Size");
            string Color        = WebUtil.GetFormValue <string>("Color");
            string StorageNum   = WebUtil.GetFormValue <string>("StorageNum");
            string DefaultLocal = WebUtil.GetFormValue <string>("DefaultLocal");
            string CusNum       = WebUtil.GetFormValue <string>("CusNum");
            string SupNum       = WebUtil.GetFormValue <string>("SupNum");
            string Display      = WebUtil.GetFormValue <string>("Display");
            string Remark       = WebUtil.GetFormValue <string>("Remark");

            dic.Add("CompanyID", CompanyID);
            dic.Add("PageIndex", PageIndex.ToString());
            dic.Add("PageSize", PageSize.ToString());
            dic.Add("BarCode", BarCode);
            dic.Add("ProductName", ProductName);
            dic.Add("UnitNum", UnitNum);
            dic.Add("CateNum", CateNum);
            dic.Add("Size", Size);
            dic.Add("Color", Color);
            dic.Add("StorageNum", StorageNum);
            dic.Add("DefaultLocal", DefaultLocal);
            dic.Add("CusNum", CusNum);
            dic.Add("SupNum", SupNum);
            dic.Add("Display", Display);
            dic.Add("Remark", Remark);

            string result = client.Execute(ProductApiName.ProductApiName_GetPage, dic);

            string returnValue = string.Empty;

            if (!result.IsEmpty())
            {
                DataListResult <ProductEntity> dataResult = JsonConvert.DeserializeObject <DataListResult <ProductEntity> >(result);
                List <ProductEntity>           listResult = dataResult.Result;
                if (!listResult.IsNullOrEmpty())
                {
                    DataTable dt = new DataTable();
                    dt.Columns.Add(new DataColumn("产品编号"));
                    dt.Columns.Add(new DataColumn("产品名称"));
                    dt.Columns.Add(new DataColumn("厂商编码"));
                    dt.Columns.Add(new DataColumn("内部编码"));
                    dt.Columns.Add(new DataColumn("规格"));
                    dt.Columns.Add(new DataColumn("类别"));
                    dt.Columns.Add(new DataColumn("存储单位"));
                    dt.Columns.Add(new DataColumn("预警(下)"));
                    dt.Columns.Add(new DataColumn("预警(上)"));
                    dt.Columns.Add(new DataColumn("包装类型"));
                    dt.Columns.Add(new DataColumn("价格"));
                    dt.Columns.Add(new DataColumn("重量"));
                    dt.Columns.Add(new DataColumn("显示名"));
                    dt.Columns.Add(new DataColumn("默认供应商"));
                    dt.Columns.Add(new DataColumn("默认客户"));
                    dt.Columns.Add(new DataColumn("备注"));
                    foreach (ProductEntity t in listResult)
                    {
                        DataRow row = dt.NewRow();
                        row[0]  = t.BarCode;
                        row[1]  = t.ProductName;
                        row[2]  = t.FactoryNum;
                        row[3]  = t.InCode;
                        row[4]  = t.Size;
                        row[5]  = t.CateName;
                        row[6]  = t.UnitName;
                        row[7]  = t.MinNum;
                        row[8]  = t.MaxNum;
                        row[9]  = EnumHelper.GetEnumDesc <EProductPackage>(t.IsSingle);
                        row[10] = t.AvgPrice;
                        row[11] = t.NetWeight;
                        row[12] = t.Display;
                        row[13] = t.SupName;
                        row[14] = t.CusName;
                        row[15] = t.Remark;
                        dt.Rows.Add(row);
                    }
                    string filePath = Server.MapPath("~/UploadFile/");
                    if (!System.IO.Directory.Exists(filePath))
                    {
                        System.IO.Directory.CreateDirectory(filePath);
                    }
                    string    filename = string.Format("产品管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmssfff"));
                    NPOIExcel excel    = new NPOIExcel("产品管理", "产品", System.IO.Path.Combine(filePath, filename));
                    excel.ToExcel(dt);
                    returnValue = ("/UploadFile/" + filename).Escape();
                }
            }
            DataResult returnResult = null;

            if (!returnValue.IsEmpty())
            {
                returnResult = new DataResult()
                {
                    Code = 1000, Message = returnValue
                };
            }
            else
            {
                returnResult = new DataResult()
                {
                    Code = 1001, Message = "没有任何数据导出"
                };
            }
            return(Content(JsonHelper.SerializeObject(returnResult)));
        }
        public ActionResult ToExcel()
        {
            string BarCode        = WebUtil.GetFormValue <string>("BarCode", string.Empty);
            string ProductName    = WebUtil.GetFormValue <string>("ProductName", string.Empty);
            string BatchNum       = WebUtil.GetFormValue <string>("BatchNum", string.Empty);
            int    Type           = WebUtil.GetFormValue <int>("Type", 0);
            string FromStorageNum = WebUtil.GetFormValue <string>("FromStorageNum");
            string OrderNum       = WebUtil.GetFormValue <string>("OrderNum");
            string ContactOrder   = WebUtil.GetFormValue <string>("ContactOrder");
            string BeginTime      = WebUtil.GetFormValue <string>("BeginTime");
            string EndTime        = WebUtil.GetFormValue <string>("EndTime");

            int PageIndex = 1;
            int PageSize  = Int32.MaxValue;

            ITopClient client = new TopClientDefault();
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("CompanyID", CompanyID);
            dic.Add("PageIndex", PageIndex.ToString());
            dic.Add("PageSize", PageSize.ToString());
            dic.Add("BarCode", BarCode);
            dic.Add("ProductName", ProductName);
            dic.Add("BatchNum", BatchNum);
            dic.Add("Type", Type.ToString());
            dic.Add("FromStorageNum", FromStorageNum);
            dic.Add("OrderNum", OrderNum);
            dic.Add("ContactOrder", ContactOrder);
            dic.Add("BeginTime", BeginTime);
            dic.Add("EndTime", EndTime);

            string result = client.Execute(InventoryApiName.InventoryApiName_GetList, dic);

            string returnValue = string.Empty;

            if (!result.IsEmpty())
            {
                DataListResult <InventoryBookEntity> dataResult = JsonHelper.DeserializeObject <DataListResult <InventoryBookEntity> >(result);
                List <InventoryBookEntity>           listResult = dataResult.Result;
                if (!listResult.IsNullOrEmpty())
                {
                    DataTable dt = new DataTable();
                    dt.Columns.Add(new DataColumn("产品名称"));
                    dt.Columns.Add(new DataColumn("产品编号"));
                    dt.Columns.Add(new DataColumn("产品规格"));
                    dt.Columns.Add(new DataColumn("产品批次"));
                    dt.Columns.Add(new DataColumn("类型"));
                    dt.Columns.Add(new DataColumn("数量"));
                    dt.Columns.Add(new DataColumn("单位"));
                    dt.Columns.Add(new DataColumn("原仓库"));
                    dt.Columns.Add(new DataColumn("原库位"));
                    dt.Columns.Add(new DataColumn("目标仓库"));
                    dt.Columns.Add(new DataColumn("目标库位"));
                    dt.Columns.Add(new DataColumn("日期"));
                    foreach (InventoryBookEntity t in listResult)
                    {
                        DataRow row = dt.NewRow();
                        row[0]  = t.ProductName;
                        row[1]  = t.BarCode;
                        row[2]  = t.Size;
                        row[3]  = t.BatchNum;
                        row[4]  = EnumHelper.GetEnumDesc <EChange>(t.Type);
                        row[5]  = t.Num;
                        row[6]  = t.UnitName;
                        row[7]  = t.FromStorageName;
                        row[8]  = t.FromLocalName;
                        row[9]  = t.ToStorageName;
                        row[10] = t.ToLocalName;
                        row[11] = t.CreateTime.To("yyyy-MM-dd");
                        dt.Rows.Add(row);
                    }
                    string filePath = Server.MapPath("~/UploadFile/");
                    if (!System.IO.Directory.Exists(filePath))
                    {
                        System.IO.Directory.CreateDirectory(filePath);
                    }
                    string    filename = string.Format("库存台账{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmssfff"));
                    NPOIExcel excel    = new NPOIExcel("库存台账", "库存台账", System.IO.Path.Combine(filePath, filename));
                    excel.ToExcel(dt);
                    returnValue = ("/UploadFile/" + filename).Escape();
                }
            }
            DataResult returnResult = null;

            if (!returnValue.IsEmpty())
            {
                returnResult = new DataResult()
                {
                    Code = 1000, Message = returnValue
                };
            }
            else
            {
                returnResult = new DataResult()
                {
                    Code = 1001, Message = "没有任何数据导出"
                };
            }
            return(Content(JsonHelper.SerializeObject(returnResult)));
        }
Example #28
0
        public ActionResult ToExcel()
        {
            DataResult returnResult         = null;
            ITopClient client               = new TopClientDefault();
            Dictionary <string, string> dic = new Dictionary <string, string>();

            string CompanyID = this.CompanyID;
            int    PageIndex = 1;
            int    PageSize  = Int32.MaxValue;

            string StorageNum  = WebUtil.GetFormValue <string>("StorageNum");
            string StorageName = WebUtil.GetFormValue <string>("StorageName", string.Empty);
            string StorageType = WebUtil.GetFormValue <string>("StorageType", string.Empty);
            string DepartNum   = WebUtil.GetFormValue <string>("DepartNum", string.Empty);
            int    Status      = WebUtil.GetFormValue <int>("Status", 0);
            int    IsForbid    = WebUtil.GetFormValue <int>("IsForbid", -1);
            int    IsDefault   = WebUtil.GetFormValue <int>("IsDefault", -1);

            dic.Add("CompanyID", CompanyID);
            dic.Add("PageIndex", PageIndex.ToString());
            dic.Add("PageSize", PageSize.ToString());
            dic.Add("StorageNum", StorageNum);
            dic.Add("StorageName", StorageName);
            dic.Add("StorageType", StorageType);
            dic.Add("DepartNum", DepartNum);
            dic.Add("Status", Status.ToString());
            dic.Add("IsForbid", IsForbid.ToString());
            dic.Add("IsDefault", IsDefault.ToString());

            string result      = client.Execute(StorageApiName.StorageApiName_GetPage, dic);
            string returnValue = string.Empty;

            if (!result.IsEmpty())
            {
                DataListResult <StorageEntity> dataResult = JsonHelper.DeserializeObject <DataListResult <StorageEntity> >(result);
                List <StorageEntity>           listResult = dataResult.Result;
                if (!listResult.IsNullOrEmpty())
                {
                    DataTable dt = new DataTable();
                    dt.Columns.Add(new DataColumn("仓库编号"));
                    dt.Columns.Add(new DataColumn("仓库名称"));
                    dt.Columns.Add(new DataColumn("租赁时间"));
                    dt.Columns.Add(new DataColumn("所属部门"));
                    dt.Columns.Add(new DataColumn("仓库类型"));
                    dt.Columns.Add(new DataColumn("是否禁用"));
                    dt.Columns.Add(new DataColumn("是否默认"));
                    dt.Columns.Add(new DataColumn("地址"));
                    dt.Columns.Add(new DataColumn("面积"));
                    dt.Columns.Add(new DataColumn("联系人"));
                    dt.Columns.Add(new DataColumn("电话"));
                    foreach (StorageEntity t in listResult)
                    {
                        DataRow row = dt.NewRow();
                        row[0]  = t.StorageNum;
                        row[1]  = t.StorageName;
                        row[2]  = t.LeaseTime.To("yyyy-MM-dd");
                        row[3]  = t.DepartName;
                        row[4]  = EnumHelper.GetEnumDesc <EStorageType>(t.StorageType);
                        row[5]  = EnumHelper.GetEnumDesc <EBool>(t.IsForbid);
                        row[6]  = EnumHelper.GetEnumDesc <EBool>(t.IsDefault);
                        row[7]  = t.Address;
                        row[8]  = t.Area.ToString("0.00");
                        row[9]  = t.Contact;
                        row[10] = t.Phone;
                        dt.Rows.Add(row);
                    }
                    string filePath = Server.MapPath("~/UploadFile/");
                    if (!System.IO.Directory.Exists(filePath))
                    {
                        System.IO.Directory.CreateDirectory(filePath);
                    }
                    string    filename = string.Format("仓库管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmssfff"));
                    NPOIExcel excel    = new NPOIExcel("仓库管理", "仓库", System.IO.Path.Combine(filePath, filename));
                    excel.ToExcel(dt);
                    returnValue = ("/UploadFile/" + filename).Escape();
                }
            }

            if (!returnValue.IsEmpty())
            {
                returnResult = new DataResult()
                {
                    Code = 1000, Message = returnValue
                };
            }
            else
            {
                returnResult = new DataResult()
                {
                    Code = 1001, Message = "没有任何数据导出"
                };
            }
            return(Content(JsonHelper.SerializeObject(returnResult)));
        }
        public ActionResult ToExcel()
        {
            string CompanyID = this.CompanyID;

            int    PageIndex     = 1;
            int    PageSize      = Int32.MaxValue;
            string OrderNum      = WebUtil.GetFormValue <string>("OrderNum");
            int    InType        = WebUtil.GetFormValue <int>("InType", 0);
            string SupName       = WebUtil.GetFormValue <string>("SupName", string.Empty);
            string SupNum        = WebUtil.GetFormValue <string>("SupNum", string.Empty);
            int    Status        = WebUtil.GetFormValue <int>("Status", 0);
            string ContractOrder = WebUtil.GetFormValue <string>("ContractOrder", string.Empty);

            ITopClient client = new TopClientDefault();
            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("CompanyID", CompanyID);
            dic.Add("PageIndex", PageIndex.ToString());
            dic.Add("PageSize", PageSize.ToString());
            dic.Add("OrderNum", OrderNum);
            dic.Add("InType", InType.ToString());
            dic.Add("SupName", SupName);
            dic.Add("SupNum", SupNum);
            dic.Add("Status", Status.ToString());
            dic.Add("ContractOrder", ContractOrder);

            string result = client.Execute(InStorageApiName.InStorageApiName_GetDetailList, dic);

            string returnValue = string.Empty;

            if (!result.IsEmpty())
            {
                DataListResult <InStorDetailEntity> dataResult = JsonConvert.DeserializeObject <DataListResult <InStorDetailEntity> >(result);
                List <InStorDetailEntity>           listResult = dataResult.Result;
                if (!listResult.IsNullOrEmpty())
                {
                    DataTable dt = new DataTable();
                    dt.Columns.Add(new DataColumn("订单号"));
                    dt.Columns.Add(new DataColumn("产品名称"));
                    dt.Columns.Add(new DataColumn("产品编号"));
                    dt.Columns.Add(new DataColumn("批次"));
                    dt.Columns.Add(new DataColumn("规格"));
                    dt.Columns.Add(new DataColumn("数量"));
                    dt.Columns.Add(new DataColumn("仓库"));
                    dt.Columns.Add(new DataColumn("库位"));
                    dt.Columns.Add(new DataColumn("入库类型"));
                    dt.Columns.Add(new DataColumn("供应商"));
                    dt.Columns.Add(new DataColumn("制单人"));
                    dt.Columns.Add(new DataColumn("制单时间"));
                    dt.Columns.Add(new DataColumn("状态"));
                    dt.Columns.Add(new DataColumn("审核人"));
                    dt.Columns.Add(new DataColumn("审核时间"));

                    foreach (InStorDetailEntity t in listResult)
                    {
                        DataRow row = dt.NewRow();
                        row[0]  = t.OrderNum;
                        row[1]  = t.ProductName;
                        row[2]  = t.BarCode;
                        row[3]  = t.BatchNum;
                        row[4]  = t.Size;
                        row[5]  = t.Num.ToString("0.00");
                        row[6]  = t.StorageName;
                        row[7]  = t.LocalName;
                        row[8]  = EnumHelper.GetEnumDesc <EInType>(t.InType);
                        row[9]  = t.SupName;
                        row[10] = t.CreateUserName;
                        row[11] = t.CreateTime.To("yyyy-MM-dd");
                        row[12] = EnumHelper.GetEnumDesc <EAudite>(t.Status);
                        row[13] = t.AuditeUserName;
                        row[14] = t.AuditeTime.To("yyyy-MM-dd");

                        dt.Rows.Add(row);
                    }
                    string filePath = Server.MapPath("~/UploadFile/");
                    if (!System.IO.Directory.Exists(filePath))
                    {
                        System.IO.Directory.CreateDirectory(filePath);
                    }
                    string    filename = string.Format("入库管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmssfff"));
                    NPOIExcel excel    = new NPOIExcel("入库管理", "入库单", System.IO.Path.Combine(filePath, filename));
                    excel.ToExcel(dt);
                    returnValue = ("/UploadFile/" + filename).Escape();
                }
            }
            DataResult returnResult = null;

            if (!returnValue.IsEmpty())
            {
                returnResult = new DataResult()
                {
                    Code = 1000, Message = returnValue
                };
            }
            else
            {
                returnResult = new DataResult()
                {
                    Code = 1001, Message = "没有任何数据导出"
                };
            }
            return(Content(JsonHelper.SerializeObject(returnResult)));
        }
        public ActionResult ToExcel()
        {
            ITopClient client = new TopClientDefault();
            Dictionary <string, string> dic = new Dictionary <string, string>();
            string CompanyID = this.CompanyID;
            int    PageIndex = 1;
            int    PageSize  = Int32.MaxValue;
            string TabName   = WebUtil.GetFormValue <string>("TabName", string.Empty);

            dic.Add("CompanyID", CompanyID);
            dic.Add("PageIndex", PageIndex.ToString());
            dic.Add("PageSize", PageSize.ToString());
            dic.Add("TabName", TabName);

            string result      = client.Execute(SequenceApiName.SequenceApiName_GetOrderList, dic);
            string returnValue = string.Empty;

            if (!result.IsEmpty())
            {
                DataListResult <SequenceEntity> dataResult = JsonConvert.DeserializeObject <DataListResult <SequenceEntity> >(result);
                List <SequenceEntity>           listResult = dataResult.Result;
                if (!listResult.IsNullOrEmpty())
                {
                    DataTable dt = new DataTable();
                    dt.Columns.Add(new DataColumn("表名"));
                    dt.Columns.Add(new DataColumn("类型1"));
                    dt.Columns.Add(new DataColumn("规则1"));
                    dt.Columns.Add(new DataColumn("长度1"));
                    dt.Columns.Add(new DataColumn("连接符"));
                    dt.Columns.Add(new DataColumn("类型2"));
                    dt.Columns.Add(new DataColumn("规则2"));
                    dt.Columns.Add(new DataColumn("长度2"));
                    foreach (SequenceEntity t in listResult)
                    {
                        DataRow row = dt.NewRow();
                        row[0] = t.TabName;
                        row[1] = EnumHelper.GetEnumDesc <ESequence>(t.FirstType);
                        row[2] = t.FirstRule;
                        row[3] = t.FirstLength;
                        row[4] = t.JoinChar;
                        row[5] = EnumHelper.GetEnumDesc <ESequence>(t.SecondType);
                        row[6] = t.SecondRule;
                        row[7] = t.SecondLength;
                        dt.Rows.Add(row);
                    }
                    string filePath = Server.MapPath("~/UploadFile/");
                    if (!System.IO.Directory.Exists(filePath))
                    {
                        System.IO.Directory.CreateDirectory(filePath);
                    }
                    string    filename = string.Format("标识符管理{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmssfff"));
                    NPOIExcel excel    = new NPOIExcel("标识符管理", "标识符管理", System.IO.Path.Combine(filePath, filename));
                    excel.ToExcel(dt);
                    returnValue = ("/UploadFile/" + filename).Escape();
                }
            }
            DataResult returnResult = null;

            if (!returnValue.IsEmpty())
            {
                returnResult = new DataResult()
                {
                    Code = 1000, Message = returnValue
                };
            }
            else
            {
                returnResult = new DataResult()
                {
                    Code = 1001, Message = "没有任何数据导出"
                };
            }
            return(Content(JsonHelper.SerializeObject(returnResult)));
        }