ucResAdditive.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  1. using System;
  2. using System.Collections;
  3. using System.Data;
  4. using System.Windows.Forms;
  5. using Core.Mes.Client.Comm.Server;
  6. using Core.StlMes.Client.LgClassModel;
  7. using CoreFS.CA06;
  8. namespace Core.StlMes.Client.LgCommon
  9. {
  10. public partial class ucResAdditive : UserControl
  11. {
  12. private OpeBase _ob;
  13. private LG_PROCESS _process;
  14. private string _stove;
  15. private string _station;
  16. private string _disposalTime;
  17. private string _userName;
  18. private string _shifCode;
  19. public ucResAdditive()
  20. {
  21. InitializeComponent();
  22. }
  23. #region 属性
  24. /// <summary>
  25. /// 有值发生变化
  26. /// </summary>
  27. public bool HasChanged
  28. {
  29. get { return toltalAdditiveChange || ucResAdditiveProcess1.Changed; }
  30. }
  31. public bool toltalAdditiveChange
  32. {
  33. get { return ucFL.HasChanged || ucHJ.HasChanged || ucWS.HasChanged || ucSTL.HasChanged; }
  34. }
  35. public bool CanSave
  36. {
  37. get { return ucResAdditiveProcess1.CanSave; }
  38. }
  39. /// <summary>
  40. /// 辅料TAB页可见
  41. /// </summary>
  42. public bool FL_VISIBLE
  43. {
  44. get { return ultraTabControl1.Tabs["FL"].Visible; }
  45. set
  46. {
  47. if (value != ultraTabControl1.Tabs["FL"].Visible)
  48. ultraTabControl1.Tabs["FL"].Visible = value;
  49. }
  50. }
  51. /// <summary>
  52. /// 合金TAB页可见
  53. /// </summary>
  54. public bool HJ_VISIBLE
  55. {
  56. get { return ultraTabControl1.Tabs["HJ"].Visible; }
  57. set
  58. {
  59. if (value != ultraTabControl1.Tabs["HJ"].Visible)
  60. ultraTabControl1.Tabs["HJ"].Visible = value;
  61. }
  62. }
  63. /// <summary>
  64. /// 喂丝TAB页可见
  65. /// </summary>
  66. public bool WS_VISIBLE
  67. {
  68. get { return ultraTabControl1.Tabs["WS"].Visible; }
  69. set
  70. {
  71. if (value != ultraTabControl1.Tabs["WS"].Visible)
  72. ultraTabControl1.Tabs["WS"].Visible = value;
  73. }
  74. }
  75. /// <summary>
  76. /// 手投料TAB页可见
  77. /// </summary>
  78. public bool STL_VISIBLE
  79. {
  80. get { return ultraTabControl1.Tabs["STL"].Visible; }
  81. set
  82. {
  83. if (value != ultraTabControl1.Tabs["STL"].Visible)
  84. ultraTabControl1.Tabs["STL"].Visible = value;
  85. }
  86. }
  87. #endregion
  88. #region 调用
  89. public void SetBase(OpeBase ob, string station,string UserName,string ShifCode, Action ac)
  90. {
  91. _ob = ob;
  92. ucFL.SetOpeBase(ob);
  93. ucHJ.SetOpeBase(ob);
  94. ucWS.SetOpeBase(ob);
  95. ucSTL.SetOpeBase(ob);
  96. ucResAdditiveProcess1.SetOb(ob);
  97. ucFL.SetHopper += () => ac();
  98. ucHJ.SetHopper += () => ac();
  99. ucWS.SetHopper += () => ac();
  100. ucSTL.SetHopper += () => ac();
  101. _userName = UserName;
  102. _shifCode = ShifCode;
  103. SetDevice_Position(station);
  104. }
  105. /// <summary>
  106. /// 设置工序
  107. /// </summary>
  108. /// <param name="DEVICE_POSITION"></param>
  109. private void SetDevice_Position(string DEVICE_POSITION)
  110. {
  111. try
  112. {
  113. ucFL.DEVICE_POSITION = DEVICE_POSITION;
  114. ucHJ.DEVICE_POSITION = DEVICE_POSITION;
  115. ucWS.DEVICE_POSITION = DEVICE_POSITION;
  116. ucSTL.DEVICE_POSITION = DEVICE_POSITION;
  117. }
  118. catch
  119. {
  120. }
  121. }
  122. // 设计物料名显示
  123. /// <summary>
  124. /// 设计物料名显示
  125. /// </summary>
  126. /// <param name="PROCESS"></param>
  127. /// <param name="DEVICE_POS"></param>
  128. /// <param name="tblMaterial"></param>
  129. /// <param name="ob"></param>
  130. public void SetHopperInfo(string StationCode, DataTable dtMaterial, OpeBase ob)
  131. {
  132. try
  133. {
  134. var strMsg = "";
  135. var bSuccess = false;
  136. try
  137. {
  138. SetDevice_Position(StationCode);
  139. var ds = ClsBusinessPack.GetHopperConfig(StationCode, out bSuccess, out strMsg, ob);
  140. if ((ds != null) && (ds.Tables.Count > 0))
  141. {
  142. ucFL.SetHopperInfo(ds.Tables[0], dtMaterial);
  143. ucHJ.SetHopperInfo(ds.Tables[0], dtMaterial);
  144. ucWS.SetHopperInfo(ds.Tables[0], dtMaterial);
  145. }
  146. }
  147. catch
  148. {
  149. }
  150. try
  151. {
  152. var ds = ClsBusinessPack.GetManualAdditiveConfig(StationCode, out bSuccess, out strMsg, ob);
  153. if ((ds != null) && (ds.Tables.Count > 0))
  154. ucSTL.SetHopperInfo(ds.Tables[0], dtMaterial);
  155. }
  156. catch
  157. {
  158. }
  159. ucResAdditiveProcess1.SetAdditiveProcess(StationCode, "01");
  160. }
  161. catch
  162. {
  163. }
  164. }
  165. public bool SaveAdditives()
  166. {
  167. if (toltalAdditiveChange)
  168. {
  169. var alMaterialCode = new ArrayList();
  170. var alMaterialName = new ArrayList();
  171. var alMaterialType = new ArrayList();
  172. var alAddtType = new ArrayList();
  173. var alAddtAmount = new ArrayList();
  174. var alAddtOrigin = new ArrayList();
  175. GetDataChanged(ref alMaterialCode, ref alMaterialName, ref alMaterialType, ref alAddtType,
  176. ref alAddtAmount, ref alAddtOrigin);
  177. var Args = new object[]
  178. {
  179. _stove, _station, "01", alMaterialCode, alMaterialName, alMaterialType, alAddtType,
  180. alAddtAmount,
  181. alAddtOrigin, _userName
  182. };
  183. var iRet = 0;
  184. var strMsg = "";
  185. try
  186. {
  187. ServerHelper.SetData("Core.LgMes.Server.LgDeviceManager.StlAdditive.SaveAdditives", Args, _ob);
  188. SetResAdditiveData();
  189. return true;
  190. }
  191. catch (Exception ex)
  192. {
  193. return false;
  194. }
  195. }
  196. if (ucResAdditiveProcess1.Changed)
  197. {
  198. var result = ucResAdditiveProcess1.SaveDate();
  199. if (result) SetResAdditiveData();
  200. return result;
  201. }
  202. return true;
  203. }
  204. public void SetResAdditiveData()
  205. {
  206. SetResAdditiveData(_process, _stove, _station, _disposalTime);
  207. }
  208. /// <summary>
  209. /// 获取并设置岗位加料汇总数据
  210. /// </summary>
  211. /// <param name="PROCESS"></param>
  212. /// <param name="strHeatNo"></param>
  213. /// <param name="strStationCode">岗位编号</param>
  214. /// <param name="strDisposalTime">处理次数</param>
  215. /// <param name="ob"></param>
  216. public void SetResAdditiveData(LG_PROCESS PROCESS, string strHeatNo, string strStationCode,
  217. string strDisposalTime)
  218. {
  219. _process = PROCESS;
  220. _stove = strHeatNo;
  221. _station = strStationCode;
  222. _disposalTime = strDisposalTime;
  223. try
  224. {
  225. var ds = ClsResAdditiveBLL.GetResAdditiveData(PROCESS, strHeatNo, strStationCode, strDisposalTime, _ob);
  226. var additiveBuffer = new CommonAdditive();
  227. ClsResAdditiveBLL.DataSetToAdditive(ref ds, ref additiveBuffer);
  228. ucFL.SetAdditiveData(additiveBuffer);
  229. ucHJ.SetAdditiveData(additiveBuffer);
  230. ucWS.SetAdditiveData(additiveBuffer);
  231. ucSTL.SetAdditiveData(additiveBuffer);
  232. ucResAdditiveProcess1.SetData(PROCESS, strHeatNo, strStationCode, strDisposalTime);
  233. }
  234. catch
  235. {
  236. }
  237. }
  238. /// <summary>
  239. /// 获取加料数据修改信息
  240. /// </summary>
  241. /// <param name="alMaterialCode">加料物料编码</param>
  242. /// <param name="alMaterialName">加料物料名</param>
  243. /// <param name="alMaterialType">加料物料类型(FL\HJ\WS)</param>
  244. /// <param name="alAddtType">加料类型(1:自动加料2:手投料)</param>
  245. /// <param name="alAddtAmount">加料量</param>
  246. /// <param name="alAddtOrigin">原始量</param>
  247. public void GetDataChanged(ref ArrayList alMaterialCode, ref ArrayList alMaterialName,
  248. ref ArrayList alMaterialType, ref ArrayList alAddtType, ref ArrayList alAddtAmount,
  249. ref ArrayList alAddtOrigin)
  250. {
  251. alMaterialCode = new ArrayList();
  252. alMaterialName = new ArrayList();
  253. alMaterialType = new ArrayList();
  254. alAddtType = new ArrayList();
  255. alAddtAmount = new ArrayList();
  256. alAddtOrigin = new ArrayList();
  257. try
  258. {
  259. if (!toltalAdditiveChange) return;
  260. GetDataChangedDetail(ucFL, ref alMaterialCode, ref alMaterialName, ref alMaterialType, ref alAddtType,
  261. ref alAddtAmount, ref alAddtOrigin);
  262. GetDataChangedDetail(ucHJ, ref alMaterialCode, ref alMaterialName, ref alMaterialType, ref alAddtType,
  263. ref alAddtAmount, ref alAddtOrigin);
  264. GetDataChangedDetail(ucWS, ref alMaterialCode, ref alMaterialName, ref alMaterialType, ref alAddtType,
  265. ref alAddtAmount, ref alAddtOrigin);
  266. GetDataChangedDetail(ucSTL, ref alMaterialCode, ref alMaterialName, ref alMaterialType, ref alAddtType,
  267. ref alAddtAmount, ref alAddtOrigin);
  268. }
  269. catch
  270. {
  271. }
  272. }
  273. /// <summary>
  274. /// 获取各选项卡加料数据修改信息
  275. /// </summary>
  276. /// <param name="ucHopper"></param>
  277. /// <param name="alMaterialCode"></param>
  278. /// <param name="alMaterialName"></param>
  279. /// <param name="alMaterialType"></param>
  280. /// <param name="alAddtType"></param>
  281. /// <param name="alAddtAmount"></param>
  282. /// <param name="alAddtOrigin"></param>
  283. private void GetDataChangedDetail(ucResAdditiveBase ucHopper, ref ArrayList alMaterialCode,
  284. ref ArrayList alMaterialName, ref ArrayList alMaterialType, ref ArrayList alAddtType,
  285. ref ArrayList alAddtAmount, ref ArrayList alAddtOrigin)
  286. {
  287. try
  288. {
  289. if (ucHopper == null) return;
  290. if ((alMaterialCode == null) || (alMaterialName == null) || (alMaterialType == null)) return;
  291. if ((alAddtType == null) || (alAddtAmount == null) || (alAddtOrigin == null)) return;
  292. var Keys = new ArrayList();
  293. if ((ucHopper.htValueChanged != null) && (ucHopper.htValueChanged.Count > 0))
  294. Keys = new ArrayList(ucHopper.htValueChanged.Keys);
  295. object ValuePre = null;
  296. object ValueCur = null;
  297. string strCode = "", strName = "", strType = "", strValueCur = "", strValuePre = "";
  298. var strSort = ((int) ucHopper.HpprCategory).ToString();
  299. for (var i = 0; i < Keys.Count; i++)
  300. {
  301. strCode = Convert.ToString(Keys[i]);
  302. strName = Convert.ToString(ucHopper.htCaptionChanged[strCode]);
  303. strType = Convert.ToString(ucHopper.htMaterialtypeChanged[strCode]);
  304. ValueCur = ucHopper.htValueChanged[strCode];
  305. ValuePre = ucHopper.htValueInitial[strCode];
  306. if (ValueCur == DBNull.Value) strValueCur = "";
  307. else strValueCur = Convert.ToString(ValueCur);
  308. if (ValuePre == DBNull.Value) strValuePre = "";
  309. else strValuePre = Convert.ToString(ValuePre);
  310. alMaterialCode.Add(strCode);
  311. alMaterialName.Add(strName);
  312. alMaterialType.Add(strType);
  313. alAddtType.Add(strSort);
  314. alAddtAmount.Add(strValueCur);
  315. alAddtOrigin.Add(strValuePre);
  316. }
  317. }
  318. catch
  319. {
  320. }
  321. }
  322. #endregion
  323. }
  324. }