frmMatMsgInfo.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. using com.hnshituo.core.webapp.vo;
  2. using Common;
  3. using Common.DbOption.work;
  4. using Infragistics.Win.UltraWinGrid;
  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.Threading.Tasks;
  13. using System.Windows.Forms;
  14. namespace CarMeterSystem
  15. {
  16. public partial class frmMatMsgInfo : Form
  17. {
  18. public frmMatMsgInfo()
  19. {
  20. InitializeComponent();
  21. }
  22. MeterWorkPreWgttypeService meterWorkPreWeightTypeService = new MeterWorkPreWgttypeService();
  23. //是否选对了
  24. public bool _isSuccess { get; set; }
  25. public string weightType = "";
  26. string _matName = "", _chkMatName = "";
  27. public frmMatMsgInfo(string matName)
  28. {
  29. InitializeComponent();
  30. _matName = matName;
  31. }
  32. private void btnCancel_Click(object sender, EventArgs e)
  33. {
  34. this.DialogResult = DialogResult.Cancel;
  35. this.Close();
  36. }
  37. private void btnSave_Click(object sender, EventArgs e)
  38. {
  39. string carNo = "湘G66666";
  40. string preTrackScaleNo = "";
  41. string weightTypes = weightType;
  42. int selectNum = 0;
  43. if (ultraGrid1.Rows.Count > 0)
  44. {
  45. foreach (UltraGridRow ugr in ultraGrid1.Rows)
  46. {
  47. string s = ugr.Cells["select"].Value.ToString();
  48. if (s == "True")
  49. {
  50. preTrackScaleNo = ugr.Cells["predictionNo"].Value.ToString();
  51. selectNum++;
  52. }
  53. }
  54. }
  55. if (weightTypes == "")
  56. {
  57. MessageBox.Show("请选择重量类型");
  58. return;
  59. }
  60. if (selectNum == 1)
  61. {
  62. string res = add(weightTypes, preTrackScaleNo, carNo);
  63. if (res == "")
  64. {
  65. MessageBox.Show("新增成功");
  66. this.DialogResult = DialogResult.OK;
  67. btnSave.Enabled = false;
  68. btnCancel.Enabled = false;
  69. ultraGrid1.UpdateData();
  70. this.Close();
  71. }
  72. else
  73. {
  74. MessageBox.Show(res);
  75. }
  76. }
  77. else
  78. {
  79. MessageBox.Show("只能选择一条委托");
  80. }
  81. }
  82. /// <summary>
  83. /// 定时关闭(15000ms)
  84. /// </summary>
  85. /// <param name="sender"></param>
  86. /// <param name="e"></param>
  87. private void timer1_Tick(object sender, EventArgs e)
  88. {
  89. this.DialogResult = DialogResult.Cancel;
  90. }
  91. private void lbMat1_Click(object sender, EventArgs e)
  92. {
  93. //_chkMatName = lbMat1.Text;
  94. //lbMat1.BackColor = Color.PaleTurquoise;
  95. //lbMat2.BackColor = Color.LightBlue;
  96. }
  97. private void lbMat2_Click(object sender, EventArgs e)
  98. {
  99. //_chkMatName = lbMat2.Text;
  100. //lbMat2.BackColor = Color.PaleTurquoise;
  101. //lbMat1.BackColor = Color.LightBlue;
  102. }
  103. private void btnTare_Click(object sender, EventArgs e)
  104. {
  105. weightType = "0";
  106. btnTare.BackColor = Color.Red;
  107. btnGross.BackColor = Color.Gray;
  108. }
  109. private void btnGross_Click(object sender, EventArgs e)
  110. {
  111. weightType = "1";
  112. btnGross.BackColor = Color.Red;
  113. btnTare.BackColor = Color.Gray;
  114. }
  115. private void frmMatMsgInfo_Load(object sender, EventArgs e)
  116. {
  117. string sql = string.Format(@"select t.PREDICTION_NO predictionNo,
  118. t.MATTER_NAME matterName,
  119. t.RECEIVING_UINT_NAME receivingUintName,
  120. t.FORWARDING_UNIT_NAME forwardingUnitName,
  121. t.TRUST_DATE_TIME trustDateTime
  122. from PRE_TRACK_SCALE t
  123. where value_flag = '1' and CAR_NO = '{0}' and LINE_DESC = '0'", "湘G66666");
  124. DataTable dtV = dtPrediction.Clone();
  125. PbModelDbService<List<PreTrackScale>> pb = new PbModelDbService<List<PreTrackScale>>();
  126. RESTfulResult<List<PreTrackScale>> rmType = pb.executeSqlDataWf(sql);
  127. if (rmType.Succeed && rmType.Data != null && rmType.Data.Count > 0)
  128. {
  129. dtV = rmType.Data.ListToDataTable<PreTrackScale>();
  130. }
  131. ClsControlPack.CopyDataToDatatable(ref dtV, ref this.dtPrediction, true);
  132. ClsControlPack.RefreshAndAutoSize(ultraGrid1);
  133. }
  134. public string add(string weightType,string preTrackScaleNo,string carNo)
  135. {
  136. MeterWorkPreWgttype meterWorkPreWeightType = new MeterWorkPreWgttype();
  137. if (weightType == "0")
  138. {
  139. meterWorkPreWeightType.weightTypeName = "毛重";
  140. meterWorkPreWeightType.weightTypeNo = "001033001";
  141. meterWorkPreWeightType.preTrackScaleNo = preTrackScaleNo;
  142. meterWorkPreWeightType.carNo = carNo;
  143. meterWorkPreWeightType.createManPhone = "";
  144. meterWorkPreWeightType.createManName = "admin";
  145. }
  146. else if (weightType == "1")
  147. {
  148. meterWorkPreWeightType.weightTypeName = "皮重";
  149. meterWorkPreWeightType.weightTypeNo = "001033002";
  150. meterWorkPreWeightType.carNo = carNo;
  151. meterWorkPreWeightType.createManPhone = "";
  152. meterWorkPreWeightType.createManName = "admin";
  153. }
  154. if (meterWorkPreWeightType.weightTypeName == null || meterWorkPreWeightType.weightTypeName == "")
  155. {
  156. return "请选择重量类型";
  157. }
  158. RESTfulResult<MeterWorkPreWgttype> rm = meterWorkPreWeightTypeService.doAddWeightType(meterWorkPreWeightType);
  159. if (rm.Succeed)
  160. {
  161. return "";
  162. }
  163. else
  164. {
  165. return rm.ResultMessage;
  166. }
  167. }
  168. }
  169. }