Example #1
0
 public List<VendorQuery> Query(VendorQuery query, ref int totalCount)
 {
     try
     {
         return _vendorDao.Query(query, ref totalCount);
     }
     catch (Exception ex)
     {
         throw new Exception("VendorMgr-->Query-->" + ex.Message, ex);
     }
 }
        /// <summary>
        /// 查詢供應商信息
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public VendorQuery GetVendorInfoByCon(VendorQuery query)
        {
            try
            {
                return _Ivendor.GetVendorInfoByCon(query);
            }
            catch (Exception ex)
            {

                throw new Exception("VendorAccountMonthMgr-->GetVendorInfoByCon-->" + ex.Message, ex);
            }
        }
        /// <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;
        }
        /// <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:[]}";
            }
        }
        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:[]}";
            }
        }
        //#region 獲取定單詳細信息
        ///// <summary>
        ///// 獲取定單詳細信息
        ///// </summary>
        ///// <returns></returns>
        //public HttpResponseBase GetOrderDetail()
        //{
        //    string json = string.Empty;
        //    List<OrderDetailQuery> listOrderDetail = new List<OrderDetailQuery>();
        //    OrderDetailQuery query = new OrderDetailQuery();
        //    try
        //    {
        //        _orderDetailMgr = new OrderDetailMgr(mySqlConnectionString);
        //        query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");
        //        query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");
        //        //if (!string.IsNullOrEmpty(Request.Params["ddlSel"]))
        //        //{//查詢條件
        //        //    query.seach_tj = Convert.ToInt32(Request.Params["ddlSel"]);
        //        //}
        //        //if (!string.IsNullOrEmpty(Request.Params["selcontent"]))
        //        //{//查詢條件內容
        //        //    query.content = Convert.ToInt32(Request.Params["selcontent"]);
        //        //}
        //        //if (!string.IsNullOrEmpty(Request.Params["ddtSel"]))
        //        //{//日期條件
        //        //    query.ddtSel = Convert.ToInt32(Request.Params["ddtSel"]);
        //        //}
        //        //if (!string.IsNullOrEmpty(Request.Params["time_start"]))
        //        //{//開始時間
        //        //    query.startdate = Convert.ToUInt32(CommonFunction.GetPHPTime(Request.Params["time_start"].ToString()));
        //        //}
        //        //if (!string.IsNullOrEmpty(Request.Params["time_end"]))
        //        //{//結束時間
        //        //    query.enddate = Convert.ToUInt32(CommonFunction.GetPHPTime(Request.Params["time_end"].ToString()));
        //        //}
        //        //if (!string.IsNullOrEmpty(Request.Params["ddlstatus"]))
        //        //{//開立狀態
        //        //    query.ddlstatus = Convert.ToInt32(Request.Params["ddlstatus"]);
        //        //}
        //        //if (!string.IsNullOrEmpty(Request.Params["ddlinvoice"]))
        //        //{//發票類型
        //        //    query.ddlinvoice = Convert.ToInt32(Request.Params["ddlinvoice"]);
        //        //}
        //        //if (!string.IsNullOrEmpty(Request.Params["ddlqh"]))
        //        //{//是否簽回
        //        //    query.ddlqh = Convert.ToInt32(Request.Params["ddlqh"]);
        //        //}
        //        int totalCount = 0;
        //        //listOrderDetail = _invoiceAllow.QueryAll(query, out totalCount);
        //        listOrderDetail = _orderDetailMgr.GetOrderDetailList(query, out totalCount);
        //        IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
        //        //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
        //        timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
        //        //listUser是准备转换的对象
        //        json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(listOrderDetail, Formatting.Indented, timeConverter) + "}";//返回json數據
        //    }
        //    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;
        //}
        //#endregion

        //#region 強制開立發票
        ///// <summary>
        ///// 強制開立發票
        ///// </summary>
        ///// <returns></returns>
        //public HttpResponseBase OpenInvoice()
        //{
        //    string json = string.Empty;
        //    string order_id = Request.Params["order_id"];
        //    OrderMaster orderMaster = new OrderMaster();
        //    _orderMasterMgr = new OrderMasterMgr(mySqlConnectionString);
        //    _orderSlaveMgr = new OrderSlaveMgr(mySqlConnectionString);
        //    imrMgr = new InvoiceMasterRecordMgr(mySqlConnectionString);
        //    int totalCount = 0;
        //    try
        //    {
        //        orderMaster = _orderMasterMgr.GetOrderMasterByOrderId(Convert.ToInt32(order_id));
        //        if (orderMaster != null && orderMaster.Invoice_Status == 0)
        //        {
        //            OrderSlaveQuery query = new OrderSlaveQuery();
        //            query.order_id = Convert.ToUInt32(order_id);
        //            query.slave_status_in = "0,2";
        //            DataTable dtOrderSlave = _orderSlaveMgr.GetList(query, out totalCount);
        //            if (dtOrderSlave.Rows.Count == 0)
        //            {
        //                //OrderMaster om = new OrderMaster()
        //                //{

        //                //};
        //                _orderMasterMgr.UpdateOrderToOpenInvoice(Convert.ToInt32(order_id));//開發票前先更新定單狀態
        //                bool flag = imrMgr.ModifyOrderInvoice(Convert.ToInt32(order_id), 1, 1, "create");
        //            }
        //            else
        //            {

        //            }
        //        }
        //    }
        //    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;
        //}
        //#endregion

        //#region 銀行匯款資料
        //#region 銀行匯款資料view
        //public ActionResult BankReportIndex()
        //{//銀行匯款資料列表
        //    return View();
        //}
        //public ActionResult YongFengBankReportList()
        //{//永業銀行匯款資料列表
        //    return View();
        //}
        //public ActionResult HuaNanBankReportList()
        //{//華南銀行匯款資料列表
        //    return View();
        //}
        //#endregion

        //#region 永豐資料列表
        //public HttpResponseBase SinopacDetailOneList()
        //{
        //    List<SinopacDetailQuery> stores = new List<SinopacDetailQuery>();

        //    string json = string.Empty;
        //    try
        //    {
        //        SinopacDetailQuery query = new SinopacDetailQuery();

        //        query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
        //        query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "20");//用於分頁的變量

        //        string selecttype = string.Empty;//查詢條件
        //        #region 查詢條件
        //        if (!string.IsNullOrEmpty(Request.Params["selecttype"]))
        //        {
        //            selecttype = Request.Params["selecttype"].ToString();
        //        }
        //        if (selecttype == "1")
        //        {
        //            if (!string.IsNullOrEmpty(Request.Params["searchcon"]))
        //            {
        //                query.order_id = int.Parse(Request.Params["searchcon"].ToString());
        //            }
        //        }
        //        else if (selecttype == "2")
        //        {
        //            if (!string.IsNullOrEmpty(Request.Params["searchcon"]))
        //            {
        //                query.sinopac_id = Request.Params["searchcon"].ToString();
        //            }
        //        }
        //        #endregion

        //        #region 日期條件一
        //        if (!string.IsNullOrEmpty(Request.Params["timeone"]))
        //        {
        //            query.timeconditionone = int.Parse(Request.Params["timeone"].ToString());
        //        }
        //        if (!string.IsNullOrEmpty(Request.Params["dateOne"]))
        //        {
        //            query.dateconditiononestart = DateTime.Parse(Request.Params["dateOne"].ToString());
        //        }
        //        if (!string.IsNullOrEmpty(Request.Params["dateTwo"]))
        //        {
        //            query.dateconditiononeend = DateTime.Parse(Request.Params["dateTwo"].ToString());
        //        }
        //        #endregion

        //        #region 日期條件二
        //        if (!string.IsNullOrEmpty(Request.Params["timetwo"]))
        //        {
        //            query.timeconditiontwo = int.Parse(Request.Params["timetwo"].ToString());
        //        }
        //        if (!string.IsNullOrEmpty(Request.Params["dateThree"]))
        //        {
        //            query.dateconditiontwostart = DateTime.Parse(Request.Params["dateThree"].ToString());
        //        }
        //        if (!string.IsNullOrEmpty(Request.Params["dateFour"]))
        //        {
        //            query.dateconditiontwoend = DateTime.Parse(Request.Params["dateFour"].ToString());
        //        }
        //        #endregion

        //        #region 核對狀態
        //        if (!string.IsNullOrEmpty(Request.Params["error_type"]))
        //        {
        //            query.error = int.Parse(Request.Params["error_type"].ToString());
        //        }
        //        #endregion

        //        #region 群組
        //        if (!string.IsNullOrEmpty(Request.Params["yes_type"]))
        //        {
        //            query.grouptype = int.Parse(Request.Params["yes_type"].ToString());
        //        }
        //        #endregion
        //        _spcdil = new SinopacDetailMgr(mySqlConnectionString);
        //        int totalCount = 0;
        //        stores = _spcdil.GetSinopacDetailInfo(query, out totalCount);
        //        foreach (var item in stores)
        //        {
        //            //獲取時間
        //            item.ocreatedate = CommonFunction.GetNetTime(item.order_createdate);
        //            item.endate = CommonFunction.GetNetTime(item.entday);
        //            item.txdate = CommonFunction.GetNetTime(item.txday);
        //            item.sinopacdate = CommonFunction.GetNetTime(item.sinopac_createdate);
        //        }
        //        IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
        //        //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
        //        timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
        //        //listUser是准备转换的对象
        //        json = "{success:true,'msg':'user',totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(stores, Formatting.Indented, timeConverter) + "}";//返回json數據

        //    }
        //    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:true,totalCount:0,data:[]}";
        //    }
        //    this.Response.Clear();
        //    this.Response.Write(json);
        //    this.Response.End();
        //    return this.Response;
        //}
        //#endregion

        //#region 華南銀行列表查詢
        //public HttpResponseBase SinopacDetailTwoList()
        //{
        //    List<OrderPaymentHncbQuery> stores = new List<OrderPaymentHncbQuery>();

        //    string json = string.Empty;
        //    try
        //    {
        //        OrderPaymentHncbQuery query = new OrderPaymentHncbQuery();

        //        query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
        //        query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "20");//用於分頁的變量

        //        string selecttype = string.Empty;//查詢條件

        //        #region 查詢條件
        //        if (!string.IsNullOrEmpty(Request.Params["selecttype"]))
        //        {
        //            selecttype = Request.Params["selecttype"].ToString();
        //        }
        //        if (selecttype == "1")
        //        {
        //            if (!string.IsNullOrEmpty(Request.Params["searchcon"]))
        //            {
        //                query.order_id = uint.Parse(Request.Params["searchcon"].ToString());
        //            }
        //        }
        //        else if (selecttype == "2")
        //        {
        //            if (!string.IsNullOrEmpty(Request.Params["searchcon"]))
        //            {
        //                query.hncb_id = Request.Params["searchcon"].ToString();
        //            }
        //        }
        //        #endregion

        //        #region 日期條件一
        //        if (!string.IsNullOrEmpty(Request.Params["timeone"]))
        //        {
        //            query.timeconditionOne = int.Parse(Request.Params["timeone"].ToString());
        //        }
        //        if (!string.IsNullOrEmpty(Request.Params["dateOne"]))
        //        {
        //            query.dateconditionone = DateTime.Parse(Request.Params["dateOne"].ToString());
        //        }
        //        if (!string.IsNullOrEmpty(Request.Params["dateTwo"]))
        //        {
        //            query.dateconditiontwo = DateTime.Parse(Request.Params["dateTwo"].ToString());
        //        }
        //        #endregion

        //        #region 沖帳狀態
        //        if (!string.IsNullOrEmpty(Request.Params["error_type"]))
        //        {
        //            query.error = uint.Parse(Request.Params["error_type"].ToString());
        //        }
        //        #endregion
        //        _spcdil = new SinopacDetailMgr(mySqlConnectionString);
        //        int totalCount = 0;
        //        stores = _spcdil.GetSinopacDetailTwoInfo(query, out totalCount);
        //        foreach (var item in stores)
        //        {
        //            //獲取時間
        //            item.ocreatedate = CommonFunction.GetNetTime(item.createdate);
        //            item.endate = CommonFunction.GetNetTime(item.entday);
        //            item.txdate = CommonFunction.GetNetTime(item.txtday);

        //        }
        //        IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
        //        //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
        //        timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
        //        //listUser是准备转换的对象
        //        json = "{success:true,'msg':'user',totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(stores, Formatting.Indented, timeConverter) + "}";//返回json數據

        //    }
        //    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:true,totalCount:0,data:[]}";
        //    }
        //    this.Response.Clear();
        //    this.Response.Write(json);
        //    this.Response.End();
        //    return this.Response;
        //}
        //#endregion

        //#region 永豐銀行匯出
        //public void ExportExcel()
        //{
        //    List<SinopacDetailQuery> stores = new List<SinopacDetailQuery>();
        //    SinopacDetailQuery query = new SinopacDetailQuery();
        //    string json = string.Empty;
        //    DataTable dtHZ = new DataTable();

        //    string newExcelName = string.Empty;
        //    dtHZ.Columns.Add("付款單號", typeof(String));
        //    dtHZ.Columns.Add("虛擬帳號", typeof(String));
        //    dtHZ.Columns.Add("付款單金額", typeof(String));
        //    dtHZ.Columns.Add("繳費金額", typeof(String));
        //    dtHZ.Columns.Add("訂購日期", typeof(String));
        //    dtHZ.Columns.Add("匯款日期", typeof(String));
        //    dtHZ.Columns.Add("入帳日期", typeof(String));
        //    dtHZ.Columns.Add("沖帳日期", typeof(String));
        //    try
        //    {
        //        string selecttype = string.Empty;//查詢條件
        //        #region 查詢條件
        //        if (!string.IsNullOrEmpty(Request.Params["selecttype"]))
        //        {
        //            selecttype = Request.Params["selecttype"].ToString();
        //        }
        //        if (selecttype == "1")
        //        {
        //            if (!string.IsNullOrEmpty(Request.Params["searchcon"]))
        //            {
        //                query.order_id = int.Parse(Request.Params["searchcon"].ToString());
        //            }
        //        }
        //        else if (selecttype == "2")
        //        {
        //            if (!string.IsNullOrEmpty(Request.Params["searchcon"]))
        //            {
        //                query.sinopac_id = Request.Params["searchcon"].ToString();
        //            }
        //        }
        //        #endregion

        //        #region 日期條件一
        //        if (!string.IsNullOrEmpty(Request.Params["timeone"]))
        //        {
        //            query.timeconditionone = int.Parse(Request.Params["timeone"].ToString());
        //        }
        //        if (!string.IsNullOrEmpty(Request.Params["dateOne"]))
        //        {
        //            query.dateconditiononestart = DateTime.Parse(Request.Params["dateOne"].ToString());
        //        }
        //        if (!string.IsNullOrEmpty(Request.Params["dateTwo"]))
        //        {
        //            query.dateconditiononeend = DateTime.Parse(Request.Params["dateTwo"].ToString());
        //        }
        //        #endregion

        //        #region 日期條件二
        //        if (!string.IsNullOrEmpty(Request.Params["timetwo"]))
        //        {
        //            query.timeconditiontwo = int.Parse(Request.Params["timetwo"].ToString());
        //        }
        //        if (!string.IsNullOrEmpty(Request.Params["dateThree"]))
        //        {
        //            query.dateconditiontwostart = DateTime.Parse(Request.Params["dateThree"].ToString());
        //        }
        //        if (!string.IsNullOrEmpty(Request.Params["dateFour"]))
        //        {
        //            query.dateconditiontwoend = DateTime.Parse(Request.Params["dateFour"].ToString());
        //        }
        //        #endregion

        //        #region 核對狀態
        //        if (!string.IsNullOrEmpty(Request.Params["error_type"]))
        //        {
        //            query.error = int.Parse(Request.Params["error_type"].ToString());
        //        }
        //        #endregion

        //        #region 群組
        //        if (!string.IsNullOrEmpty(Request.Params["yes_type"]))
        //        {
        //            query.grouptype = int.Parse(Request.Params["yes_type"].ToString());
        //        }
        //        #endregion

        //        _spcdil = new SinopacDetailMgr(mySqlConnectionString);
        //        stores = _spcdil.GetSinopacDetailInfo(query);
        //        foreach (var item in stores)
        //        {
        //            DataRow dr = dtHZ.NewRow();
        //            dr[0] = item.order_id.ToString();
        //            dr[1] = item.sinopac_id.ToString();
        //            dr[2] = item.order_amount;
        //            dr[3] = item.pay_amount;

        //            dr[4] = CommonFunction.GetNetTime(item.order_createdate).ToString("yyyy-MM-dd HH:mm:ss:f");
        //            dr[5] = CommonFunction.GetNetTime(item.entday).ToString("yyyy-MM-dd HH:mm:ss:f");

        //            dr[6] = CommonFunction.GetNetTime(item.txday).ToString("yyyy-MM-dd HH:mm:ss:f");
        //            dr[7] = CommonFunction.GetNetTime(item.sinopac_createdate).ToString("yyyy-MM-dd HH:mm:ss:f");

        //            dtHZ.Rows.Add(dr);

        //        }
        //        string[] colname = new string[dtHZ.Columns.Count];
        //        string fileName = "sinpac_list_" + DateTime.Now.ToString("yyyyMMdd HHmmss") + ".csv";
        //        newExcelName = Server.MapPath(excelPath) + fileName;
        //        for (int i = 0; i < dtHZ.Columns.Count; i++)
        //        {
        //            colname[i] = dtHZ.Columns[i].ColumnName;
        //        }

        //        if (System.IO.File.Exists(newExcelName))
        //        {
        //            System.IO.File.Delete(newExcelName);
        //        }
        //        StringWriter sw = ExcelHelperXhf.SetCsvFromData(dtHZ, "sinpac_export_.csv");
        //        Response.Clear();
        //        Response.AddHeader("Content-Disposition", "attachment; filename=" + "sinpac_export_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv");
        //        Response.ContentType = "application/ms-excel";
        //        Response.ContentEncoding = Encoding.Default;
        //        Response.Write(sw);
        //        Response.End();
        //    }
        //    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);
        //    }
        //}
        //#endregion

        //#endregion


        #region 獲取同一表頭 +DataTable GetTitle(DataTable dtHZ, VendorQuery vendorQuery, DataTable tempTemp, int tempFreightDelivery_Normal, int tempFreightDelivery_Low)
        public DataTable GetTitle(DataTable dtHZ, VendorQuery vendorQuery, DataTable tempTemp, int tempFreightDelivery_Normal, int tempFreightDelivery_Low)
        {
            //結帳總金額扣除批次出貨運費
            int M_Account_Amount = Convert.ToInt32(tempTemp.Rows[0]["m_account_amount"]);

            int M_Account_Amount_total = M_Account_Amount;
            int jicang = 0;
            if (!string.IsNullOrEmpty(tempTemp.Rows[0]["m_bag_check_money"].ToString()))
            {
                if (int.TryParse(tempTemp.Rows[0]["m_bag_check_money"].ToString(), out jicang))
                {
                    M_Account_Amount_total = M_Account_Amount_total - jicang;
                }
            }
            if (tempFreightDelivery_Normal != 0)
            {
                M_Account_Amount_total += tempFreightDelivery_Normal;
            }
            if (tempFreightDelivery_Low != 0)
            {
                M_Account_Amount_total += tempFreightDelivery_Low;
            }
            string dispatch = string.Empty;
            if (vendorQuery.dispatch == 1)
            {
                dispatch = "調度倉";
            }
            else
            {
                dispatch = "非調度倉";
            }

            #region 匯出樣式

            DataRow dr1 = dtHZ.NewRow();
            DataRow dr2 = dtHZ.NewRow();
            DataRow dr3 = dtHZ.NewRow();
            DataRow dr4 = dtHZ.NewRow();
            DataRow dr5 = dtHZ.NewRow();
            DataRow dr6 = dtHZ.NewRow();
            DataRow dr7 = dtHZ.NewRow();
            DataRow dr8 = dtHZ.NewRow();
            DataRow dr9 = dtHZ.NewRow();
            string strTemp = string.Empty;
            strTemp = "吉甲地市集" + Request.Params["dateOne"].ToString() + "年" + Request.Params["dateTwo"].ToString() + "月銷售報表";
            dr1[0] = strTemp.ToString();
            dr2[0] = "供應商編號:" + vendorQuery.vendor_code;
            dr3[0] = "供應商名稱:" + vendorQuery.vendor_name_simple;
            dr4[0] = "報表輸出時間:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");

            dr5[0] = "結帳金額:" + M_Account_Amount;
            dr6[0] = "廠商業績獎金:" + 0;

            dr6[2] = "寄倉:-" + jicang;
            dr6[3] = "調度常溫運費:" + tempFreightDelivery_Normal;
            dr6[5] = "調度低溫運費:" + tempFreightDelivery_Low;
            dr7[0] = "廠商帳款總計:" + (M_Account_Amount_total + 0);//總計金額應該是結帳金額+獎金-寄倉費+調度常溫運費+調度低溫運費
            dr8[0] = "出貨模式:" + dispatch;
            dr9[0] = "歸檔日期";
            dr9[1] = "訂單日期";
            dr9[2] = "出貨日期";
            dr9[3] = "付款單編號";
            dr9[4] = "訂單編號";
            dr9[5] = "商品售價";
            dr9[6] = "商品成本";
            dr9[7] = "付款方式";
            dr9[8] = "一期刷卡費";
            dr9[9] = "常溫運費";
            dr9[10] = "低溫運費";
            dr9[11] = "常溫逆物流";
            dr9[12] = "低溫逆物流";
            dr9[13] = "結帳金額";
            dr9[14] = "商品模式";
            dr9[15] = "運費條件";
            dr9[16] = "組合方式";
            dr9[17] = "商品名稱";
            dr9[18] = "數量";
            dr9[19] = "子商品數量";
            dr9[20] = "成本";
            dr9[21] = "成本小計";
            dr9[22] = "活動價成本";
            dr9[23] = "滿額滿件折扣";
            dr9[24] = "售價";
            dr9[25] = "售價小計";
            dr9[26] = "退貨日期";
            dr9[27] = "商品狀態";
            dr9[28] = "父親商品編號";
            dr9[29] = "寄倉費";
            dr9[30] = "稅別";
            dr9[31] = "商品細項編號";
            dr9[32] = "國際編碼";
            dr9[33] = "管理員備註";
            dtHZ.Rows.Add(dr1);
            dtHZ.Rows.Add(dr2);
            dtHZ.Rows.Add(dr3);
            dtHZ.Rows.Add(dr4);
            dtHZ.Rows.Add(dr5);
            dtHZ.Rows.Add(dr6);
            dtHZ.Rows.Add(dr7);
            dtHZ.Rows.Add(dr8);
            dtHZ.Rows.Add(dr9);
            #endregion
            return dtHZ;
        }
        //#region 業績報表明細Excel信息+void ExportVendorAccountMonthDetail()
        //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);
        //        Dictionary<int, DataTable> tempDT = new Dictionary<int, DataTable>();
        //        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;
        //        //調度倉運費
        //        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);
        //        //結帳總金額扣除批次出貨運費
        //        int M_Account_Amount = Convert.ToInt32(tempTemp.Rows[0]["m_account_amount"]);
        //        if (!string.IsNullOrEmpty(tempTemp.Rows[0]["m_bag_check_money"].ToString()))
        //        {
        //            M_Account_Amount = M_Account_Amount - Convert.ToInt32(tempTemp.Rows[0]["m_bag_check_money"]);
        //        }
        //        if (tempFreightDelivery_Normal != 0)
        //        {
        //            M_Account_Amount += tempFreightDelivery_Normal;
        //        }
        //        if (tempFreightDelivery_Low != 0)
        //        {
        //            M_Account_Amount += tempFreightDelivery_Low;
        //        }
        //        string dispatch = string.Empty;
        //        if (vendorQuery.dispatch == 1)
        //        {
        //            dispatch = "調度倉";
        //        }
        //        else
        //        {
        //            dispatch = "非調度倉";
        //        }

        //        #region 匯出樣式
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        DataRow dr1 = dtHZ.NewRow();
        //        DataRow dr2 = dtHZ.NewRow();
        //        DataRow dr3 = dtHZ.NewRow();
        //        DataRow dr4 = dtHZ.NewRow();
        //        DataRow dr5 = dtHZ.NewRow();
        //        DataRow dr6 = dtHZ.NewRow();
        //        DataRow dr7 = dtHZ.NewRow();
        //        DataRow dr8 = dtHZ.NewRow();
        //        DataRow dr9 = dtHZ.NewRow();
        //        string strTemp = string.Empty;
        //        strTemp = "吉甲地市集" + Request.Params["dateOne"].ToString() + "年" + Request.Params["dateTwo"].ToString() + "月銷售報表";
        //        dr1[0] = strTemp.ToString();
        //        dr2[0] = "供應商編號:" + vendorQuery.vendor_code;
        //        dr3[0] = "供應商名稱:" + vendorQuery.vendor_name_simple;
        //        dr4[0] = "報表輸出時間:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
        //        dr5[0] = "結帳金額:" + M_Account_Amount;
        //        dr6[0] = "廠商業績獎金:" + 0 + "   " + "寄倉:" + tempTemp.Rows[0]["m_bag_check_money"].ToString() + "   " + "    " + "調度常溫運費:" + tempFreightDelivery_Normal + "   " + "調度低溫運費:" + tempFreightDelivery_Low;
        //        //dr6[2] = "寄倉:" + tempTemp.Rows[0]["m_bag_check_money"].ToString();
        //        //dr6[3] = "調度常溫運費:" + tempFreightDelivery_Normal;
        //        //dr6[5] = "調度低溫運費:" + tempFreightDelivery_Low;
        //        dr7[0] = "廠商帳款總計:" + (M_Account_Amount - 0);
        //        dr8[0] = "出貨模式:" + dispatch;
        //        dr9[0] = "歸檔日期";
        //        dr9[1] = "訂單日期";
        //        dr9[2] = "出貨日期";
        //        dr9[3] = "付款單編號";
        //        dr9[4] = "訂單編號";
        //        dr9[5] = "商品售價";
        //        dr9[6] = "商品成本";
        //        dr9[7] = "付款方式";
        //        dr9[8] = "一期刷卡費";
        //        dr9[9] = "常溫運費";
        //        dr9[10] = "低溫運費";
        //        dr9[11] = "常溫逆物流";
        //        dr9[12] = "低溫逆物流";
        //        dr9[13] = "結帳金額";
        //        dr9[14] = "商品模式";
        //        dr9[15] = "運費條件";
        //        dr9[16] = "組合方式";
        //        dr9[17] = "商品名稱";
        //        dr9[18] = "數量";
        //        dr9[19] = "子商品數量";
        //        dr9[20] = "成本";
        //        dr9[21] = "成本小計";
        //        dr9[22] = "活動價成本";
        //        dr9[23] = "滿額滿件折扣";
        //        dr9[24] = "售價";
        //        dr9[25] = "售價小計";
        //        dr9[26] = "退貨日期";
        //        dr9[27] = "商品狀態";
        //        dr9[28] = "父親商品編號";
        //        dr9[29] = "寄倉費";
        //        dr9[30] = "稅別";
        //        dr9[31] = "管理員備註";
        //        dtHZ.Rows.Add(dr1);
        //        dtHZ.Rows.Add(dr2);
        //        dtHZ.Rows.Add(dr3);
        //        dtHZ.Rows.Add(dr4);
        //        dtHZ.Rows.Add(dr5);
        //        dtHZ.Rows.Add(dr6);
        //        dtHZ.Rows.Add(dr7);
        //        dtHZ.Rows.Add(dr8);
        //        dtHZ.Rows.Add(dr9);
        //        #endregion
        //        _dt = _IVAMMgr.VendorAccountDetailExport(query);
        //        int product_money = 0;
        //        int product_cost = 0;
        //        int order_payment = 0;
        //        int money_creditcard_1 = 0;
        //        int freight_delivery_normal = 0;
        //        int freight_delivery_low = 0;
        //        int freight_return_normal = 0;
        //        int freight_return_low = 0;
        //        int account_amount = 0;
        //        int freeTax = 0;
        //        int taxAmount = 0;
        //        int mianx = 0;
        //        int yingx = 0;
        //        int yings = 0;
        //        string strOrderIds = string.Empty;
        //        for (int i = 0; i < _dt.Rows.Count; i++)
        //        {
        //            DataRow dr = dtHZ.NewRow();
        //            if (i > 0)
        //            {

        //                if (Convert.ToInt32(_dt.Rows[i]["order_id"]) != Convert.ToInt32(_dt.Rows[i - 1]["order_id"]))
        //                {
        //                    strOrderIds += _dt.Rows[i]["order_id"].ToString() + ",";
        //                    dr[0] = _dt.Rows[i]["account_date"].ToString();
        //                    dr[1] = _dt.Rows[i]["order_createdate"].ToString();
        //                    dr[2] = _dt.Rows[i]["slave_date_delivery"].ToString();
        //                    dr[3] = _dt.Rows[i]["order_id"].ToString();
        //                    dr[4] = _dt.Rows[i]["slave_id"].ToString();
        //                    dr[5] = _dt.Rows[i]["product_money"].ToString();
        //                    dr[6] = _dt.Rows[i]["product_cost"].ToString();
        //                    dr[7] = _dt.Rows[i]["parameterName"].ToString();
        //                    if (Convert.ToInt32(_dt.Rows[i]["money_creditcard_1"].ToString()) != 0)
        //                    {
        //                        dr[8] = "-" + _dt.Rows[i]["money_creditcard_1"].ToString();
        //                    }
        //                    else
        //                    {
        //                        dr[8] = 0;
        //                    }
        //                    dr[9] = _dt.Rows[i]["freight_delivery_normal"].ToString();
        //                    dr[10] = _dt.Rows[i]["freight_delivery_low"].ToString();
        //                    if (_dt.Rows[i]["freight_return_normal"].ToString() == "0")
        //                    {
        //                        dr[11] = _dt.Rows[i]["freight_return_normal"].ToString();
        //                    }
        //                    else
        //                    {
        //                        dr[11] = "-" + _dt.Rows[i]["freight_return_normal"].ToString();

        //                    }
        //                    if (_dt.Rows[i]["freight_return_low"].ToString() == "0")
        //                    {
        //                        dr[12] = _dt.Rows[i]["freight_return_low"].ToString();
        //                    }
        //                    else
        //                    {
        //                        dr[12] = "-" + _dt.Rows[i]["freight_return_low"].ToString();
        //                    }
        //                    dr[13] = _dt.Rows[i]["account_amount"].ToString();
        //                    if (!string.IsNullOrEmpty(_dt.Rows[i]["free_tax"].ToString()))
        //                    {
        //                        freeTax += Convert.ToInt32(_dt.Rows[i]["free_tax"].ToString());
        //                    }

        //                    if (!string.IsNullOrEmpty(_dt.Rows[i]["tax_amount"].ToString()))
        //                    {
        //                        taxAmount += Convert.ToInt32(_dt.Rows[i]["tax_amount"].ToString());
        //                    }
        //                    product_money += Convert.ToInt32(_dt.Rows[i]["product_money"].ToString());
        //                    product_cost += Convert.ToInt32(_dt.Rows[i]["product_cost"].ToString());
        //                    //order_payment += Convert.ToInt32(_dt.Rows[i]["order_payment"].ToString());原來php程式是所有的付款方式相加,因為是字符串所有加總都是0
        //                    money_creditcard_1 += Convert.ToInt32(_dt.Rows[i]["money_creditcard_1"].ToString());
        //                    freight_delivery_normal += Convert.ToInt32(_dt.Rows[i]["freight_delivery_normal"].ToString());
        //                    freight_delivery_low += Convert.ToInt32(_dt.Rows[i]["freight_delivery_low"].ToString());
        //                    freight_return_normal += Convert.ToInt32(_dt.Rows[i]["freight_return_normal"].ToString());
        //                    freight_return_low += Convert.ToInt32(_dt.Rows[i]["freight_return_low"].ToString());
        //                    account_amount += Convert.ToInt32(_dt.Rows[i]["account_amount"].ToString());

        //                }

        //            }
        //            else
        //            {
        //                strOrderIds += _dt.Rows[i]["order_id"].ToString() + ",";
        //                dr[0] = _dt.Rows[i]["account_date"].ToString();
        //                dr[1] = _dt.Rows[i]["order_createdate"].ToString();
        //                dr[2] = _dt.Rows[i]["slave_date_delivery"].ToString();
        //                dr[3] = _dt.Rows[i]["order_id"].ToString();
        //                dr[4] = _dt.Rows[i]["slave_id"].ToString();
        //                dr[5] = _dt.Rows[i]["product_money"].ToString();
        //                dr[6] = _dt.Rows[i]["product_cost"].ToString();
        //                dr[7] = _dt.Rows[i]["parameterName"].ToString();
        //                if (Convert.ToInt32(_dt.Rows[i]["money_creditcard_1"].ToString()) != 0)
        //                {
        //                    dr[8] = "-" + _dt.Rows[i]["money_creditcard_1"].ToString();
        //                }
        //                else
        //                {
        //                    dr[8] = 0;
        //                }
        //                dr[9] = _dt.Rows[i]["freight_delivery_normal"].ToString();
        //                dr[10] = _dt.Rows[i]["freight_delivery_low"].ToString();
        //                if (_dt.Rows[i]["freight_return_normal"].ToString() == "0")
        //                {
        //                    dr[11] = _dt.Rows[i]["freight_return_normal"].ToString();
        //                }
        //                else
        //                {
        //                    dr[11] = "-" + _dt.Rows[i]["freight_return_normal"].ToString();
        //                }
        //                if (_dt.Rows[i]["freight_return_low"].ToString() == "0")
        //                {
        //                    dr[12] = _dt.Rows[i]["freight_return_low"].ToString();
        //                }
        //                else
        //                {
        //                    dr[12] = "-" + _dt.Rows[i]["freight_return_low"].ToString();
        //                }
        //                dr[13] = _dt.Rows[i]["account_amount"].ToString();
        //                if (!string.IsNullOrEmpty(_dt.Rows[i]["free_tax"].ToString()))
        //                {
        //                    freeTax += Convert.ToInt32(_dt.Rows[i]["free_tax"].ToString());
        //                }

        //                if (!string.IsNullOrEmpty(_dt.Rows[i]["tax_amount"].ToString()))
        //                {
        //                    taxAmount += Convert.ToInt32(_dt.Rows[i]["tax_amount"].ToString());
        //                }
        //                product_money += Convert.ToInt32(_dt.Rows[i]["product_money"].ToString());
        //                product_cost += Convert.ToInt32(_dt.Rows[i]["product_cost"].ToString());
        //                //order_payment += Convert.ToInt32(_dt.Rows[i]["order_payment"].ToString());
        //                money_creditcard_1 += Convert.ToInt32(_dt.Rows[i]["money_creditcard_1"].ToString());
        //                freight_delivery_normal += Convert.ToInt32(_dt.Rows[i]["freight_delivery_normal"].ToString());
        //                freight_delivery_low += Convert.ToInt32(_dt.Rows[i]["freight_delivery_low"].ToString());
        //                freight_return_normal += Convert.ToInt32(_dt.Rows[i]["freight_return_normal"].ToString());
        //                freight_return_low += Convert.ToInt32(_dt.Rows[i]["freight_return_low"].ToString());
        //                account_amount += Convert.ToInt32(_dt.Rows[i]["account_amount"].ToString());
        //            }
        //            if (Convert.ToInt32(_dt.Rows[i]["product_mode"]) == 1)
        //            {
        //                dr[14] = "自出";
        //            }
        //            else if (Convert.ToInt32(_dt.Rows[i]["product_mode"]) == 2)
        //            {
        //                dr[14] = "寄倉";
        //            }
        //            else if (Convert.ToInt32(_dt.Rows[i]["product_mode"]) == 3)
        //            {
        //                dr[14] = "調度倉";
        //            }
        //            string single_cost_subtotal = string.Empty;//成本小計
        //            if (Convert.ToInt32(_dt.Rows[i]["detail_status"]) != 4)//已出貨
        //            {
        //                _dt.Rows[i]["single_money"] = 0;
        //                _dt.Rows[i]["single_cost"] = 0;
        //                single_cost_subtotal = "0";
        //            }
        //            else
        //            {
        //                single_cost_subtotal = (Convert.ToInt32(_dt.Rows[i]["single_cost"].ToString()) * Convert.ToInt32(_dt.Rows[i]["buy_num"].ToString())).ToString();
        //            }
        //            dr[15] = _dt.Rows[i]["product_freight"];//運送方式
        //            if (Convert.ToInt32(_dt.Rows[i]["item_mode"]) == 0)
        //            {
        //                dr[16] = "單一";
        //            }
        //            else if (Convert.ToInt32(_dt.Rows[i]["item_mode"]) == 1)
        //            {
        //                dr[16] = "父";
        //            }
        //            else if (Convert.ToInt32(_dt.Rows[i]["item_mode"]) == 2)
        //            {
        //                dr[16] = "子";
        //            }
        //            dr[17] = _dt.Rows[i]["product_name"].ToString() + _dt.Rows[i]["product_spec_name"].ToString();
        //            if (Convert.ToInt32(_dt.Rows[i]["item_mode"]) == 2)
        //            {
        //                dr[18] = "";
        //                dr[19] = _dt.Rows[i]["buy_num"].ToString();
        //                dr[20] = "";
        //                dr[21] = "";
        //                dr[22] = "";
        //                dr[23] = "";
        //                dr[24] = "";
        //                dr[25] = "";
        //            }
        //            else
        //            {
        //                dr[18] = _dt.Rows[i]["buy_num"].ToString();
        //                dr[19] = "";
        //                dr[20] = _dt.Rows[i]["single_cost"].ToString();
        //                dr[21] = single_cost_subtotal;
        //                dr[22] = Convert.ToInt32(_dt.Rows[i]["event_cost"].ToString()) == 0 ? "-" : Convert.ToInt32(_dt.Rows[i]["event_cost"].ToString()).ToString();
        //                dr[23] = _dt.Rows[i]["deduct_account"].ToString();
        //                dr[24] = _dt.Rows[i]["single_money"].ToString();
        //                dr[25] = (Convert.ToInt32(_dt.Rows[i]["single_money"].ToString()) * Convert.ToInt32(_dt.Rows[i]["buy_num"].ToString())).ToString();
        //            }
        //            dr[26] = "";
        //            dr[27] = _dt.Rows[i]["order_status_name"].ToString();
        //            dr[28] = _dt.Rows[i]["parent_id"].ToString();
        //            if (Convert.ToInt32(_dt.Rows[i]["od_bag_check_money"].ToString()) * Convert.ToInt32(_dt.Rows[i]["buy_num"].ToString()) == 0)
        //            {
        //                dr[29] = (Convert.ToInt32(_dt.Rows[i]["od_bag_check_money"].ToString()) * Convert.ToInt32(_dt.Rows[i]["buy_num"].ToString())).ToString();
        //            }
        //            else
        //            {
        //                dr[29] = "-" + (Convert.ToInt32(_dt.Rows[i]["od_bag_check_money"].ToString()) * Convert.ToInt32(_dt.Rows[i]["buy_num"].ToString())).ToString();
        //            }
        //            if (Convert.ToInt32(_dt.Rows[i]["tax_type"].ToString()) == 1)
        //            {
        //                dr[30] = "應稅";

        //            }
        //            if (Convert.ToInt32(_dt.Rows[i]["tax_type"].ToString()) == 3)
        //            {
        //                if (_dt.Rows[i]["freight_return_normal"].ToString() == "0" && _dt.Rows[i]["freight_return_low"].ToString() == "0")
        //                {
        //                    dr[30] = "應稅";
        //                }
        //                else
        //                {
        //                    dr[30] = "免稅";
        //                }
        //            }
        //            dr[31] = _dt.Rows[i]["note_admin"].ToString();
        //            dtHZ.Rows.Add(dr);
        //        }
        //        VendorAccountDetailQuery taxQuery = new VendorAccountDetailQuery();
        //        taxQuery.orderIds = strOrderIds.Remove(strOrderIds.LastIndexOf(','));
        //        DataTable dtTax = _IVAMMgr.GetTaxMoney(taxQuery);
        //        for (int i = 0; i < dtTax.Rows.Count; i++)
        //        {
        //            if (Convert.ToInt32(dtTax.Rows[i]["tax_type"]) == 1)
        //            {
        //                yingx += Convert.ToInt32(dtTax.Rows[i]["free_tax"]);
        //                yings += Convert.ToInt32(dtTax.Rows[i]["tax_amount"]);
        //            }
        //            if (Convert.ToInt32(dtTax.Rows[i]["tax_type"]) == 3)
        //            {
        //                mianx += Convert.ToInt32(dtTax.Rows[i]["free_tax"]);
        //            }
        //        }
        //        DataRow dre = dtHZ.NewRow();
        //        dre[0] = "總計";
        //        dre[5] = product_money;
        //        dre[6] = product_cost;
        //        dre[7] = order_payment;
        //        dre[8] = money_creditcard_1;
        //        dre[9] = freight_delivery_normal;
        //        dre[10] = freight_delivery_low;
        //        if (freight_return_normal != 0)
        //        {
        //            dre[11] = "-" + freight_return_normal;
        //        }
        //        else
        //        {
        //            dre[11] = freight_return_normal;
        //        }
        //        if (freight_return_low == 0)
        //        {
        //            dre[12] = freight_return_low;
        //        }
        //        else
        //        {
        //            dre[12] = "-" + freight_return_low;
        //        }
        //        dre[13] = account_amount;
        //        dtHZ.Rows.Add(dre);
        //        DataRow drTt = dtHZ.NewRow();
        //        dtHZ.Rows.Add(drTt);
        //        DataRow drTv = dtHZ.NewRow();
        //        dtHZ.Rows.Add(drTv);
        //        DataRow drT1 = dtHZ.NewRow();
        //        drT1[0] = "※廠商款每月20日結帳,逾20日收到的發票或收據其款項將計入下期支付。";
        //        dtHZ.Rows.Add(drT1);
        //        DataRow drT2 = dtHZ.NewRow();
        //        drT2[0] = "※發票抬頭:吉甲地好市集股份有限公司,統編:25137186。";
        //        dtHZ.Rows.Add(drT2);
        //        DataRow drShuiBei = dtHZ.NewRow();
        //        drShuiBei[13] = "稅別";
        //        drShuiBei[14] = "免稅";
        //        drShuiBei[15] = "應稅";
        //        drShuiBei[16] = "統計";
        //        dtHZ.Rows.Add(drShuiBei);
        //        DataRow DrXS = dtHZ.NewRow();
        //        DrXS[13] = "銷售額";
        //        DrXS[14] = mianx;
        //        DrXS[15] = yingx;
        //        DrXS[16] = "/";
        //        dtHZ.Rows.Add(DrXS);
        //        DataRow DrS = dtHZ.NewRow();
        //        DrS[13] = "稅額";
        //        DrS[14] = 0;
        //        DrS[15] = yings;
        //        DrS[16] = "/";
        //        dtHZ.Rows.Add(DrS);
        //        DataRow DrZong = dtHZ.NewRow();
        //        DrZong[13] = "發票金額";
        //        DrZong[14] = mianx;
        //        DrZong[15] = yings + yingx;
        //        DrZong[16] = mianx + yings + yingx;
        //        dtHZ.Rows.Add(DrZong);
        //        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 = new DataTable();
        //        if (dt.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_Low;
        //            dtYF.Rows.Add(tempdr2);
        //            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:[]}";
        //    }
        //}
        //#endregion

        //#region 總表明細+void ExportVendorAccountMonthAll()
        ///// <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;
        //        #region 定義列
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        dtHZ.Columns.Add("", typeof(String));
        //        #endregion
        //        //供應商信息
        //        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);

        //            //tempDT.Add(0, tempTemp);
        //            //供應商信息
        //            vendorQuery = _IVAMMgr.GetVendorInfoByCon(vendorQuery);
        //            //結帳總金額扣除批次出貨運費
        //            int M_Account_Amount = 0;
        //            if (!string.IsNullOrEmpty(tempTemp.Rows[0]["m_account_amount"].ToString()))
        //            {
        //                M_Account_Amount = Convert.ToInt32(tempTemp.Rows[0]["m_account_amount"]);
        //                if (!string.IsNullOrEmpty(tempTemp.Rows[0]["m_bag_check_money"].ToString()))
        //                {
        //                    M_Account_Amount = M_Account_Amount - Convert.ToInt32(tempTemp.Rows[0]["m_bag_check_money"]);
        //                }
        //                if (tempFreightDelivery_Normal != 0)
        //                {
        //                    M_Account_Amount += tempFreightDelivery_Normal;
        //                }
        //                if (tempFreightDelivery_Low != 0)
        //                {
        //                    M_Account_Amount += tempFreightDelivery_Low;
        //                }
        //            }

        //            string dispatch = string.Empty;
        //            if (vendorQuery.dispatch == 1)
        //            {
        //                dispatch = "調度倉";
        //            }
        //            else
        //            {
        //                dispatch = "非調度倉";
        //            }

        //            #region 匯出樣式
        //            DataRow dr1 = dtHZ.NewRow();
        //            DataRow dr2 = dtHZ.NewRow();
        //            DataRow dr3 = dtHZ.NewRow();
        //            DataRow dr4 = dtHZ.NewRow();
        //            DataRow dr5 = dtHZ.NewRow();
        //            DataRow dr6 = dtHZ.NewRow();
        //            DataRow dr7 = dtHZ.NewRow();
        //            DataRow dr8 = dtHZ.NewRow();
        //            DataRow dr9 = dtHZ.NewRow();
        //            dr1[0] = "吉甲地市集" + Request.Params["dateOne"].ToString() + "年" + Request.Params["dateTwo"].ToString() + "月銷售報表";
        //            //dr1[0] = "吉甲地市集" + 2014 + "年" + 2 + "月銷售報表";
        //            dr2[0] = "供應商編號:" + vendorQuery.vendor_code;
        //            dr3[0] = "供應商名稱:" + vendorQuery.vendor_name_simple;
        //            dr4[0] = "報表輸出時間:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
        //            dr5[0] = "結帳金額:" + M_Account_Amount;
        //            dr6[0] = "廠商業績獎金:" + 0 + "   " + "寄倉:" + tempTemp.Rows[0]["m_bag_check_money"].ToString() + "   " + "    " + "調度常溫運費:" + tempFreightDelivery_Normal + "   " + "調度低溫運費:" + tempFreightDelivery_Low; ;
        //            //dr6[2] = "寄倉:" + tempTemp.Rows[0]["m_bag_check_money"].ToString();
        //            //dr6[3] = "調度常溫運費:" + tempFreightDelivery_Normal;
        //            //dr6[5] = "調度低溫運費:" + tempFreightDelivery_Low;
        //            dr7[0] = "廠商帳款總計:" + (M_Account_Amount - 0);
        //            dr8[0] = "出貨模式:" + dispatch;
        //            dr9[0] = "歸檔日期";
        //            dr9[1] = "訂單日期";
        //            dr9[2] = "出貨日期";
        //            dr9[3] = "付款單編號";
        //            dr9[4] = "訂單編號";
        //            dr9[5] = "商品售價";
        //            dr9[6] = "商品成本";
        //            dr9[7] = "付款方式";
        //            dr9[8] = "一期刷卡費";
        //            dr9[9] = "常溫運費";
        //            dr9[10] = "低溫運費";
        //            dr9[11] = "常溫逆物流";
        //            dr9[12] = "低溫逆物流";
        //            dr9[13] = "結帳金額";
        //            dr9[14] = "商品模式";
        //            dr9[15] = "運費條件";
        //            dr9[16] = "組合方式";
        //            dr9[17] = "商品名稱";
        //            dr9[18] = "數量";
        //            dr9[19] = "子商品數量";
        //            dr9[20] = "成本";
        //            dr9[21] = "成本小計";
        //            dr9[22] = "活動價成本";
        //            dr9[23] = "滿額滿件折扣";
        //            dr9[24] = "售價";
        //            dr9[25] = "售價小計";
        //            dr9[26] = "退貨日期";
        //            dr9[27] = "商品狀態";
        //            dr9[28] = "寄倉費用";
        //            dr9[29] = "稅別";
        //            dr9[30] = "管理員備註";
        //            dtHZ.Rows.Add(dr1);
        //            dtHZ.Rows.Add(dr2);
        //            dtHZ.Rows.Add(dr3);
        //            dtHZ.Rows.Add(dr4);
        //            dtHZ.Rows.Add(dr5);
        //            dtHZ.Rows.Add(dr6);
        //            dtHZ.Rows.Add(dr7);
        //            dtHZ.Rows.Add(dr8);
        //            dtHZ.Rows.Add(dr9);
        //            #endregion
        //            _dt = _IVAMMgr.VendorAccountDetailExport(query);
        //            int product_money = 0;
        //            int product_cost = 0;
        //            int order_payment = 0;
        //            int money_creditcard_1 = 0;
        //            int freight_delivery_normal = 0;
        //            int freight_delivery_low = 0;
        //            int freight_return_normal = 0;
        //            int freight_return_low = 0;
        //            int account_amount = 0;
        //            int mianx = 0;
        //            int yingx = 0;
        //            int yings = 0;
        //            string strOrderIds = string.Empty;
        //            for (int i = 0; i < _dt.Rows.Count; i++)
        //            {
        //                DataRow dr = dtHZ.NewRow();
        //                if (i > 0)
        //                {
        //                    if (Convert.ToInt32(_dt.Rows[i]["order_id"]) != Convert.ToInt32(_dt.Rows[i - 1]["order_id"]))
        //                    {
        //                        strOrderIds += _dt.Rows[i]["order_id"].ToString() + ",";
        //                        dr[0] = _dt.Rows[i]["account_date"].ToString();
        //                        dr[1] = _dt.Rows[i]["order_createdate"].ToString();
        //                        dr[2] = _dt.Rows[i]["slave_date_delivery"].ToString();
        //                        dr[3] = _dt.Rows[i]["order_id"].ToString();
        //                        dr[4] = _dt.Rows[i]["slave_id"].ToString();
        //                        dr[5] = _dt.Rows[i]["product_money"].ToString();
        //                        dr[6] = _dt.Rows[i]["product_cost"].ToString();
        //                        dr[7] = _dt.Rows[i]["parameterName"].ToString();
        //                        if (Convert.ToInt32(_dt.Rows[i]["money_creditcard_1"].ToString()) != 0)
        //                        {
        //                            dr[8] = "-" + _dt.Rows[i]["money_creditcard_1"].ToString();
        //                        }
        //                        else
        //                        {
        //                            dr[8] = 0;
        //                        }
        //                        dr[9] = _dt.Rows[i]["freight_delivery_normal"].ToString();
        //                        dr[10] = _dt.Rows[i]["freight_delivery_low"].ToString();
        //                        if (_dt.Rows[i]["freight_return_normal"].ToString() == "0")
        //                        {
        //                            dr[11] = _dt.Rows[i]["freight_return_normal"].ToString();
        //                        }
        //                        else
        //                        {
        //                            dr[11] = "-" + _dt.Rows[i]["freight_return_normal"].ToString();
        //                        }
        //                        if (_dt.Rows[i]["freight_return_low"].ToString() == "0")
        //                        {
        //                            dr[12] = _dt.Rows[i]["freight_return_low"].ToString();
        //                        }
        //                        else
        //                        {
        //                            dr[12] = "-" + _dt.Rows[i]["freight_return_low"].ToString();
        //                        }
        //                        dr[13] = _dt.Rows[i]["account_amount"].ToString();
        //                        product_money += Convert.ToInt32(_dt.Rows[i]["product_money"].ToString());
        //                        product_cost += Convert.ToInt32(_dt.Rows[i]["product_cost"].ToString());
        //                        order_payment += Convert.ToInt32(_dt.Rows[i]["order_payment"].ToString());
        //                        money_creditcard_1 += Convert.ToInt32(_dt.Rows[i]["money_creditcard_1"].ToString());
        //                        freight_delivery_normal += Convert.ToInt32(_dt.Rows[i]["freight_delivery_normal"].ToString());
        //                        freight_delivery_low += Convert.ToInt32(_dt.Rows[i]["freight_delivery_low"].ToString());
        //                        freight_return_normal += Convert.ToInt32(_dt.Rows[i]["freight_return_normal"].ToString());
        //                        freight_return_low += Convert.ToInt32(_dt.Rows[i]["freight_return_low"].ToString());
        //                        account_amount += Convert.ToInt32(_dt.Rows[i]["account_amount"].ToString());
        //                    }
        //                }
        //                else
        //                {
        //                    strOrderIds += _dt.Rows[i]["order_id"].ToString() + ",";
        //                    dr[0] = _dt.Rows[i]["account_date"].ToString();
        //                    dr[1] = _dt.Rows[i]["order_createdate"].ToString();
        //                    dr[2] = _dt.Rows[i]["slave_date_delivery"].ToString();
        //                    dr[3] = _dt.Rows[i]["order_id"].ToString();
        //                    dr[4] = _dt.Rows[i]["slave_id"].ToString();
        //                    dr[5] = _dt.Rows[i]["product_money"].ToString();
        //                    dr[6] = _dt.Rows[i]["product_cost"].ToString();
        //                    dr[7] = _dt.Rows[i]["parameterName"].ToString();
        //                    if (Convert.ToInt32(_dt.Rows[i]["money_creditcard_1"].ToString()) != 0)
        //                    {
        //                        dr[8] = "-" + _dt.Rows[i]["money_creditcard_1"].ToString();
        //                    }
        //                    else
        //                    {
        //                        dr[8] = 0;
        //                    }
        //                    dr[9] = _dt.Rows[i]["freight_delivery_normal"].ToString();
        //                    dr[10] = _dt.Rows[i]["freight_delivery_low"].ToString();
        //                    if (_dt.Rows[i]["freight_return_normal"].ToString() == "0")
        //                    {
        //                        dr[11] = _dt.Rows[i]["freight_return_normal"].ToString();
        //                    }
        //                    else
        //                    {
        //                        dr[11] = "-" + _dt.Rows[i]["freight_return_normal"].ToString();
        //                    }
        //                    if (_dt.Rows[i]["freight_return_low"].ToString() == "0")
        //                    {
        //                        dr[12] = _dt.Rows[i]["freight_return_low"].ToString();
        //                    }
        //                    else
        //                    {
        //                        dr[12] = "-" + _dt.Rows[i]["freight_return_low"].ToString();
        //                    }
        //                    dr[13] = _dt.Rows[i]["account_amount"].ToString();
        //                    product_money += Convert.ToInt32(_dt.Rows[i]["product_money"].ToString());
        //                    product_cost += Convert.ToInt32(_dt.Rows[i]["product_cost"].ToString());
        //                    order_payment += Convert.ToInt32(_dt.Rows[i]["order_payment"].ToString());
        //                    money_creditcard_1 += Convert.ToInt32(_dt.Rows[i]["money_creditcard_1"].ToString());
        //                    freight_delivery_normal += Convert.ToInt32(_dt.Rows[i]["freight_delivery_normal"].ToString());
        //                    freight_delivery_low += Convert.ToInt32(_dt.Rows[i]["freight_delivery_low"].ToString());
        //                    freight_return_normal += Convert.ToInt32(_dt.Rows[i]["freight_return_normal"].ToString());
        //                    freight_return_low += Convert.ToInt32(_dt.Rows[i]["freight_return_low"].ToString());
        //                    account_amount += Convert.ToInt32(_dt.Rows[i]["account_amount"].ToString());
        //                }

        //                if (Convert.ToInt32(_dt.Rows[i]["product_mode"]) == 1)
        //                {
        //                    dr[14] = "自出";
        //                }
        //                else if (Convert.ToInt32(_dt.Rows[i]["product_mode"]) == 2)
        //                {
        //                    dr[14] = "寄倉";
        //                }
        //                else if (Convert.ToInt32(_dt.Rows[i]["product_mode"]) == 3)
        //                {
        //                    dr[14] = "調度倉";
        //                }
        //                string single_cost_subtotal = string.Empty;//成本小計
        //                if (Convert.ToInt32(_dt.Rows[i]["detail_status"]) != 4)//已出貨
        //                {
        //                    _dt.Rows[i]["single_money"] = 0;
        //                    _dt.Rows[i]["single_cost"] = 0;
        //                    single_cost_subtotal = "0";
        //                }
        //                else
        //                {
        //                    single_cost_subtotal = (Convert.ToInt32(_dt.Rows[i]["single_cost"].ToString()) * Convert.ToInt32(_dt.Rows[i]["buy_num"].ToString())).ToString();

        //                }
        //                dr[15] = _dt.Rows[i]["product_freight"];
        //                if (Convert.ToInt32(_dt.Rows[i]["item_mode"]) == 0)
        //                {
        //                    dr[16] = "單一";
        //                }
        //                if (Convert.ToInt32(_dt.Rows[i]["item_mode"]) == 1)
        //                {
        //                    dr[16] = "父";
        //                }
        //                if (Convert.ToInt32(_dt.Rows[i]["item_mode"]) == 2)
        //                {
        //                    dr[16] = "子";
        //                }
        //                dr[17] = _dt.Rows[i]["product_name"].ToString() + _dt.Rows[i]["product_spec_name"].ToString();
        //                if (Convert.ToInt32(_dt.Rows[i]["item_mode"]) == 2)
        //                {
        //                    dr[18] = "";
        //                    dr[19] = dt.Rows[i]["buy_num"].ToString();
        //                    dr[20] = "";
        //                    dr[21] = "";
        //                    dr[22] = "";
        //                    dr[23] = "";
        //                    dr[24] = "";
        //                    dr[25] = "";
        //                }
        //                else
        //                {
        //                    dr[18] = _dt.Rows[i]["buy_num"].ToString();
        //                    dr[19] = "";
        //                    dr[20] = _dt.Rows[i]["single_cost"].ToString();
        //                    dr[21] = single_cost_subtotal;
        //                    dr[22] = Convert.ToInt32(_dt.Rows[i]["event_cost"].ToString()) == 0 ? "-" : Convert.ToInt32(_dt.Rows[i]["event_cost"].ToString()).ToString();
        //                    dr[23] = _dt.Rows[i]["deduct_account"].ToString();
        //                    dr[24] = _dt.Rows[i]["single_money"].ToString();
        //                    dr[25] = (Convert.ToInt32(_dt.Rows[i]["single_money"].ToString()) * Convert.ToInt32(_dt.Rows[i]["buy_num"].ToString())).ToString();
        //                }
        //                dr[26] = "";
        //                dr[27] = _dt.Rows[i]["order_status_name"].ToString();
        //                if (Convert.ToInt32(_dt.Rows[i]["od_bag_check_money"].ToString()) * Convert.ToInt32(_dt.Rows[i]["buy_num"].ToString()) == 0)
        //                {
        //                    dr[28] = (Convert.ToInt32(_dt.Rows[i]["od_bag_check_money"].ToString()) * Convert.ToInt32(_dt.Rows[i]["buy_num"].ToString())).ToString();
        //                }
        //                else
        //                {
        //                    dr[28] = "-" + (Convert.ToInt32(_dt.Rows[i]["od_bag_check_money"].ToString()) * Convert.ToInt32(_dt.Rows[i]["buy_num"].ToString())).ToString();
        //                }
        //                if (Convert.ToInt32(_dt.Rows[i]["tax_type"].ToString()) == 1)
        //                {
        //                    dr[29] = "應稅";
        //                }
        //                if (Convert.ToInt32(_dt.Rows[i]["tax_type"].ToString()) == 3)
        //                {
        //                    if (_dt.Rows[i]["freight_return_normal"].ToString() != "0" && _dt.Rows[i]["freight_return_low"].ToString() != "0")
        //                    {
        //                        dr[29] = "應稅";
        //                    }
        //                    else
        //                    {
        //                        dr[29] = "免稅";
        //                    }
        //                }
        //                dr[30] = _dt.Rows[i]["note_admin"].ToString();
        //                dtHZ.Rows.Add(dr);
        //            }

        //            //DataRow dre = dtHZ.NewRow();
        //            //dre[0] = "總計";
        //            //dre[5] = product_money;
        //            //dre[6] = product_cost;
        //            //dre[7] = order_payment;
        //            //dre[8] = money_creditcard_1;
        //            //dre[9] = freight_delivery_normal;
        //            //dre[10] = freight_delivery_low;
        //            //if (freight_return_normal == 0)
        //            //{
        //            //    dre[11] = freight_return_normal;
        //            //}
        //            //else
        //            //{
        //            //    dre[11] = "-" + freight_return_normal;
        //            //}
        //            //if (freight_return_low == 0)
        //            //{
        //            //    dre[12] = freight_return_low;
        //            //}
        //            //else
        //            //{
        //            //    dre[12] = "-" + freight_return_low;
        //            //}
        //            //dre[13] = account_amount;
        //            //dtHZ.Rows.Add(dre);
        //            VendorAccountDetailQuery taxQuery = new VendorAccountDetailQuery();
        //            if (!string.IsNullOrEmpty(strOrderIds))
        //            {
        //                taxQuery.orderIds = strOrderIds.Remove(strOrderIds.LastIndexOf(','));
        //                DataTable dtTax = _IVAMMgr.GetTaxMoney(taxQuery);
        //                for (int i = 0; i < dtTax.Rows.Count; i++)
        //                {
        //                    if (Convert.ToInt32(dtTax.Rows[i]["tax_type"]) == 1)
        //                    {
        //                        yingx += Convert.ToInt32(dtTax.Rows[i]["free_tax"]);
        //                        yings += Convert.ToInt32(dtTax.Rows[i]["tax_amount"]);
        //                    }
        //                    if (Convert.ToInt32(dtTax.Rows[i]["tax_type"]) == 3)
        //                    {
        //                        mianx += Convert.ToInt32(dtTax.Rows[i]["free_tax"]);
        //                    }
        //                }
        //            }
        //            DataRow drTt = dtHZ.NewRow();
        //            dtHZ.Rows.Add(drTt);
        //            DataRow drTv = dtHZ.NewRow();
        //            dtHZ.Rows.Add(drTv);
        //            //if (m == vendorDt.Rows.Count - 1)
        //            //{
        //            //    DataRow drTt = dtHZ.NewRow();
        //            //    dtHZ.Rows.Add(drTt);
        //            //    DataRow drTv = dtHZ.NewRow();
        //            //    dtHZ.Rows.Add(drTv);
        //            //    DataRow drT1 = dtHZ.NewRow();
        //            //    drT1[0] = "※廠商款每月20日結帳,逾20日收到的發票或收據其款項將計入下期支付。";
        //            //    dtHZ.Rows.Add(drT1);
        //            //    DataRow drT2 = dtHZ.NewRow();
        //            //    drT2[0] = "※發票抬頭:吉甲地好市集股份有限公司,統編:25137186。";
        //            //    dtHZ.Rows.Add(drT2);
        //            //    DataRow drShuiBei = dtHZ.NewRow();
        //            //    drShuiBei[13] = "稅別";
        //            //    drShuiBei[14] = "免稅";
        //            //    drShuiBei[15] = "應稅";
        //            //    drShuiBei[16] = "統計";
        //            //    dtHZ.Rows.Add(drShuiBei);
        //            //    DataRow DrXS = dtHZ.NewRow();
        //            //    DrXS[13] = "銷售額";
        //            //    DrXS[14] = mianx;
        //            //    DrXS[15] = yingx;
        //            //    DrXS[16] = "/";
        //            //    dtHZ.Rows.Add(DrXS);
        //            //    DataRow DrS = dtHZ.NewRow();
        //            //    DrS[13] = "稅額";
        //            //    DrS[14] = 0;
        //            //    DrS[15] = yings;
        //            //    DrS[16] = "/";
        //            //    dtHZ.Rows.Add(DrS);
        //            //    DataRow DrZong = dtHZ.NewRow();
        //            //    DrZong[13] = "發票金額";
        //            //    DrZong[14] = mianx;
        //            //    DrZong[15] = yings + yingx;
        //            //    DrZong[16] = mianx + yings + yingx;
        //            //    dtHZ.Rows.Add(DrZong);
        //            //}
        //            //else
        //            //{
        //            //    DataRow drShuiBei = dtHZ.NewRow();
        //            //    drShuiBei[13] = "稅別";
        //            //    drShuiBei[14] = "免稅";
        //            //    drShuiBei[15] = "應稅";
        //            //    drShuiBei[16] = "統計";
        //            //    dtHZ.Rows.Add(drShuiBei);
        //            //    DataRow DrXS = dtHZ.NewRow();
        //            //    DrXS[13] = "銷售額";
        //            //    DrXS[14] = mianx;
        //            //    DrXS[15] = yingx;
        //            //    DrXS[16] = "/";
        //            //    dtHZ.Rows.Add(DrXS);
        //            //    DataRow DrS = dtHZ.NewRow();
        //            //    DrS[13] = "稅額";
        //            //    DrS[14] = 0;
        //            //    DrS[15] = yings;
        //            //    DrS[16] = "/";
        //            //    dtHZ.Rows.Add(DrS);
        //            //    DataRow DrZong = dtHZ.NewRow();
        //            //    DrZong[13] = "發票金額";
        //            //    DrZong[14] = mianx;
        //            //    DrZong[15] = yings + yingx;
        //            //    DrZong[16] = mianx + yings + yingx;
        //            //    dtHZ.Rows.Add(DrZong);
        //            //}
        //        }

        //        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:[]}";
        //        Response.Write("不存在");
        //    }
        //}
        //#endregion

        //#region 批次匯出各供應商的業績明細 +AllExportVendorAccountMonthDetail()
        ///// <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 _dt = new DataTable();
        //            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);
        //            //結帳總金額扣除批次出貨運費
        //            int M_Account_Amount = Convert.ToInt32(tempTemp.Rows[0]["m_account_amount"]);
        //            if (!string.IsNullOrEmpty(tempTemp.Rows[0]["m_bag_check_money"].ToString()))
        //            {
        //                M_Account_Amount = M_Account_Amount - Convert.ToInt32(tempTemp.Rows[0]["m_bag_check_money"]);
        //            }
        //            if (tempFreightDelivery_Normal != 0)
        //            {
        //                M_Account_Amount += tempFreightDelivery_Normal;
        //            }
        //            if (tempFreightDelivery_Low != 0)
        //            {
        //                M_Account_Amount += tempFreightDelivery_Low;
        //            }
        //            string dispatch = string.Empty;
        //            if (vendorQuery.dispatch == 1)
        //            {
        //                dispatch = "調度倉";
        //            }
        //            else
        //            {
        //                dispatch = "非調度倉";
        //            }

        //            #region 匯出樣式
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            dtHZ.Columns.Add("", typeof(String));
        //            DataRow dr1 = dtHZ.NewRow();
        //            DataRow dr2 = dtHZ.NewRow();
        //            DataRow dr3 = dtHZ.NewRow();
        //            DataRow dr4 = dtHZ.NewRow();
        //            DataRow dr5 = dtHZ.NewRow();
        //            DataRow dr6 = dtHZ.NewRow();
        //            DataRow dr7 = dtHZ.NewRow();
        //            DataRow dr8 = dtHZ.NewRow();
        //            DataRow dr9 = dtHZ.NewRow();
        //            dr1[0] = "吉甲地市集" + Request.Params["dateOne"].ToString() + "年" + Request.Params["dateTwo"].ToString() + "月銷售報表";
        //            //dr1[0] = "吉甲地市集" + 2014 + "年" + 2 + "月銷售報表";
        //            dr2[0] = "供應商編號:" + vendorQuery.vendor_code;
        //            dr3[0] = "供應商名稱:" + vendorQuery.vendor_name_simple;
        //            dr4[0] = "報表輸出時間:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
        //            dr5[0] = "結帳金額:" + M_Account_Amount;
        //            dr6[0] = "廠商業績獎金:" + 0 + "   " + "寄倉:" + tempTemp.Rows[0]["m_bag_check_money"].ToString() + "   " + "    " + "調度常溫運費:" + tempFreightDelivery_Normal + "   " + "調度低溫運費:" + tempFreightDelivery_Low; ;
        //            //dr6[2] = "寄倉:" + tempTemp.Rows[0]["m_bag_check_money"].ToString();
        //            //dr6[3] = "調度常溫運費:" + tempFreightDelivery_Normal;
        //            //dr6[5] = "調度低溫運費:" + tempFreightDelivery_Low;
        //            dr7[0] = "廠商帳款總計:" + (M_Account_Amount - 0);
        //            dr8[0] = "出貨模式:" + dispatch;
        //            dr9[0] = "歸檔日期";
        //            dr9[1] = "訂單日期";
        //            dr9[2] = "出貨日期";
        //            dr9[3] = "付款單編號";
        //            dr9[4] = "訂單編號";
        //            dr9[5] = "商品售價";
        //            dr9[6] = "商品成本";
        //            dr9[7] = "付款方式";
        //            dr9[8] = "一期刷卡費";
        //            dr9[9] = "常溫運費";
        //            dr9[10] = "低溫運費";
        //            dr9[11] = "常溫逆物流";
        //            dr9[12] = "低溫逆物流";
        //            dr9[13] = "結帳金額";
        //            dr9[14] = "商品模式";
        //            dr9[15] = "運費條件";
        //            dr9[16] = "組合方式";
        //            dr9[17] = "商品名稱";
        //            dr9[18] = "數量";
        //            dr9[19] = "子商品數量";
        //            dr9[20] = "成本";
        //            dr9[21] = "成本小計";
        //            dr9[22] = "活動價成本";
        //            dr9[23] = "滿額滿件折扣";
        //            dr9[24] = "售價";
        //            dr9[25] = "售價小計";
        //            dr9[26] = "退貨日期";
        //            dr9[27] = "商品狀態";
        //            dr9[28] = "父親商品編號";
        //            dr9[29] = "寄倉費";
        //            dr9[30] = "稅別";
        //            dr9[31] = "管理員備註";
        //            dtHZ.Rows.Add(dr1);
        //            dtHZ.Rows.Add(dr2);
        //            dtHZ.Rows.Add(dr3);
        //            dtHZ.Rows.Add(dr4);
        //            dtHZ.Rows.Add(dr5);
        //            dtHZ.Rows.Add(dr6);
        //            dtHZ.Rows.Add(dr7);
        //            dtHZ.Rows.Add(dr8);
        //            dtHZ.Rows.Add(dr9);
        //            #endregion
        //            _dt = _IVAMMgr.VendorAccountDetailExport(query);
        //            int product_money = 0;
        //            int product_cost = 0;
        //            int order_payment = 0;
        //            int money_creditcard_1 = 0;
        //            int freight_delivery_normal = 0;
        //            int freight_delivery_low = 0;
        //            int freight_return_normal = 0;
        //            int freight_return_low = 0;
        //            int account_amount = 0;
        //            //int freeTax = 0;
        //            //int taxAmount = 0;
        //            int mianx = 0;
        //            int yingx = 0;
        //            int yings = 0;
        //            string strOrderIds = string.Empty;
        //            for (int i = 0; i < _dt.Rows.Count; i++)
        //            {
        //                DataRow dr = dtHZ.NewRow();
        //                if (i > 0)
        //                {
        //                    if (Convert.ToInt32(_dt.Rows[i]["order_id"]) != Convert.ToInt32(_dt.Rows[i - 1]["order_id"]))
        //                    {
        //                        strOrderIds += _dt.Rows[i]["order_id"].ToString() + ",";
        //                        dr[0] = _dt.Rows[i]["account_date"].ToString();
        //                        dr[1] = _dt.Rows[i]["order_createdate"].ToString();
        //                        dr[2] = _dt.Rows[i]["slave_date_delivery"].ToString();
        //                        dr[3] = _dt.Rows[i]["order_id"].ToString();
        //                        dr[4] = _dt.Rows[i]["slave_id"].ToString();
        //                        dr[5] = _dt.Rows[i]["product_money"].ToString();
        //                        dr[6] = _dt.Rows[i]["product_cost"].ToString();
        //                        dr[7] = _dt.Rows[i]["parameterName"].ToString();
        //                        if (Convert.ToInt32(_dt.Rows[i]["money_creditcard_1"].ToString()) != 0)
        //                        {
        //                            dr[8] = "-" + _dt.Rows[i]["money_creditcard_1"].ToString();
        //                        }
        //                        else
        //                        {
        //                            dr[8] = 0;
        //                        }
        //                        dr[9] = _dt.Rows[i]["freight_delivery_normal"].ToString();
        //                        dr[10] = _dt.Rows[i]["freight_delivery_low"].ToString();
        //                        if (_dt.Rows[i]["freight_return_normal"].ToString() == "0")
        //                        {
        //                            dr[11] = _dt.Rows[i]["freight_return_normal"].ToString();
        //                        }
        //                        else
        //                        {
        //                            dr[11] = "-" + _dt.Rows[i]["freight_return_normal"].ToString();
        //                        }
        //                        if (_dt.Rows[i]["freight_return_low"].ToString() == "0")
        //                        {
        //                            dr[12] = _dt.Rows[i]["freight_return_low"].ToString();
        //                        }
        //                        else
        //                        {
        //                            dr[12] = "-" + _dt.Rows[i]["freight_return_low"].ToString();
        //                        }
        //                        dr[13] = _dt.Rows[i]["account_amount"].ToString();
        //                        product_money += Convert.ToInt32(_dt.Rows[i]["product_money"].ToString());
        //                        product_cost += Convert.ToInt32(_dt.Rows[i]["product_cost"].ToString());
        //                        //order_payment += Convert.ToInt32(_dt.Rows[i]["order_payment"].ToString());
        //                        money_creditcard_1 += Convert.ToInt32(_dt.Rows[i]["money_creditcard_1"].ToString());
        //                        freight_delivery_normal += Convert.ToInt32(_dt.Rows[i]["freight_delivery_normal"].ToString());
        //                        freight_delivery_low += Convert.ToInt32(_dt.Rows[i]["freight_delivery_low"].ToString());
        //                        freight_return_normal += Convert.ToInt32(_dt.Rows[i]["freight_return_normal"].ToString());
        //                        freight_return_low += Convert.ToInt32(_dt.Rows[i]["freight_return_low"].ToString());
        //                        account_amount += Convert.ToInt32(_dt.Rows[i]["account_amount"].ToString());
        //                    }

        //                }
        //                else
        //                {
        //                    strOrderIds += _dt.Rows[i]["order_id"].ToString() + ",";
        //                    dr[0] = _dt.Rows[i]["account_date"].ToString();
        //                    dr[1] = _dt.Rows[i]["order_createdate"].ToString();
        //                    dr[2] = _dt.Rows[i]["slave_date_delivery"].ToString();
        //                    dr[3] = _dt.Rows[i]["order_id"].ToString();
        //                    dr[4] = _dt.Rows[i]["slave_id"].ToString();
        //                    dr[5] = _dt.Rows[i]["product_money"].ToString();
        //                    dr[6] = _dt.Rows[i]["product_cost"].ToString();
        //                    dr[7] = _dt.Rows[i]["parameterName"].ToString();
        //                    if (Convert.ToInt32(_dt.Rows[i]["money_creditcard_1"].ToString()) != 0)
        //                    {
        //                        dr[8] = "-" + _dt.Rows[i]["money_creditcard_1"].ToString();
        //                    }
        //                    else
        //                    {
        //                        dr[8] = 0;
        //                    }
        //                    dr[9] = _dt.Rows[i]["freight_delivery_normal"].ToString();
        //                    dr[10] = _dt.Rows[i]["freight_delivery_low"].ToString();
        //                    if (_dt.Rows[i]["freight_return_normal"].ToString() == "0")
        //                    {
        //                        dr[11] = _dt.Rows[i]["freight_return_normal"].ToString();
        //                    }
        //                    else
        //                    {
        //                        dr[11] = "-" + _dt.Rows[i]["freight_return_normal"].ToString();

        //                    }
        //                    if (_dt.Rows[i]["freight_return_low"].ToString() == "0")
        //                    {
        //                        dr[12] = _dt.Rows[i]["freight_return_low"].ToString();
        //                    }
        //                    else
        //                    {
        //                        dr[12] = "-" + _dt.Rows[i]["freight_return_low"].ToString();
        //                    }
        //                    dr[13] = _dt.Rows[i]["account_amount"].ToString();
        //                    product_money += Convert.ToInt32(_dt.Rows[i]["product_money"].ToString());
        //                    product_cost += Convert.ToInt32(_dt.Rows[i]["product_cost"].ToString());
        //                    //order_payment += Convert.ToInt32(_dt.Rows[i]["order_payment"].ToString());
        //                    money_creditcard_1 += Convert.ToInt32(_dt.Rows[i]["money_creditcard_1"].ToString());
        //                    freight_delivery_normal += Convert.ToInt32(_dt.Rows[i]["freight_delivery_normal"].ToString());
        //                    freight_delivery_low += Convert.ToInt32(_dt.Rows[i]["freight_delivery_low"].ToString());
        //                    freight_return_normal += Convert.ToInt32(_dt.Rows[i]["freight_return_normal"].ToString());
        //                    freight_return_low += Convert.ToInt32(_dt.Rows[i]["freight_return_low"].ToString());
        //                    account_amount += Convert.ToInt32(_dt.Rows[i]["account_amount"].ToString());
        //                }

        //                if (Convert.ToInt32(_dt.Rows[i]["product_mode"]) == 1)
        //                {
        //                    dr[14] = "自出";
        //                }
        //                else if (Convert.ToInt32(_dt.Rows[i]["product_mode"]) == 2)
        //                {
        //                    dr[14] = "寄倉";
        //                }
        //                else if (Convert.ToInt32(_dt.Rows[i]["product_mode"]) == 3)
        //                {
        //                    dr[14] = "調度倉";
        //                }
        //                string single_cost_subtotal = string.Empty;//成本小計
        //                if (Convert.ToInt32(_dt.Rows[i]["detail_status"]) != 4)//已出貨
        //                {
        //                    _dt.Rows[i]["single_money"] = 0;
        //                    _dt.Rows[i]["single_cost"] = 0;
        //                    single_cost_subtotal = "0";
        //                }
        //                else
        //                {
        //                    single_cost_subtotal = (Convert.ToInt32(_dt.Rows[i]["single_cost"].ToString()) * Convert.ToInt32(_dt.Rows[i]["buy_num"].ToString())).ToString();
        //                }
        //                dr[15] = _dt.Rows[i]["product_freight"];//運送方式
        //                if (Convert.ToInt32(_dt.Rows[i]["item_mode"]) == 0)
        //                {
        //                    dr[16] = "單一";
        //                }
        //                else if (Convert.ToInt32(_dt.Rows[i]["item_mode"]) == 1)
        //                {
        //                    dr[16] = "父";
        //                }
        //                else if (Convert.ToInt32(_dt.Rows[i]["item_mode"]) == 2)
        //                {
        //                    dr[16] = "子";
        //                }
        //                dr[17] = _dt.Rows[i]["product_name"].ToString() + _dt.Rows[i]["product_spec_name"].ToString();
        //                if (Convert.ToInt32(_dt.Rows[i]["item_mode"]) == 2)
        //                {
        //                    dr[18] = "";
        //                    dr[19] = _dt.Rows[i]["buy_num"].ToString();
        //                    dr[20] = "";
        //                    dr[21] = "";
        //                    dr[22] = "";
        //                    dr[23] = "";
        //                    dr[24] = "";
        //                    dr[25] = "";
        //                }
        //                else
        //                {
        //                    dr[18] = _dt.Rows[i]["buy_num"].ToString();
        //                    dr[19] = "";
        //                    dr[20] = _dt.Rows[i]["single_cost"].ToString();
        //                    dr[21] = single_cost_subtotal;
        //                    dr[22] = Convert.ToInt32(_dt.Rows[i]["event_cost"].ToString()) == 0 ? "-" : Convert.ToInt32(_dt.Rows[i]["event_cost"].ToString()).ToString();
        //                    dr[23] = _dt.Rows[i]["deduct_account"].ToString();
        //                    dr[24] = _dt.Rows[i]["single_money"].ToString();
        //                    dr[25] = (Convert.ToInt32(_dt.Rows[i]["single_money"].ToString()) * Convert.ToInt32(_dt.Rows[i]["buy_num"].ToString())).ToString();
        //                }
        //                dr[26] = "";
        //                dr[27] = _dt.Rows[i]["order_status_name"].ToString();
        //                dr[28] = _dt.Rows[i]["parent_id"].ToString();
        //                if ((Convert.ToInt32(_dt.Rows[i]["od_bag_check_money"].ToString()) * Convert.ToInt32(_dt.Rows[i]["buy_num"].ToString())).ToString() == "0")
        //                {
        //                    dr[29] = (Convert.ToInt32(_dt.Rows[i]["od_bag_check_money"].ToString()) * Convert.ToInt32(_dt.Rows[i]["buy_num"].ToString())).ToString();
        //                }
        //                else
        //                {
        //                    dr[29] = "-" + (Convert.ToInt32(_dt.Rows[i]["od_bag_check_money"].ToString()) * Convert.ToInt32(_dt.Rows[i]["buy_num"].ToString())).ToString();
        //                }
        //                if (Convert.ToInt32(_dt.Rows[i]["tax_type"].ToString()) == 1)
        //                {

        //                    dr[30] = "應稅";
        //                }
        //                if (Convert.ToInt32(_dt.Rows[i]["tax_type"].ToString()) == 3)
        //                {
        //                    if (_dt.Rows[i]["freight_return_normal"].ToString() != "0" && _dt.Rows[i]["freight_return_low"].ToString() != "0")
        //                    {
        //                        dr[30] = "應稅";
        //                    }
        //                    else
        //                    {
        //                        dr[30] = "免稅";
        //                    }
        //                }
        //                dr[31] = _dt.Rows[i]["note_admin"].ToString();
        //                dtHZ.Rows.Add(dr);
        //            }
        //            VendorAccountDetailQuery taxQuery = new VendorAccountDetailQuery();
        //            if (!string.IsNullOrEmpty(strOrderIds))
        //            {
        //                taxQuery.orderIds = strOrderIds.Remove(strOrderIds.LastIndexOf(','));
        //                DataTable dtTax = _IVAMMgr.GetTaxMoney(taxQuery);
        //                for (int i = 0; i < dtTax.Rows.Count; i++)
        //                {
        //                    if (Convert.ToInt32(dtTax.Rows[i]["tax_type"]) == 1)
        //                    {
        //                        yingx += Convert.ToInt32(dtTax.Rows[i]["free_tax"]);
        //                        yings += Convert.ToInt32(dtTax.Rows[i]["tax_amount"]);
        //                    }
        //                    if (Convert.ToInt32(dtTax.Rows[i]["tax_type"]) == 3)
        //                    {
        //                        mianx += Convert.ToInt32(dtTax.Rows[i]["free_tax"]);
        //                    }
        //                }
        //            }

        //            DataRow dre = dtHZ.NewRow();
        //            dre[0] = "總計";
        //            dre[5] = product_money;
        //            dre[6] = product_cost;
        //            dre[7] = order_payment;
        //            dre[8] = money_creditcard_1;
        //            dre[9] = freight_delivery_normal;
        //            dre[10] = freight_delivery_low;
        //            if (freight_return_normal == 0)
        //            {
        //                dre[11] = freight_return_normal;
        //            }
        //            else
        //            {
        //                dre[11] = "-" + freight_return_normal;
        //            }
        //            if (freight_return_low == 0)
        //            {
        //                dre[12] = freight_return_low;
        //            }
        //            else
        //            {
        //                dre[12] = "-" + freight_return_low;
        //            }
        //            dre[13] = account_amount;
        //            dtHZ.Rows.Add(dre);
        //            DataRow drTt = dtHZ.NewRow();
        //            dtHZ.Rows.Add(drTt);
        //            DataRow drTv = dtHZ.NewRow();
        //            dtHZ.Rows.Add(drTv);
        //            DataRow drT1 = dtHZ.NewRow();
        //            drT1[0] = "※廠商款每月20日結帳,逾20日收到的發票或收據其款項將計入下期支付。";
        //            dtHZ.Rows.Add(drT1);
        //            DataRow drT2 = dtHZ.NewRow();
        //            drT2[0] = "※發票抬頭:吉甲地好市集股份有限公司,統編:25137186。";
        //            dtHZ.Rows.Add(drT2);
        //            DataRow drShuiBei = dtHZ.NewRow();
        //            drShuiBei[13] = "稅別";
        //            drShuiBei[14] = "免稅";
        //            drShuiBei[15] = "應稅";
        //            drShuiBei[16] = "統計";
        //            dtHZ.Rows.Add(drShuiBei);
        //            DataRow DrXS = dtHZ.NewRow();
        //            DrXS[13] = "銷售額";
        //            DrXS[14] = mianx;
        //            DrXS[15] = yingx;
        //            DrXS[16] = "/";
        //            dtHZ.Rows.Add(DrXS);
        //            DataRow DrS = dtHZ.NewRow();
        //            DrS[13] = "稅額";
        //            DrS[14] = 0;
        //            DrS[15] = yings;
        //            DrS[16] = "/";
        //            dtHZ.Rows.Add(DrS);
        //            DataRow DrZong = dtHZ.NewRow();
        //            DrZong[13] = "發票金額";
        //            DrZong[14] = mianx;
        //            DrZong[15] = yings + yingx;
        //            DrZong[16] = mianx + yings + yingx;
        //            dtHZ.Rows.Add(DrZong);
        //            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 = new DataTable();
        //            if (dt.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 (_dt.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);
        //                //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 = "";
        //        //string[] filesOrDirectoriesPaths = new string[] { @"D:\ConsultSystem\mgr\user.txt" };
        //        // Zip(strZipPath, strZipTopDirectoryPath, intZipLevel, strPassword, filesOrDirectoriesPaths);
        //        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}";
        //    }
        //    this.Response.Clear();
        //    this.Response.Write(json);
        //    this.Response.End();
        //    return this.Response;
        //}
        //#endregion

        public HttpResponseBase VendorName()
        {
            string json = string.Empty;
            DataTable _dt = new DataTable();
            VendorQuery query = new VendorQuery();
            try
            {

                _IVAMMgr = new VendorAccountMonthMgr(mySqlConnectionString);
                if (!string.IsNullOrEmpty(Request.Params["vendor_id"]))
                {
                    query.vendor_id = Convert.ToUInt32(Request.Params["vendor_id"]);
                }
                VendorQuery vendorQuery = _IVAMMgr.GetVendorInfoByCon(query);

                json = "{success:true,'msg':'" + vendorQuery.vendor_name_simple + "'}";//返回json數據
            }
            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;
        }
        /// <summary>
        /// 查詢調度倉運費計算
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public DataTable GetFreightMoney(VendorAccountDetailQuery query, out int tempFreightDelivery_Normal, out int tempFreightDelivery_Low)
        {
            tempFreightDelivery_Normal = 0;
            tempFreightDelivery_Low = 0;
            StringBuilder sql = new StringBuilder();
            try
            {
                VendorQuery VQuery = new VendorQuery();
                VQuery.vendor_id = query.vendor_id;
                VendorQuery vendorTemp = GetVendorInfoByCon(VQuery);
                sql.AppendFormat("select * , sum(normal_subtotal) as gnormal_subtotal , sum(hypothermia_subtotal) as ghypothermia_subtotal from order_slave_master where 1=1 ");
                sql.AppendFormat(" and deliver_time  + (86400 * 10)  >={0} and deliver_time  + (86400 * 10) <={1} and creator = {2} group by deliver_time ", query.search_start_time, query.search_end_time, query.vendor_id);
                DataTable temp = _access.getDataTable(sql.ToString());
                for (int i = 0; i < temp.Rows.Count; i++)
                {
                    if (Convert.ToInt32(temp.Rows[i]["gnormal_subtotal"]) != 0)
                    {
                        if (vendorTemp.freight_normal_limit > Convert.ToInt32(temp.Rows[i]["gnormal_subtotal"]))
                        {
                            tempFreightDelivery_Normal += Convert.ToInt32(vendorTemp.freight_normal_money);
                        }
                    }
                    if (Convert.ToInt32(temp.Rows[i]["ghypothermia_subtotal"]) != 0)
                    {
                        if (vendorTemp.freight_low_limit > Convert.ToInt32(temp.Rows[i]["ghypothermia_subtotal"]))
                        {
                            tempFreightDelivery_Low += Convert.ToInt32(vendorTemp.freight_low_money);
                        }
                    }
                    //temp.Rows[i]["Temp_Freight_Delivery_Normal"] = tempFreightDelivery_Normal;
                    //temp.Rows[i]["Temp_Freight_Delivery_Low"] = tempFreightDelivery_Low;
                }

                return temp;
            }
            catch (Exception ex)
            {

                throw new Exception("VendorAccountMonthDao-->GetFreightMoney-->" + sql.ToString() + ex.Message, ex);
            }
        }
