Beispiel #1
0
        public JsonResult LoadSearchDeliverBillsGrid(string sidx, string sord, int page, int rows, string startTime, string endTime, string customerName, string deliveryNo, string carNo)
        {
            //读取数据
            string strErrText;
            DeliverSystem deliver = new DeliverSystem();
            List<DeliverBill> listDeliverBill = deliver.LoadDeliverBillsByConditions(startTime, endTime, string.Empty, customerName, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, carNo, deliveryNo, string.Empty, "1", LoginAccountId, LoginStaffName, out strErrText);
            if (listDeliverBill == null)
            {
                throw new Exception(strErrText);
            }

            //提取当前页面数据
            int nTotalRows = listDeliverBill.Count;
            int nPageIndex = page;
            int nPageSize = rows;
            int nTotalPages = nTotalRows / nPageSize;
            if (nTotalRows % nPageSize > 0)
                nTotalPages++;

            string sortExpression = (sidx ?? "CreateTime") + " " + (sord ?? "ASC");
            var data = listDeliverBill.OrderBy(sortExpression).Skip((nPageIndex - 1) * nPageSize).Take(nPageSize).ToList();

            //生成表格数据
            var ret = new
            {
                total = nTotalPages,
                page = nPageIndex,
                records = nTotalRows,
                rows = (
                      from b in data
                      select new
                      {
                          id = b.Id,
                          cell = new string[] {
                              b.Id.ToString(),
                              b.CreateTime.ToString("yyyy-MM-dd"),
                              b.DeliveryNo,
                              b.CarNo,
                              b.CustomerName,
                              b.ReceiverName,
                              b.ReceiverProvince + b.ReceiverCity + b.ReceiverAddress,
                              b.TotalPackages.ToString(),
                              b.TotalTunnages.ToString("#0.######"),
                              b.TotalPiles.ToString("#0.######"),
                              b.TotalTenThousands.ToString("#0.######"),
                              b.ContractNo,
                              b.OriginalContractNo,
                              b.TransportCharges.ToString()
                          }
                      }).ToArray(),
                userdata = new
                {
                    CreateTime = InnoSoft.LS.Resources.Labels.Total,
                    TotalPackages = data.Sum(s => s.TotalPackages),
                    TotalTunnages = data.Sum(s => s.TotalTunnages),
                    TotalPiles = data.Sum(s => s.TotalPiles),
                    TotalTenThousands = data.Sum(s => s.TotalTenThousands),
                    TransportCharges = data.Sum(s => s.TransportCharges)
                }
            };
            return Json(ret, JsonRequestBehavior.AllowGet);
        }
Beispiel #2
0
        public JsonResult LoadReprintDeliverBillsGrid(string sidx, string sord, int page, int rows, string startTime, string endTime, string deliverBillNo, string customerName, string carNo)
        {
            //读取数据
            string strErrText;
            DeliverSystem deliver = new DeliverSystem();
            List<DeliverBill> listDeliverBill = deliver.LoadDeliverBillsByConditions(startTime, endTime, deliverBillNo, customerName, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, carNo, string.Empty, string.Empty, "1", LoginAccountId, LoginStaffName, out strErrText);
            if (listDeliverBill == null)
            {
                throw new Exception(strErrText);
            }

            //提取当前页面数据
            int nTotalRows = listDeliverBill.Count;
            int nPageIndex = page;
            int nPageSize = rows;
            int nTotalPages = nTotalRows / nPageSize;
            if (nTotalRows % nPageSize > 0)
                nTotalPages++;

            string sortExpression = (sidx ?? "BillNo") + " " + (sord ?? "ASC");
            var data = listDeliverBill.OrderBy(sortExpression).Skip((nPageIndex - 1) * nPageSize).Take(nPageSize).ToList();

            //生成表格数据
            var ret = new
            {
                total = nTotalPages,
                page = nPageIndex,
                records = nTotalRows,
                rows = (
                      from b in data
                      select new
                      {
                          id = b.Id,
                          cell = new string[] {
                              b.Id.ToString(),
                              b.BillNo,
                              b.CustomerName,
                              b.DeliveryNo,
                              b.ReceiverName,
                              b.ReceiverCity,
                              b.CarNo,
                              b.TrailerNo,
                              b.PlanType,
                              b.TotalPackages.ToString(),
                              b.TotalTunnages.ToString("#0.######"),
                              b.TotalPiles.ToString("#0.######"),
                              b.TotalTenThousands.ToString("#0.######")
                          }
                      }).ToArray()
            };
            return Json(ret, JsonRequestBehavior.AllowGet);
        }
