/// <summary>
        /// 總表明細
        /// </summary>
        public void ExportVendorAccountMonthAll()
        {
            string json = string.Empty;
            DataTable _dt = new DataTable();
            DataTable dtHZ = new DataTable();
            VendorAccountDetailQuery query = new VendorAccountDetailQuery();
            VendorAccountMonthQuery VAMQuery = new VendorAccountMonthQuery();
            VendorQuery vendorQuery = new VendorQuery();
            List<DataTable> Elist = new List<DataTable>();
            List<string> NameList = new List<string>();
            List<bool> comName = new List<bool>();
            try
            {
                List<string> list = GetTime(uint.Parse(Request.Params["dateone"]), uint.Parse(Request.Params["datetwo"]));
                _IVAMMgr = new VendorAccountMonthMgr(mySqlConnectionString);
                VAMQuery.account_year = Convert.ToUInt32(Request.Params["dateOne"]);
                VAMQuery.account_month = Convert.ToUInt32(Request.Params["dateTwo"]);
                query.search_start_time = list[0];
                query.search_end_time = list[1];
                int tempFreightDelivery_Normal = 0;
                int tempFreightDelivery_Low = 0;
                for (int i = 1; i <= 34; i++)
                {
                    dtHZ.Columns.Add("", typeof(String));
                }
                //供應商信息
                DataTable vendorDt = _IVAMMgr.GetVendorAccountMonthInfo(VAMQuery);
                DataTable dtPiCi = _IVAMMgr.BatchOrderDetail(query);
                for (int m = 0; m < vendorDt.Rows.Count; m++)
                {
                    vendorQuery.vendor_id = Convert.ToUInt32(vendorDt.Rows[m]["vendor_id"]);
                    VAMQuery.vendor_id = Convert.ToUInt32(vendorDt.Rows[m]["vendor_id"]);
                    query.vendor_id = Convert.ToUInt32(vendorDt.Rows[m]["vendor_id"]);
                    //調度倉運費
                    DataTable dt = _IVAMMgr.GetFreightMoney(query, out tempFreightDelivery_Normal, out tempFreightDelivery_Low);
                    // 查供應商總帳
                    DataTable tempTemp = _IVAMMgr.GetVendorAccountMonthZongZhang(VAMQuery);

                    //供應商信息
                    vendorQuery = _IVAMMgr.GetVendorInfoByCon(vendorQuery);
                    dtHZ = GetTitle(dtHZ, vendorQuery, tempTemp, tempFreightDelivery_Normal, tempFreightDelivery_Low);
                    List<VendorAccountCustom> liStore = _IVAMMgr.VendorAccountDetailExport(query);
                    dtHZ = GetData(dtHZ, liStore, 2, tempTemp, tempFreightDelivery_Normal, tempFreightDelivery_Low);//1:單獨 2:全部 3:批次
                }
                comName.Add(false);
                Elist.Add(dtHZ);
                NameList.Add("應付金額與商品明細");
                DataTable dtYF = new DataTable();
                if (dtPiCi.Rows.Count > 0)
                {
                    dtYF.Columns.Add("批次出貨單號");
                    dtYF.Columns.Add("常溫商品總額");
                    dtYF.Columns.Add("低溫商品總額");
                    dtYF.Columns.Add("批次出貨明細");
                    dtYF.Columns.Add("廠商出貨單編號");
                    dtYF.Columns.Add("出貨時間");
                    dtYF.Columns.Add("付款單號");
                    for (int s = 0; s < dtPiCi.Rows.Count; s++)
                    {
                        DataRow yfDr = dtYF.NewRow();
                        yfDr[0] = dtPiCi.Rows[s]["code_num"];
                        yfDr[1] = dtPiCi.Rows[s]["normal_subtotal"];
                        yfDr[2] = dtPiCi.Rows[s]["hypothermia_subtotal"];
                        yfDr[3] = dtPiCi.Rows[s]["code_num"];
                        yfDr[4] = dtPiCi.Rows[s]["slave_id"];
                        yfDr[5] = dtPiCi.Rows[s]["deliver_time"];
                        yfDr[6] = dtPiCi.Rows[s]["order_id"];
                        dtYF.Rows.Add(yfDr);
                    }
                    DataRow tempdr1 = dtYF.NewRow();
                    tempdr1[0] = "常溫運費補貼:" + tempFreightDelivery_Normal;
                    dtYF.Rows.Add(tempdr1);
                    DataRow tempdr2 = dtYF.NewRow();
                    tempdr2[0] = "低溫運費補貼:" + tempFreightDelivery_Normal;
                    dtYF.Rows.Add(tempdr2);
                    comName.Add(true);
                    Elist.Add(dtYF);
                    NameList.Add("調度倉運費");

                }
                if (dtHZ.Rows.Count > 0)
                {
                    string fileName = "供應商對賬報表-" + VAMQuery.account_year + "-" + VAMQuery.account_month + ".xls";
                    MemoryStream ms = ExcelHelperXhf.ExportDTNoColumns(Elist, NameList, comName);
                    Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
                    Response.BinaryWrite(ms.ToArray());
                }
                else
                {
                    Response.Write("匯出數據不存在");
                }
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false,totalCount:0,data:[]}";
            }
        }
        /// <summary>
        /// 批次匯出各供應商的業績明細
        /// </summary>
        public HttpResponseBase AllExportVendorAccountMonthDetail()
        {
            string json = string.Empty;
            List<string> strPath = new List<string>();
            VendorQuery vendorQuery = new VendorQuery();
            try
            {
                List<string> list = GetTime(uint.Parse(Request.Params["dateone"]), uint.Parse(Request.Params["datetwo"]));
                _IVAMMgr = new VendorAccountMonthMgr(mySqlConnectionString);
                //Dictionary<int, DataTable> tempDT = new Dictionary<int, DataTable>();
                VendorAccountMonthQuery VAMQueryTemp = new VendorAccountMonthQuery();

                VAMQueryTemp.account_year = Convert.ToUInt32(Request.Params["dateOne"]);
                VAMQueryTemp.account_month = Convert.ToUInt32(Request.Params["dateTwo"]);
                DataTable vendorDt = _IVAMMgr.GetVendorAccountMonthInfo(VAMQueryTemp);
                for (int l = 0; l < vendorDt.Rows.Count; l++)
                {
                    DataTable dtHZ = new DataTable();
                    VendorAccountDetailQuery query = new VendorAccountDetailQuery();
                    VendorAccountMonthQuery VAMQuery = new VendorAccountMonthQuery();
                    int tempFreightDelivery_Normal = 0;
                    int tempFreightDelivery_Low = 0;
                    vendorQuery.vendor_id = Convert.ToUInt32(vendorDt.Rows[l]["vendor_id"]);
                    VAMQuery.vendor_id = Convert.ToUInt32(vendorDt.Rows[l]["vendor_id"]);
                    VAMQuery.account_year = VAMQueryTemp.account_year;
                    VAMQuery.account_month = VAMQueryTemp.account_month;
                    query.vendor_id = Convert.ToUInt32(vendorDt.Rows[l]["vendor_id"]);
                    query.search_start_time = list[0];
                    query.search_end_time = list[1];
                    //調度倉運費
                    DataTable dt = _IVAMMgr.GetFreightMoney(query, out tempFreightDelivery_Normal, out tempFreightDelivery_Low);
                    // 查供應商總帳
                    DataTable tempTemp = _IVAMMgr.GetVendorAccountMonthZongZhang(VAMQuery);

                    DataTable dtPiCi = _IVAMMgr.BatchOrderDetail(query);
                    //tempDT.Add(0, tempTemp);
                    //供應商信息
                    vendorQuery = _IVAMMgr.GetVendorInfoByCon(vendorQuery);
                    for (int i = 1; i <= 34; i++)
                    {
                        dtHZ.Columns.Add("", typeof(String));
                    }
                    dtHZ = GetTitle(dtHZ, vendorQuery, tempTemp, tempFreightDelivery_Normal, tempFreightDelivery_Low);
                    List<VendorAccountCustom> liStore = _IVAMMgr.VendorAccountDetailExport(query);
                    dtHZ = GetData(dtHZ, liStore, 3, tempTemp, tempFreightDelivery_Normal, tempFreightDelivery_Low);//1:單獨 2:全部 3:批次
                    List<DataTable> Elist = new List<DataTable>();
                    List<string> NameList = new List<string>();
                    List<bool> comName = new List<bool>();
                    comName.Add(false);
                    Elist.Add(dtHZ);
                    NameList.Add("對賬報表");
                    DataTable dtYF = GetDZ(dt, dtPiCi, tempFreightDelivery_Normal, tempFreightDelivery_Low);
                    comName.Add(true);
                    Elist.Add(dtYF);
                    NameList.Add("調度倉運費");
                    if (liStore.Count > 0)
                    {
                        string fileName = vendorQuery.vendor_id + "-" + vendorQuery.vendor_code + "-供應商對帳報表" + vendorQuery.vendor_name_full + VAMQuery.account_year + "-" + VAMQuery.account_month + ".xls";
                        MemoryStream ms = ExcelHelperXhf.ExportDTNoColumns(Elist, NameList, comName);
                        //MemoryStream m = new MemoryStream();

                        FileStream fs = new FileStream(Server.MapPath("../ImportUserIOExcel/" + fileName), FileMode.OpenOrCreate);
                        BinaryWriter w = new BinaryWriter(fs);
                        w.Write(ms.ToArray());
                        fs.Close();
                        ms.Close();
                        strPath.Add(Server.MapPath("../ImportUserIOExcel/" + fileName));
                    }
                }
                string strZipPath = Server.MapPath("../ImportUserIOExcel/供應商對賬報表.zip");
                string strZipTopDirectoryPath = Server.MapPath("../ImportUserIOExcel/");
                int intZipLevel = 6;
                string strPassword = "";
                SharpZipLibHelp szlh = new SharpZipLibHelp();
                szlh.Zip(strZipPath, strZipTopDirectoryPath, intZipLevel, strPassword, strPath);
                json = "{success:'true'}";
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false,totalCount:0,data:[]}";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
        public void ExportVendorAccountMonthDetail()
        {
            string json = string.Empty;
            DataTable _dt = new DataTable();
            DataTable dtHZ = new DataTable();
            VendorAccountDetailQuery query = new VendorAccountDetailQuery();
            VendorAccountMonthQuery VAMQuery = new VendorAccountMonthQuery();
            VendorQuery vendorQuery = new VendorQuery();
            try
            {
                List<string> list = GetTime(uint.Parse(Request.Params["dateone"]), uint.Parse(Request.Params["datetwo"]));
                _IVAMMgr = new VendorAccountMonthMgr(mySqlConnectionString);
                vendorQuery.vendor_id = Convert.ToUInt32(Request.Params["vendorid"]);
                VAMQuery.vendor_id = Convert.ToUInt32(Request.Params["vendorid"]);
                VAMQuery.account_year = Convert.ToUInt32(Request.Params["dateOne"]);
                VAMQuery.account_month = Convert.ToUInt32(Request.Params["dateTwo"]);
                query.vendor_id = Convert.ToUInt32(Request.Params["vendorid"]);
                query.search_start_time = list[0];
                query.search_end_time = list[1];
                int tempFreightDelivery_Normal = 0;
                int tempFreightDelivery_Low = 0;
                for (int i = 1; i <= 34; i++)
                {
                    dtHZ.Columns.Add("", typeof(String));
                }
                //調度倉運費
                DataTable dt = _IVAMMgr.GetFreightMoney(query, out tempFreightDelivery_Normal, out tempFreightDelivery_Low);
                // 查供應商總帳
                DataTable tempTemp = _IVAMMgr.GetVendorAccountMonthZongZhang(VAMQuery);
                DataTable dtPiCi = _IVAMMgr.BatchOrderDetail(query);
                //供應商信息
                vendorQuery = _IVAMMgr.GetVendorInfoByCon(vendorQuery);
                dtHZ = GetTitle(dtHZ, vendorQuery, tempTemp, tempFreightDelivery_Normal, tempFreightDelivery_Low);
                List<VendorAccountCustom> liStore = _IVAMMgr.VendorAccountDetailExport(query);
                dtHZ = GetData(dtHZ, liStore, 1, tempTemp, tempFreightDelivery_Normal, tempFreightDelivery_Low);//1:單獨 2:全部 3:批次

                List<DataTable> Elist = new List<DataTable>();
                List<string> NameList = new List<string>();
                List<bool> comName = new List<bool>();
                comName.Add(false);
                Elist.Add(dtHZ);
                NameList.Add("對賬報表");
                DataTable dtYF = GetDZ(dt, dtPiCi, tempFreightDelivery_Normal, tempFreightDelivery_Low);
                comName.Add(true);
                Elist.Add(dtYF);
                NameList.Add("調度倉運費");
                if (dtHZ.Rows.Count > 0)
                {
                    string fileName = vendorQuery.vendor_id + "-" + vendorQuery.vendor_code + "-供應商對帳報表" + vendorQuery.vendor_name_full + VAMQuery.account_year + "-" + VAMQuery.account_month + ".xls";
                    MemoryStream ms = ExcelHelperXhf.ExportDTNoColumns(Elist, NameList, comName);
                    Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
                    Response.BinaryWrite(ms.ToArray());
                }
                else
                {
                    Response.Write("匯出數據不存在");
                }
            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                json = "{success:false,totalCount:0,data:[]}";
            }
        }