FrmArrearsOfDayReport.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. namespace LYFZ.Software.MainBusiness.StatisticalInquiry
  10. {
  11. public partial class FrmArrearsOfDayReport : LYFZ.Software.UI.StatisticalInquiry.FrmArrearsOfDayReport
  12. {
  13. LYFZ.BLL.BLL_ErpOrder orderBll = new BLL.BLL_ErpOrder();
  14. public FrmArrearsOfDayReport()
  15. {
  16. this.btn_Search.Click+=btn_Search_Click;
  17. }
  18. public void btn_Search_Click(object sender, EventArgs e)
  19. {
  20. BindDataRow();
  21. }
  22. public void BindDataRow()
  23. {
  24. string sql = @"select t1.* from (select sum(ord_seriesprice) as 业绩款,Cus_Name as 客户名称,Cus_Telephone as 联系电话,Company_Name as 门店名称,ord_number 订单号,Ord_CreateDateTime as 时间,付款, (sum(ord_seriesprice)-付款) as 欠款 from
  25. (SELECT CASE WHEN (Ord_SeriesPrice) IS NULL THEN 0 ELSE (Ord_SeriesPrice) END AS Ord_SeriesPrice,Ord_DividedShop ,tb_ErpOrder.Ord_Number,convert(datetime,Ord_CreateDateTime) as Ord_CreateDateTime,
  26. isnull(( SELECT sum(CASE WHEN (Pay_AmountOf) IS NULL THEN 0 ELSE (Pay_AmountOf) END) AS Pay_AmountOf
  27. FROM dbo.tb_ErpPayment where Pay_DividedShop= Ord_DividedShop and Pay_OrdNumber=Ord_Number
  28. and Pay_CreateDatetime >='" + DateTime.Now.ToString("yyyy-MM-dd") + @" 00:00:00' and Pay_CreateDatetime <='" + DateTime.Now.ToString("yyyy-MM-dd") + @" 23:59:59' ),0) as 付款
  29. FROM dbo.tb_ErpOrder
  30. WHERE (Ord_Class = '1')
  31. union
  32. SELECT CASE WHEN (Plu_Amount) IS NULL THEN 0 else(Plu_Amount) END AS Plu_Amount,Plu_DividedShop,Plu_OrdNumber,convert(datetime,Plu_CreateTime) as Ord_CreateDateTime,
  33. isnull(( SELECT sum( CASE WHEN (Pay_AmountOf) IS NULL THEN 0 ELSE (Pay_AmountOf) END) AS Pay_AmountOf
  34. FROM dbo.tb_ErpPayment where Pay_DividedShop= Plu_DividedShop and Pay_OrdNumber=Plu_OrdNumber
  35. and Pay_CreateDatetime >='" + DateTime.Now.ToString("yyyy-MM-dd") + @" 00:00:00' and Pay_CreateDatetime <='" + DateTime.Now.ToString("yyyy-MM-dd") + @" 23:59:59' ),0) as 付款
  36. FROM dbo.tb_ErpPlusPickItems
  37. union
  38. SELECT CASE WHEN (Tsorder_Money) IS NULL THEN 0 ELSE (Tsorder_Money) END AS Tsorder_Money,Tsorder_DividedShop ,Tsorder_Name,convert(datetime,Tsorder_CreateDatetime) as Ord_CreateDateTime,
  39. isnull(( SELECT sum(CASE WHEN (Pay_AmountOf) IS NULL THEN 0 ELSE (Pay_AmountOf) END) AS Pay_AmountOf
  40. FROM dbo.tb_ErpPayment where Pay_DividedShop= Tsorder_DividedShop and Pay_OrdNumber=Tsorder_Number
  41. and Pay_CreateDatetime >='" + DateTime.Now.ToString("yyyy-MM-dd") + @" 00:00:00' and Pay_CreateDatetime <='" + DateTime.Now.ToString("yyyy-MM-dd") + @" 23:59:59' ),0) as 付款
  42. FROM dbo.tb_ErpTwoSalesOrder
  43. union
  44. SELECT CASE WHEN (Dsro_Amount) IS NULL THEN 0 ELSE (Dsro_Amount) END AS Dsro_Amount,Dsro_DividedShop,Dsro_Number,Dsro_CreateDateTime,
  45. isnull(( SELECT sum(CASE WHEN (Pay_AmountOf) IS NULL THEN 0 ELSE (Pay_AmountOf) END) AS Pay_AmountOf
  46. FROM dbo.tb_ErpPayment where Pay_DividedShop= Dsro_DividedShop and Pay_OrdNumber=Dsro_Number
  47. and Pay_CreateDatetime >='" + DateTime.Now.ToString("yyyy-MM-dd") + @" 00:00:00' and Pay_CreateDatetime <='" + DateTime.Now.ToString("yyyy-MM-dd") + @" 23:59:59' ),0) as 付款
  48. FROM dbo.tb_ErpDressSaleRentalOrder
  49. ) as t inner join tempTB_AggregationCustomer on t.Ord_Number = GP_OrderNumber inner join tb_ErpCompanyInfo on Ord_DividedShop = Company_DividedShop
  50. group by ord_dividedshop,ord_number,Ord_CreateDateTime,Cus_Name,Cus_Telephone, Company_Name ,付款
  51. ) as t1 ";
  52. sql += " where 时间 >= '" + DateTime.Now.ToString("yyyy-MM-dd") + " 00:00:00' and 时间 <= '" + DateTime.Now.ToString("yyyy-MM-dd") + " 23:59:59' and t1.欠款>0 ";
  53. DataTable dtBll = orderBll.GetView_Custom(sql).Tables[0];
  54. foreach(DataRow dr in dtBll.Rows)
  55. {
  56. int rowIndex = this.dgv.Rows.Add();
  57. foreach (DataColumn columName in dtBll.Columns)
  58. {
  59. this.dgv.Rows[rowIndex].Cells[columName.ColumnName].Value = dr[columName.ColumnName].ToString();
  60. }
  61. }
  62. }
  63. public void BindDataRow2(List<string> numbers)
  64. {
  65. if (numbers.Count > 0)
  66. {
  67. string sql = @"select t1.* from (select sum(ord_seriesprice) as 业绩款,Cus_Name as 客户名称,Cus_Telephone as 联系电话,Company_Name as 门店名称,ord_dividedshop 门店编号,ord_number 订单号,Ord_CreateDateTime as 时间,付款, (sum(ord_seriesprice)-付款) as 欠款 from
  68. (SELECT CASE WHEN (Ord_SeriesPrice) IS NULL THEN 0 ELSE (Ord_SeriesPrice) END AS Ord_SeriesPrice,Ord_DividedShop ,tb_ErpOrder.Ord_Number,convert(datetime,Ord_CreateDateTime) as Ord_CreateDateTime,
  69. isnull(( SELECT sum(CASE WHEN (Pay_AmountOf) IS NULL THEN 0 ELSE (Pay_AmountOf) END) AS Pay_AmountOf
  70. FROM dbo.tb_ErpPayment where Pay_DividedShop= Ord_DividedShop and Pay_OrdNumber=Ord_Number
  71. and Pay_CreateDatetime >='" + DateTime.Now.ToString("yyyy-MM-dd") + @" 00:00:00' and Pay_CreateDatetime <='" + DateTime.Now.ToString("yyyy-MM-dd") + @" 23:59:59' ),0) as 付款
  72. FROM dbo.tb_ErpOrder
  73. WHERE (Ord_Class = '1')
  74. union
  75. SELECT CASE WHEN (Plu_Amount) IS NULL THEN 0 else(Plu_Amount) END AS Plu_Amount,Plu_DividedShop,Plu_OrdNumber,convert(datetime,Plu_CreateTime) as Ord_CreateDateTime,
  76. isnull(( SELECT sum( CASE WHEN (Pay_AmountOf) IS NULL THEN 0 ELSE (Pay_AmountOf) END) AS Pay_AmountOf
  77. FROM dbo.tb_ErpPayment where Pay_DividedShop= Plu_DividedShop and Pay_OrdNumber=Plu_OrdNumber
  78. and Pay_CreateDatetime >='" + DateTime.Now.ToString("yyyy-MM-dd") + @" 00:00:00' and Pay_CreateDatetime <='" + DateTime.Now.ToString("yyyy-MM-dd") + @" 23:59:59' ),0) as 付款
  79. FROM dbo.tb_ErpPlusPickItems
  80. union
  81. SELECT CASE WHEN (Tsorder_Money) IS NULL THEN 0 ELSE (Tsorder_Money) END AS Tsorder_Money,Tsorder_DividedShop ,Tsorder_Name,convert(datetime,Tsorder_CreateDatetime) as Ord_CreateDateTime,
  82. isnull(( SELECT sum(CASE WHEN (Pay_AmountOf) IS NULL THEN 0 ELSE (Pay_AmountOf) END) AS Pay_AmountOf
  83. FROM dbo.tb_ErpPayment where Pay_DividedShop= Tsorder_DividedShop and Pay_OrdNumber=Tsorder_Number
  84. and Pay_CreateDatetime >='" + DateTime.Now.ToString("yyyy-MM-dd") + @" 00:00:00' and Pay_CreateDatetime <='" + DateTime.Now.ToString("yyyy-MM-dd") + @" 23:59:59' ),0) as 付款
  85. FROM dbo.tb_ErpTwoSalesOrder
  86. union
  87. SELECT CASE WHEN (Dsro_Amount) IS NULL THEN 0 ELSE (Dsro_Amount) END AS Dsro_Amount,Dsro_DividedShop,Dsro_Number,Dsro_CreateDateTime,
  88. isnull(( SELECT sum(CASE WHEN (Pay_AmountOf) IS NULL THEN 0 ELSE (Pay_AmountOf) END) AS Pay_AmountOf
  89. FROM dbo.tb_ErpPayment where Pay_DividedShop= Dsro_DividedShop and Pay_OrdNumber=Dsro_Number
  90. and Pay_CreateDatetime >='" + DateTime.Now.ToString("yyyy-MM-dd") + @" 00:00:00' and Pay_CreateDatetime <='" + DateTime.Now.ToString("yyyy-MM-dd") + @" 23:59:59' ),0) as 付款
  91. FROM dbo.tb_ErpDressSaleRentalOrder
  92. ) as t inner join tempTB_AggregationCustomer on t.Ord_Number = GP_OrderNumber inner join tb_ErpCompanyInfo on Ord_DividedShop = Company_DividedShop
  93. group by ord_dividedshop,ord_number,Ord_CreateDateTime,Cus_Name,Cus_Telephone, Company_Name ,付款
  94. ) as t1 ";
  95. sql += " where 订单号 in ('" + string.Join("','", numbers.ToArray()) + "')";
  96. DataTable dtBll = orderBll.GetView_Custom(sql).Tables[0];
  97. foreach (DataRow dr in dtBll.Rows)
  98. {
  99. int rowIndex = this.dgv.Rows.Add();
  100. foreach (DataColumn columName in dtBll.Columns)
  101. {
  102. this.dgv.Rows[rowIndex].Cells[columName.ColumnName].Value = dr[columName.ColumnName].ToString();
  103. }
  104. }
  105. }
  106. }
  107. }
  108. }