Beispiel #3
0
        public JsonResult LoadSyntheticalSearchGrid(string sidx, string sord, int page, int rows, string startTime, string endTime, string payerName, string startCountry, string startProvince, string startCity, string destCountry, string destProvince, string destCity, string carNo, string organId)
        {
            //读取数据
            string strErrText;
            DeliverSystem deliver = new DeliverSystem();
            List<DeliverBill> listBill = deliver.LoadDeliverBillsByConditions(startTime, endTime, string.Empty, string.Empty, payerName, startCountry, startProvince, startCity, destCountry, destProvince, destCity, carNo, string.Empty, organId, string.Empty, LoginAccountId, LoginStaffName, out strErrText);
            if (listBill == null)
            {
                throw new Exception(strErrText);
            }

            //根据结算公式计算运费
            foreach (DeliverBill bill in listBill)
            {
                if (bill.CustomerTransportCharges == 0 && bill.SettlementExpression != null && bill.SettlementExpression != string.Empty)
                {
                    try
                    {
                        EvaluatorHelper evaluator = new EvaluatorHelper();

                        evaluator.SetExpression(bill.SettlementExpression);

                        evaluator.AddVariable(InnoSoft.LS.Resources.Labels.KM, bill.KM == null || bill.KM == string.Empty ? "0" : bill.KM);
                        evaluator.AddVariable(InnoSoft.LS.Resources.Labels.Tunnages, bill.TotalTunnages.ToString());
                        evaluator.AddVariable(InnoSoft.LS.Resources.Labels.Piles, bill.TotalPiles.ToString());
                        evaluator.AddVariable(InnoSoft.LS.Resources.Labels.TransportPrice, bill.CustomerTransportPrice.ToString());
                        evaluator.AddVariable(InnoSoft.LS.Resources.Labels.TransportCharges, "0");

                        string strTransportCharges = evaluator.EvaluateExpression();
                        bill.CustomerTransportCharges = decimal.Parse(strTransportCharges);
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }
                }
            }

            //计算拼车费
            var grpShipmentNos = listBill.GroupBy(s => s.ShipmentNo).OrderBy(s => s.Key);
            foreach (var grpShipmentNo in grpShipmentNos)
            {
                if (grpShipmentNo.Key != null && grpShipmentNo.Key != string.Empty)
                {
                    List<DeliverBill> listShipmentNoDetail = grpShipmentNo.ToList<DeliverBill>();

                    int i = 0;
                    while (i < listShipmentNoDetail.Count)
                    {
                        if (i > 0)
                        {
                            int j = 0;
                            while (j < i)
                            {
                                if (listShipmentNoDetail[i].ReceiverAddress == listShipmentNoDetail[j].ReceiverAddress)
                                {
                                    break;
                                }
                                j++;
                            }
                            if (j >= i)
                            {
                                listShipmentNoDetail[i].CarpoolFee = 100;
                            }
                        }
                        i++;
                    }
                }
            }

            //提取当前页面数据
            int nTotalRows = listBill.Count;
            int nPageIndex = page;
            int nPageSize = rows;
            int nTotalPages = nTotalRows / nPageSize;
            if (nTotalRows % nPageSize > 0)
                nTotalPages++;

            string sortExpression = (sidx ?? "CreateTime") + " " + (sord ?? "ASC");
            var data = listBill.OrderBy(sortExpression).Skip((nPageIndex - 1) * nPageSize).Take(nPageSize).ToList();

            //生成表格数据
            var ret = new
            {
                total = nTotalPages,
                page = nPageIndex,
                records = nTotalRows,
                rows = (
                      from b in data
                      select new
                      {
                          id = b.Id,
                          cell = new string[] {
                              b.Id.ToString(),
                              b.ShipmentBillId.ToString(),
                              b.PlanId.ToString(),
                              b.CreateTime.ToString("yyyy-MM-dd"),
                              b.PlanNo,
                              b.CustomerName,
                              b.PayerId.ToString(),
                              b.PayerName,
                              b.ShipmentNo,
                              b.DeliveryNo,
                              b.ReceiverName,
                              b.ReceiverCountry + b.ReceiverProvince + b.ReceiverCity + b.ReceiverAddress,
                              b.StartCity,
                              b.ReceiverCity,
                              b.ReceiveType,
                              b.GoodsName,
                              b.TotalPackages.ToString(),
                              b.TotalTunnages.ToString("#0.######"),
                              b.TotalPiles.ToString("#0.######"),
                              b.TotalTenThousands.ToString("#0.######"),
                              b.CarNo,
                              b.TrailerNo,
                              b.CarType,
                              b.BillNo,
                              b.ContractId.ToString(),
                              b.ContractNo,
                              b.OriginalContractNo,
                              b.TransportCharges.ToString(),
                              (b.CustomerTransportCharges + b.CarpoolFee + b.RiverCrossingCharges).ToString(),
                              (b.CustomerTransportCharges + b.CarpoolFee + b.RiverCrossingCharges - b.TransportCharges).ToString(),
                              b.IsCustomerTransportChargesSettled.ToString(),
                              b.IsCarrierTransportChargesSettled.ToString(),
                              b.IsDeliverBillReceiptReceived.ToString(),
                              b.IsDeliverBillReceiptReceived ? b.ReturnTime.ToString("yyyy-MM-dd") : string.Empty,
                              b.ReverseAmount.ToString(),
                              b.TransportChargesBalance.ToString(),
                              b.Remark
                          }
                      }).ToArray(),
                userdata = new
                {
                    CreateTime = InnoSoft.LS.Resources.Labels.Total,
                    TotalPackages = data.Sum(s => s.TotalPackages),
                    TotalTunnages = data.Sum(s => s.TotalTunnages),
                    TotalPiles = data.Sum(s => s.TotalPiles),
                    TotalTenThousands = data.Sum(s => s.TotalTenThousands),
                    TransportCharges = data.Sum(s => s.TransportCharges),
                    CustomerTransportCharges = data.Sum(s => s.CustomerTransportCharges + s.CarpoolFee + s.RiverCrossingCharges),
                    TransportChargesDifference = data.Sum(s => s.CustomerTransportCharges + s.CarpoolFee + s.RiverCrossingCharges - s.TransportCharges),
                    ReverseAmount = data.Sum(s => s.ReverseAmount),
                    TransportChargesBalance = data.Sum(s => s.TransportChargesBalance)
                }
            };
            return Json(ret, JsonRequestBehavior.AllowGet);
        }
