예제 #1
0
        /// <summary>
        /// 下载模板
        /// </summary>
        public void StorerDemoExecl()
        {
            DataSet   ds       = new DataSet();
            DataTable dt       = new DataTable();
            DataTable dtDetail = new DataTable();

            //主表信息
            dt.Columns.Add("StorerKey", typeof(string));
            dt.Columns.Add("状态", typeof(string));
            dt.Columns.Add("店铺名称", typeof(string));
            dt.Columns.Add("SAP代码", typeof(string));
            dt.Columns.Add("类型", typeof(string));
            dt.Columns.Add("地址1", typeof(string));
            dt.Columns.Add("地址2", typeof(string));
            dt.Columns.Add("地址3", typeof(string));
            dt.Columns.Add("地址4", typeof(string));
            dt.Columns.Add("城市", typeof(string));
            dt.Columns.Add("州", typeof(string));
            dt.Columns.Add("邮编", typeof(string));
            dt.Columns.Add("国家", typeof(string));
            dt.Columns.Add("国家代码", typeof(string));
            dt.Columns.Add("联系人1", typeof(string));
            dt.Columns.Add("联系人2", typeof(string));
            dt.Columns.Add("联系电话1", typeof(string));
            dt.Columns.Add("联系电话2", typeof(string));
            dt.Columns.Add("传真1", typeof(string));
            dt.Columns.Add("传真2", typeof(string));
            dt.Columns.Add("邮箱1", typeof(string));
            dt.Columns.Add("邮箱2", typeof(string));
            dt.Columns.Add("创建人", typeof(string));
            dt.Columns.Add("更新人", typeof(string));
            DataRow dr1 = dt.NewRow();

            dr1["StorerKey"] = "3602";
            dr1["店铺名称"]      = "耐克成都双流换季优惠店";
            dr1["SAP代码"]     = "8006902";
            dr1["类型"]        = "SELLER";
            dr1["地址1"]       = "成都市双流区东升街道双楠大道中段633号时代奥特莱斯S-1184,1185,S-2189,2190";
            dr1["国家代码"]      = "CN";
            dr1["联系人1"]      = "刘力";
            dr1["联系电话1"]     = "028-61915601";
            dr1["创建人"]       = "NIKENFSCD";
            dt.Rows.Add(dr1);
            ds.Tables.Add(dt);
            //明细信息
            //dtDetail.Columns.Add("SKU", typeof(string));
            //dtDetail.Columns.Add("UPC", typeof(string));
            //dtDetail.Columns.Add("UPC名称", typeof(string));
            //dtDetail.Columns.Add("UPC类型", typeof(string));
            //dtDetail.Columns.Add("UPC数量", typeof(string));
            //ds.Tables.Add(dtDetail);
            //ExportDataToExcelHelper.ExportDataSetToExcel(ds, "店铺导入模板.xls");//生成Excel
            EPPlusOperation.ExportByEPPlus(ds.Tables[0], "店铺导入模板");
        }
