frmAssign.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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.Text.RegularExpressions;
  9. using System.Windows.Forms;
  10. using Core.Mes.Client.Comm.Control;
  11. using Core.Mes.Client.Comm.Format;
  12. using Core.Mes.Client.Comm.Tool;
  13. using Core.StlMes.Client.YdmBcPipeManage.Entity;
  14. using CoreFS.CA06;
  15. namespace Core.StlMes.Client.YdmBcPipeManage.Demand
  16. {
  17. public partial class frmAssign : FrmBase
  18. {
  19. List<TmsCarBaseEntity> All = new List<TmsCarBaseEntity>();
  20. private readonly List<TmsDemandM> tmsDemandMs;
  21. private string startnode = "";
  22. private string endnode = "";
  23. public frmAssign(OpeBase _ob, List<TmsDemandM> tmsDemand)
  24. {
  25. InitializeComponent();
  26. //lblCarrierName.Text = tmsDemand[0].CarrierName;
  27. lblStart.Text = tmsDemand[0].StartNodeDesc;
  28. lblEnd.Text = tmsDemand[0].EndNodeDesc;
  29. lblUnplnQty.Text = tmsDemand.Sum(p => p.UnPlanQtyVal).ToString2();
  30. lblUnplnWt.Text = tmsDemand.Sum(p => p.UnPlanWtVal).ToString2();
  31. lblRealQty.Text = tmsDemand.Sum(p => p.CanPlanQtyVal).ToString2();
  32. lblRealWt.Text = tmsDemand.Sum(p => p.CanPlanWtVal).ToString2();
  33. ob = _ob;
  34. tmsDemandMs = tmsDemand;
  35. EntityHelper.ShowGridCaption<TmsCarBaseEntity>(ugStation.DisplayLayout.Bands[0]);
  36. All = EntityHelper.GetData<TmsCarBaseEntity>(
  37. "com.steering.Demand.sever.TmsDemandServer.queryCar", new[] {tmsDemand[0].CarrierCode},
  38. _ob);
  39. tmsCarBaseEntityBindingSource.DataSource = All;
  40. GridHelper.RefreshAndAutoSizeExceptColumns(ugStation, "CarDemandQty", "CarDemandWt");
  41. }
  42. private void txtQuery_TextChanged(object sender, EventArgs e)
  43. {
  44. if (All == null) return;
  45. tmsCarBaseEntityBindingSource.DataSource = string.IsNullOrWhiteSpace(txtQuery.Text.Trim())
  46. ? All
  47. : All.Where(
  48. p =>
  49. p.CarLicense.IndexOf(txtQuery.Text.Trim(), StringComparison.Ordinal) >= 0 ||
  50. p.CarNo.IndexOf(txtQuery.Text.Trim(), StringComparison.Ordinal) >= 0).ToList();
  51. ugStation.UpdateData();
  52. ugStation.Update();
  53. ugStation.Refresh();
  54. }
  55. private void ugStation_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  56. {
  57. if (e.Cell.Column.Key != "Chk")
  58. {
  59. e.Cell.Row.Cells["Chk"].Value = true;
  60. }
  61. if (e.Cell.Column.Key == "CarDemandQty")
  62. {
  63. if (e.Cell.Text.Replace("_", "") == "") e.Cell.Row.Cells["CarDemandWt"].Value = null;
  64. else
  65. {
  66. try
  67. {
  68. e.Cell.Row.Cells["CarDemandWt"].Value = decimal.Round(decimal.Parse(lblRealWt.Text) /
  69. decimal.Parse(lblRealQty.Text) * decimal.Parse(e.Cell.Text.Replace("_", "")), 3);
  70. }
  71. catch (Exception ex)
  72. {
  73. e.Cell.Row.Cells["CarDemandWt"].Value = null;
  74. }
  75. }
  76. }
  77. }
  78. private void ubtSave_Click(object sender, EventArgs e)
  79. {
  80. ugStation.UpdateData();
  81. var data = tmsCarBaseEntityBindingSource.DataSource as List<TmsCarBaseEntity>;
  82. if (data == null)
  83. {
  84. MessageBox.Show("请选择需要分派的车辆");
  85. return;
  86. }
  87. var cars = data.Where(p => p.Chk).ToList();
  88. if (!cars.Any())
  89. {
  90. MessageBox.Show("请选择需要分派的车辆");
  91. return;
  92. }
  93. if (cars.Any(p => p.CarDemandQty == null || p.CarDemandQty < 0))
  94. {
  95. MessageBox.Show("请对勾选上的车辆分派需运输的支数!");
  96. return;
  97. }
  98. var ccp = new CoreClientParam();
  99. ccp.ServerName = "com.steering.Demand.sever.TmsDemandServer";
  100. ccp.MethodName = "Assign";
  101. ccp.ServerParams = new object[]
  102. {
  103. tmsDemandMs.Select(JSONFormat.Format).ToList(),
  104. cars.Select(JSONFormat.Format).ToList(),
  105. startnode,
  106. endnode,
  107. UserInfo.GetUserName()
  108. };
  109. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  110. if (ccp.ReturnCode != -1)
  111. {
  112. MessageUtil.ShowTips(ccp.ReturnInfo);
  113. if (ccp.ReturnInfo.Equals("分派成功!"))
  114. this.DialogResult = DialogResult.OK;
  115. }
  116. }
  117. private void ultraButton1_Click(object sender, EventArgs e)
  118. {
  119. using (var frmDemandSetting = new frmDemandSetting(ob))
  120. {
  121. if (frmDemandSetting.ShowDialog() == DialogResult.OK)
  122. {
  123. lblEnd.Text = frmDemandSetting.SelectRow.UnloadingDesc;
  124. endnode = frmDemandSetting.SelectRow.UnloadingCode;
  125. }
  126. }
  127. }
  128. }
  129. }