Beispiel #4
0
        public ActionResult ExportDeliverBills()
        {
            string strErrText;

            //提取查询条件
            var request = HttpContext.Request;
            string strStartTime = request.QueryString["startTime"] ?? string.Empty;
            string strEndTime = request.QueryString["endTime"] ?? string.Empty;
            string strCustomerName = request.QueryString["customerName"] ?? string.Empty;
            string strDeliveryNo = request.QueryString["deliveryNo"] ?? string.Empty;
            string strCarNo = request.QueryString["carNo"] ?? string.Empty;

            //读取回单数据
            DeliverSystem deliver = new DeliverSystem();
            List<DeliverBill> listDeliverBill = deliver.LoadDeliverBillsByConditions(strStartTime, strEndTime, string.Empty, strCustomerName, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, strCarNo, strDeliveryNo, string.Empty, "1", LoginAccountId, LoginStaffName, out strErrText);
            if (listDeliverBill == null)
            {
                throw new Exception(strErrText);
            }

            //生成GridView
            BoundField colCreateTime = new BoundField();
            colCreateTime.HeaderText = InnoSoft.LS.Resources.Labels.DeliverDate;
            colCreateTime.DataField = "CreateTime";

            BoundField colDeliveryNo = new BoundField();
            colDeliveryNo.HeaderText = InnoSoft.LS.Resources.Labels.DeliveryNo;
            colDeliveryNo.DataField = "DeliveryNo";

            BoundField colCarNo = new BoundField();
            colCarNo.HeaderText = InnoSoft.LS.Resources.Labels.CarNo;
            colCarNo.DataField = "CarNo";

            BoundField colCustomerName = new BoundField();
            colCustomerName.HeaderText = InnoSoft.LS.Resources.Labels.CustomerName;
            colCustomerName.DataField = "CustomerName";

            BoundField colReceiverName = new BoundField();
            colReceiverName.HeaderText = InnoSoft.LS.Resources.Labels.ReceiverName;
            colReceiverName.DataField = "ReceiverName";

            BoundField colReceiverAddress = new BoundField();
            colReceiverAddress.HeaderText = InnoSoft.LS.Resources.Labels.ReceiverAddress;
            colReceiverAddress.DataField = "ReceiverAddress";

            BoundField colTotalPackages = new BoundField();
            colTotalPackages.HeaderText = InnoSoft.LS.Resources.Labels.Pieces;
            colTotalPackages.DataField = "TotalPackages";

            BoundField colTotalTunnages = new BoundField();
            colTotalTunnages.HeaderText = InnoSoft.LS.Resources.Labels.Tunnages;
            colTotalTunnages.DataField = "TotalTunnages";

            BoundField colTotalPiles = new BoundField();
            colTotalPiles.HeaderText = InnoSoft.LS.Resources.Labels.Piles;
            colTotalPiles.DataField = "TotalPiles";

            BoundField colTotalTenThousands = new BoundField();
            colTotalTenThousands.HeaderText = InnoSoft.LS.Resources.Labels.TenThousands;
            colTotalTenThousands.DataField = "TotalTenThousands";

            BoundField colContractNo = new BoundField();
            colContractNo.HeaderText = InnoSoft.LS.Resources.Labels.ContractNo;
            colContractNo.DataField = "ContractNo";

            BoundField colOriginalContractNo = new BoundField();
            colOriginalContractNo.HeaderText = InnoSoft.LS.Resources.Labels.OriginalContractNo;
            colOriginalContractNo.DataField = "OriginalContractNo";

            BoundField colTransportCharges = new BoundField();
            colTransportCharges.HeaderText = InnoSoft.LS.Resources.Labels.TransportCharges;
            colTransportCharges.DataField = "TransportCharges";

            var grid = new GridView();
            grid.Columns.Add(colCreateTime);
            grid.Columns.Add(colDeliveryNo);
            grid.Columns.Add(colCarNo);
            grid.Columns.Add(colCustomerName);
            grid.Columns.Add(colReceiverName);
            grid.Columns.Add(colReceiverAddress);
            grid.Columns.Add(colTotalPackages);
            grid.Columns.Add(colTotalTunnages);
            grid.Columns.Add(colTotalPiles);
            grid.Columns.Add(colTotalTenThousands);
            grid.Columns.Add(colContractNo);
            grid.Columns.Add(colOriginalContractNo);
            grid.Columns.Add(colTransportCharges);

            grid.AutoGenerateColumns = false;

            grid.RowDataBound += new GridViewRowEventHandler(SearchDeliverBillsGrid_RowDataBound);
            grid.DataSource = from bill in listDeliverBill
                              select new
                              {
                                  CreateTime = bill.CreateTime.ToString("yyyy-MM-dd"),
                                  DeliveryNo = bill.DeliveryNo,
                                  CarNo = bill.CarNo,
                                  CustomerName = bill.CustomerName,
                                  ReceiverName = bill.ReceiverName,
                                  ReceiverAddress = bill.ReceiverProvince + bill.ReceiverCity + bill.ReceiverAddress,
                                  TotalPackages = bill.TotalPackages > 0 ? bill.TotalPackages.ToString() : string.Empty,
                                  TotalTunnages = bill.TotalTunnages > 0 ? bill.TotalTunnages.ToString("#0.######") : string.Empty,
                                  TotalPiles = bill.TotalPiles > 0 ? bill.TotalPiles.ToString("#0.######") : string.Empty,
                                  TotalTenThousands = bill.TotalTenThousands > 0 ? bill.TotalTenThousands.ToString("#0.######") : string.Empty,
                                  ContractNo = bill.ContractNo,
                                  OriginalContractNo = bill.OriginalContractNo,
                                  TransportCharges = bill.TransportCharges.ToString("N2")
                              };
            grid.DataBind();

            //导出GridView
            Response.ClearContent();
            Response.Charset = InnoSoft.LS.Resources.Encoding.ExcelCharset;
            Response.ContentEncoding = System.Text.Encoding.GetEncoding(InnoSoft.LS.Resources.Encoding.ExcelContent);
            Response.ContentType = "application/ms-excel";
            Response.Write("<meta http-equiv=Content-Type content=text/html charset=" + InnoSoft.LS.Resources.Encoding.ExcelCharset + ">");
            Response.AddHeader("content-disposition", "attachment; filename=DeliverBills.xls");
            StringWriter sw = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);
            grid.RenderControl(htw);
            Response.Write(@"<style> .text { mso-number-format:'\@'; } </style>");//定义字符串转换样式
            Response.Write(sw.ToString());
            Response.End();

            return View("SearchDeliverBills");
        }
