ucCarMeterInfo.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453
  1. using com.hnshituo.core.webapp.vo;
  2. using Common;
  3. using Infragistics.Win.UltraWinGrid;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Windows.Forms;
  8. namespace MeterModuleLibrary
  9. {
  10. public delegate void EventOpenWgt(string e);
  11. public partial class ucCarMeterInfo : UserControl
  12. {
  13. public ucCarMeterInfo()
  14. {
  15. InitializeComponent();
  16. }
  17. private frmNumberKey fnk = null;
  18. private bool bFnk = false;
  19. private frmApplianceCheck fac = null;
  20. private bool bFac = false;
  21. private frmScaleQuery fah = null;
  22. private bool bFah = false;
  23. private frmPhNo fpn = null;
  24. private bool bFpn = false;
  25. public event EventOpenWgt openWgt;
  26. public event EventOpenWgt openTareWgt;
  27. /// <summary>
  28. /// 斗重
  29. /// </summary>
  30. public double dWeight = 0;
  31. public void setFormControlValue(UltraGridRow ugr)
  32. {
  33. txtPREDICTION_NO.Text = "";
  34. String bussinessNo = ugr.Cells["predictionNo"].Text.Trim();
  35. if (String.IsNullOrEmpty(bussinessNo))
  36. {
  37. bussinessNo = ugr.Cells["matterNo"].Text.Trim() + ugr.Cells["forwardingUnitNo"].Text.Trim() + ugr.Cells["receivingUintNo"].Text.Trim();
  38. }
  39. if (!String.IsNullOrEmpty(bussinessNo) && bussinessNo.Length == 9)
  40. {
  41. txtPREDICTION_NO.Text = bussinessNo;
  42. }
  43. txtMATTER_NAME.Text = ugr.Cells["matterName"].Text.Trim();
  44. txtFORWARDING_UNIT_NAME.Text = ugr.Cells["forwardingUnitName"].Text.Trim();
  45. txtRECEIVING_UINT_NAME.Text = ugr.Cells["receivingUintName"].Text.Trim();
  46. lp = new List<PbModelDb>();
  47. lp.Add(new PbModelDb { id = "matterNo", text = ugr.Cells["matterNo"].Text.Trim() });
  48. lp.Add(new PbModelDb { id = "matterName", text = ugr.Cells["matterName"].Text.Trim() });
  49. lp.Add(new PbModelDb { id = "forwardingUnitNo", text = ugr.Cells["forwardingUnitNo"].Text.Trim() });
  50. lp.Add(new PbModelDb { id = "forwardingUnitName", text = ugr.Cells["forwardingUnitName"].Text.Trim() });
  51. lp.Add(new PbModelDb { id = "receivingUintNo", text = ugr.Cells["receivingUintNo"].Text.Trim() });
  52. lp.Add(new PbModelDb { id = "receivingUintName", text = ugr.Cells["receivingUintName"].Text.Trim() });
  53. lp.Add(new PbModelDb { id = "meterTypeNo", text = ugr.Cells["meterTypeNo"].Text.Trim() });
  54. lp.Add(new PbModelDb { id = "meterTypeName", text = ugr.Cells["meterTypeName"].Text.Trim() });
  55. setAddWgtBtnVisable();
  56. }
  57. public void setFormControlValue(MeterWorkCarActualFirst first)
  58. {
  59. txtMATTER_NAME.Text = first.matterName;
  60. txtFORWARDING_UNIT_NAME.Text = first.forwardingUnitName;
  61. txtRECEIVING_UINT_NAME.Text = first.receivingUintName;
  62. lp = new List<PbModelDb>();
  63. lp.Add(new PbModelDb { id = "matterNo", text = first.matterNo });
  64. lp.Add(new PbModelDb { id = "matterName", text = first.matterName });
  65. lp.Add(new PbModelDb { id = "forwardingUnitNo", text = first.forwardingUnitNo });
  66. lp.Add(new PbModelDb { id = "forwardingUnitName", text = first.forwardingUnitName });
  67. lp.Add(new PbModelDb { id = "receivingUintNo", text = first.receivingUintNo });
  68. lp.Add(new PbModelDb { id = "receivingUintName", text = first.receivingUintName });
  69. lp.Add(new PbModelDb { id = "meterTypeNo", text = first.meterTypeNo });
  70. lp.Add(new PbModelDb { id = "meterTypeName", text = first.meterTypeName });
  71. txtBATCH_NO.Text = first.batchNo;
  72. if (!String.IsNullOrEmpty(first.predictionNo) && first.predictionNo.Length == 9)
  73. {
  74. txtPREDICTION_NO.Text = first.predictionNo; //2021年6月7日 杨秀东添加,用于临时委托,存到数据库中去
  75. }
  76. setAddWgtBtnVisable();
  77. //如果第一次计量是毛重
  78. if (first.weightType == "0" && lbWgt.Visible)
  79. {
  80. if (first.addWeight != null && first.addWeight.Value > 0)
  81. {
  82. lbWgt.Text = first.addWeight.Value + "";
  83. if (!string.IsNullOrEmpty(first.addWgtNo))
  84. {
  85. foreach (string str in first.addWgtNo.Split(','))
  86. {
  87. if (lb1.Items.Count < 7)
  88. {
  89. lb1.Items.Add(str);
  90. }
  91. else
  92. {
  93. lb2.Items.Add(str);
  94. }
  95. }
  96. }
  97. }
  98. else
  99. lbWgt.Text = "";
  100. lbWgt.Enabled = false;
  101. btnCheck.Visible = false;
  102. }
  103. }
  104. public string getAddWgtPk = "";
  105. private List<string> ls = new List<string>();
  106. private void btnCheck_Click(object sender, EventArgs e)
  107. {
  108. fac = new frmApplianceCheck();
  109. fac.ltAddWeightNo = ls == null ? null : ls;
  110. bFac = true;
  111. if (fac.ShowDialog() == DialogResult.OK)
  112. {
  113. bFac = false;
  114. lbUTENSIL_UTENSIL_NAME.Text = "";
  115. lbWgt.Text = "0";
  116. lb1.Items.Clear();
  117. lb2.Items.Clear();
  118. getAddWgtPk = "";
  119. DataTable dt = fac.dtChecked;
  120. ls = fac.ltAddWeightNo;
  121. if (dt != null && dt.Rows.Count > 0)
  122. {
  123. double dWgt = 0;
  124. foreach (DataRow dr in dt.Rows)
  125. {
  126. if (lbUTENSIL_UTENSIL_NAME.Text == "")
  127. {
  128. lbUTENSIL_UTENSIL_NAME.Text = dr["utensilUtensilName"].ToString();
  129. }
  130. if (lb1.Items.Count < 7)
  131. {
  132. lb1.Items.Add(dr["utensilNo"].ToString());
  133. }
  134. else
  135. {
  136. lb2.Items.Add(dr["utensilNo"].ToString());
  137. }
  138. dWgt += Convert.ToDouble(dr["utensilWeight"].ToString());
  139. getAddWgtPk += dr["addWeightNo"].ToString() + ",";
  140. }
  141. lbWgt.Text = dWgt + "";
  142. openWgt(dWgt + "");
  143. }
  144. }
  145. }
  146. public string getJz()
  147. {
  148. string sJz = "";
  149. foreach (string str in lb1.Items)
  150. {
  151. sJz += str + ",";
  152. }
  153. foreach (string str in lb2.Items)
  154. {
  155. sJz += str + ",";
  156. }
  157. return (sJz != "" ? sJz.Substring(0, sJz.Length - 1) : sJz);
  158. }
  159. public double getLbWgtValue
  160. {
  161. get
  162. {
  163. try
  164. {
  165. return string.IsNullOrEmpty(lbWgt.Text.Trim()) ? 0 : Convert.ToDouble(lbWgt.Text.Trim());
  166. }
  167. catch
  168. {
  169. return 0;
  170. }
  171. }
  172. }
  173. public List<PbModelDb> lp = null;
  174. /// <summary>
  175. /// 【业务编号】按钮点击事件
  176. /// </summary>
  177. /// <param name="sender"></param>
  178. /// <param name="e"></param>
  179. private void btnNo_Click(object sender, EventArgs e)
  180. {
  181. fah = new frmScaleQuery();
  182. bFah = true;
  183. if (fah.ShowDialog() == DialogResult.OK)
  184. {
  185. bFah = false;
  186. lp = new List<PbModelDb>();
  187. txtPREDICTION_NO.Text = fah.strValue;
  188. if (fah.ht != null && fah.ht.Count == 3)
  189. {
  190. txtMATTER_NAME.Text = fah.ht[2].text;
  191. txtFORWARDING_UNIT_NAME.Text = fah.ht[0].text;
  192. txtRECEIVING_UINT_NAME.Text = fah.ht[1].text;
  193. lp.Add(new PbModelDb { id = "matterNo", text = fah.ht[2].id });
  194. lp.Add(new PbModelDb { id = "matterName", text = fah.ht[2].text });
  195. lp.Add(new PbModelDb { id = "forwardingUnitNo", text = fah.ht[0].id });
  196. lp.Add(new PbModelDb { id = "forwardingUnitName", text = fah.ht[0].text });
  197. lp.Add(new PbModelDb { id = "receivingUintNo", text = fah.ht[1].id });
  198. lp.Add(new PbModelDb { id = "receivingUintName", text = fah.ht[1].text });
  199. }
  200. else
  201. {
  202. txtMATTER_NAME.Text = "";
  203. txtFORWARDING_UNIT_NAME.Text = "";
  204. txtRECEIVING_UINT_NAME.Text = "";
  205. lp.Add(new PbModelDb { id = "matterNo", text = "" });
  206. lp.Add(new PbModelDb { id = "matterName", text = "" });
  207. lp.Add(new PbModelDb { id = "forwardingUnitNo", text = "" });
  208. lp.Add(new PbModelDb { id = "forwardingUnitName", text = "" });
  209. lp.Add(new PbModelDb { id = "receivingUintNo", text = "" });
  210. lp.Add(new PbModelDb { id = "receivingUintName", text = "" });
  211. }
  212. setAddWgtBtnVisable();
  213. #region 如果有可用期限皮,且没有一次计量数据,且当前重量大于期限皮重1000kg 则将期限皮重量填充皮重
  214. MeterWorkCarActualFirstService workCarActualFirstService = new MeterWorkCarActualFirstService();
  215. RESTfulResult<List<MeterWorkCarActualFirst>> RESTfulResult = workCarActualFirstService.doQueryWf(new MeterWorkCarActualFirst { carNo = PbCache.collect.carno, valueFlag = "1" });
  216. if (RESTfulResult.Succeed)
  217. {
  218. if (RESTfulResult.Data == null || RESTfulResult.Data.Count == 0)
  219. {
  220. openTareWgt("");
  221. if (PbCache.isTermTare)
  222. {
  223. MeterBaseTermTareDataService termTareDate = new MeterBaseTermTareDataService();
  224. RESTfulResult<List<MeterBaseTermTareData>> rmD = termTareDate.doQueryWf(new MeterBaseTermTareData { carNo = PbCache.collect.carno });
  225. if (rmD.Succeed)
  226. {
  227. if (rmD.Data != null && rmD.Data.Count > 0 && (PbCache.collect.weight - rmD.Data[0].meterWeight.Value >= 1000))
  228. {
  229. openTareWgt(rmD.Data[0].meterWeight.Value + "");
  230. }
  231. }
  232. }
  233. }
  234. }
  235. #endregion 如果有可用期限皮,且没有一次计量数据,且当前重量大于期限皮重1000kg 则将期限皮重量填充皮重
  236. }
  237. }
  238. public string meterTypeName = "";
  239. public void setMeterType(string meterType)
  240. {
  241. txtMETER_TYPE.Text = meterType;
  242. meterTypeName = meterType;
  243. }
  244. #region 设置按钮是否可点击
  245. private bool btnCheckVisible = false;
  246. public bool BtnCheckVisible
  247. {
  248. get { return btnCheckVisible; }
  249. set
  250. {
  251. btnCheckVisible = value;
  252. SetText(value);
  253. }
  254. }
  255. private void SetText(bool bflag)
  256. {
  257. if (btnCheck.InvokeRequired)
  258. {
  259. Action<bool> action = new Action<bool>(SetText);
  260. Invoke(action, new object[] { bflag });
  261. }
  262. else
  263. {
  264. btnCheck.Visible = bflag;
  265. }
  266. }
  267. private bool btnNoVisible = false;
  268. public bool BtnNoVisible
  269. {
  270. get { return btnNoVisible; }
  271. set
  272. {
  273. btnNoVisible = value;
  274. SetNoText(value);
  275. }
  276. }
  277. private void SetNoText(bool bflag)
  278. {
  279. if (btnCheck.InvokeRequired)
  280. {
  281. Action<bool> action = new Action<bool>(SetNoText);
  282. Invoke(action, new object[] { bflag });
  283. }
  284. else
  285. {
  286. btnNo.Visible = bflag;
  287. }
  288. }
  289. #endregion 设置按钮是否可点击
  290. private void lbWgt_Enter(object sender, EventArgs e)
  291. {
  292. bFnk = true;
  293. fnk = new frmNumberKey();
  294. fnk.bControl = true;
  295. fnk.sValue = lbWgt.Text.Trim();
  296. if (fnk.ShowDialog() == DialogResult.OK)
  297. {
  298. bFnk = false;
  299. try
  300. {
  301. lbWgt.Text = fnk.sValue;
  302. }
  303. catch { }
  304. }
  305. }
  306. private void setAddWgtBtnVisable()
  307. {
  308. btnCheck.Visible = false;
  309. lbWgt.Visible = false;
  310. lbWgt.Text = "";
  311. PbCache.addWgt = 0;
  312. PbCache.isTermTare = false;
  313. if (lp != null && lp.Count > 0)
  314. {
  315. string sql = @"select matter_no id,
  316. allowed_tare_weight text,
  317. allowed_add_weight text2
  318. from meter_base_matter_info
  319. where valid_Flag = '1' and matter_no = '" + lp[0].text + "'";
  320. PbModelDbService<List<PbModelDb>> pb = new PbModelDbService<List<PbModelDb>>();
  321. RESTfulResult<List<PbModelDb>> rm = pb.executeSqlDataWf(sql);
  322. if (rm.Succeed)
  323. {
  324. if (rm.Data != null && rm.Data.Count > 0)
  325. {
  326. if (rm.Data[0].text == "1")
  327. {
  328. PbCache.isTermTare = true;
  329. }
  330. if (rm.Data[0].text2 == "1")
  331. {
  332. btnCheck.Visible = true;
  333. lbWgt.Visible = true;
  334. }
  335. }
  336. }
  337. }
  338. }
  339. private void lbWgt_TextChanged(object sender, EventArgs e)
  340. {
  341. openWgt(lbWgt.Text.Trim());
  342. }
  343. private void btnPC_Click(object sender, EventArgs e)
  344. {
  345. bFpn = true;
  346. fpn = new frmPhNo();
  347. if (fpn.ShowDialog() == DialogResult.OK)
  348. {
  349. bFpn = false;
  350. txtBATCH_NO.Text = string.IsNullOrEmpty(fpn.strValue) ? "" : fpn.strValue;
  351. }
  352. }
  353. /// <summary>
  354. /// 批次编号
  355. /// </summary>
  356. /// <returns></returns>
  357. public string batchNo()
  358. {
  359. return txtBATCH_NO.Text.Trim();
  360. }
  361. /// <summary>
  362. /// 业务号
  363. /// </summary>
  364. /// <returns></returns>
  365. public string predictionNo()
  366. {
  367. return txtPREDICTION_NO.Text.Trim();
  368. }
  369. public void ClosingFrm()
  370. {
  371. try
  372. {
  373. if (bFnk) fnk.Close();
  374. }
  375. catch { }
  376. try
  377. {
  378. if (bFac) fac.Close();
  379. }
  380. catch { }
  381. try
  382. {
  383. if (bFah) fah.Close();
  384. }
  385. catch { }
  386. try
  387. {
  388. if (bFpn) fpn.Close();
  389. }
  390. catch { }
  391. }
  392. }
  393. }