Example #9
0
 public string ReturnHistoryCon(VendorQuery model)
 {
     model.Replace4MySQL();
     StringBuilder strSql = new StringBuilder();
     try
     {
         strSql.AppendFormat(" vendor_status:'{0}',vendor_email:'{1}',vendor_password:'{2}',vendor_name_full:'{3}',vendor_name_simple:'{4}',vendor_invoice:'{5}', ", model.vendor_status, model.vendor_email, model.vendor_password, model.vendor_name_full, model.vendor_name_simple, model.vendor_invoice);
         strSql.AppendFormat("company_phone:'{0}',company_fax:'{1}',company_person:'{2}',company_zip:'{3}',company_address:'{4}',invoice_zip:'{5}',invoice_address:'{6}',contact_type_1:'{7}',contact_name_1:'{8}',contact_phone_1_1:'{9}',", model.company_phone, model.company_fax, model.company_person, model.company_zip, model.company_address, model.invoice_zip, model.invoice_address, model.contact_type_1, model.contact_name_1, model.contact_phone_1_1);
         strSql.AppendFormat("contact_phone_2_1:'{0}',contact_mobile_1:'{1}',contact_email_1:'{2}',contact_type_2:'{3}',contact_name_2:'{4}',contact_phone_1_2:'{5}',contact_phone_2_2:'{6}',contact_mobile_2:'{7}',contact_email_2:'{8}',", model.contact_phone_2_1, model.contact_mobile_1, model.contact_email_1, model.contact_type_2, model.contact_name_2, model.contact_phone_1_2, model.contact_phone_2_2, model.contact_mobile_2, model.contact_email_2);
         strSql.AppendFormat("contact_type_3:'{0}',contact_name_3:'{1}',contact_phone_1_3:'{2}',contact_phone_2_3:'{3}',contact_mobile_3:'{4}',contact_email_3:'{5}',contact_type_4:'{6}',contact_name_4:'{7}',contact_phone_1_4:'{8}',", model.contact_type_3, model.contact_name_3, model.contact_phone_1_3, model.contact_phone_2_3, model.contact_mobile_3, model.contact_email_3, model.contact_type_4, model.contact_name_4, model.contact_phone_1_4);
         strSql.AppendFormat("contact_phone_2_4:'{0}',contact_mobile_4:'{1}',contact_email_4:'{2}',contact_type_5:'{3}',contact_name_5:'{4}',contact_phone_1_5:'{5}',contact_phone_2_5:'{6}',contact_mobile_5:'{7}',contact_email_5:'{8}',", model.contact_phone_2_4, model.contact_mobile_4, model.contact_email_4, model.contact_type_5, model.contact_name_5, model.contact_phone_1_5, model.contact_phone_2_5, model.contact_mobile_5, model.contact_email_5);
         strSql.AppendFormat("cost_percent:'{0}',creditcard_1_percent:'{1}',creditcard_3_percent:'{2}',sales_limit:'{3}',bonus_percent:'{4}',agreement_createdate:'{5}',agreement_start:'{6}',agreement_end:'{7}',checkout_type:'{8}',", model.cost_percent, model.creditcard_1_percent, model.creditcard_3_percent, model.sales_limit, model.bonus_percent, model.agreement_createdate, model.agreement_start, model.agreement_end, model.checkout_type);
         strSql.AppendFormat("checkout_other:'{0}',bank_code:'{1}',bank_name:'{2}',bank_number:'{3}',bank_account:'{4}',freight_low_limit:'{5}',freight_low_money:'{6}',freight_normal_limit:'{7}',freight_normal_money:'{8}',",
              model.checkout_other, model.bank_code, model.bank_name, model.bank_number, model.bank_account, model.freight_low_limit, model.freight_low_money, model.freight_normal_limit, model.freight_normal_money);
         strSql.AppendFormat("freight_return_low_money:'{0}',freight_return_normal_money:'{1}',vendor_note:'{2}',vendor_confirm_code:'{3}',vendor_login_attempts:'{4}',assist:'{5}',dispatch:'{6}',product_mode:'{7}',", model.freight_return_low_money, model.freight_return_normal_money, model.vendor_note, model.vendor_confirm_code, model.vendor_login_attempts, model.assist, model.dispatch, model.product_mode);
         strSql.AppendFormat("product_manage:'{0}',gigade_bunus_percent:'{1}',gigade_bunus_threshold :'{2}'", model.product_manage, model.gigade_bunus_percent, model.gigade_bunus_threshold);
         strSql.AppendFormat(",procurement_days:'{0}',self_send_days:'{1}',stuff_ware_days:'{2}',dispatch_days:'{3}'", model.procurement_days, model.self_send_days, model.stuff_ware_days, model.dispatch_days);
         return strSql.ToString();
     }
     catch (Exception ex)
     {
         throw new Exception(" VendorDao-->ReturnHistoryCon-->" + ex.Message + strSql.ToString(), ex);
     }
 }