Beispiel #5
0
        public ActionResult ExportSyntheticalSearch()
        {
            string strErrText;

            #region 提取参数

            var request = HttpContext.Request;
            string strStartTime = request.QueryString["startTime"] ?? string.Empty;
            string strEndTime = request.QueryString["endTime"] ?? string.Empty;
            string strPayerName = request.QueryString["payerName"] ?? string.Empty;
            string strStartCountry = request.QueryString["startCountry"] ?? string.Empty;
            string strStartProvince = request.QueryString["startProvince"] ?? string.Empty;
            string strStartCity = request.QueryString["startCity"] ?? string.Empty;
            string strDestCountry = request.QueryString["destCountry"] ?? string.Empty;
            string strDestProvince = request.QueryString["destProvince"] ?? string.Empty;
            string strDestCity = request.QueryString["destCity"] ?? string.Empty;
            string strCarNo = request.QueryString["carNo"] ?? string.Empty;
            string strOrganId = request.QueryString["organId"] ?? string.Empty;

            #endregion

            #region 读取明细数据

            DeliverSystem deliver = new DeliverSystem();
            List<DeliverBill> listBill = deliver.LoadDeliverBillsByConditions(strStartTime, strEndTime, string.Empty, string.Empty, strPayerName, strStartCountry, strStartProvince, strStartCity, strDestCountry, strDestProvince, strDestCity, strCarNo, string.Empty, strOrganId, string.Empty, LoginAccountId, LoginStaffName, out strErrText);
            if (listBill == null)
            {
                throw new Exception(strErrText);
            }

            #endregion

            #region 根据结算公式计算运费
            {
                foreach (DeliverBill bill in listBill)
                {
                    if (bill.CustomerTransportCharges == 0 && bill.SettlementExpression != null && bill.SettlementExpression != string.Empty)
                    {
                        try
                        {
                            EvaluatorHelper evaluator = new EvaluatorHelper();

                            evaluator.SetExpression(bill.SettlementExpression);

                            evaluator.AddVariable(InnoSoft.LS.Resources.Labels.KM, bill.KM == null || bill.KM == string.Empty ? "0" : bill.KM);
                            evaluator.AddVariable(InnoSoft.LS.Resources.Labels.Tunnages, bill.TotalTunnages.ToString());
                            evaluator.AddVariable(InnoSoft.LS.Resources.Labels.Piles, bill.TotalPiles.ToString());
                            evaluator.AddVariable(InnoSoft.LS.Resources.Labels.TransportPrice, bill.CustomerTransportPrice.ToString());
                            evaluator.AddVariable(InnoSoft.LS.Resources.Labels.TransportCharges, "0");

                            string strTransportCharges = evaluator.EvaluateExpression();
                            bill.CustomerTransportCharges = decimal.Parse(strTransportCharges);
                        }
                        catch (Exception e)
                        {
                            throw e;
                        }
                    }
                }
            }
            #endregion

            #region 计算拼车费
            {
                var grpShipmentNos = listBill.GroupBy(s => s.ShipmentNo).OrderBy(s => s.Key);
                foreach (var grpShipmentNo in grpShipmentNos)
                {
                    if (grpShipmentNo.Key != null && grpShipmentNo.Key != string.Empty)
                    {
                        List<DeliverBill> listShipmentNoDetail = grpShipmentNo.ToList<DeliverBill>();

                        int i = 0;
                        while (i < listShipmentNoDetail.Count)
                        {
                            if (i > 0)
                            {
                                int j = 0;
                                while (j < i)
                                {
                                    if (listShipmentNoDetail[i].ReceiverAddress == listShipmentNoDetail[j].ReceiverAddress)
                                    {
                                        break;
                                    }
                                    j++;
                                }
                                if (j >= i)
                                {
                                    listShipmentNoDetail[i].CarpoolFee = 100;
                                }
                            }
                            i++;
                        }
                    }
                }
            }
            #endregion

            #region 输出Excel

            //生成GridView
            BoundField colCreateTime = new BoundField();
            colCreateTime.HeaderText = InnoSoft.LS.Resources.Labels.DeliverDate;
            colCreateTime.DataField = "CreateTime";

            BoundField colPlanNo = new BoundField();
            colPlanNo.HeaderText = InnoSoft.LS.Resources.Labels.PlanNo;
            colPlanNo.DataField = "PlanNo";

            BoundField colCustomerName = new BoundField();
            colCustomerName.HeaderText = InnoSoft.LS.Resources.Labels.CustomerName;
            colCustomerName.DataField = "CustomerName";

            BoundField colPayerName = new BoundField();
            colPayerName.HeaderText = InnoSoft.LS.Resources.Labels.PayerName;
            colPayerName.DataField = "PayerName";

            BoundField colShipmentNo = new BoundField();
            colShipmentNo.HeaderText = InnoSoft.LS.Resources.Labels.ShipmentNo;
            colShipmentNo.DataField = "ShipmentNo";

            BoundField colDeliveryNo = new BoundField();
            colDeliveryNo.HeaderText = InnoSoft.LS.Resources.Labels.DeliveryNo;
            colDeliveryNo.DataField = "DeliveryNo";

            BoundField colReceiverName = new BoundField();
            colReceiverName.HeaderText = InnoSoft.LS.Resources.Labels.ReceiverName;
            colReceiverName.DataField = "ReceiverName";

            BoundField colStartCity = new BoundField();
            colStartCity.HeaderText = InnoSoft.LS.Resources.Labels.StartPlace;
            colStartCity.DataField = "StartCity";

            BoundField colReceiverCity = new BoundField();
            colReceiverCity.HeaderText = InnoSoft.LS.Resources.Labels.DestPlace;
            colReceiverCity.DataField = "ReceiverCity";

            BoundField colReceiveType = new BoundField();
            colReceiveType.HeaderText = InnoSoft.LS.Resources.Labels.ReceiveType;
            colReceiveType.DataField = "ReceiveType";

            BoundField colGoodsName = new BoundField();
            colGoodsName.HeaderText = InnoSoft.LS.Resources.Labels.GoodsName;
            colGoodsName.DataField = "GoodsName";

            BoundField colTotalPackages = new BoundField();
            colTotalPackages.HeaderText = InnoSoft.LS.Resources.Labels.Pieces;
            colTotalPackages.DataField = "TotalPackages";

            BoundField colTotalTunnages = new BoundField();
            colTotalTunnages.HeaderText = InnoSoft.LS.Resources.Labels.Tunnages;
            colTotalTunnages.DataField = "TotalTunnages";

            BoundField colTotalPiles = new BoundField();
            colTotalPiles.HeaderText = InnoSoft.LS.Resources.Labels.Piles;
            colTotalPiles.DataField = "TotalPiles";

            BoundField colTotalTenThousands = new BoundField();
            colTotalTenThousands.HeaderText = InnoSoft.LS.Resources.Labels.TenThousands;
            colTotalTenThousands.DataField = "TotalTenThousands";

            BoundField colCarNo = new BoundField();
            colCarNo.HeaderText = InnoSoft.LS.Resources.Labels.CarNo;
            colCarNo.DataField = "CarNo";

            BoundField colTrailerNo = new BoundField();
            colTrailerNo.HeaderText = InnoSoft.LS.Resources.Labels.TrailerNo;
            colTrailerNo.DataField = "TrailerNo";

            BoundField colCarType = new BoundField();
            colCarType.HeaderText = InnoSoft.LS.Resources.Labels.CarType;
            colCarType.DataField = "CarType";

            BoundField colDeliverBillNo = new BoundField();
            colDeliverBillNo.HeaderText = InnoSoft.LS.Resources.Labels.DeliverBillNo;
            colDeliverBillNo.DataField = "BillNo";

            BoundField colContractNo = new BoundField();
            colContractNo.HeaderText = InnoSoft.LS.Resources.Labels.ContractNo;
            colContractNo.DataField = "ContractNo";

            BoundField colOriginalContractNo = new BoundField();
            colOriginalContractNo.HeaderText = InnoSoft.LS.Resources.Labels.OriginalContractNo;
            colOriginalContractNo.DataField = "OriginalContractNo";

            BoundField colCarrierTransportCharges = new BoundField();
            colCarrierTransportCharges.HeaderText = InnoSoft.LS.Resources.Labels.CarrierTransportCharges;
            colCarrierTransportCharges.DataField = "TransportCharges";

            BoundField colCustomerTransportCharges = new BoundField();
            colCustomerTransportCharges.HeaderText = InnoSoft.LS.Resources.Labels.CustomerTransportCharges;
            colCustomerTransportCharges.DataField = "CustomerTransportCharges";

            BoundField colTransportChargesDifference = new BoundField();
            colTransportChargesDifference.HeaderText = InnoSoft.LS.Resources.Labels.TransportChargesDifference;
            colTransportChargesDifference.DataField = "TransportChargesDifference";

            BoundField colIsCustomerTransportChargesSettled = new BoundField();
            colIsCustomerTransportChargesSettled.HeaderText = InnoSoft.LS.Resources.Labels.IsCustomerTransportChargesSettled;
            colIsCustomerTransportChargesSettled.DataField = "IsCustomerTransportChargesSettled";

            BoundField colIsCarrierTransportChargesSettled = new BoundField();
            colIsCarrierTransportChargesSettled.HeaderText = InnoSoft.LS.Resources.Labels.IsCarrierTransportChargesSettled;
            colIsCarrierTransportChargesSettled.DataField = "IsCarrierTransportChargesSettled";

            BoundField colIsDeliverBillReceiptReceived = new BoundField();
            colIsDeliverBillReceiptReceived.HeaderText = InnoSoft.LS.Resources.Labels.IsReceiptReceived;
            colIsDeliverBillReceiptReceived.DataField = "IsDeliverBillReceiptReceived";

            BoundField colReturnTime = new BoundField();
            colReturnTime.HeaderText = InnoSoft.LS.Resources.Labels.ReturnTime;
            colReturnTime.DataField = "ReturnTime";

            BoundField colReverseAmount = new BoundField();
            colReverseAmount.HeaderText = InnoSoft.LS.Resources.Labels.ReverseAmount;
            colReverseAmount.DataField = "ReverseAmount";

            BoundField colTransportChargesBalance = new BoundField();
            colTransportChargesBalance.HeaderText = InnoSoft.LS.Resources.Labels.TransportChargesBalance;
            colTransportChargesBalance.DataField = "TransportChargesBalance";

            BoundField colRemark = new BoundField();
            colRemark.HeaderText = InnoSoft.LS.Resources.Labels.Remark;
            colRemark.DataField = "Remark";

            var grid = new GridView();
            grid.Columns.Add(colCreateTime);
            grid.Columns.Add(colPlanNo);
            grid.Columns.Add(colCustomerName);
            grid.Columns.Add(colPayerName);
            grid.Columns.Add(colShipmentNo);
            grid.Columns.Add(colDeliveryNo);
            grid.Columns.Add(colReceiverName);
            grid.Columns.Add(colStartCity);
            grid.Columns.Add(colReceiverCity);
            grid.Columns.Add(colReceiveType);
            grid.Columns.Add(colGoodsName);
            grid.Columns.Add(colTotalPackages);
            grid.Columns.Add(colTotalTunnages);
            grid.Columns.Add(colTotalPiles);
            grid.Columns.Add(colTotalTenThousands);
            grid.Columns.Add(colCarNo);
            grid.Columns.Add(colTrailerNo);
            grid.Columns.Add(colCarType);
            grid.Columns.Add(colDeliverBillNo);
            grid.Columns.Add(colContractNo);
            grid.Columns.Add(colOriginalContractNo);
            grid.Columns.Add(colCarrierTransportCharges);
            grid.Columns.Add(colCustomerTransportCharges);
            grid.Columns.Add(colTransportChargesDifference);
            grid.Columns.Add(colIsCustomerTransportChargesSettled);
            grid.Columns.Add(colIsCarrierTransportChargesSettled);
            grid.Columns.Add(colIsDeliverBillReceiptReceived);
            grid.Columns.Add(colReturnTime);
            grid.Columns.Add(colReverseAmount);
            grid.Columns.Add(colTransportChargesBalance);
            grid.Columns.Add(colRemark);

            grid.AutoGenerateColumns = false;

            grid.RowDataBound += new GridViewRowEventHandler(SyntheticalSearchGrid_RowDataBound);
            grid.DataSource = from b in listBill
                              select new
                              {
                                  CreateTime = b.CreateTime.ToString("yyyy-MM-dd"),
                                  PlanNo = b.PlanNo,
                                  CustomerName = b.CustomerName,
                                  PayerName = b.PayerName,
                                  ShipmentNo = b.ShipmentNo,
                                  DeliveryNo = b.DeliveryNo,
                                  ReceiverName = b.ReceiverName,
                                  StartCity = b.StartCity,
                                  ReceiverCity = b.ReceiverCity,
                                  ReceiveType = b.ReceiveType,
                                  GoodsName = b.GoodsName,
                                  TotalPackages = b.TotalPackages != 0 ? b.TotalPackages.ToString() : string.Empty,
                                  TotalTunnages = b.TotalTunnages != 0 ? b.TotalTunnages.ToString("#0.######") : string.Empty,
                                  TotalPiles = b.TotalPiles != 0 ? b.TotalPiles.ToString("#0.######") : string.Empty,
                                  TotalTenThousands = b.TotalTenThousands != 0 ? b.TotalTenThousands.ToString("#0.######") : string.Empty,
                                  CarNo = b.CarNo,
                                  TrailerNo = b.TrailerNo,
                                  CarType = b.CarType,
                                  BillNo = b.BillNo,
                                  ContractNo = b.ContractNo,
                                  OriginalContractNo = b.OriginalContractNo,
                                  TransportCharges = b.TransportCharges != 0 ? b.TransportCharges.ToString("N") : string.Empty,
                                  CustomerTransportCharges = (b.CustomerTransportCharges + b.CarpoolFee + b.RiverCrossingCharges) != 0 ? (b.CustomerTransportCharges + b.CarpoolFee + b.RiverCrossingCharges).ToString("N") : string.Empty,
                                  TransportChargesDifference = (b.CustomerTransportCharges + b.CarpoolFee + b.RiverCrossingCharges - b.TransportCharges) != 0 ? (b.CustomerTransportCharges + b.CarpoolFee + b.RiverCrossingCharges - b.TransportCharges).ToString("N") : string.Empty,
                                  IsCustomerTransportChargesSettled = b.IsCustomerTransportChargesSettled ? InnoSoft.LS.Resources.Options.Yes : InnoSoft.LS.Resources.Options.No,
                                  IsCarrierTransportChargesSettled = b.IsCarrierTransportChargesSettled ? InnoSoft.LS.Resources.Options.Yes : InnoSoft.LS.Resources.Options.No,
                                  IsDeliverBillReceiptReceived = b.IsDeliverBillReceiptReceived ? InnoSoft.LS.Resources.Options.Yes : InnoSoft.LS.Resources.Options.No,
                                  ReturnTime = b.IsDeliverBillReceiptReceived ? b.ReturnTime.ToString("yyyy-MM-dd") : string.Empty,
                                  ReverseAmount = b.ReverseAmount != 0 ? b.ReverseAmount.ToString("N") : string.Empty,
                                  TransportChargesBalance = b.TransportChargesBalance != 0 ? b.TransportChargesBalance.ToString("N") : string.Empty,
                                  Remark = b.Remark
                              };
            grid.DataBind();

            //导出GridView
            Response.ClearContent();
            Response.Charset = InnoSoft.LS.Resources.Encoding.ExcelCharset;
            Response.ContentEncoding = System.Text.Encoding.GetEncoding(InnoSoft.LS.Resources.Encoding.ExcelContent);
            Response.ContentType = "application/ms-excel";
            Response.Write("<meta http-equiv=Content-Type content=text/html charset=" + InnoSoft.LS.Resources.Encoding.ExcelCharset + ">");
            Response.AddHeader("content-disposition", "attachment; filename=SyntheticalSearch.xls");
            StringWriter sw = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);
            grid.RenderControl(htw);
            Response.Write(sw.ToString());
            Response.End();

            #endregion

            return View("SyntheticalSearch");
        }