예제 #2
0
        /// <summary>
        /// 导出箱清单
        /// </summary>
        /// <param name="id">orderid</param>
        /// <param name="type">1</param>
        /// <param name="OrderID">0</param>
        public void ExportBoxDetail(string id, string type, string OrderID)
        {
            DataSet   ds = new OrderManagementService().ExportBoxDetailsYXDR(id.ToString());
            DataTable dt = ds.Tables[0];

            //这段代码我承认写的很lj
            if (dt.Rows.Count > 0)
            {
                DataTable dtheader    = new DataTable(); //订单主信息
                DataTable dtBoxdetail = new DataTable(); //箱明细信息

                dtheader.Columns.Add("dc1", typeof(string));
                dtheader.Columns.Add("dc2", typeof(string));
                dtheader.Columns.Add("dc3", typeof(string));
                dtheader.Columns.Add("dc4", typeof(string));
                dtheader.Columns.Add("dc5", typeof(string));
                dtheader.Columns.Add("dc6", typeof(string));
                dtheader.Columns.Add("dc7", typeof(string));
                dtheader.Columns.Add("dc8", typeof(string));
                dtheader.Columns.Add("dc9", typeof(string));
                dtheader.Columns.Add("dc10", typeof(string));
                dtheader.Columns.Add("dc11", typeof(string));
                dtheader.Columns.Add("dc12", typeof(string));
                dtheader.Columns.Add("dc13", typeof(string));

                #region 先把一单的头信息加上
                //第一行
                DataRow dr = dtheader.NewRow();
                dr["dc1"]  = "箱清单";
                dr["dc2"]  = "订单号:";
                dr["dc3"]  = dt.Rows[0]["ExternOrderNumber"].ToString().Trim();
                dr["dc4"]  = "货主:";
                dr["dc5"]  = "Haddad";
                dr["dc6"]  = "门店代码:";
                dr["dc7"]  = dt.Rows[0]["str4"].ToString().Trim();
                dr["dc8"]  = "门店名称:";
                dr["dc9"]  = dt.Rows[0]["Company"].ToString();
                dr["dc10"] = "门店地址:";
                dr["dc11"] = dt.Rows[0]["AddressLine1"].ToString();
                dr["dc12"] = "出货日期:";
                dr["dc13"] = DateTime.Now;
                dtheader.Rows.Add(dr);
                //第二行明细列
                DataRow dr2 = dtheader.NewRow();
                dr2["dc1"]  = "箱唛号";
                dr2["dc2"]  = "箱号";
                dr2["dc3"]  = "款号";
                dr2["dc4"]  = "描述";
                dr2["dc5"]  = "尺码";
                dr2["dc6"]  = "数量";
                dr2["dc7"]  = "订单号";
                dr2["dc8"]  = "条形码";
                dr2["dc9"]  = "";
                dr2["dc10"] = "";
                dr2["dc11"] = "";
                dtheader.Rows.Add(dr2);
                #endregion

                List <string> list          = new List <string>();
                int           boxnumber     = 1;  //箱号
                int           packageSumQty = 0;  //每箱总数
                string        packagenumber = ""; //箱唛号


                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataRow dr3 = dtheader.NewRow();
                    if (i == 0)
                    {
                        packagenumber = dt.Rows[i]["PackageNumber"].ToString();
                        dr3["dc1"]    = dt.Rows[i]["ShippingMark"].ToString();
                        dr3["dc2"]    = boxnumber.ToString();
                        dr3["dc3"]    = dt.Rows[i]["Atrcle"].ToString();
                        dr3["dc4"]    = dt.Rows[i]["GoodsName"].ToString();
                        dr3["dc5"]    = dt.Rows[i]["Size"].ToString();
                        dr3["dc6"]    = dt.Rows[i]["Qty"].ToString();
                        dr3["dc7"]    = dt.Rows[i]["ExternOrderNumber"].ToString();
                        dr3["dc8"]    = dt.Rows[i]["SKU"].ToString();
                    }
                    else
                    {
                        if (packagenumber != dt.Rows[i]["PackageNumber"].ToString())
                        {
                            DataRow dr4 = dtheader.NewRow();
                            dr4["dc1"] = "箱总数:";
                            dr4["dc2"] = packageSumQty.ToString(".00");
                            dr4["dc3"] = "";
                            dr4["dc4"] = "";
                            dr4["dc5"] = "";
                            dr4["dc6"] = "";
                            dr4["dc7"] = "";
                            dr4["dc8"] = "";
                            dtheader.Rows.Add(dr4);
                            packagenumber = dt.Rows[i]["PackageNumber"].ToString();
                            packageSumQty = 0;
                            boxnumber++;
                        }

                        dr3["dc1"] = dt.Rows[i]["ShippingMark"].ToString();
                        dr3["dc2"] = boxnumber;
                        dr3["dc3"] = dt.Rows[i]["Atrcle"].ToString();
                        dr3["dc4"] = dt.Rows[i]["GoodsName"].ToString();
                        dr3["dc5"] = dt.Rows[i]["Size"].ToString();
                        dr3["dc6"] = dt.Rows[i]["Qty"].ToString();
                        dr3["dc7"] = dt.Rows[i]["ExternOrderNumber"].ToString();
                        dr3["dc8"] = dt.Rows[i]["SKU"].ToString();
                    }
                    dtheader.Rows.Add(dr3);
                    packageSumQty += Convert.ToInt32(Convert.ToDouble(dt.Rows[i]["Qty"].ToString()));
                }
                DataRow dr5 = dtheader.NewRow();
                dr5["dc1"] = "箱总数:";
                dr5["dc2"] = packageSumQty.ToString(".00");
                dr5["dc3"] = "";
                dr5["dc4"] = "";
                dr5["dc5"] = "";
                dr5["dc6"] = "";
                dr5["dc7"] = "";
                dr5["dc8"] = "";
                dtheader.Rows.Add(dr5);
                //ExportDataToExcelHelper.ExportDataSetToExcel(dtheader, "箱清单" + DateTime.Now.ToString("yyyy-MM-dd"), "");
                EPPlusOperation.ExportByEPPlus(dtheader, "箱清单" + DateTime.Now.ToString("yyyy-MM-dd"));
            }
            else
            {
                //ExportDataToExcelHelper.ExportDataSetToExcel(dt, "箱清单" + DateTime.Now.ToString("yyyy-MM-dd"), "");
                EPPlusOperation.ExportByEPPlus(dt, "箱清单" + DateTime.Now.ToString("yyyy-MM-dd"));
            }
        }