Example #10
0
        public HttpResponseBase SaveVendor()
        {
            string jsonStr = String.Empty;
            try
            {
                VendorQuery venQuery = new VendorQuery();

                venQuery.user_type = 2;//變更者類型1.供應商2.管理員
                if (Request.Params["vendor_id"].ToString() == "")
                {
                    #region 獲取供應商數據
                    if (!string.IsNullOrEmpty(Request.Params["vendor_status"].ToString()))
                    {
                        venQuery.vendor_status = Convert.ToUInt32(Request.Params["vendor_status"].ToString());
                    }
                    else
                    {
                        venQuery.vendor_status = 1;
                    }

                    _vendorMgr = new VendorMgr(connectionString);
                    if (!string.IsNullOrEmpty(Request.Params["vendor_email"].ToString()))
                    {
                        try
                        {
                            if (_vendorMgr.IsExitEmail(Request.Params["vendor_email"].ToString().ToLower()) != 0)
                            {
                                jsonStr = "{success:true,msg:0}";//返回json數據
                                this.Response.Clear();
                                this.Response.Write(jsonStr);
                                this.Response.End();
                                return this.Response;
                            }
                            else
                            {
                                venQuery.vendor_email = Request.Params["vendor_email"].Trim().ToLower();
                            }
                        }
                        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);
                            jsonStr = "{success:false,msg:1}";
                            this.Response.Clear();
                            this.Response.Write(jsonStr);
                            this.Response.End();
                            return this.Response;
                        }
                    }
                    else
                    {
                        venQuery.vendor_email = "";
                    }

                    BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();
                    if (!string.IsNullOrEmpty(Request.Params["vendor_password"].ToString()))
                    {
                        venQuery.vendor_password = hash.SHA256Encrypt(Request.Params["vendor_password"].ToString());
                    }
                    else
                    {
                        //新增供應商時如果未設置密碼則將統一編號進行加密作為密碼進行保存
                        venQuery.vendor_password = hash.SHA256Encrypt(Request.Params["vendor_invoice"]);
                    }

                    if (!string.IsNullOrEmpty(Request.Params["vendor_name_full"].ToString()))
                    {
                        venQuery.vendor_name_full = Request.Params["vendor_name_full"].ToString().Trim();
                    }
                    else
                    {
                        venQuery.vendor_name_full = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["vendor_name_simple"].ToString()))
                    {
                        venQuery.vendor_name_simple = Request.Params["vendor_name_simple"].ToString().Trim();
                    }
                    else
                    {
                        venQuery.vendor_name_simple = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["vendor_invoice"].ToString()))
                    {
                        venQuery.vendor_invoice = Request.Params["vendor_invoice"].ToString();
                    }
                    else
                    {
                        venQuery.vendor_invoice = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["company_phone"].ToString()))
                    {
                        venQuery.company_phone = Request.Params["company_phone"].ToString();
                    }
                    else
                    {
                        venQuery.company_phone = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["company_fax"].ToString()))
                    {
                        venQuery.company_fax = Request.Params["company_fax"].ToString();
                    }
                    else
                    {
                        venQuery.company_fax = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["company_person"].ToString()))
                    {
                        venQuery.company_person = Request.Params["company_person"].ToString();
                    }
                    else
                    {
                        venQuery.company_person = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["company_zip"].ToString()))
                    {
                        venQuery.company_zip = Convert.ToUInt32(Request.Params["company_zip"].ToString());
                    }
                    else
                    {
                        venQuery.company_zip = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["company_address"].ToString()))
                    {
                        venQuery.company_address = Request.Params["company_address"].ToString();
                    }
                    else
                    {
                        venQuery.company_address = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["invoice_zip"].ToString()))
                    {
                        venQuery.invoice_zip = Convert.ToUInt32(Request.Params["invoice_zip"].ToString());
                    }
                    else
                    {
                        venQuery.invoice_zip = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["invoice_address"].ToString()))
                    {
                        venQuery.invoice_address = Request.Params["invoice_address"].ToString();
                    }
                    else
                    {
                        venQuery.invoice_address = "";
                    }

                    if (!string.IsNullOrEmpty(Request.Params["pm"].ToString()))
                    {
                        venQuery.product_manage = Convert.ToUInt32(Request.Params["pm"].ToString());
                    }
                    else
                    {
                        venQuery.product_manage = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["cost_percent"].ToString()))
                    {
                        venQuery.cost_percent = Convert.ToUInt32(Request.Params["cost_percent"].ToString());
                    }
                    else
                    {
                        venQuery.cost_percent = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["creditcard_1_percent"].ToString()))
                    {
                        venQuery.creditcard_1_percent = Convert.ToUInt32(Request.Params["creditcard_1_percent"].ToString());
                    }
                    else
                    {
                        venQuery.creditcard_1_percent = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["creditcard_3_percent"].ToString()))
                    {
                        venQuery.creditcard_3_percent = Request.Params["creditcard_3_percent"].ToString();
                    }
                    else
                    {
                        venQuery.creditcard_3_percent = "0";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["agreement_createdate"].ToString()))
                    {
                        venQuery.agreement_createdate = Convert.ToUInt32(CommonFunction.GetPHPTime(Request.Params["agreement_createdate"].ToString()));

                    }
                    else
                    {
                        venQuery.agreement_createdate = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["agreement_start"].ToString()))
                    {
                        venQuery.agreement_start = Convert.ToUInt32(CommonFunction.GetPHPTime(Request.Params["agreement_start"].ToString()));
                    }
                    else
                    {
                        venQuery.agreement_start = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["agreement_end"].ToString()))
                    {
                        venQuery.agreement_end = Convert.ToUInt32(CommonFunction.GetPHPTime(Request.Params["agreement_end"].ToString()));
                    }
                    else
                    {
                        venQuery.agreement_end = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["checkout_type"].ToString()))
                    {
                        venQuery.checkout_type = Convert.ToUInt32(Request.Params["checkout_type"].ToString());
                    }
                    else
                    {
                        venQuery.checkout_type = 1;
                    }
                    if (venQuery.checkout_type == 3)
                    {
                        if (!string.IsNullOrEmpty(Request.Params["checkout_other"].ToString()))
                        {
                            venQuery.checkout_other = Request.Params["checkout_other"].ToString();
                        }
                        else
                        {
                            venQuery.checkout_other = "";
                        }
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_code"].ToString()))
                    {
                        venQuery.bank_code = Request.Params["bank_code"].ToString();
                    }
                    else
                    {
                        venQuery.bank_code = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_name"].ToString()))
                    {
                        venQuery.bank_name = Request.Params["bank_name"].ToString();
                    }
                    else
                    {
                        venQuery.bank_name = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_number"].ToString()))
                    {
                        venQuery.bank_number = Request.Params["bank_number"].ToString();
                    }
                    else
                    {
                        venQuery.bank_number = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_account"].ToString()))
                    {
                        venQuery.bank_account = Request.Params["bank_account"].ToString();
                    }
                    else
                    {
                        venQuery.bank_account = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_number"].ToString()))
                    {
                        venQuery.bank_number = Request.Params["bank_number"].ToString();
                    }
                    else
                    {
                        venQuery.bank_number = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["freight_low_limit"].ToString()))
                    {
                        venQuery.freight_low_limit = Convert.ToUInt32(Request.Params["freight_low_limit"].ToString());
                    }
                    else
                    {
                        venQuery.freight_low_limit = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["freight_low_money"].ToString()))
                    {
                        venQuery.freight_low_money = Convert.ToUInt32(Request.Params["freight_low_money"].ToString());
                    }
                    else
                    {
                        venQuery.freight_low_money = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["freight_return_low_money"].ToString()))
                    {
                        venQuery.freight_return_low_money = Convert.ToUInt32(Request.Params["freight_return_low_money"].ToString());
                    }
                    else
                    {
                        venQuery.freight_return_low_money = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["freight_normal_limit"].ToString()))
                    {
                        venQuery.freight_normal_limit = Convert.ToUInt32(Request.Params["freight_normal_limit"].ToString());
                    }
                    else
                    {
                        venQuery.freight_normal_limit = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["freight_normal_money"].ToString()))
                    {
                        venQuery.freight_normal_money = Convert.ToUInt32(Request.Params["freight_normal_money"].ToString());
                    }
                    else
                    {
                        venQuery.freight_normal_money = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["freight_return_normal_money"].ToString()))
                    {
                        venQuery.freight_return_normal_money = Convert.ToUInt32(Request.Params["freight_return_normal_money"].ToString());
                    }
                    else
                    {
                        venQuery.freight_return_normal_money = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["assist"].ToString()))
                    {
                        venQuery.assist = Convert.ToUInt32(Request.Params["assist"].ToString());
                    }
                    else
                    {
                        venQuery.assist = 0;
                    }
                    //if (!string.IsNullOrEmpty(Request.Params["dispatch"].ToString()))
                    //{
                    //    venQuery.dispatch = Convert.ToUInt32(Request.Params["dispatch"].ToString());
                    //}
                    //else
                    //{
                    //    venQuery.dispatch = 0;
                    //}
                    //if (!string.IsNullOrEmpty(Request.Params["product_mode"].ToString()))
                    //{
                    //    venQuery.product_mode = Convert.ToUInt32(Request.Params["product_mode"].ToString());
                    //}
                    //else
                    //{
                    //    venQuery.product_mode = 1;
                    //}
                    if (!string.IsNullOrEmpty(Request.Params["procurement_days"].ToString()))
                    {
                        venQuery.procurement_days = Convert.ToInt32(Request.Params["procurement_days"].ToString());
                    }
                    else
                    {
                        venQuery.procurement_days = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["self_send_days"].ToString()))
                    {
                        venQuery.self_send_days = Convert.ToInt32(Request.Params["self_send_days"].ToString());
                    }
                    else
                    {
                        venQuery.self_send_days = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["stuff_ware_days"].ToString()))
                    {
                        venQuery.stuff_ware_days = Convert.ToInt32(Request.Params["stuff_ware_days"].ToString());
                    }
                    else
                    {
                        venQuery.stuff_ware_days = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["dispatch_days"].ToString()))
                    {
                        venQuery.dispatch_days = Convert.ToInt32(Request.Params["dispatch_days"].ToString());
                    }
                    else
                    {
                        venQuery.dispatch_days = 0;
                    }

                    if (!string.IsNullOrEmpty(Request.Params["gigade_bunus_percent"].ToString()))
                    {
                        venQuery.gigade_bunus_percent = Convert.ToUInt32(Request.Params["gigade_bunus_percent"].ToString());
                    }
                    else
                    {
                        venQuery.gigade_bunus_percent = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["gigade_bunus_threshold"].ToString()))
                    {
                        venQuery.gigade_bunus_threshold = Convert.ToUInt32(Request.Params["gigade_bunus_threshold"].ToString());
                    }
                    else
                    {
                        venQuery.gigade_bunus_threshold = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["vendor_note"].ToString()))
                    {
                        venQuery.vendor_note = Request.Params["vendor_note"].ToString();
                    }
                    else
                    {
                        venQuery.vendor_note = "";
                    }

                    if (!string.IsNullOrEmpty(Request.Params["prod_cate"].ToString()))
                    {
                        venQuery.prod_cate = Request.Params["prod_cate"].ToString();
                    }
                    else
                    {
                        venQuery.prod_cate = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["buy_cate"].ToString()))
                    {
                        venQuery.buy_cate = Request.Params["buy_cate"].ToString();
                    }
                    else
                    {
                        venQuery.buy_cate = "";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["tax_type"].ToString()))
                    {
                        venQuery.tax_type = Request.Params["tax_type"].ToString();
                    }
                    else
                    {
                        venQuery.tax_type = "";
                    }
                    #endregion

                    #region   //對聯絡人的 信息處理


                    if (!string.IsNullOrEmpty(Request.Params["conactValues"].ToString()))
                    {
                        string contact = Request.Params["conactValues"].ToString();
                        string[] contactarr = contact.Split('|');
                        string[] contact1;
                        for (int i = 0; i < contactarr.Length - 1; i++)
                        {
                            contact1 = contactarr[i].Split(',');
                            if (i == 0)
                            {
                                venQuery.contact_type_1 = 4;
                                venQuery.contact_name_1 = contact1[1];
                                venQuery.contact_phone_1_1 = contact1[2];
                                venQuery.contact_phone_2_1 = contact1[3];
                                venQuery.contact_mobile_1 = contact1[4];
                                venQuery.contact_email_1 = contact1[5].ToLower();
                            }
                            else if (i == 1)
                            {
                                venQuery.contact_type_2 = Convert.ToUInt32(ContactType(contact1[0].ToString()));
                                venQuery.contact_name_2 = contact1[1];
                                venQuery.contact_phone_1_2 = contact1[2];
                                venQuery.contact_phone_2_2 = contact1[3];
                                venQuery.contact_mobile_2 = contact1[4];
                                venQuery.contact_email_2 = contact1[5].ToLower().ToLower();
                            }
                            else if (i == 2)
                            {
                                venQuery.contact_type_3 = Convert.ToUInt32(ContactType(contact1[0].ToString()));
                                venQuery.contact_name_3 = contact1[1];
                                venQuery.contact_phone_1_3 = contact1[2];
                                venQuery.contact_phone_2_3 = contact1[3];
                                venQuery.contact_mobile_3 = contact1[4];
                                venQuery.contact_email_3 = contact1[5].ToLower();
                            }
                            else if (i == 3)
                            {
                                venQuery.contact_type_4 = Convert.ToUInt32(ContactType(contact1[0].ToString()));
                                venQuery.contact_name_4 = contact1[1];
                                venQuery.contact_phone_1_4 = contact1[2];
                                venQuery.contact_phone_2_4 = contact1[3];
                                venQuery.contact_mobile_4 = contact1[4];
                                venQuery.contact_email_4 = contact1[5].ToLower();
                            }
                            else if (i == 4)
                            {
                                venQuery.contact_type_5 = Convert.ToUInt32(ContactType(contact1[0].ToString()));
                                venQuery.contact_name_5 = contact1[1];
                                venQuery.contact_phone_1_5 = contact1[2];
                                venQuery.contact_phone_2_5 = contact1[3];
                                venQuery.contact_mobile_5 = contact1[4];
                                venQuery.contact_email_5 = contact1[5].ToLower();
                            }

                        }


                    }
                    #endregion
                    venQuery.ip = Request.UserHostAddress;
                    venQuery.file_name = "VendorList.chtml";
                    venQuery.created = DateTime.Now;
                    venQuery.kuser_id = Convert.ToUInt32((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString());
                    venQuery.export_flag = 1;
                    venQuery.kuser = (int)venQuery.kuser_id;
                    venQuery.kdate = venQuery.created;
                    //供應商類型
                    if (!string.IsNullOrEmpty(Request.Params["gigade_vendor_type"]))
                    {
                        venQuery.vendor_type = Request.Params["gigade_vendor_type"].ToString();
                    }
                    mgr = new CallerMgr(connectionString);
                    Caller caller = new Caller();
                    caller = mgr.GetUserById(Convert.ToInt32(venQuery.kuser_id));
                    venQuery.kuser_name = caller.user_username;

                    return VendorAdd(venQuery);
                }
                else
                {
                    venQuery.vendor_id = Convert.ToUInt32(Request.Params["vendor_id"].ToString());
                    venQuery.vendor_code = Request.Params["vendor_code"].ToString();
                    _vendorMgr = new VendorMgr(connectionString);
                    _configMgr = new ConfigMgr(connectionString);
                    Vendor oldven = _vendorMgr.GetSingle(venQuery);
                    StringBuilder update_log = new StringBuilder();
                    List<TableChangeLog> list = new List<TableChangeLog>();

                    #region 獲取供應商數據
                    uint isUint = 0;//判斷字符串是否能夠轉換為uint類型
                    if (uint.TryParse(Request.Params["vendor_status"].ToString(), out isUint))
                    {
                        venQuery.vendor_status = Convert.ToUInt32(Request.Params["vendor_status"].ToString());
                        if (oldven.vendor_status != venQuery.vendor_status)
                        {//1:啟用2:停用3:失格
                            // update_log.AppendFormat("vendor_status:{0}:{1}:供應商狀態#", oldven.vendor_status, venQuery.vendor_status);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "vendor_status";
                            item.old_value = oldven.vendor_status.ToString();
                            item.new_value = venQuery.vendor_status.ToString();
                            item.field_ch_name = "供應商狀態";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.vendor_status = oldven.vendor_status;
                    }
                    //供應商類型
                    if (!string.IsNullOrEmpty(Request.Params["gigade_vendor_type"]))
                    {
                        venQuery.vendor_type = Request.Params["gigade_vendor_type"].ToString();

                    }
                    int tmp = 0;
                    string[] strs = venQuery.vendor_type.Split(',');
                    for (int i = 0; i < strs.Length; i++)
                    {
                        if (!int.TryParse(strs[i], out tmp))
                        {
                            venQuery.vendor_type = oldven.vendor_type;
                            break;
                        }
                    }
                    if (oldven.vendor_type != venQuery.vendor_type)
                    {
                        // update_log.AppendFormat("vendor_type:{0}:{1}:供應商類型#", oldven.vendor_type, venQuery.vendor_type);
                        TableChangeLog item = new TableChangeLog();
                        item.change_field = "vendor_type";
                        item.old_value = oldven.vendor_type;
                        item.new_value = venQuery.vendor_type;
                        item.field_ch_name = "供應商類型";
                        list.Add(item);
                    }
                    if (!string.IsNullOrEmpty(Request.Params["vendor_email"].ToString()))
                    {
                        int total = _vendorMgr.IsExitEmail(Request.Params["vendor_email"].ToString().ToLower());
                        try
                        {
                            if (total > 1)
                            {
                                jsonStr = "{success:true,msg:0}";//返回json數據
                                this.Response.Clear();
                                this.Response.Write(jsonStr);
                                this.Response.End();
                                return this.Response;
                            }
                            else
                            {
                                if (total == 1)
                                {
                                    if (Request.Params["vendor_email"].ToString().ToLower() == oldven.vendor_email.ToLower())
                                    {
                                        venQuery.vendor_email = oldven.vendor_email.ToLower();
                                    }
                                    else
                                    {
                                        jsonStr = "{success:true,msg:0}";//返回json數據rue
                                        this.Response.Clear();
                                        this.Response.Write(jsonStr);
                                        this.Response.End();
                                        return this.Response;
                                    }
                                }
                                else if (total == 0)
                                {
                                    venQuery.vendor_email = Request.Params["vendor_email"].ToString().ToLower();
                                    if (oldven.vendor_email != venQuery.vendor_email)
                                    {
                                        // update_log.AppendFormat("vendor_email:{0}:{1}:公司Email#", oldven.vendor_email, venQuery.vendor_email);
                                        TableChangeLog item = new TableChangeLog();
                                        item.change_field = "vendor_email";
                                        item.old_value = oldven.vendor_email;
                                        item.new_value = venQuery.vendor_email;
                                        item.field_ch_name = "公司Email";
                                        list.Add(item);
                                    }
                                }
                            }
                        }
                        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);
                            jsonStr = "{success:false,msg:1}";
                            this.Response.Clear();
                            this.Response.Write(jsonStr);
                            this.Response.End();
                            return this.Response;
                        }
                    }
                    else
                    {
                        venQuery.vendor_email = oldven.vendor_email;
                    }
                    //if (!string.IsNullOrEmpty(Request.Params["vendor_password"].ToString()))
                    //{
                    //    BLL.gigade.Common.HashEncrypt hash = new BLL.gigade.Common.HashEncrypt();
                    //    venQuery.vendor_password = hash.SHA256Encrypt(Request.Params["vendor_password"].ToString());
                    //}
                    //else
                    //{
                    //    venQuery.vendor_password = oldven.vendor_password;
                    //}
                    if (!string.IsNullOrEmpty(Request.Params["vendor_name_full"].ToString()))
                    {
                        venQuery.vendor_name_full = Request.Params["vendor_name_full"].ToString().Trim();
                    }
                    else
                    {
                        venQuery.vendor_name_full = oldven.vendor_name_full;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["vendor_name_simple"].ToString()))
                    {
                        venQuery.vendor_name_simple = Request.Params["vendor_name_simple"].ToString().Trim();
                    }
                    else
                    {
                        venQuery.vendor_name_simple = oldven.vendor_name_simple;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["vendor_invoice"].ToString()))
                    {
                        venQuery.vendor_invoice = Request.Params["vendor_invoice"].ToString();
                        if (oldven.vendor_invoice != venQuery.vendor_invoice)
                        {
                            // update_log.AppendFormat("vendor_invoice:{0}:{1}:統一編號#", oldven.vendor_invoice, venQuery.vendor_invoice);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "vendor_invoice";
                            item.old_value = oldven.vendor_invoice;
                            item.new_value = venQuery.vendor_invoice;
                            item.field_ch_name = "統一編號";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.vendor_invoice = oldven.vendor_invoice;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["company_phone"].ToString()))
                    {
                        venQuery.company_phone = Request.Params["company_phone"].ToString();
                        if (oldven.company_phone != venQuery.company_phone)
                        {
                            //update_log.AppendFormat("company_phone:{0}:{1}:公司電話#", oldven.company_phone, venQuery.company_phone);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "company_phone";
                            item.old_value = oldven.company_phone;
                            item.new_value = venQuery.company_phone;
                            item.field_ch_name = "公司電話";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.company_phone = oldven.company_phone;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["company_fax"].ToString()))
                    {
                        venQuery.company_fax = Request.Params["company_fax"].ToString();
                        if (oldven.company_fax != venQuery.company_fax)
                        {
                            // update_log.AppendFormat("company_fax:{0}:{1}:公司傳真#", oldven.company_fax, venQuery.company_fax);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "company_fax";
                            item.old_value = oldven.company_fax;
                            item.new_value = venQuery.company_fax;
                            item.field_ch_name = "公司傳真";
                            list.Add(item);
                        }
                    }


                    if (!string.IsNullOrEmpty(Request.Params["company_person"].ToString()))
                    {
                        venQuery.company_person = Request.Params["company_person"].ToString();
                        if (oldven.company_person != venQuery.company_person)
                        {
                            //update_log.AppendFormat("company_person:{0}:{1}:公司負責人#", oldven.company_person, venQuery.company_person);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "company_person";
                            item.old_value = oldven.company_person;
                            item.new_value = venQuery.company_person;
                            item.field_ch_name = "公司負責人";
                            list.Add(item);
                        }
                    }

                    if (!string.IsNullOrEmpty(Request.Params["company_zip"].ToString()))
                    {

                        venQuery.company_zip = Convert.ToUInt32(Request.Params["company_zip"].ToString());

                    }

                    venQuery.company_address = Request.Params["company_address"].ToString();
                    if (oldven.company_zip != venQuery.company_zip || oldven.company_address != venQuery.company_address)
                    {
                        //update_log.AppendFormat("company_address:{0}:{1}:公司地址#", oldven.company_zip + "&" + oldven.company_address, venQuery.company_zip + "&" + venQuery.company_address);
                        TableChangeLog item = new TableChangeLog();
                        item.change_field = "company_address";
                        item.old_value = oldven.company_zip + "&" + oldven.company_address;
                        item.new_value = venQuery.company_zip + "&" + venQuery.company_address;
                        item.field_ch_name = "公司地址";
                        list.Add(item);
                    }
                    if (!string.IsNullOrEmpty(Request.Params["invoice_zip"].ToString()))
                    {
                        venQuery.invoice_zip = Convert.ToUInt32(Request.Params["invoice_zip"].ToString());
                    }

                    venQuery.invoice_address = Request.Params["invoice_address"].ToString();

                    if (oldven.invoice_zip != venQuery.invoice_zip || oldven.invoice_address != venQuery.invoice_address)
                    {
                        //update_log.AppendFormat("invoice_address:{0}:{1}:發票地址#", oldven.invoice_zip + "&" + oldven.invoice_address, venQuery.invoice_zip + "&" + venQuery.invoice_address);
                        TableChangeLog item = new TableChangeLog();
                        item.change_field = "invoice_address";
                        item.old_value = oldven.invoice_zip + "&" + oldven.invoice_address;
                        item.new_value = venQuery.invoice_zip + "&" + venQuery.invoice_address;
                        item.field_ch_name = "發票地址";
                        list.Add(item);
                    }
                    venQuery.erp_id = oldven.erp_id;
                    if (uint.TryParse(Request.Params["cost_percent"].ToString(), out isUint))
                    {
                        venQuery.cost_percent = Convert.ToUInt32(Request.Params["cost_percent"].ToString());
                        if (oldven.cost_percent != venQuery.cost_percent)
                        {
                            //update_log.AppendFormat("cost_percent:{0}:{1}:成本百分比#", oldven.cost_percent, venQuery.cost_percent);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "cost_percent";
                            item.old_value = oldven.cost_percent.ToString();
                            item.new_value = venQuery.cost_percent.ToString();
                            item.field_ch_name = "成本百分比";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.cost_percent = 0;
                    }


                    if (uint.TryParse(Request.Params["creditcard_1_percent"].ToString(), out isUint))
                    {
                        venQuery.creditcard_1_percent = Convert.ToUInt32(Request.Params["creditcard_1_percent"].ToString());
                    }
                    else
                    {
                        venQuery.creditcard_1_percent = 0;
                    }

                    if (!string.IsNullOrEmpty(Request.Params["creditcard_3_percent"].ToString()))
                    {
                        venQuery.creditcard_3_percent = Request.Params["creditcard_3_percent"].ToString();
                    }
                    else
                    {
                        venQuery.creditcard_3_percent = "0";
                    }
                    if (!string.IsNullOrEmpty(Request.Params["agreement_createdate"].ToString()))
                    {
                        venQuery.agreement_createdate = Convert.ToUInt32(CommonFunction.GetPHPTime(Request.Params["agreement_createdate"].ToString()));
                        if (oldven.agreement_createdate != venQuery.agreement_createdate)
                        {

                            //update_log.AppendFormat("agreement_createdate:{0}:{1}:合約簽訂日期#", CommonFunction.GetNetTime(oldven.agreement_createdate).ToShortDateString(), CommonFunction.GetNetTime(venQuery.agreement_createdate).ToShortDateString());
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "agreement_createdate";
                            item.old_value = CommonFunction.GetNetTime(oldven.agreement_createdate).ToShortDateString();
                            item.new_value = CommonFunction.GetNetTime(venQuery.agreement_createdate).ToShortDateString();
                            item.field_ch_name = "合約簽訂日期";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.agreement_createdate = oldven.agreement_createdate;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["agreement_start"].ToString()))
                    {
                        venQuery.agreement_start = Convert.ToUInt32(CommonFunction.GetPHPTime(Request.Params["agreement_start"].ToString()));
                        if (oldven.agreement_start != venQuery.agreement_start)
                        {
                            // update_log.AppendFormat("agreement_start:{0}:{1}:合約開始日#", CommonFunction.GetNetTime(oldven.agreement_start).ToShortDateString(), CommonFunction.GetNetTime(venQuery.agreement_start).ToShortDateString());
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "agreement_start";
                            item.old_value = CommonFunction.GetNetTime(oldven.agreement_start).ToShortDateString();
                            item.new_value = CommonFunction.GetNetTime(venQuery.agreement_start).ToShortDateString();
                            item.field_ch_name = "合約開始日";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.agreement_start = oldven.agreement_start;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["agreement_end"].ToString()))
                    {
                        venQuery.agreement_end = Convert.ToUInt32(CommonFunction.GetPHPTime(Request.Params["agreement_end"].ToString()));
                        if (oldven.agreement_end != venQuery.agreement_end)
                        {
                            // update_log.AppendFormat("agreement_end:{0}:{1}:合約結束日#", CommonFunction.GetNetTime(oldven.agreement_end).ToShortDateString(), CommonFunction.GetNetTime(venQuery.agreement_end).ToShortDateString());
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "agreement_end";
                            item.old_value = CommonFunction.GetNetTime(oldven.agreement_end).ToShortDateString();
                            item.new_value = CommonFunction.GetNetTime(venQuery.agreement_end).ToShortDateString();
                            item.field_ch_name = "合約結束日";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.agreement_end = oldven.agreement_end;
                    }
                    if (uint.TryParse(Request.Params["checkout_type"].ToString(), out isUint))
                    {
                        venQuery.checkout_type = Convert.ToUInt32(Request.Params["checkout_type"].ToString());
                    }
                    else
                    {
                        venQuery.checkout_type = oldven.checkout_type;
                    }
                    if (venQuery.checkout_type == 3)
                    {
                        if (!string.IsNullOrEmpty(Request.Params["checkout_other"].ToString()))
                        {
                            venQuery.checkout_other = Request.Params["checkout_other"].ToString();
                        }
                        else
                        {
                            venQuery.checkout_other = oldven.checkout_other;
                        }
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_code"].ToString()))
                    {
                        venQuery.bank_code = Request.Params["bank_code"].ToString();
                        if (oldven.bank_code != venQuery.bank_code)
                        {
                            //update_log.AppendFormat("bank_code:{0}:{1}:銀行代碼#", oldven.bank_code, venQuery.bank_code);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "bank_code";
                            item.old_value = oldven.bank_code;
                            item.new_value = venQuery.bank_code;
                            item.field_ch_name = "銀行代碼";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.bank_code = oldven.bank_code;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_name"].ToString()))
                    {
                        venQuery.bank_name = Request.Params["bank_name"].ToString();
                        if (oldven.bank_name != venQuery.bank_name)
                        {
                            //update_log.AppendFormat("bank_name:{0}:{1}:銀行名稱#", oldven.bank_name, venQuery.bank_name);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "bank_name";
                            item.old_value = oldven.bank_name;
                            item.new_value = venQuery.bank_name;
                            item.field_ch_name = "銀行名稱";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.bank_name = oldven.bank_name;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_number"].ToString()))
                    {
                        venQuery.bank_number = Request.Params["bank_number"].ToString();
                        if (oldven.bank_number != venQuery.bank_number)
                        {
                            // update_log.AppendFormat("bank_number:{0}:{1}:銀行賬號#", oldven.bank_number, venQuery.bank_number);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "bank_number";
                            item.old_value = oldven.bank_number;
                            item.new_value = venQuery.bank_number;
                            item.field_ch_name = "銀行賬號";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.bank_number = oldven.bank_number;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_account"].ToString()))
                    {
                        venQuery.bank_account = Request.Params["bank_account"].ToString();
                        if (oldven.bank_account != venQuery.bank_account)
                        {
                            //update_log.AppendFormat("bank_account:{0}:{1}:銀行戶名#", oldven.bank_account, venQuery.bank_account);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "bank_account";
                            item.old_value = oldven.bank_account;
                            item.new_value = venQuery.bank_account;
                            item.field_ch_name = "銀行戶名";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.bank_account = oldven.bank_account;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["bank_number"].ToString()))
                    {
                        venQuery.bank_number = Request.Params["bank_number"].ToString();
                    }
                    else
                    {
                        venQuery.bank_number = oldven.bank_number;
                    }

                    if (uint.TryParse(Request.Params["freight_low_limit"].ToString(), out isUint))
                    {
                        venQuery.freight_low_limit = Convert.ToUInt32(Request.Params["freight_low_limit"].ToString());
                    }
                    else
                    {
                        venQuery.freight_low_limit = 0;
                    }
                    if (uint.TryParse(Request.Params["freight_low_money"].ToString(), out isUint))
                    {
                        venQuery.freight_low_money = Convert.ToUInt32(Request.Params["freight_low_money"].ToString());
                    }
                    else
                    {
                        venQuery.freight_low_money = 0;
                    }
                    if (uint.TryParse(Request.Params["freight_return_low_money"].ToString(), out isUint))
                    {
                        venQuery.freight_return_low_money = Convert.ToUInt32(Request.Params["freight_return_low_money"].ToString());
                    }
                    else
                    {
                        venQuery.freight_return_low_money = 0;
                    }
                    if (uint.TryParse(Request.Params["freight_normal_limit"].ToString(), out isUint))
                    {
                        venQuery.freight_normal_limit = Convert.ToUInt32(Request.Params["freight_normal_limit"].ToString());
                    }
                    else
                    {
                        venQuery.freight_normal_limit = 0;
                    }
                    if (uint.TryParse(Request.Params["freight_normal_money"].ToString(), out isUint))
                    {
                        venQuery.freight_normal_money = Convert.ToUInt32(Request.Params["freight_normal_money"].ToString());
                    }
                    else
                    {
                        venQuery.freight_normal_money = 0;
                    }
                    if (uint.TryParse(Request.Params["freight_return_normal_money"].ToString(), out isUint))
                    {
                        venQuery.freight_return_normal_money = Convert.ToUInt32(Request.Params["freight_return_normal_money"].ToString());
                    }
                    else
                    {
                        venQuery.freight_return_normal_money = 0;
                    }
                    if (uint.TryParse(Request.Params["assist"].ToString(), out isUint))
                    {
                        venQuery.assist = Convert.ToUInt32(Request.Params["assist"].ToString());
                    }
                    else
                    {
                        venQuery.assist = venQuery.assist;
                    }
                    //if (uint.TryParse(Request.Params["dispatch"].ToString(), out isUint))
                    //{
                    //    venQuery.dispatch = Convert.ToUInt32(Request.Params["dispatch"].ToString());
                    //}
                    //else
                    //{
                    //    venQuery.dispatch = 0;
                    //}
                    //if (uint.TryParse(Request.Params["product_mode"].ToString(), out isUint))
                    //{
                    //    venQuery.product_mode = Convert.ToUInt32(Request.Params["product_mode"].ToString());
                    //}
                    //else
                    //{
                    //    venQuery.product_mode = 0;
                    //}
                    //try
                    //{
                    //    //Regex email = new System.Text.RegularExpressions.Regex("(([a-z0-9]{1})([\\.a-z0-9_-]*)@([a-z0-9]+)(\\.([a-z0-9]+)){1,3})");
                    //    //Regex name = new System.Text.RegularExpressions.Regex("[\u4e00-\u9fa5]");
                    //    //if (email.IsMatch(Request.Params["pm"].ToString()))
                    //    //{
                    //    //    venQuery.product_manage = _configMgr.QueryByEmail(Request.Params["pm"].ToString());
                    //    //}
                    //    //else if (name.IsMatch(Request.Params["pm"].ToString()))
                    //    //{
                    //    //    venQuery.product_manage = _configMgr.QueryByName(Request.Params["pm"].ToString());
                    //    //}
                    //}
                    //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);
                    //    venQuery.product_manage = 0;
                    //}
                    if (!string.IsNullOrEmpty(Request.Params["procurement_days"].ToString()))
                    {
                        venQuery.procurement_days = Convert.ToInt32(Request.Params["procurement_days"].ToString());
                    }
                    else
                    {
                        venQuery.procurement_days = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["self_send_days"].ToString()))
                    {
                        venQuery.self_send_days = Convert.ToInt32(Request.Params["self_send_days"].ToString());
                        if (oldven.self_send_days != venQuery.self_send_days)
                        {
                            //update_log.AppendFormat("self_send_days:{0}:{1}:自出出貨天數#", oldven.self_send_days, venQuery.self_send_days);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "self_send_days";
                            item.old_value = oldven.self_send_days.ToString();
                            item.new_value = venQuery.self_send_days.ToString();
                            item.field_ch_name = "自出出貨天數";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.self_send_days = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["stuff_ware_days"].ToString()))
                    {
                        venQuery.stuff_ware_days = Convert.ToInt32(Request.Params["stuff_ware_days"].ToString());
                        if (oldven.stuff_ware_days != venQuery.stuff_ware_days)
                        {
                            // update_log.AppendFormat("stuff_ware_days:{0}:{1}:寄倉出貨天數#", oldven.stuff_ware_days, venQuery.stuff_ware_days);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "stuff_ware_days";
                            item.old_value = oldven.stuff_ware_days.ToString();
                            item.new_value = venQuery.stuff_ware_days.ToString();
                            item.field_ch_name = "寄倉出貨天數";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.stuff_ware_days = 0;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["dispatch_days"].ToString()))
                    {
                        venQuery.dispatch_days = Convert.ToInt32(Request.Params["dispatch_days"].ToString());
                        if (oldven.dispatch_days != venQuery.dispatch_days)
                        {
                            // update_log.AppendFormat("dispatch_days:{0}:{1}:調度出貨天數#", oldven.dispatch_days, venQuery.dispatch_days);
                            TableChangeLog item = new TableChangeLog();
                            item.change_field = "dispatch_days";
                            item.old_value = oldven.dispatch_days.ToString();
                            item.new_value = venQuery.dispatch_days.ToString();
                            item.field_ch_name = "調度出貨天數";
                            list.Add(item);
                        }
                    }
                    else
                    {
                        venQuery.dispatch_days = 0;
                    }
                    if (Request.Params["pm"].ToString() == "")
                    {
                        venQuery.product_manage = 0;
                    }
                    else
                    {
                        if (uint.TryParse(Request.Params["pm"].ToString(), out isUint))
                        {
                            venQuery.product_manage = Convert.ToUInt32(Request.Params["pm"].ToString());
                        }
                        else
                        {
                            venQuery.product_manage = oldven.product_manage;
                        }
                    }
                    if (oldven.product_manage != venQuery.product_manage)
                    {
                        // update_log.AppendFormat("product_manage:{0}:{1}:管理人員#", oldven.product_manage, venQuery.product_manage);
                        TableChangeLog item = new TableChangeLog();
                        item.change_field = "product_manage";
                        item.old_value = oldven.product_manage.ToString();
                        item.new_value = venQuery.product_manage.ToString();
                        item.field_ch_name = "管理人員";
                        list.Add(item);
                    }
                    if (uint.TryParse(Request.Params["gigade_bunus_percent"].ToString(), out isUint))
                    {
                        venQuery.gigade_bunus_percent = Convert.ToUInt32(Request.Params["gigade_bunus_percent"].ToString());
                    }
                    else
                    {
                        venQuery.gigade_bunus_percent = 0;
                    }
                    if (uint.TryParse(Request.Params["gigade_bunus_threshold"].ToString(), out isUint))
                    {
                        venQuery.gigade_bunus_threshold = Convert.ToUInt32(Request.Params["gigade_bunus_threshold"].ToString());
                    }
                    else
                    {
                        venQuery.gigade_bunus_threshold = 0;
                    }
                    venQuery.vendor_note = Request.Params["vendor_note"].ToString();
                    #endregion

                    #region 對聯絡人的 信息處理
                    string delcon = string.Empty;

                    if (!string.IsNullOrEmpty(Request.Params["delconnect"].ToString()))
                    {
                        delcon = Request.Params["delconnect"].ToString().TrimEnd(',');
                        var delArr = delcon.Split(',');
                        int re_1 = 0, re_2 = 0, re_3 = 0;
                        if (delArr.Length == 4)
                        {
                            //update_log.AppendFormat("contact_type_2:{0}:{1}:原第二聯絡人類型#", oldven.contact_type_2, 7);                           
                            //update_log.AppendFormat("contact_name_2:{0}:{1}:原第二聯絡人姓名#", oldven.contact_name_2, "刪除");                          
                            //update_log.AppendFormat("contact_phone_1_2:{0}:{1}:原第二聯絡人電話一#", oldven.contact_phone_1_2, "刪除");
                            //update_log.AppendFormat("contact_phone_2_2:{0}:{1}:原第二聯絡人電話二#", oldven.contact_phone_2_2, "刪除");
                            //update_log.AppendFormat("contact_mobile_2:{0}:{1}:原第二聯絡人手機號碼#", oldven.contact_mobile_2, "刪除");
                            //update_log.AppendFormat("contact_email_2:{0}:{1}:原第二聯絡人郵箱#", oldven.contact_email_2, "刪除");
                            //update_log.AppendFormat("contact_type_3:{0}:{1}:原第三聯絡人類型#", oldven.contact_type_3, 7);
                            //update_log.AppendFormat("contact_name_3:{0}:{1}:原第三聯絡人姓名#", oldven.contact_name_3, "刪除");
                            //update_log.AppendFormat("contact_phone_1_3:{0}:{1}:原第三聯絡人電話一#", oldven.contact_phone_1_3, "刪除");
                            //update_log.AppendFormat("contact_phone_2_3:{0}:{1}:原第三聯絡人電話二#", oldven.contact_phone_2_3, "刪除");
                            //update_log.AppendFormat("contact_mobile_3:{0}:{1}:原第三聯絡人手機號碼#", oldven.contact_mobile_3, "刪除");
                            //update_log.AppendFormat("contact_email_3:{0}:{1}:原第三聯絡人郵箱#", oldven.contact_email_3, "刪除");
                            //update_log.AppendFormat("contact_type_4:{0}:{1}:原第四聯絡人類型#", oldven.contact_type_4, 7);
                            //update_log.AppendFormat("contact_name_4:{0}:{1}:原第四聯絡人姓名#", oldven.contact_name_4, "刪除");
                            //update_log.AppendFormat("contact_phone_1_4:{0}:{1}:原第四聯絡人電話一#", oldven.contact_phone_1_4, "刪除");
                            //update_log.AppendFormat("contact_phone_2_4:{0}:{1}:原第四聯絡人電話二#", oldven.contact_phone_2_4, "刪除");
                            //update_log.AppendFormat("contact_mobile_4:{0}:{1}:原第四聯絡人手機號碼#", oldven.contact_mobile_4, "刪除");
                            //update_log.AppendFormat("contact_email_4:{0}:{1}:原第四聯絡人郵箱#", oldven.contact_email_4, "刪除");
                            //update_log.AppendFormat("contact_type_5:{0}:{1}:第五聯絡人類型#", oldven.contact_type_5, 7);
                            //update_log.AppendFormat("contact_name_5:{0}:{1}:第五聯絡人姓名#", oldven.contact_name_5, "刪除");
                            //update_log.AppendFormat("contact_phone_1_5:{0}:{1}:第五聯絡人電話一#", oldven.contact_phone_1_5, "刪除");
                            //update_log.AppendFormat("contact_phone_2_5:{0}:{1}:第五聯絡人電話二#", oldven.contact_phone_2_5, "刪除");
                            //update_log.AppendFormat("contact_mobile_5:{0}:{1}:第五聯絡人手機號碼#", oldven.contact_mobile_5, "刪除");
                            //update_log.AppendFormat("contact_email_5:{0}:{1}:第五聯絡人郵箱#", oldven.contact_email_5, "刪除");

                            list.Add(new TableChangeLog() { change_field = "contact_type_2", old_value = oldven.contact_type_2.ToString(), new_value = "7", field_ch_name = "原第二聯絡人類型" });
                            list.Add(new TableChangeLog() { change_field = "contact_name_2", old_value = oldven.contact_name_2, new_value = "刪除", field_ch_name = "原第二聯絡人姓名" });
                            list.Add(new TableChangeLog() { change_field = "contact_phone_1_2", old_value = oldven.contact_phone_1_2, new_value = "刪除", field_ch_name = "原第二聯絡人電話一" });
                            list.Add(new TableChangeLog() { change_field = "contact_phone_2_2", old_value = oldven.contact_phone_2_2, new_value = "刪除", field_ch_name = "原第二聯絡人電話二" });
                            list.Add(new TableChangeLog() { change_field = "contact_mobile_2", old_value = oldven.contact_mobile_2, new_value = "刪除", field_ch_name = "原第二聯絡人手機號碼" });
                            list.Add(new TableChangeLog() { change_field = "contact_email_2", old_value = oldven.contact_email_2, new_value = "刪除", field_ch_name = "原第二聯絡人郵箱" });
                            list.Add(new TableChangeLog() { change_field = "contact_type_3", old_value = oldven.contact_type_3.ToString(), new_value = "7", field_ch_name = "原第三聯絡人類型" });
                            list.Add(new TableChangeLog() { change_field = "contact_name_3", old_value = oldven.contact_name_3, new_value = "刪除", field_ch_name = "原第三聯絡人姓名" });
                            list.Add(new TableChangeLog() { change_field = "contact_phone_1_3", old_value = oldven.contact_phone_1_3, new_value = "刪除", field_ch_name = "原第三聯絡人電話一" });
                            list.Add(new TableChangeLog() { change_field = "contact_phone_2_3", old_value = oldven.contact_phone_2_3, new_value = "刪除", field_ch_name = "原第三聯絡人電話二" });
                            list.Add(new TableChangeLog() { change_field = "contact_mobile_3", old_value = oldven.contact_mobile_3, new_value = "刪除", field_ch_name = "原第三聯絡人手機號碼" });
                            list.Add(new TableChangeLog() { change_field = "contact_email_3", old_value = oldven.contact_email_3, new_value = "刪除", field_ch_name = "原第三聯絡人郵箱" });
                            list.Add(new TableChangeLog() { change_field = "contact_type_4", old_value = oldven.contact_type_4.ToString(), new_value = "7", field_ch_name = "原第四聯絡人類型" });
                            list.Add(new TableChangeLog() { change_field = "contact_name_4", old_value = oldven.contact_name_4, new_value = "刪除", field_ch_name = "原第四聯絡人姓名" });
                            list.Add(new TableChangeLog() { change_field = "contact_phone_1_4", old_value = oldven.contact_phone_1_4, new_value = "刪除", field_ch_name = "原第四聯絡人電話一" });
                            list.Add(new TableChangeLog() { change_field = "contact_phone_2_4", old_value = oldven.contact_phone_2_4, new_value = "刪除", field_ch_name = "原第四聯絡人電話二" });
                            list.Add(new TableChangeLog() { change_field = "contact_mobile_4", old_value = oldven.contact_mobile_4, new_value = "刪除", field_ch_name = "原第四聯絡人手機號碼" });
                            list.Add(new TableChangeLog() { change_field = "contact_email_4", old_value = oldven.contact_email_4, new_value = "刪除", field_ch_name = "原第四聯絡人郵箱" });
                            list.Add(new TableChangeLog() { change_field = "contact_type_5", old_value = oldven.contact_type_5.ToString(), new_value = "7", field_ch_name = "第五聯絡人類型" });
                            list.Add(new TableChangeLog() { change_field = "contact_name_5", old_value = oldven.contact_name_5, new_value = "刪除", field_ch_name = "第五聯絡人姓名" });
                            list.Add(new TableChangeLog() { change_field = "contact_phone_1_5", old_value = oldven.contact_phone_1_5, new_value = "刪除", field_ch_name = "第五聯絡人電話一" });
                            list.Add(new TableChangeLog() { change_field = "contact_phone_2_5", old_value = oldven.contact_phone_2_5, new_value = "刪除", field_ch_name = "第五聯絡人電話二" });
                            list.Add(new TableChangeLog() { change_field = "contact_mobile_5", old_value = oldven.contact_mobile_5, new_value = "刪除", field_ch_name = "第五聯絡人手機號碼" });
                            list.Add(new TableChangeLog() { change_field = "contact_email_5", old_value = oldven.contact_email_5, new_value = "刪除", field_ch_name = "第五聯絡人郵箱" });
                        }
                        else
                        {
                            for (int i = 0; i < delArr.Length; i++)
                            {
                                int del = Convert.ToInt32(delArr[i]);

                                if (del == 1 && re_1 == 0 && oldven.contact_type_2 != 0)
                                {
                                    re_1++;
                                    //update_log.AppendFormat("contact_type_2:{0}:{1}:原第二聯絡人類型#", oldven.contact_type_2, 7);
                                    //update_log.AppendFormat("contact_name_2:{0}:{1}:原第二聯絡人姓名#", oldven.contact_name_2, "刪除");
                                    //update_log.AppendFormat("contact_phone_1_2:{0}:{1}:原第二聯絡人電話一#", oldven.contact_phone_1_2, "刪除");
                                    //update_log.AppendFormat("contact_phone_2_2:{0}:{1}:原第二聯絡人電話二#", oldven.contact_phone_2_2, "刪除");
                                    //update_log.AppendFormat("contact_mobile_2:{0}:{1}:原第二聯絡人手機號碼#", oldven.contact_mobile_2, "刪除");
                                    //update_log.AppendFormat("contact_email_2:{0}:{1}:原第二聯絡人郵箱#", oldven.contact_email_2, "刪除");

                                    list.Add(new TableChangeLog() { change_field = "contact_type_2", old_value = oldven.contact_type_2.ToString(), new_value = "7", field_ch_name = "原第二聯絡人類型" });
                                    list.Add(new TableChangeLog() { change_field = "contact_name_2", old_value = oldven.contact_name_2, new_value = "刪除", field_ch_name = "原第二聯絡人姓名" });
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_1_2", old_value = oldven.contact_phone_1_2, new_value = "刪除", field_ch_name = "原第二聯絡人電話一" });
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_2_2", old_value = oldven.contact_phone_2_2, new_value = "刪除", field_ch_name = "原第二聯絡人電話二" });
                                    list.Add(new TableChangeLog() { change_field = "contact_mobile_2", old_value = oldven.contact_mobile_2, new_value = "刪除", field_ch_name = "原第二聯絡人手機號碼" });
                                    list.Add(new TableChangeLog() { change_field = "contact_email_2", old_value = oldven.contact_email_2, new_value = "刪除", field_ch_name = "原第二聯絡人郵箱" });

                                }
                                else if (((del == 2 && re_2 == 0) || re_1 == 1) && oldven.contact_type_3 != 0)
                                {
                                    if (re_1 == 1)
                                    {
                                        re_1++;
                                    }
                                    else
                                    {
                                        re_2++;
                                    }
                                    //update_log.AppendFormat("contact_type_3:{0}:{1}:原第三聯絡人類型#", oldven.contact_type_3, 7);
                                    //update_log.AppendFormat("contact_name_3:{0}:{1}:原第三聯絡人姓名#", oldven.contact_name_3, "刪除");
                                    //update_log.AppendFormat("contact_phone_1_3:{0}:{1}:原第三聯絡人電話一#", oldven.contact_phone_1_3, "刪除");
                                    //update_log.AppendFormat("contact_phone_2_3:{0}:{1}:原第三聯絡人電話二#", oldven.contact_phone_2_3, "刪除");
                                    //update_log.AppendFormat("contact_mobile_3:{0}:{1}:原第三聯絡人手機號碼#", oldven.contact_mobile_3, "刪除");
                                    //update_log.AppendFormat("contact_email_3:{0}:{1}:原第三聯絡人郵箱#", oldven.contact_email_3, "刪除");
                                    list.Add(new TableChangeLog() { change_field = "contact_type_3", old_value = oldven.contact_type_3.ToString(), new_value = "7", field_ch_name = "原第三聯絡人類型" });
                                    list.Add(new TableChangeLog() { change_field = "contact_name_3", old_value = oldven.contact_name_3, new_value = "刪除", field_ch_name = "原第三聯絡人姓名" });
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_1_3", old_value = oldven.contact_phone_1_3, new_value = "刪除", field_ch_name = "原第三聯絡人電話一" });
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_2_3", old_value = oldven.contact_phone_2_3, new_value = "刪除", field_ch_name = "原第三聯絡人電話二" });
                                    list.Add(new TableChangeLog() { change_field = "contact_mobile_3", old_value = oldven.contact_mobile_3, new_value = "刪除", field_ch_name = "原第三聯絡人手機號碼" });
                                    list.Add(new TableChangeLog() { change_field = "contact_email_3", old_value = oldven.contact_email_3, new_value = "刪除", field_ch_name = "原第三聯絡人郵箱" });
                                }
                                else if (((del == 3 && re_3 == 0) || re_1 == 2 || re_2 == 1) && oldven.contact_type_4 != 0)
                                {
                                    if (re_1 == 2)
                                    {
                                        re_1++;
                                    }
                                    else if (re_2 == 1)
                                    {
                                        re_2++;
                                    }
                                    else
                                    {
                                        re_3++;
                                    }
                                    //update_log.AppendFormat("contact_type_4:{0}:{1}:原第四聯絡人類型#", oldven.contact_type_4, 7);
                                    //update_log.AppendFormat("contact_name_4:{0}:{1}:原第四聯絡人姓名#", oldven.contact_name_4, "刪除");
                                    //update_log.AppendFormat("contact_phone_1_4:{0}:{1}:原第四聯絡人電話一#", oldven.contact_phone_1_4, "刪除");
                                    //update_log.AppendFormat("contact_phone_2_4:{0}:{1}:原第四聯絡人電話二#", oldven.contact_phone_2_4, "刪除");
                                    //update_log.AppendFormat("contact_mobile_4:{0}:{1}:原第四聯絡人手機號碼#", oldven.contact_mobile_4, "刪除");
                                    //update_log.AppendFormat("contact_email_4:{0}:{1}:原第四聯絡人郵箱#", oldven.contact_email_4, "刪除");
                                    list.Add(new TableChangeLog() { change_field = "contact_type_4", old_value = oldven.contact_type_4.ToString(), new_value = "7", field_ch_name = "原第四聯絡人類型" });
                                    list.Add(new TableChangeLog() { change_field = "contact_name_4", old_value = oldven.contact_name_4, new_value = "刪除", field_ch_name = "原第四聯絡人姓名" });
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_1_4", old_value = oldven.contact_phone_1_4, new_value = "刪除", field_ch_name = "原第四聯絡人電話一" });
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_2_4", old_value = oldven.contact_phone_2_4, new_value = "刪除", field_ch_name = "原第四聯絡人電話二" });
                                    list.Add(new TableChangeLog() { change_field = "contact_mobile_4", old_value = oldven.contact_mobile_4, new_value = "刪除", field_ch_name = "原第四聯絡人手機號碼" });
                                    list.Add(new TableChangeLog() { change_field = "contact_email_4", old_value = oldven.contact_email_4, new_value = "刪除", field_ch_name = "原第四聯絡人郵箱" });
                                }
                                else if ((del == 4 || re_1 == 3 || re_2 == 2 || re_3 == 1) && oldven.contact_type_5 != 0)
                                {


                                    //update_log.AppendFormat("contact_type_5:{0}:{1}:第五聯絡人類型#", oldven.contact_type_5, 7);
                                    //update_log.AppendFormat("contact_name_5:{0}:{1}:第五聯絡人姓名#", oldven.contact_name_5, "刪除");
                                    //update_log.AppendFormat("contact_phone_1_5:{0}:{1}:第五聯絡人電話一#", oldven.contact_phone_1_5, "刪除");
                                    //update_log.AppendFormat("contact_phone_2_5:{0}:{1}:第五聯絡人電話二#", oldven.contact_phone_2_5, "刪除");
                                    //update_log.AppendFormat("contact_mobile_5:{0}:{1}:第五聯絡人手機號碼#", oldven.contact_mobile_5, "刪除");
                                    //update_log.AppendFormat("contact_email_5:{0}:{1}:第五聯絡人郵箱#", oldven.contact_email_5, "刪除");
                                    list.Add(new TableChangeLog() { change_field = "contact_type_5", old_value = oldven.contact_type_5.ToString(), new_value = "7", field_ch_name = "第五聯絡人類型" });
                                    list.Add(new TableChangeLog() { change_field = "contact_name_5", old_value = oldven.contact_name_5, new_value = "刪除", field_ch_name = "第五聯絡人姓名" });
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_1_5", old_value = oldven.contact_phone_1_5, new_value = "刪除", field_ch_name = "第五聯絡人電話一" });
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_2_5", old_value = oldven.contact_phone_2_5, new_value = "刪除", field_ch_name = "第五聯絡人電話二" });
                                    list.Add(new TableChangeLog() { change_field = "contact_mobile_5", old_value = oldven.contact_mobile_5, new_value = "刪除", field_ch_name = "第五聯絡人手機號碼" });
                                    list.Add(new TableChangeLog() { change_field = "contact_email_5", old_value = oldven.contact_email_5, new_value = "刪除", field_ch_name = "第五聯絡人郵箱" });
                                }
                            }
                        }
                    }


                    string[] contactarr = null;
                    if (!string.IsNullOrEmpty(Request.Params["conactValues"].ToString()))
                    {

                        string contact = Request.Params["conactValues"].ToString();
                        contactarr = contact.Split('|');
                    }
                    for (int i = 0; i < 5; i++)
                    {
                        string[] contact1 = null;
                        if (contactarr != null && contactarr.Length > i + 1)
                        {
                            contact1 = contactarr[i].Split(',');
                        }
                        if (i == 0)
                        {
                            if (contact1 != null)
                            {
                                venQuery.contact_type_1 = 4;
                                venQuery.contact_name_1 = contact1[1];
                                venQuery.contact_phone_1_1 = contact1[2];
                                venQuery.contact_phone_2_1 = contact1[3];
                                venQuery.contact_mobile_1 = contact1[4];
                                venQuery.contact_email_1 = contact1[5].ToLower();

                                if (oldven.contact_type_1 != venQuery.contact_type_1)
                                {
                                    // update_log.AppendFormat("contact_type_1:{0}:{1}:第一聯絡人類型#", oldven.contact_type_1, venQuery.contact_type_1);
                                    list.Add(new TableChangeLog() { change_field = "contact_type_1", old_value = oldven.contact_type_1.ToString(), new_value = venQuery.contact_type_1.ToString(), field_ch_name = "第一聯絡人類型" });
                                }
                                if (oldven.contact_name_1 != venQuery.contact_name_1)
                                {
                                    // update_log.AppendFormat("contact_name_1:{0}:{1}:第一聯絡人姓名#", oldven.contact_name_1, venQuery.contact_name_1);
                                    list.Add(new TableChangeLog() { change_field = "contact_name_1", old_value = oldven.contact_name_1, new_value = venQuery.contact_name_1, field_ch_name = "第一聯絡人姓名" });
                                }
                                if (oldven.contact_phone_1_1 != venQuery.contact_phone_1_1)
                                {
                                    //update_log.AppendFormat("contact_phone_1_1:{0}:{1}:第一聯絡人電話一#", oldven.contact_phone_1_1, venQuery.contact_phone_1_1);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_1_1", old_value = oldven.contact_phone_1_1, new_value = venQuery.contact_phone_1_1, field_ch_name = "第一聯絡人電話一" });
                                }
                                if (oldven.contact_phone_2_1 != venQuery.contact_phone_2_1)
                                {
                                    // update_log.AppendFormat("contact_phone_2_1:{0}:{1}:第一聯絡人電話二#", oldven.contact_phone_2_1, venQuery.contact_phone_2_1);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_2_1", old_value = oldven.contact_phone_2_1, new_value = venQuery.contact_phone_2_1, field_ch_name = "第一聯絡人電話二" });
                                }
                                if (oldven.contact_mobile_1 != venQuery.contact_mobile_1)
                                {
                                    // update_log.AppendFormat("contact_mobile_1:{0}:{1}:第一聯絡人手機號碼#", oldven.contact_mobile_1, venQuery.contact_mobile_1);
                                    list.Add(new TableChangeLog() { change_field = "contact_mobile_1", old_value = oldven.contact_mobile_1, new_value = venQuery.contact_mobile_1, field_ch_name = "第一聯絡人手機號碼" });
                                }
                                if (oldven.contact_email_1 != venQuery.contact_email_1)
                                {
                                    //update_log.AppendFormat("contact_email_1:{0}:{1}:第一聯絡人郵箱#", oldven.contact_email_1, venQuery.contact_email_1);
                                    list.Add(new TableChangeLog() { change_field = "contact_email_1", old_value = oldven.contact_email_1, new_value = venQuery.contact_email_1, field_ch_name = "第一聯絡人郵箱" });
                                }

                            }
                        }
                        else if (i == 1)
                        {


                            if (contact1 != null)
                            {
                                venQuery.contact_type_2 = Convert.ToUInt32(ContactType(contact1[0].ToString()));
                                venQuery.contact_name_2 = contact1[1];
                                venQuery.contact_phone_1_2 = contact1[2];
                                venQuery.contact_phone_2_2 = contact1[3];
                                venQuery.contact_mobile_2 = contact1[4];
                                venQuery.contact_email_2 = contact1[5].ToLower().ToLower();

                                if (oldven.contact_type_2 != venQuery.contact_type_2)
                                {
                                    // update_log.AppendFormat("contact_type_2:{0}:{1}:第二聯絡人類型#", oldven.contact_type_2, venQuery.contact_type_2);
                                    list.Add(new TableChangeLog() { change_field = "contact_type_2", old_value = oldven.contact_type_2.ToString(), new_value = venQuery.contact_type_2.ToString(), field_ch_name = "第二聯絡人類型" });
                                }
                                if (oldven.contact_name_2 != venQuery.contact_name_2)
                                {
                                    //update_log.AppendFormat("contact_name_2:{0}:{1}:第二聯絡人姓名#", oldven.contact_name_2, venQuery.contact_name_2);
                                    list.Add(new TableChangeLog() { change_field = "contact_name_2", old_value = oldven.contact_name_2, new_value = venQuery.contact_name_2, field_ch_name = "第二聯絡人姓名" });
                                }
                                if (oldven.contact_phone_1_2 != venQuery.contact_phone_1_2)
                                {
                                    //update_log.AppendFormat("contact_phone_1_2:{0}:{1}:第二聯絡人電話一#", oldven.contact_phone_1_2, venQuery.contact_phone_1_2);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_1_2", old_value = oldven.contact_phone_1_2, new_value = venQuery.contact_phone_1_2, field_ch_name = "第二聯絡人電話一" });
                                }
                                if (oldven.contact_phone_2_2 != venQuery.contact_phone_2_2)
                                {
                                    //update_log.AppendFormat("contact_phone_2_2:{0}:{1}:第二聯絡人電話二#", oldven.contact_phone_2_2, venQuery.contact_phone_2_2);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_2_2", old_value = oldven.contact_phone_2_2, new_value = venQuery.contact_phone_2_2, field_ch_name = "第二聯絡人電話二" });
                                }
                                if (oldven.contact_mobile_2 != venQuery.contact_mobile_2)
                                {
                                    // update_log.AppendFormat("contact_mobile_2:{0}:{1}:第二聯絡人手機號碼#", oldven.contact_mobile_2, venQuery.contact_mobile_2);
                                    list.Add(new TableChangeLog() { change_field = "contact_mobile_2", old_value = oldven.contact_mobile_2, new_value = venQuery.contact_mobile_2, field_ch_name = "第二聯絡人手機號碼" });
                                }
                                if (oldven.contact_email_2 != venQuery.contact_email_2)
                                {
                                    // update_log.AppendFormat("contact_email_2:{0}:{1}:第二聯絡人郵箱#", oldven.contact_email_2, venQuery.contact_email_2);
                                    list.Add(new TableChangeLog() { change_field = "contact_email_2", old_value = oldven.contact_email_2, new_value = venQuery.contact_email_2, field_ch_name = "第二聯絡人郵箱" });
                                }
                            }
                        }
                        else if (i == 2)
                        {


                            if (contact1 != null)
                            {
                                venQuery.contact_type_3 = Convert.ToUInt32(ContactType(contact1[0].ToString()));
                                venQuery.contact_name_3 = contact1[1];
                                venQuery.contact_phone_1_3 = contact1[2];
                                venQuery.contact_phone_2_3 = contact1[3];
                                venQuery.contact_mobile_3 = contact1[4];
                                venQuery.contact_email_3 = contact1[5].ToLower();
                                if (oldven.contact_type_3 != venQuery.contact_type_3)
                                {
                                    //update_log.AppendFormat("contact_type_3:{0}:{1}:第三聯絡人類型#", oldven.contact_type_3, venQuery.contact_type_3);
                                    list.Add(new TableChangeLog() { change_field = "contact_type_3", old_value = oldven.contact_type_3.ToString(), new_value = venQuery.contact_type_3.ToString(), field_ch_name = "第三聯絡人類型" });
                                }
                                if (oldven.contact_name_3 != venQuery.contact_name_3)
                                {
                                    //update_log.AppendFormat("contact_name_3:{0}:{1}:第三聯絡人姓名#", oldven.contact_name_3, venQuery.contact_name_3);
                                    list.Add(new TableChangeLog() { change_field = "contact_name_3", old_value = oldven.contact_name_3, new_value = venQuery.contact_name_3, field_ch_name = "第三聯絡人姓名" });
                                }
                                if (oldven.contact_phone_1_3 != venQuery.contact_phone_1_3)
                                {
                                    // update_log.AppendFormat("contact_phone_1_3:{0}:{1}:第三聯絡人電話一#", oldven.contact_phone_1_3, venQuery.contact_phone_1_3);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_1_3", old_value = oldven.contact_phone_1_3, new_value = venQuery.contact_phone_1_3, field_ch_name = "第三聯絡人電話一" });
                                }
                                if (oldven.contact_phone_2_3 != venQuery.contact_phone_2_3)
                                {
                                    // update_log.AppendFormat("contact_phone_2_3:{0}:{1}:第三聯絡人電話二#", oldven.contact_phone_2_3, venQuery.contact_phone_2_3);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_2_3", old_value = oldven.contact_phone_2_3, new_value = venQuery.contact_phone_2_3, field_ch_name = "第三聯絡人電話二" });
                                }
                                if (oldven.contact_mobile_3 != venQuery.contact_mobile_3)
                                {
                                    //  update_log.AppendFormat("contact_mobile_3:{0}:{1}:第三聯絡人手機號碼#", oldven.contact_mobile_3, venQuery.contact_mobile_3);
                                    list.Add(new TableChangeLog() { change_field = "contact_mobile_3", old_value = oldven.contact_mobile_3, new_value = venQuery.contact_mobile_3, field_ch_name = "第三聯絡人手機號碼" });
                                }
                                if (oldven.contact_email_3 != venQuery.contact_email_3)
                                {
                                    // update_log.AppendFormat("contact_email_3:{0}:{1}:第三聯絡人郵箱#", oldven.contact_email_3, venQuery.contact_email_3);
                                    list.Add(new TableChangeLog() { change_field = "contact_email_3", old_value = oldven.contact_email_3, new_value = venQuery.contact_email_3, field_ch_name = "第三聯絡人郵箱" });
                                }
                            }
                        }
                        else if (i == 3)
                        {


                            if (contact1 != null)
                            {
                                venQuery.contact_type_4 = Convert.ToUInt32(ContactType(contact1[0].ToString()));
                                venQuery.contact_name_4 = contact1[1];
                                venQuery.contact_phone_1_4 = contact1[2];
                                venQuery.contact_phone_2_4 = contact1[3];
                                venQuery.contact_mobile_4 = contact1[4];
                                venQuery.contact_email_4 = contact1[5].ToLower();
                                if (oldven.contact_type_4 != venQuery.contact_type_4)
                                {
                                    //update_log.AppendFormat("contact_type_4:{0}:{1}:第四聯絡人類型#", oldven.contact_type_4, venQuery.contact_type_4);
                                    list.Add(new TableChangeLog() { change_field = "contact_type_4", old_value = oldven.contact_type_4.ToString(), new_value = venQuery.contact_type_4.ToString(), field_ch_name = "原第四聯絡人類型" });
                                }
                                if (oldven.contact_name_4 != venQuery.contact_name_4)
                                {
                                    // update_log.AppendFormat("contact_name_4:{0}:{1}:第四聯絡人姓名#", oldven.contact_name_4, venQuery.contact_name_4);
                                    list.Add(new TableChangeLog() { change_field = "contact_name_4", old_value = oldven.contact_name_4, new_value = venQuery.contact_name_4, field_ch_name = "第四聯絡人姓名" });
                                }
                                if (oldven.contact_phone_1_4 != venQuery.contact_phone_1_4)
                                {
                                    //update_log.AppendFormat("contact_phone_1_4:{0}:{1}:第四聯絡人電話一#", oldven.contact_phone_1_4, venQuery.contact_phone_1_4);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_1_4", old_value = oldven.contact_phone_1_4, new_value = venQuery.contact_phone_1_4, field_ch_name = "第四聯絡人電話一" });
                                }
                                if (oldven.contact_phone_2_4 != venQuery.contact_phone_2_4)
                                {
                                    // update_log.AppendFormat("contact_phone_2_4:{0}:{1}:第四聯絡人電話二#", oldven.contact_phone_2_4, venQuery.contact_phone_2_4);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_2_4", old_value = oldven.contact_phone_2_4, new_value = venQuery.contact_phone_2_4, field_ch_name = "第四聯絡人電話二" });
                                }
                                if (oldven.contact_mobile_4 != venQuery.contact_mobile_4)
                                {
                                    // update_log.AppendFormat("contact_mobile_4:{0}:{1}:第四聯絡人手機號碼#", oldven.contact_mobile_4, venQuery.contact_mobile_4);
                                    list.Add(new TableChangeLog() { change_field = "contact_mobile_4", old_value = oldven.contact_mobile_4, new_value = venQuery.contact_mobile_4, field_ch_name = "第四聯絡人手機號碼" });
                                }
                                if (oldven.contact_email_4 != venQuery.contact_email_4)
                                {
                                    // update_log.AppendFormat("contact_email_4:{0}:{1}:第四聯絡人郵箱#", oldven.contact_email_4, venQuery.contact_email_4);
                                    list.Add(new TableChangeLog() { change_field = "contact_email_4", old_value = oldven.contact_email_4, new_value = venQuery.contact_email_4, field_ch_name = "第四聯絡人郵箱" });
                                }
                            }
                        }
                        else if (i == 4)
                        {


                            if (contact1 != null)
                            {
                                venQuery.contact_type_5 = Convert.ToUInt32(ContactType(contact1[0].ToString()));
                                venQuery.contact_name_5 = contact1[1];
                                venQuery.contact_phone_1_5 = contact1[2];
                                venQuery.contact_phone_2_5 = contact1[3];
                                venQuery.contact_mobile_5 = contact1[4];
                                venQuery.contact_email_5 = contact1[5].ToLower();
                                if (oldven.contact_type_5 != venQuery.contact_type_5)
                                {
                                    //update_log.AppendFormat("contact_type_5:{0}:{1}:第五聯絡人類型#", oldven.contact_type_5, venQuery.contact_type_5);
                                    list.Add(new TableChangeLog() { change_field = "contact_type_5", old_value = oldven.contact_type_5.ToString(), new_value = venQuery.contact_type_5.ToString(), field_ch_name = "第五聯絡人類型" });
                                }
                                if (oldven.contact_name_5 != venQuery.contact_name_5)
                                {
                                    // update_log.AppendFormat("contact_name_5:{0}:{1}:第五聯絡人姓名#", oldven.contact_name_5, venQuery.contact_name_5);
                                    list.Add(new TableChangeLog() { change_field = "contact_name_5", old_value = oldven.contact_name_5, new_value = venQuery.contact_name_5, field_ch_name = "第五聯絡人姓名" });
                                }
                                if (oldven.contact_phone_1_5 != venQuery.contact_phone_1_5)
                                {
                                    // update_log.AppendFormat("contact_phone_1_5:{0}:{1}:第五聯絡人電話一#", oldven.contact_phone_1_5, venQuery.contact_phone_1_5);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_1_5", old_value = oldven.contact_phone_1_5, new_value = venQuery.contact_phone_1_5, field_ch_name = "第五聯絡人電話一" });
                                }
                                if (oldven.contact_phone_2_5 != venQuery.contact_phone_2_5)
                                {
                                    // update_log.AppendFormat("contact_phone_2_5:{0}:{1}:第五聯絡人電話二#", oldven.contact_phone_2_5, venQuery.contact_phone_2_5);
                                    list.Add(new TableChangeLog() { change_field = "contact_phone_2_5", old_value = oldven.contact_phone_2_5, new_value = venQuery.contact_phone_2_5, field_ch_name = "第五聯絡人電話二" });
                                }
                                if (oldven.contact_mobile_5 != venQuery.contact_mobile_5)
                                {
                                    //update_log.AppendFormat("contact_mobile_5:{0}:{1}:第五聯絡人手機號碼#", oldven.contact_mobile_5, venQuery.contact_mobile_5);
                                    list.Add(new TableChangeLog() { change_field = "contact_mobile_5", old_value = oldven.contact_mobile_5, new_value = venQuery.contact_mobile_5, field_ch_name = "第五聯絡人手機號碼" });
                                }
                                if (oldven.contact_email_5 != venQuery.contact_email_5)
                                {
                                    //update_log.AppendFormat("contact_email_5:{0}:{1}:第五聯絡人郵箱#", oldven.contact_email_5, venQuery.contact_email_5);
                                    list.Add(new TableChangeLog() { change_field = "contact_email_5", old_value = oldven.contact_email_5, new_value = venQuery.contact_email_5, field_ch_name = "第五聯絡人郵箱" });
                                }
                            }
                        }
                    }

                    #endregion


                    venQuery.ip = Request.UserHostAddress;
                    venQuery.file_name = "VendorList.chtml";
                    venQuery.created = DateTime.Now;
                    venQuery.kuser_id = Convert.ToUInt32((System.Web.HttpContext.Current.Session["caller"] as Caller).user_id.ToString());
                    venQuery.export_flag = 1;
                    mgr = new CallerMgr(connectionString);
                    Caller caller = new Caller();
                    caller = mgr.GetUserById(Convert.ToInt32(venQuery.kuser_id));
                    venQuery.kuser_name = caller.user_username;
                    return VendorEdit(venQuery, list);
                }
            }
            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);
                jsonStr = "{success:false}";
            }

            this.Response.Clear();
            this.Response.Write(jsonStr.ToString());
            this.Response.End();
            return this.Response;
        }
Example #11
0
        public HttpResponseBase GetVendorTypeStore()
        {
            paraMgr = new ParameterMgr(connectionString);
            List<Parametersrc> store = new List<Parametersrc>();
            string json = string.Empty;
            List<VendorQuery> query = new List<VendorQuery>();
            try
            {
                string type = "vendor_type";
                store = paraMgr.GetElementType(type);
                for (int i = 0; i < store.Count; i++)
                {
                    VendorQuery vendor = new VendorQuery();
                    vendor.vendor_type = store[i].ParameterCode.ToString();
                    vendor.vendor_type_name = store[i].parameterName.ToString();
                    query.Add(vendor);

                }
                json = "{success:true,data:" + JsonConvert.SerializeObject(query, Formatting.Indented) + "}";
            }
            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 = "無預覽信息";
            }
            this.Response.Clear();
            this.Response.Write(json);
            this.Response.End();
            return this.Response;
        }
Example #12
0
        public HttpResponseBase VendorEdit(VendorQuery venQuery, List<TableChangeLog> list)
        {
            string jsonStr = "{success:false}";
            _vendorMgr = new VendorMgr(connectionString);
            _productMgr = new ProductMgr(connectionString);
            try
            {
                if (_vendorMgr.Update(venQuery, list) > 0)
                {
                    //變更商品可販售狀態
                    if (_productMgr.UpdateSaleStatusByCondition(new Product { Vendor_Id = venQuery.vendor_id }))
                    {
                        jsonStr = "{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);
                jsonStr = "{success:false}";
            }

            this.Response.Clear();
            this.Response.Write(jsonStr.ToString());
            this.Response.End();
            return this.Response;
        }
Example #13
0
        public HttpResponseBase VendorAdd(VendorQuery venQuery)
        {
            string jsonStr = "{success:false}";
            try
            {
                _vendorMgr = new VendorMgr(connectionString);

                if (!string.IsNullOrEmpty(Request.Params["pm"]))
                {
                    venQuery.product_manage = Convert.ToUInt32(Request.Params["pm"]);
                }
                int result = _vendorMgr.Add(venQuery);
                if (result > 0)
                {

                    jsonStr = "{success:true}";

                }
                else if (result == -1)
                {
                    jsonStr = "{success:false,msg:-1}";
                }
            }
            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);
                jsonStr = "{success:false}";
            }

            this.Response.Clear();
            this.Response.Write(jsonStr.ToString());
            this.Response.End();
            return this.Response;
        }
Example #14
0
        /// <summary>
        /// 獲取供應商列表數據
        /// </summary>
        /// <returns></returns>
        public HttpResponseBase GetVendorList()
        {
            List<VendorQuery> stores = new List<VendorQuery>();
            string json = string.Empty;

            try
            {
                _vendorMgr = new VendorMgr(connectionString);
                #region 搜索條件
                VendorQuery query = new VendorQuery();
                query.Start = Convert.ToInt32(Request.Params["start"] ?? "0");//用於分頁的變量
                query.Limit = Convert.ToInt32(Request.Params["limit"] ?? "25");//用於分頁的變量


                if (!string.IsNullOrEmpty(Request.Params["relation_id"]))
                {
                    query.vendor_id = Convert.ToUInt32(Request.Params["relation_id"].ToString());
                }
                if (!string.IsNullOrEmpty(Request.Params["VendorId"]))
                {
                    query.vendor_id = Convert.ToUInt32(Request.Params["VendorId"].ToString());
                }
                string type = string.Empty;
                string con = string.Empty;

                if (!string.IsNullOrEmpty(Request.Params["dateType"]))
                {
                    type = Request.Params["dateType"].ToString();
                }
                if (!string.IsNullOrEmpty(Request.Params["dateCon"]))
                {
                    con = Request.Params["dateCon"].ToString();
                }
                int totalCount = 0;
                if (!string.IsNullOrEmpty(type) && !string.IsNullOrEmpty(con) && type != "0")
                {//當查詢條件和查詢內容都有值時執行
                    switch (type)
                    {
                        case "0":
                            break;
                        case "1":
                            query.searchEmail = con.ToLower();
                            break;
                        case "2":
                            query.searchName = con;
                            break;
                        case "3":
                            query.vendor_name_full = con;
                            break;
                        case "4":
                            query.searchInvoice = con;
                            break;
                        case "5":
                            query.erp_id = con;
                            break;
                        case "6":
                            uint isTranUint = 0;
                            if (uint.TryParse(con, out isTranUint))
                            {
                                query.vendor_id = Convert.ToUInt32(con);
                            }
                            break;
                        case "7":
                            query.vendor_code = con;
                            break;
                    }
                    if (!string.IsNullOrEmpty(Request.Params["vendortype"]))//供应商类型
                    {
                        query.vendor_type = Request.Params["vendortype"].ToString();
                        query.vendor_type = query.vendor_type.TrimEnd(',');
                    }
                    if (!string.IsNullOrEmpty(Request.Params["dateOne"]))
                    {
                        // query.create_dateOne = (uint)CommonFunction.GetPHPTime(Convert.ToDateTime(Request.Params["dateOne"]).ToString("yyyy-MM-dd 00:00:00"));
                        query.create_dateOne = (uint)CommonFunction.GetPHPTime(Request.Params["dateOne"]);
                    }
                    if (!string.IsNullOrEmpty(Request.Params["dateTwo"]))
                    {
                        //query.create_dateTwo = (uint)CommonFunction.GetPHPTime(Convert.ToDateTime(Request.Params["dateTwo"]).ToString("yyyy-MM-dd 23:59:59"));
                        query.create_dateTwo = (uint)CommonFunction.GetPHPTime(Request.Params["dateTwo"]);
                    }
                    stores = _vendorMgr.Query(query, ref totalCount);
                }
                else
                { //當查詢條件和查詢內容都沒有值時執行
                    if (!string.IsNullOrEmpty(Request.Params["vendortype"]))//供应商类型
                    {
                        query.vendor_type = Request.Params["vendortype"].ToString();
                        query.vendor_type = query.vendor_type.TrimEnd(',');
                    }
                    if (!string.IsNullOrEmpty(Request.Params["dateOne"]))
                    {
                        //query.create_dateOne = (uint)CommonFunction.GetPHPTime(Convert.ToDateTime(Request.Params["dateOne"]).ToString("yyyy-MM-dd 00:00:00"));
                        query.create_dateOne = (uint)CommonFunction.GetPHPTime(Request.Params["dateOne"]);
                    }
                    if (!string.IsNullOrEmpty(Request.Params["dateTwo"]))
                    {
                        //query.create_dateTwo = (uint)CommonFunction.GetPHPTime(Convert.ToDateTime(Request.Params["dateTwo"]).ToString("yyyy-MM-dd 23:59:59"));
                        query.create_dateTwo = (uint)CommonFunction.GetPHPTime(Request.Params["dateTwo"]);
                    }
                    stores = _vendorMgr.Query(query, ref totalCount);
                }
                #endregion
                #region 供應商類型參數
                List<Parametersrc> list = new List<Parametersrc>();
                paraMgr = new ParameterMgr(connectionString);
                string types = "vendor_type";
                list = paraMgr.GetElementType(types);
                #endregion


                foreach (var item in stores)
                {
                    item.vendor_name_full = Server.HtmlDecode(Server.HtmlDecode(item.vendor_name_full));
                    item.vendor_name_simple = Server.HtmlDecode(Server.HtmlDecode(item.vendor_name_simple));
                    string temp = string.Empty;

                    #region 供應商類型關聯參數表
                    if (!string.IsNullOrEmpty(item.vendor_type) && item.vendor_type != null)
                    {
                        string[] vendor_types = item.vendor_type.Split(',');
                        for (int i = 0; i < vendor_types.Length; i++)
                        {
                            for (int j = 0; j < list.Count; j++)
                            {
                                if (list[j].ParameterCode == vendor_types[i].ToString())
                                {
                                    item.vendor_type_name += list[j].parameterName + ",";
                                }
                            }

                        }
                        item.vendor_type_name = item.vendor_type_name.Substring(0, item.vendor_type_name.Length - 1);
                    }
                    #endregion
                    if (item.self_send_days == 0)
                    {
                        if (item.stuff_ware_days == 0)
                        {
                            if (item.dispatch_days == 0)
                            {
                                temp = "";
                            }
                            else
                            {
                                temp = "調度";
                            }
                        }
                        else
                        {
                            if (item.dispatch_days == 0)
                            {
                                temp = "寄倉";
                            }
                            else
                            {
                                temp = "寄倉,調度";
                            }
                        }
                    }
                    else
                    {
                        if (item.stuff_ware_days == 0)
                        {
                            if (item.dispatch_days == 0)
                            {
                                temp = "自出";
                            }
                            else
                            {
                                temp = "自出,調度";
                            }
                        }
                        else
                        {
                            if (item.dispatch_days == 0)
                            {
                                temp = "自出,寄倉";
                            }
                            else
                            {
                                temp = "自出,寄倉,調度";
                            }
                        }
                    }
                    item.vendor_mode = temp;

                    if (Convert.ToBoolean(Request.Params["isSecret"]))
                    {

                        if (!string.IsNullOrEmpty(item.vendor_name_full))
                        {
                            item.vendor_name_full = item.vendor_name_full.Substring(0, 1) + "**";
                        }
                        //
                        if (!string.IsNullOrEmpty(item.vendor_name_simple))
                        {
                            item.vendor_name_simple = item.vendor_name_simple.Substring(0, 1) + "**";
                        }//vendor_company_address
                        if (item.vendor_company_address.ToString().Length > 3)
                        {
                            item.vendor_company_address = item.vendor_company_address.Substring(0, 3) + "***";
                        }
                        else
                        {
                            item.vendor_company_address = item.vendor_company_address + "***";
                        }
                        if (!string.IsNullOrEmpty(item.contact_email_1))
                        {
                            item.contact_email_1 = item.contact_email_1.Split('@')[0] + "@***";
                        }
                        if (!string.IsNullOrEmpty(item.contact_email_2))
                        {
                            item.contact_email_2 = item.contact_email_2.Split('@')[0] + "@***";
                        }
                        if (!string.IsNullOrEmpty(item.contact_email_3))
                        {
                            item.contact_email_3 = item.contact_email_3.Split('@')[0] + "@***";
                        }
                        if (!string.IsNullOrEmpty(item.contact_email_4))
                        {
                            item.contact_email_4 = item.contact_email_4.Split('@')[0] + "@***";
                        }
                        if (!string.IsNullOrEmpty(item.contact_email_5))
                        {
                            item.contact_email_5 = item.contact_email_5.Split('@')[0] + "@***";
                        }


                        if (item.contact_mobile_1.ToString().Length > 3)
                        {
                            item.contact_mobile_1 = item.contact_mobile_1.Substring(0, 3) + "***";
                        }
                        else
                        {
                            item.contact_mobile_1 = item.contact_mobile_1 + "***";
                        }
                        if (item.contact_mobile_2.ToString().Length > 3)
                        {
                            item.contact_mobile_2 = item.contact_mobile_2.Substring(0, 3) + "***";
                        }
                        else
                        {
                            item.contact_mobile_2 = item.contact_mobile_2 + "***";
                        }
                        if (item.contact_mobile_3.ToString().Length > 3)
                        {
                            item.contact_mobile_3 = item.contact_mobile_3.Substring(0, 3) + "***";
                        }
                        else
                        {
                            item.contact_mobile_3 = item.contact_mobile_3 + "***";
                        }
                        if (item.contact_mobile_4.ToString().Length > 3)
                        {
                            item.contact_mobile_4 = item.contact_mobile_4.Substring(0, 3) + "***";
                        }
                        else
                        {
                            item.contact_mobile_4 = item.contact_mobile_4 + "***";
                        }
                        if (item.contact_mobile_5.ToString().Length > 3)
                        {
                            item.contact_mobile_5 = item.contact_mobile_5.Substring(0, 3) + "***";
                        }
                        else
                        {
                            item.contact_mobile_5 = item.contact_mobile_5 + "***";
                        }

                        if (item.contact_phone_1_1.ToString().Length > 3)
                        {
                            item.contact_phone_1_1 = item.contact_phone_1_1.Substring(0, 3) + "***";
                        }
                        else
                        {
                            item.contact_phone_1_1 = item.contact_phone_1_1 + "***";
                        }
                        if (item.contact_phone_1_2.ToString().Length > 3)
                        {
                            item.contact_phone_1_2 = item.contact_phone_1_2.Substring(0, 3) + "***";
                        }
                        else
                        {
                            item.contact_phone_1_2 = item.contact_phone_1_2 + "***";
                        }
                        if (item.contact_phone_1_3.ToString().Length > 3)
                        {
                            item.contact_phone_1_3 = item.contact_phone_1_3.Substring(0, 3) + "***";
                        }
                        else
                        {
                            item.contact_phone_1_3 = item.contact_phone_1_3 + "***";
                        }
                        if (item.contact_phone_1_4.ToString().Length > 3)
                        {
                            item.contact_phone_1_4 = item.contact_phone_1_4.Substring(0, 3) + "***";
                        }
                        else
                        {
                            item.contact_phone_1_4 = item.contact_phone_1_4 + "***";
                        }
                        if (item.contact_phone_1_5.ToString().Length > 3)
                        {
                            item.contact_phone_1_5 = item.contact_phone_1_5.Substring(0, 3) + "***";
                        }
                        else
                        {
                            item.contact_phone_1_5 = item.contact_phone_1_5 + "***";
                        }


                        if (item.contact_phone_2_1.ToString().Length > 3)
                        {
                            item.contact_phone_2_1 = item.contact_phone_2_1.Substring(0, 3) + "***";
                        }
                        else
                        {
                            item.contact_phone_2_1 = item.contact_phone_2_1 + "***";
                        }
                        if (item.contact_phone_2_2.ToString().Length > 3)
                        {
                            item.contact_phone_2_2 = item.contact_phone_2_2.Substring(0, 3) + "***";
                        }
                        else
                        {
                            item.contact_phone_2_2 = item.contact_phone_2_2 + "***";
                        }
                        if (item.contact_phone_2_3.ToString().Length > 3)
                        {
                            item.contact_phone_2_3 = item.contact_phone_2_3.Substring(0, 3) + "***";
                        }
                        else
                        {
                            item.contact_phone_2_3 = item.contact_phone_2_3 + "***";
                        }
                        if (item.contact_phone_2_4.ToString().Length > 3)
                        {
                            item.contact_phone_2_4 = item.contact_phone_2_4.Substring(0, 3) + "***";
                        }
                        else
                        {
                            item.contact_phone_2_4 = item.contact_phone_2_4 + "***";
                        }
                        if (item.contact_phone_2_5.ToString().Length > 3)
                        {
                            item.contact_phone_2_5 = item.contact_phone_2_5.Substring(0, 3) + "***";
                        }
                        else
                        {
                            item.contact_phone_2_5 = item.contact_phone_2_5 + "***";
                        }

                        if (!string.IsNullOrEmpty(item.contact_name_1))
                        {
                            item.contact_name_1 = item.contact_name_1.Substring(0, 1) + "**";
                        }
                        if (!string.IsNullOrEmpty(item.contact_name_2))
                        {
                            item.contact_name_2 = item.contact_name_2.Substring(0, 1) + "**";
                        }
                        if (!string.IsNullOrEmpty(item.contact_name_3))
                        {
                            item.contact_name_3 = item.contact_name_3.Substring(0, 1) + "**";
                        }
                        if (!string.IsNullOrEmpty(item.contact_name_4))
                        {
                            item.contact_name_4 = item.contact_name_4.Substring(0, 1) + "**";
                        }
                        if (!string.IsNullOrEmpty(item.contact_name_5))
                        {
                            item.contact_name_5 = item.contact_name_5.Substring(0, 1) + "**";
                        }

                        if (!string.IsNullOrEmpty(item.manage_name))
                        {
                            item.manage_name = item.manage_name.Substring(0, 1) + "**";
                        }
                        if (!string.IsNullOrEmpty(item.manage_email))
                        {
                            item.manage_email = item.manage_email.Split('@')[0] + "@***";
                        }
                        if (!string.IsNullOrEmpty(item.vendor_email))
                        {
                            item.vendor_email = item.vendor_email.Split('@')[0] + "@***";
                        }
                        if (!string.IsNullOrEmpty(item.company_person))
                        {
                            item.company_person = item.company_person.Substring(0, 1) + "**";
                        }
                        if (item.company_address.ToString().Length > 3)
                        {
                            item.company_address = item.company_address.Substring(0, 3) + "***";
                        }
                        else
                        {
                            item.company_address = item.company_address + "***";
                        }
                        if (item.invoice_address.ToString().Length > 3)
                        {
                            item.invoice_address = item.invoice_address.Substring(0, 3) + "***";
                        }
                        else
                        {
                            item.invoice_address = item.invoice_address + "***";
                        }
                    }
                }
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式     
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss";
                json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(stores, Formatting.Indented, timeConverter) + "}";//返回json數據
            }
            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;
        }
Example #15
0
        public int Update(VendorQuery model, List<TableChangeLog> list)
        {
            UserHistoryDao _userhistoryDao = new UserHistoryDao(connStr);
            SerialDao _serialDao = new SerialDao(connStr);
            model.Replace4MySQL();
            int i = 0;

            try
            {
                ArrayList _list = new ArrayList();

                model.content = _vendorDao.ReturnHistoryCon(model).ToString();

                #region 處理vendor表
                _list.Add(_vendorDao.UpdateVendor(model));

                #endregion
                #region 處理userhistory表
                _list.Add(_userhistoryDao.Save(model));

                #endregion

                #region 處理table_change_log 記錄供應商資料異動
                //if (!string.IsNullOrEmpty(update_log))
                //{
                //    update_log = update_log.TrimEnd('#');//去掉最後一個#
                //    string[] arr_log = update_log.Split('#');//分離每條記錄
                //    foreach (string item in arr_log)
                //    {
                //        TableChangeLogDao _logDao = new TableChangeLogDao(connStr);
                //        string[] arr_col = item.Split(':');
                //        TableChangeLog tcl = new TableChangeLog();
                //        tcl.change_table = "vendor";
                //        tcl.change_field = arr_col[0].ToString();
                //        tcl.field_ch_name = arr_col[3].ToString();
                //        tcl.create_time = model.created;
                //        tcl.create_user = (int)model.kuser_id;
                //        tcl.pk_id = (int)model.vendor_id;
                //        tcl.old_value = arr_col[1].ToString();
                //        tcl.new_value = arr_col[2].ToString();
                //        tcl.user_type = model.user_type;
                //        _list.Add(_logDao.insert(tcl));
                //    }
                //}
                if (list != null)
                {
                    foreach (TableChangeLog t in list)
                    {
                        TableChangeLogDao _logDao = new TableChangeLogDao(connStr);
                        t.change_table = "vendor";
                        t.create_time = model.created;
                        t.create_user = (int)model.kuser_id;
                        t.pk_id = (int)model.vendor_id;
                        t.user_type = model.user_type;
                        _list.Add(_logDao.insert(t));
                    }
                }
                #endregion

                if (_mysqlDao.ExcuteSqls(_list))
                {
                    i = 1;
                }
                return i;
            }
            catch (Exception ex)
            {

                throw new Exception("VendorDao-->Update-->" + ex.Message, ex);
            }
        }
Example #16
0
 /// <summary>
 /// 用於返回事物所用到的sql語句
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public string Save(VendorQuery model)
 {
     model.Replace4MySQL();
     StringBuilder sb = new StringBuilder();
     sb.AppendFormat(" insert into user_history (user_id,user_name,file_name,content,creat_time,ip ) ");
     sb.AppendFormat(" values('{0}','{1}','{2}','{3}','{4}','{5}');", model.kuser_id, model.kuser_name, model.file_name, model.content, CommonFunction.GetPHPTime(model.created.ToString()), model.ip);
     return sb.ToString();
 }
Example #17
0
        //public int Update(VendorQuery model, string update_log)
        //{
        //    _userhistoryDao = new UserHistoryDao(connStr);
        //    _serialDao = new SerialDao(connStr);

        //    model.Replace4MySQL();
        //    int i = 0;
        //    MySqlCommand mySqlCmd = new MySqlCommand();
        //    MySqlConnection mySqlConn = new MySqlConnection(connStr);
        //    try
        //    {
        //        if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Closed)
        //        {
        //            mySqlConn.Open();
        //        }
        //        mySqlCmd.Connection = mySqlConn;
        //        mySqlCmd.Transaction = mySqlConn.BeginTransaction();
        //        mySqlCmd.CommandType = System.Data.CommandType.Text;

        //        model.content = ReturnHistoryCon(model).ToString();

        //        #region 處理vendor表
        //        mySqlCmd.CommandText = UpdateVendor(model);
        //        i += mySqlCmd.ExecuteNonQuery();
        //        #endregion
        //        #region 處理userhistory表
        //        mySqlCmd.CommandText += _userhistoryDao.Save(model);
        //        i += mySqlCmd.ExecuteNonQuery();
        //        #endregion

        //        #region 處理table_change_log 記錄供應商資料異動
        //        if (!string.IsNullOrEmpty(update_log))
        //        {
        //            update_log = update_log.TrimEnd('#');//去掉最後一個#
        //            string[] arr_log = update_log.Split('#');//分離每條記錄
        //            foreach (string item in arr_log)
        //            {

        //            }
        //        }
        //        #endregion

        //        mySqlCmd.Transaction.Commit();
        //    }
        //    catch (Exception ex)
        //    {
        //        mySqlCmd.Transaction.Rollback();
        //        throw new Exception("VendorDao-->Update-->" + ex.Message, ex);
        //    }
        //    finally
        //    {
        //        if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Open)
        //        {
        //            mySqlConn.Close();
        //        }
        //    }
        //    return i;
        //}

        public int Add(VendorQuery model)
        {
            model.Replace4MySQL();
            int i = 0;
            StringBuilder sql = new StringBuilder();
            MySqlCommand mySqlCmd = new MySqlCommand();
            MySqlConnection mySqlConn = new MySqlConnection(connStr);
            try
            {
                if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Closed)
                {
                    mySqlConn.Open();
                }
                mySqlCmd.Connection = mySqlConn;
                mySqlCmd.Transaction = mySqlConn.BeginTransaction();
                mySqlCmd.CommandType = System.Data.CommandType.Text;

                #region 獲取vendor_id
                mySqlCmd.CommandText = _serialDao.Update(10);
                sql.Append(mySqlCmd.CommandText);
                model.vendor_id = Convert.ToUInt32(mySqlCmd.ExecuteScalar());
                #endregion

                #region 獲取vendor_code
                mySqlCmd.CommandText = "select max(vendor_code)as vendor_code from vendor;";
                sql.Append(mySqlCmd.CommandText);
                string tempCode = mySqlCmd.ExecuteScalar().ToString();
                int nowYear = Convert.ToInt32(DateTime.Today.Year.ToString().Substring(2));
                int nowDays = DateTime.Today.DayOfYear;
                int nCode_4 = 1;
                if (!string.IsNullOrEmpty(tempCode))
                {
                    int tCode_2 = Convert.ToInt32(tempCode.Substring(1, 2));
                    int tCode_3 = Convert.ToInt32(tempCode.Substring(3, 3));
                    int tCode_4 = Convert.ToInt32(tempCode.Substring(6));
                    if (tCode_2 == nowYear && tCode_3 == nowDays)
                    {
                        nCode_4 = tCode_4 + 1;
                    }
                }
                string tYear = StrPad_Left(nowYear.ToString(), 2);
                string tDays = StrPad_Left(nowDays.ToString(), 3);

                model.vendor_code = "V" + tYear + tDays + StrPad_Left(nCode_4.ToString(), 4);
                #endregion

                model.content = ReturnHistoryCon(model).ToString();

                #region 獲取erp_id
                if (!string.IsNullOrEmpty(model.prod_cate) && !string.IsNullOrEmpty(model.buy_cate)
                   && !string.IsNullOrEmpty(model.tax_type)
                   && model.buy_cate.StartsWith(model.prod_cate))
                {
                    //獲取serial_id;
                    Serial serModel = _serialDao.GetSerialById(77);
                    if (serModel == null)
                    {
                        serModel = new Serial();
                        serModel.Serial_id = 77;
                        serModel.Serial_Value = 500;//默認從500開始
                        mySqlCmd.CommandText = _serialDao.InsertStr(serModel);
                        sql.Append(mySqlCmd.CommandText);
                        i += mySqlCmd.ExecuteNonQuery();
                    }
                    mySqlCmd.CommandText = _serialDao.Update(77);//77代表erp_id的serial
                    sql.Append(mySqlCmd.CommandText);
                    model.serial = mySqlCmd.ExecuteScalar().ToString();
                    if (!string.IsNullOrEmpty(model.serial))
                    {
                        model.erp_id = model.buy_cate + CommonFunction.Supply(model.serial, "0", 5) + model.tax_type;

                        if (IsExitErpID(model.erp_id) > 0)
                        {
                            i = -1;
                            return i;
                        }
                    }
                }
                #endregion

                #region 處理vendor表
                mySqlCmd.CommandText = InsertVendor(model);
                sql.Append(mySqlCmd.CommandText);
                i += mySqlCmd.ExecuteNonQuery();
                #endregion

                #region 處理userhistory表
                mySqlCmd.CommandText = _userhistoryDao.Save(model);
                sql.Append(mySqlCmd.CommandText);
                i += mySqlCmd.ExecuteNonQuery();
                #endregion


                mySqlCmd.Transaction.Commit();
            }
            catch (Exception ex)
            {
                mySqlCmd.Transaction.Rollback();
                throw new Exception("VendorDao-->Add-->" + ex.Message + sql.ToString(), ex);
            }
            finally
            {
                if (mySqlConn != null && mySqlConn.State == System.Data.ConnectionState.Open)
                {
                    mySqlConn.Close();
                }
            }
            return i;
        }
        /// <summary>
        /// 供應商對帳總表
        /// </summary>
        public void VendorAccountCountExport()
        {
            string json = string.Empty;
            DataTable _dt = new DataTable();
            DataTable dtHZ = new DataTable();
            VendorAccountMonthQuery VAMQuery = new VendorAccountMonthQuery();
            VendorQuery vendorQuery = new VendorQuery();
            try
            {
                string type = Request.Params["dateType"].ToString();//根據統一編號/電子信箱/供應商名稱
                string con = Request.Params["dateCon"].ToString();//查詢內容
                if (!string.IsNullOrEmpty(type) && !string.IsNullOrEmpty(con))
                {
                    VAMQuery.type = Convert.ToInt32(type);
                    VAMQuery.keyworks = con;
                }
                //List<string> list = GetTime(uint.Parse(Request.Params["dateone"]), uint.Parse(Request.Params["datetwo"]));
                //List<string> list = GetTime(2014, 2);
                _IVAMMgr = new VendorAccountMonthMgr(mySqlConnectionString);
                // Dictionary<int, DataTable> tempDT = new Dictionary<int, DataTable>();
                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"]);
                //tempDT.Add(0, tempTemp);
                _dt = _IVAMMgr.VendorAccountCountExport(VAMQuery);// 查詢訂單筆數
                DataTable tableTemp = _IVAMMgr.VendorAccountInfoExport(VAMQuery);// 供應商總表部分信息
                Dictionary<string, double> tempDT = new Dictionary<string, double>();
                for (int i = 0; i < tableTemp.Rows.Count; i++)
                {
                    double creditcard_Money = 0;
                    int orderpPayment = Convert.ToInt32(tableTemp.Rows[i]["order_payment"]);
                    if (orderpPayment == 1)//支付方式為聯合信用卡的
                    {
                        creditcard_Money = Math.Round(Convert.ToInt32(tableTemp.Rows[i]["deduction"]) * 0.02);
                    }
                    else if (orderpPayment == 11 || orderpPayment == 12 || orderpPayment == 14 || orderpPayment == 10)//支付方式分別為中國信託信用卡紅利折抵、10%、20%、中國信託信用卡
                    {
                        creditcard_Money = Math.Round(Convert.ToInt32(tableTemp.Rows[i]["deduction"]) * 0.025);
                    }
                    else if (orderpPayment == 13)
                    {
                        creditcard_Money = Math.Round(Convert.ToInt32(tableTemp.Rows[i]["deduction"]) * 0.018);
                    }
                    if (!tempDT.ContainsKey(tableTemp.Rows[i]["vendor_id"].ToString()))
                    {
                        tempDT.Add(tableTemp.Rows[i]["vendor_id"].ToString(), creditcard_Money);
                    }
                    else
                    {
                        tempDT[tableTemp.Rows[i]["vendor_id"].ToString()] = creditcard_Money + Convert.ToDouble(tempDT[tableTemp.Rows[i]["vendor_id"].ToString()]);
                    }

                }
                dtHZ.Columns.Add("供應商編號");
                dtHZ.Columns.Add("供應商編碼");
                dtHZ.Columns.Add("ERP 廠商編號");
                dtHZ.Columns.Add("供應商名稱");
                dtHZ.Columns.Add("供應商簡稱");
                dtHZ.Columns.Add("供應商統編");
                dtHZ.Columns.Add("出貨模式");
                dtHZ.Columns.Add("寄倉模式");
                dtHZ.Columns.Add("商品總售價");
                dtHZ.Columns.Add("商品折扣總價");
                dtHZ.Columns.Add("商品淨售價");
                dtHZ.Columns.Add("商品總成本");
                dtHZ.Columns.Add("一期刷卡費");
                dtHZ.Columns.Add("廠商常溫運費");
                dtHZ.Columns.Add("廠商調度常溫運費");
                dtHZ.Columns.Add("廠商自出低溫運費");
                dtHZ.Columns.Add("廠商調度低溫運費");
                dtHZ.Columns.Add("廠商常溫逆物流");
                dtHZ.Columns.Add("廠商低溫逆物流");
                dtHZ.Columns.Add("廠商業績獎金");
                dtHZ.Columns.Add("寄倉費用");
                dtHZ.Columns.Add("應付廠商款");
                dtHZ.Columns.Add("刷卡費用");
                dtHZ.Columns.Add("廠商成本小計");
                dtHZ.Columns.Add("淨毛利(淨售價-成本小計)");
                dtHZ.Columns.Add("淨毛利率(毛利/淨售價)");
                dtHZ.Columns.Add("總毛利(商品總售價-成本小計)");
                dtHZ.Columns.Add("總毛利率(毛利/總售價)");
                for (int i = 0; i < _dt.Rows.Count; i++)
                {
                    if (Convert.ToInt32(_dt.Rows[i]["m_product_cost"]) != 0)
                    {
                        DataRow dr = dtHZ.NewRow();
                        dr[0] = _dt.Rows[i]["vendor_id"];
                        dr[1] = _dt.Rows[i]["vendor_code"];
                        dr[2] = _dt.Rows[i]["erp_id"];
                        dr[3] = _dt.Rows[i]["vendor_name_full"];
                        dr[4] = _dt.Rows[i]["vendor_name_simple"];
                        dr[5] = _dt.Rows[i]["vendor_invoice"];
                        if (Convert.ToInt32(_dt.Rows[i]["dispatch"]) == 1)
                        {
                            dr[6] = "調度倉";
                        }
                        else
                        {
                            dr[6] = "自行出貨";
                        }
                        if (Convert.ToInt32(_dt.Rows[i]["product_mode"]) == 1)
                        {
                            dr[7] = "非寄倉";
                        }
                        else if (Convert.ToInt32(_dt.Rows[i]["product_mode"]) == 2)
                        {
                            dr[7] = "寄倉";
                        }
                        dr[8] = _dt.Rows[i]["m_product_money"].ToString();
                        dr[9] = (Convert.ToInt32(_dt.Rows[i]["m_product_money"]) - Convert.ToInt32(_dt.Rows[i]["m_all_deduction"])).ToString();
                        dr[10] = _dt.Rows[i]["m_all_deduction"];
                        dr[11] = _dt.Rows[i]["m_product_cost"];
                        //dr[12] = "-" + _dt.Rows[i]["m_money_creditcard_1"];
                        if (Convert.ToInt32(_dt.Rows[i]["m_money_creditcard_1"].ToString()) != 0)
                        {
                            dr[12] = "-" + _dt.Rows[i]["m_money_creditcard_1"].ToString();
                        }
                        else
                        {
                            dr[12] = 0;
                        }
                        dr[13] = _dt.Rows[i]["m_freight_delivery_normal"];
                        dr[14] = _dt.Rows[i]["m_dispatch_freight_delivery_normal"];
                        dr[15] = _dt.Rows[i]["m_freight_delivery_low"];
                        dr[16] = _dt.Rows[i]["m_dispatch_freight_delivery_low"];
                        if (_dt.Rows[i]["m_freight_return_normal"].ToString() == "0")
                        {
                            dr[17] = _dt.Rows[i]["m_freight_return_normal"];
                        }
                        else
                        {
                            dr[17] = "-" + _dt.Rows[i]["m_freight_return_normal"];
                        }
                        if (_dt.Rows[i]["m_freight_return_low"].ToString() == "0")
                        {
                            dr[18] = _dt.Rows[i]["m_freight_return_low"];
                        }
                        else
                        {
                            dr[18] = "-" + _dt.Rows[i]["m_freight_return_low"];
                        }
                        dr[19] = "?";
                        if (_dt.Rows[i]["m_bag_check_money"].ToString() == "0")
                        {
                            dr[20] = _dt.Rows[i]["m_bag_check_money"];
                        }
                        else
                        {
                            dr[20] = "-" + _dt.Rows[i]["m_bag_check_money"];
                        }
                        int m_product_cost = Convert.ToInt32(_dt.Rows[i]["m_product_cost"]) - (Convert.ToInt32(_dt.Rows[i]["m_money_creditcard_1"]) + Convert.ToInt32(_dt.Rows[i]["m_freight_return_normal"]) + Convert.ToInt32(_dt.Rows[i]["m_freight_return_low"]));
                        m_product_cost = m_product_cost - Convert.ToInt32(_dt.Rows[i]["m_bag_check_money"]);
                        m_product_cost = m_product_cost + (Convert.ToInt32(_dt.Rows[i]["m_freight_delivery_normal"]) - Convert.ToInt32(_dt.Rows[i]["m_freight_delivery_low"]));
                        dr[21] = m_product_cost;
                        double temp1 = 0;
                        if (tempDT.ContainsKey(_dt.Rows[i]["vendor_id"].ToString()))
                        {
                            temp1 = tempDT[_dt.Rows[i]["vendor_id"].ToString()];
                        }
                        dr[22] = temp1.ToString();
                        dr[23] = Convert.ToInt32(_dt.Rows[i]["m_product_cost"]) + temp1;
                        dr[24] = Convert.ToInt32(_dt.Rows[i]["m_all_deduction"]) - Convert.ToInt32(_dt.Rows[i]["m_product_cost"]);
                        if (Convert.ToInt32(_dt.Rows[i]["m_all_deduction"]) != 0)
                        {
                            dr[25] = (Convert.ToInt32(_dt.Rows[i]["m_all_deduction"]) - Convert.ToInt32(_dt.Rows[i]["m_product_cost"])) / Convert.ToDecimal(_dt.Rows[i]["m_all_deduction"]);
                        }
                        else
                        {
                            dr[25] = "";
                        }
                        dr[26] = Convert.ToInt32(_dt.Rows[i]["m_product_money"]) - Convert.ToInt32(_dt.Rows[i]["m_product_cost"]);
                        if (Convert.ToDecimal(_dt.Rows[i]["m_product_money"]) != 0)
                        {
                            dr[27] = (Convert.ToInt32(_dt.Rows[i]["m_product_money"]) - Convert.ToInt32(_dt.Rows[i]["m_product_cost"])) / Convert.ToDecimal(_dt.Rows[i]["m_product_money"]);
                        }
                        else
                        {
                            dr[27] = "";
                        }
                        dtHZ.Rows.Add(dr);
                    }

                }
                if (dtHZ.Rows.Count > 0)
                {
                    string fileName = "供應商對帳總表" + VAMQuery.account_year + "-" + VAMQuery.account_month + ".xls";
                    MemoryStream ms = ExcelHelperXhf.ExportDT(dtHZ, "");
                    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:[]}";
            }
        }
Example #19
0
        public List<VendorQuery> Query(VendorQuery query, ref int totalCount)
        {
            query.Replace4MySQL();
            StringBuilder sql = new StringBuilder("");
            StringBuilder sqlCon = new StringBuilder("");
            try
            {
                sql.Append(@" select  zipI.bigcode as i_bigcode, zipI.middlecode as i_midcode, zipI.middle as i_middle,zipI.zipcode as i_zipcode, CONCAT(zipI.zipcode ,'/',zipI.small) as 'i_zip',CONCAT(CONCAT(zipC.middle,zipC.small),vendor.company_address) as vendor_company_address, ");
                sql.Append(" zipC.bigcode as c_bigcode, zipC.middlecode as c_midcode,zipC.middle as c_middle,zipC.zipcode as c_zipcode,CONCAT(zipC.zipcode ,'/',zipC.small) as 'c_zip' ,");
                sql.Append(@" us.user_username as manage_name, vendor.*,");
                sql.Append(" FROM_UNIXTIME(vendor.agreement_createdate) as agr_date,FROM_UNIXTIME(vendor.agreement_start) as agr_start,FROM_UNIXTIME(vendor.agreement_end) as agr_end");//將php時間轉化為net時間
                sql.Append(" from vendor ");
                sql.Append(" left join t_zip_code zipC on vendor.company_zip=zipC.zipcode");
                sql.Append(" left join manage_user us on us.user_id=vendor.product_manage");
                sql.Append(" left join t_zip_code zipI on vendor.invoice_zip=zipI.zipcode ");
                sql.Append(" where 1=1 ");
                if (!string.IsNullOrEmpty(query.searchEmail))
                {
                    sqlCon.AppendFormat(" and vendor_email like '%{0}%'", query.searchEmail);
                }
                if (!string.IsNullOrEmpty(query.searchName))
                {
                    sqlCon.AppendFormat(" and vendor_name_simple like '%{0}%'", query.searchName);
                }
                if (!string.IsNullOrEmpty(query.vendor_name_full))
                {
                    sqlCon.AppendFormat(" and vendor_name_full like '%{0}%'", query.vendor_name_full);
                }
                if (!string.IsNullOrEmpty(query.searchInvoice))
                {
                    sqlCon.AppendFormat(" and vendor.vendor_invoice like '%{0}%'", query.searchInvoice);
                }
                if (!string.IsNullOrEmpty(query.erp_id))
                {
                    sqlCon.AppendFormat(" and vendor.erp_id like '%{0}%'", query.erp_id);
                }
                if (!string.IsNullOrEmpty(query.vendor_code))
                {
                    sqlCon.AppendFormat(" and vendor.vendor_code like '%{0}%'", query.vendor_code);
                }
                if (query.vendor_id != 0)
                {
                    sqlCon.AppendFormat(" and vendor.vendor_id = '{0}'", query.vendor_id);
                }
                if (query.create_dateOne != 0)
                {
                    sqlCon.AppendFormat(" and agreement_createdate >= '{0}'", query.create_dateOne);
                }
                if (query.create_dateTwo != 0)
                {
                    sqlCon.AppendFormat(" and agreement_createdate <= '{0}'", query.create_dateTwo);
                }
                if (query.searchStatus != -1)
                {
                    sqlCon.AppendFormat(" and dispatch='{0}'", query.searchStatus);
                }
                if (!string.IsNullOrEmpty(query.vendor_type))
                {
                    sqlCon.Append(" and (");
                    string[] checks = query.vendor_type.Split(',');
                    int num = 0;
                    for (int i = 0; i < checks.Length; i++)
                    {
                        if (num == 0)
                        {
                            sqlCon.AppendFormat(" vendor_type like '%{0}%'", checks[i]);
                            num++;
                        }
                        else
                        {
                            sqlCon.AppendFormat(" or vendor_type like '%{0}%'", checks[i]);
                            num++;
                        }
                    }
                    sqlCon.Append(" ) ");
                }
                sqlCon.Append(" order by vendor_id desc ");

                //得到數據總條數
                totalCount = 0;
                System.Data.DataTable _dt = _dbAccess.getDataTable(" select count(vendor_id) as totalCount from vendor where 1=1 " + sqlCon.ToString());
                if (_dt != null)
                {
                    totalCount = Convert.ToInt32(_dt.Rows[0]["totalCount"]);
                }
                sqlCon.AppendFormat(" limit {0},{1}", query.Start, query.Limit);
                return _dbAccess.getDataTableForObj<VendorQuery>(sql.ToString() + sqlCon.ToString());
            }
            catch (Exception ex)
            {
                throw new Exception(" VendorDao-->Query-->" + ex.Message + sql.ToString() + sqlCon.ToString(), ex);
            }
        }
        /// <summary>
        /// 查詢供應商信息
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public VendorQuery GetVendorInfoByCon(VendorQuery query)
        {
            StringBuilder sql = new StringBuilder();
            try
            {
                sql.AppendFormat("select * from vendor where vendor_id={0} ", query.vendor_id);
                return _access.getSinggleObj<VendorQuery>(sql.ToString());
            }
            catch (Exception ex)
            {

                throw new Exception("VendorAccountMonthDao-->GetVendorInfoByCon-->" + sql.ToString() + ex.Message, ex);
            }
        }