FrmCrmBillAll.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Tool;
  3. using Core.StlMes.Client.YdmBcPipeManage.Entity;
  4. using CoreFS.CA06;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.ComponentModel;
  8. using System.Data;
  9. using System.Drawing;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Windows.Forms;
  13. namespace Core.StlMes.Client.YdmBcPipeManage
  14. {
  15. public partial class FrmCrmBillAll : FrmBase
  16. {
  17. public FrmCrmBillAll()
  18. {
  19. InitializeComponent();
  20. EntityHelper.ShowGridCaption<CrmBillAllEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  21. EntityHelper.ShowGridCaption<CrmBillCEntity>(ultraGrid1.DisplayLayout.Bands[1]);
  22. IsLoadUserView = true;
  23. }
  24. public override void ToolBar_Click(object sender, string ToolbarKey)
  25. {
  26. switch (ToolbarKey)
  27. {
  28. case "Query":
  29. doQuery();
  30. break;
  31. case "Export":
  32. doExport();
  33. break;
  34. case "Close":
  35. this.Close();
  36. break;
  37. }
  38. }
  39. private void doExport()
  40. {
  41. GridHelper.ulGridToExcel(ultraGrid1, "crm提单信息");
  42. }
  43. private void doQuery()
  44. {
  45. string billNo = "";
  46. string orderNo = "";
  47. String startDate = "";
  48. String endDate = "";
  49. if (billNoCheck.Checked)
  50. {
  51. billNo = billNoText.Text;
  52. }
  53. if (orderNoCheck.Checked)
  54. {
  55. orderNo = orderNoText.Text;
  56. }
  57. if (crateDateCheck.Checked)
  58. {
  59. startDate = startDateTime.DateTime.ToString("yyyy-MM-dd") + " 00:00:00"; ;
  60. endDate = endDateTime.DateTime.ToString("yyyy-MM-dd") + " 23:59:59";
  61. }
  62. if (!billNoCheck.Checked && !orderNoCheck.Checked && !crateDateCheck.Checked)
  63. {
  64. MessageUtil.ShowTips("请选择至少一个筛选条件!");
  65. return;
  66. }
  67. TimeSpan ts1 = new TimeSpan(DateTime.ParseExact(startDateTime.DateTime.ToString("yyyy-MM-dd"), "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture).Ticks);
  68. TimeSpan ts2 = new TimeSpan(DateTime.ParseExact(endDateTime.DateTime.ToString("yyyy-MM-dd"), "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture).Ticks);
  69. if (ts2.Subtract(ts1).Days > 180)
  70. {
  71. MessageUtil.ShowTips("最大查询7天的数据!");
  72. return;
  73. }
  74. List<CrmBillAllEntity> listSource = EntityHelper.GetData<CrmBillAllEntity>(
  75. "com.steering.pss.crm.server.CrmBillAllServer.CrmBillMQuery",
  76. new object[] { billNo, orderNo, startDate, endDate }, ob);
  77. if (listSource.Count == 0)
  78. {
  79. return;
  80. }
  81. List<CrmBillCEntity> listProject = EntityHelper.GetData<CrmBillCEntity>(
  82. "com.steering.pss.crm.server.CrmBillAllServer.CrmBillCQuery",
  83. new object[] { listSource.Select(p => p.BillNo).ToArray() }, ob);
  84. listSource.ForEach(p => p.crmBillCList = listProject.Where(q =>
  85. q.BillNoSeq == p.BillNoSeq && q.DataStatus == p.DataStatus
  86. //&& q.CreateTime.Substring(0, q.CreateTime.Length - 2) == p.CreateTime.Substring(0, p.CreateTime.Length - 2)
  87. //&& (new TimeSpan(DateTime.ParseExact(p.CreateTime, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture).Ticks)
  88. // .Subtract(new TimeSpan(DateTime.ParseExact(q.CreateTime, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture).Ticks))).Seconds <= 5
  89. //&& ((DiffSeconds(DateTime.ParseExact(p.CreateTime, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture), DateTime.ParseExact(q.CreateTime, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture)) <= 10
  90. // && DiffSeconds(DateTime.ParseExact(p.CreateTime, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture), DateTime.ParseExact(q.CreateTime, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture)) >= 0)
  91. // ||
  92. // (DiffSeconds(DateTime.ParseExact(p.CreateTime, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture), DateTime.ParseExact(q.CreateTime, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture)) >= -10
  93. //&& DiffSeconds(DateTime.ParseExact(p.CreateTime, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture), DateTime.ParseExact(q.CreateTime, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.CurrentCulture)) <= 0)
  94. //)
  95. ).ToList()
  96. );
  97. crmBillAllEntityBindingSource.DataSource = listSource;
  98. }
  99. public double DiffSeconds(DateTime startTime, DateTime endTime)
  100. {
  101. TimeSpan secondSpan = new TimeSpan(endTime.Ticks - startTime.Ticks);
  102. return secondSpan.TotalSeconds;
  103. }
  104. }
  105. }