FeedSaw.cs 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Drawing;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using CoreFS.CA06;
  11. using Core.Mes.Client.Comm.Server;
  12. using Core.Mes.Client.Comm.Control;
  13. using Core.StlMes.Client.ZGMil;
  14. using com.steering.mes.zgmil.entity;
  15. using Infragistics.Win.UltraWinGrid;
  16. namespace Core.StlMes.Client.ZGMil.ResultConrtrol
  17. {
  18. public partial class FeedSaw : UserControl
  19. {
  20. private Infragistics.Win.UltraWinGrid.UltraGrid _grid = null;
  21. public FeedSaw()
  22. {
  23. InitializeComponent();
  24. GridHelper.InitCardGrid(FeedDataSource, ultraGrid4);
  25. _grid = this.ultraGrid4;
  26. this.ultraGrid4.DisplayLayout.Override.AllowRowFiltering = Infragistics.Win.DefaultableBoolean.False;
  27. }
  28. private FeedRowPlan _feedPlan = new FeedRowPlan();
  29. [Browsable(false)]
  30. [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
  31. public FeedRowPlan Value
  32. {
  33. get { return _feedPlan; }
  34. set
  35. {
  36. if (value != null)
  37. {
  38. _feedPlan = value;
  39. UpdateData(0);
  40. }
  41. }
  42. }
  43. public void UpdateData(double CutDZWeight)
  44. {
  45. if (_feedPlan != null)
  46. {
  47. //计划上料支数
  48. FeedDataSource.Rows[0]["FeedNumPlan"] = _feedPlan.FeedNumPlan;
  49. //上料支数
  50. if (!string.IsNullOrEmpty(_feedPlan.FeedNumPlan) && !string.IsNullOrEmpty(_feedPlan.ScrapNumOld))
  51. {
  52. FeedDataSource.Rows[0]["FeedNum"] = (int.Parse(_feedPlan.FeedNumPlan) - int.Parse(_feedPlan.ScrapNumOld)).ToString();
  53. }
  54. else
  55. {
  56. FeedDataSource.Rows[0]["FeedNum"] = _feedPlan.FeedNum;
  57. }
  58. //上料长度
  59. FeedDataSource.Rows[0]["FeedLength"] = _feedPlan.FeedLength;
  60. //使用长度
  61. FeedDataSource.Rows[0]["UseLength"] = _feedPlan.UseLength;
  62. //未使用长度
  63. FeedDataSource.Rows[0]["NoUserLength"] = _feedPlan.NonUseLength;
  64. //切损去向
  65. FeedDataSource.Rows[0]["WasterTarget"] = _feedPlan.CutTarget;
  66. //倍尺数
  67. FeedDataSource.Rows[0]["DBNum"] = _feedPlan.DBNum;
  68. //单倍长度
  69. FeedDataSource.Rows[0]["DBLength"] = _feedPlan.DBLength;
  70. //计划单倍总支数
  71. if (!string.IsNullOrEmpty(_feedPlan.FeedNum) && !string.IsNullOrEmpty(_feedPlan.DBNum))
  72. {
  73. FeedDataSource.Rows[0]["PlanDBTotalCount"] = (Convert.ToInt32(_feedPlan.FeedNum) * Convert.ToInt32(_feedPlan.DBNum)).ToString();
  74. }
  75. else
  76. {
  77. FeedDataSource.Rows[0]["PlanDBTotalCount"] = "0";
  78. }
  79. //上料剔除支数
  80. if (!string.IsNullOrEmpty(_feedPlan.ScrapNumOld))
  81. {
  82. FeedDataSource.Rows[0]["ScrapFeedNum"] = _feedPlan.ScrapNumOld;
  83. }
  84. else
  85. {
  86. FeedDataSource.Rows[0]["ScrapFeedNum"] = "0";
  87. }
  88. //单倍坯剔除支数
  89. if (!string.IsNullOrEmpty(_feedPlan.ScrapNum))
  90. {
  91. FeedDataSource.Rows[0]["ScrapDBNum"] = _feedPlan.ScrapNum;
  92. }
  93. else
  94. {
  95. FeedDataSource.Rows[0]["ScrapDBNum"] = "0";
  96. }
  97. //单倍坯合格支数
  98. if (!string.IsNullOrEmpty(_feedPlan.FeedNum) && !string.IsNullOrEmpty(_feedPlan.DBNum))
  99. {
  100. int ScrapNum = 0;
  101. if (!string.IsNullOrEmpty(_feedPlan.ScrapNum))
  102. {
  103. ScrapNum = int.Parse(_feedPlan.ScrapNum);
  104. }
  105. FeedDataSource.Rows[0]["QualityDBNum"] = (Convert.ToInt32(FeedDataSource.Rows[0]["FeedNum"].ToString()) * Convert.ToInt32(FeedDataSource.Rows[0]["DBNum"].ToString()) - ScrapNum).ToString();
  106. }
  107. else
  108. {
  109. FeedDataSource.Rows[0]["QualityDBNum"] = "0";
  110. }
  111. //交接班总支数
  112. FeedDataSource.Rows[0]["CHANGENUM"] = _feedPlan.ChangeNumTotal;
  113. //交接班支数
  114. FeedDataSource.Rows[0]["ChangeGroupNum"] = _feedPlan.ChangeNum;
  115. //交接班支数
  116. FeedDataSource.Rows[0]["FeedChangeNum"] = _feedPlan.ChangeNum;
  117. //交班取消
  118. FeedDataSource.Rows[0]["CHANGENUMCANCEL"] ="交班取消";
  119. //单倍坯合格总重量
  120. if (!string.IsNullOrEmpty(FeedDataSource.Rows[0]["QualityDBNum"].ToString()) && !string.IsNullOrEmpty(_feedPlan.DBHeight))
  121. {
  122. FeedDataSource.Rows[0]["QualityDBHeight"] = (Convert.ToDouble(FeedDataSource.Rows[0]["QualityDBNum"].ToString()) * Convert.ToDouble(_feedPlan.DBHeight)).ToString();
  123. }
  124. else
  125. {
  126. FeedDataSource.Rows[0]["QualityDBHeight"] = "0";
  127. }
  128. //单倍坯合格总长度
  129. if (!string.IsNullOrEmpty(FeedDataSource.Rows[0]["ScrapFeedNum"].ToString()) && !string.IsNullOrEmpty(_feedPlan.DBLength))
  130. {
  131. FeedDataSource.Rows[0]["QualityDBLength"] = (Convert.ToInt32(FeedDataSource.Rows[0]["QualityDBNum"].ToString()) * Convert.ToDouble(_feedPlan.DBLength)).ToString();
  132. }
  133. else
  134. {
  135. FeedDataSource.Rows[0]["QualityDBLength"] = "0";
  136. }
  137. //切损总长度 = (上料支数 - 切前剔除支数) * 未使用长度
  138. if (!string.IsNullOrEmpty(FeedDataSource.Rows[0]["QualityDBNum"].ToString()) && !string.IsNullOrEmpty(_feedPlan.FeedNum) && !string.IsNullOrEmpty(_feedPlan.NonUseLength))
  139. {
  140. int ScrapFeedNum = 0;
  141. if (!string.IsNullOrEmpty(_feedPlan.ScrapNumOld))
  142. {
  143. ScrapFeedNum = int.Parse(_feedPlan.ScrapNumOld);
  144. }
  145. FeedDataSource.Rows[0]["WasterLength"] = ((Convert.ToInt32(_feedPlan.FeedNum) * Convert.ToDouble(_feedPlan.NonUseLength))).ToString();
  146. }
  147. else
  148. {
  149. FeedDataSource.Rows[0]["WasterLength"] = "0";
  150. }
  151. //切损总重量 = (上料支数 - 切前剔除支数)* 单支切损重
  152. if (!string.IsNullOrEmpty(FeedDataSource.Rows[0]["QualityDBNum"].ToString()) && !string.IsNullOrEmpty(_feedPlan.FeedNum))
  153. {
  154. int ScrapFeedNum = 0;
  155. if (!string.IsNullOrEmpty(_feedPlan.ScrapNumOld))
  156. {
  157. ScrapFeedNum = int.Parse(_feedPlan.ScrapNumOld);
  158. }
  159. FeedDataSource.Rows[0]["WasterHeight"] = Convert.ToInt32(_feedPlan.FeedNum) * CutDZWeight;
  160. }
  161. else
  162. {
  163. FeedDataSource.Rows[0]["WasterHeight"] = "0";
  164. }
  165. //开始时间
  166. FeedDataSource.Rows[0]["StartTime"] = _feedPlan.StartTime;
  167. //结束时间
  168. FeedDataSource.Rows[0]["EndTime"] = _feedPlan.EndTime;
  169. FeedDataSource.Rows[0]["Remark"] = _feedPlan.ReMark;
  170. }
  171. }
  172. public void UpdateDataForRack(double CutDZWeight)
  173. {
  174. if (_feedPlan != null)
  175. {
  176. //上料剔除支数
  177. if (!string.IsNullOrEmpty(_feedPlan.ScrapNumOld))
  178. {
  179. FeedDataSource.Rows[0]["ScrapFeedNum"] = _feedPlan.ScrapNumOld;
  180. }
  181. else
  182. {
  183. FeedDataSource.Rows[0]["ScrapFeedNum"] = "0";
  184. }
  185. //单倍坯剔除支数
  186. if (!string.IsNullOrEmpty(_feedPlan.ScrapNum))
  187. {
  188. FeedDataSource.Rows[0]["ScrapDBNum"] = _feedPlan.ScrapNum;
  189. }
  190. else
  191. {
  192. FeedDataSource.Rows[0]["ScrapDBNum"] = "0";
  193. }
  194. //单倍坯合格支数
  195. if (!string.IsNullOrEmpty(_feedPlan.FeedNum) && !string.IsNullOrEmpty(_feedPlan.DBNum))
  196. {
  197. int ScrapNum = 0;
  198. if (!string.IsNullOrEmpty(_feedPlan.ScrapNum))
  199. {
  200. ScrapNum = int.Parse(_feedPlan.ScrapNum);
  201. }
  202. FeedDataSource.Rows[0]["QualityDBNum"] = (Convert.ToInt32(FeedDataSource.Rows[0]["FeedNum"].ToString()) * Convert.ToInt32(FeedDataSource.Rows[0]["DBNum"].ToString()) - ScrapNum).ToString();
  203. }
  204. else
  205. {
  206. FeedDataSource.Rows[0]["QualityDBNum"] = "0";
  207. }
  208. //实际上料支数
  209. FeedDataSource.Rows[0]["FeedNum"] = _feedPlan.FeedNum;
  210. //交接班支数
  211. FeedDataSource.Rows[0]["ChangeGroupNum"] = _feedPlan.ChangeNum;
  212. //交接班支数
  213. FeedDataSource.Rows[0]["FeedChangeNum"] = _feedPlan.ChangeNum;
  214. //交接班总支数
  215. FeedDataSource.Rows[0]["CHANGENUM"] = _feedPlan.ChangeNumTotal;
  216. //单倍坯合格总重量
  217. if (!string.IsNullOrEmpty(FeedDataSource.Rows[0]["QualityDBNum"].ToString()) && !string.IsNullOrEmpty(_feedPlan.DBHeight))
  218. {
  219. FeedDataSource.Rows[0]["QualityDBHeight"] = (Convert.ToDouble(FeedDataSource.Rows[0]["QualityDBNum"].ToString()) * Convert.ToDouble(_feedPlan.DBHeight)).ToString();
  220. }
  221. else
  222. {
  223. FeedDataSource.Rows[0]["QualityDBHeight"] = "0";
  224. }
  225. //单倍坯合格总长度
  226. if (!string.IsNullOrEmpty(FeedDataSource.Rows[0]["ScrapFeedNum"].ToString()) && !string.IsNullOrEmpty(_feedPlan.DBLength))
  227. {
  228. FeedDataSource.Rows[0]["QualityDBLength"] = (Convert.ToInt32(FeedDataSource.Rows[0]["QualityDBNum"].ToString()) * Convert.ToDouble(_feedPlan.DBLength)).ToString();
  229. }
  230. else
  231. {
  232. FeedDataSource.Rows[0]["QualityDBLength"] = "0";
  233. }
  234. //切损总长度 = (上料支数 - 切前剔除支数) * 未使用长度
  235. if (!string.IsNullOrEmpty(FeedDataSource.Rows[0]["QualityDBNum"].ToString()) && !string.IsNullOrEmpty(_feedPlan.FeedNum) && !string.IsNullOrEmpty(_feedPlan.NonUseLength))
  236. {
  237. int ScrapFeedNum = 0;
  238. if (!string.IsNullOrEmpty(_feedPlan.ScrapNumOld))
  239. {
  240. ScrapFeedNum = int.Parse(_feedPlan.ScrapNumOld);
  241. }
  242. FeedDataSource.Rows[0]["WasterLength"] = (((Convert.ToDouble(_feedPlan.FeedNum) - ScrapFeedNum) * Convert.ToDouble(_feedPlan.NonUseLength)) / 1000).ToString();
  243. }
  244. else
  245. {
  246. FeedDataSource.Rows[0]["WasterLength"] = "0";
  247. }
  248. //切损总重量 = (上料支数 - 切前剔除支数) * 上料坯重量 - 合格单倍坯支数 * 单倍重
  249. //切损总重量 = (上料支数 - 切前剔除支数)* 单支切损重
  250. if (!string.IsNullOrEmpty(FeedDataSource.Rows[0]["QualityDBNum"].ToString()) && !string.IsNullOrEmpty(_feedPlan.FeedNum))
  251. {
  252. int ScrapFeedNum = 0;
  253. if (!string.IsNullOrEmpty(_feedPlan.ScrapNumOld))
  254. {
  255. ScrapFeedNum = int.Parse(_feedPlan.ScrapNumOld);
  256. }
  257. FeedDataSource.Rows[0]["WasterHeight"] = (Convert.ToInt32(_feedPlan.FeedNum) - ScrapFeedNum) * CutDZWeight;
  258. }
  259. else
  260. {
  261. FeedDataSource.Rows[0]["WasterHeight"] = "0";
  262. }
  263. }
  264. }
  265. public void DataClear()
  266. {
  267. //计划上料支数
  268. FeedDataSource.Rows[0]["FeedNumPlan"] = "";
  269. //上料支数
  270. FeedDataSource.Rows[0]["FeedNum"] = "";
  271. //上料长度
  272. FeedDataSource.Rows[0]["FeedLength"] = "";
  273. //使用长度
  274. FeedDataSource.Rows[0]["UseLength"] = "";
  275. //未使用长度
  276. FeedDataSource.Rows[0]["NoUserLength"] = "";
  277. //切损去向
  278. FeedDataSource.Rows[0]["WasterTarget"] = "";
  279. //倍尺数
  280. FeedDataSource.Rows[0]["DBNum"] = "";
  281. //单倍长度
  282. FeedDataSource.Rows[0]["DBLength"] = "";
  283. //计划单倍总支数
  284. FeedDataSource.Rows[0]["PlanDBTotalCount"] = "";
  285. FeedDataSource.Rows[0]["ScrapFeedNum"] = "";
  286. FeedDataSource.Rows[0]["ScrapDBNum"] = "";
  287. FeedDataSource.Rows[0]["QualityDBNum"] = "";
  288. FeedDataSource.Rows[0]["QualityDBHeight"] = "";
  289. FeedDataSource.Rows[0]["QualityDBLength"] = "";
  290. FeedDataSource.Rows[0]["WasterLength"] = "";
  291. FeedDataSource.Rows[0]["WasterHeight"] = "";
  292. //开始时间
  293. FeedDataSource.Rows[0]["StartTime"] = DBNull.Value;
  294. //结束时间
  295. FeedDataSource.Rows[0]["EndTime"] = DBNull.Value;
  296. FeedDataSource.Rows[0]["Remark"] = "";
  297. }
  298. private void FeedDataSource_CellDataRequested(object sender, Infragistics.Win.UltraWinDataSource.CellDataRequestedEventArgs e)
  299. {
  300. }
  301. private void ultraGrid4_Error(object sender, ErrorEventArgs e)
  302. {
  303. e.Cancel = true;
  304. if (ultraGrid4.ActiveCell.Column.Key == "StartTime" || ultraGrid4.ActiveCell.Column.Key == "EndTime")
  305. {
  306. MessageBox.Show("请输入完整的时间");
  307. }
  308. }
  309. }
  310. }