NewResultsBase.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Windows.Forms;
  8. using Core.Mes.Client.Comm.Server;
  9. using Core.StlMes.Client.LgClassModel;
  10. using Core.StlMes.Client.LgCommon;
  11. using CoreFS.CA06;
  12. using CoreFS.SA06;
  13. namespace Core.StlMes.Client.LgResMgt
  14. {
  15. public partial class NewResultsBase : FrmBase
  16. {
  17. private DataTable _materialData = null;
  18. protected List<string> Plines;
  19. protected string CurrentPline;
  20. public string uceStatusText
  21. {
  22. get { return ucStoveQuery1.uceStatusText; }
  23. set { ucStoveQuery1.uceStatusText = value; }
  24. }
  25. protected DataTable DtMaterial {
  26. get
  27. {
  28. if (_materialData == null || _materialData.Rows.Count <= 0)
  29. {
  30. GetMaterialData();
  31. }
  32. return _materialData;
  33. }
  34. set { _materialData = value; }
  35. }
  36. protected PlnSteelforfurnaceEntity CurrentEntity = null;
  37. protected string Station
  38. {
  39. get { return Process + (CurrentPline=="C001"?"01": (CurrentPline=="C003"?"02":(CurrentPline=="C006"?"03":"00"))); }
  40. }
  41. private int Width1 = 300;
  42. public int Width2 = 340;
  43. public int Width3 = 168;
  44. public NewResultsBase()
  45. {
  46. InitializeComponent();
  47. }
  48. public bool OrderByPline
  49. {
  50. get { return ucStoveQuery1.OrderByPline; }
  51. set
  52. {
  53. ucStoveQuery1.OrderByPline = value;
  54. }
  55. }
  56. protected override void OnLoad(EventArgs e)
  57. {
  58. base.OnLoad(e);
  59. try
  60. {
  61. if (ob==null) return;
  62. Plines = ClsBusinessPack.InitDropPlinePower(OrderByPline?"A":"B", null, this.ValidDataPurviewIds, this.ob);
  63. if (Plines == null || Plines.Count <= 0)
  64. {
  65. MessageBox.Show(@"无产线数据权限");
  66. this.Close();
  67. }
  68. else
  69. {
  70. CurrentPline = Plines[0];
  71. }
  72. ucStoveQuery1.GetStoveResultDelegate += GetHeatResult;
  73. ucStoveQuery1.Init(ob, Plines, Process);
  74. ucStoveQuery1.GiveUp = GiveupResult;
  75. ClsControlPack.SetUltraGridAppearance(this);
  76. }
  77. catch
  78. {
  79. }
  80. }
  81. /// <summary>
  82. /// 工序
  83. /// </summary>
  84. protected LG_PROCESS Process { get; set; }
  85. protected string DeviceName { get; set; } //岗位中文名:如转炉
  86. // 获取物料基础数据
  87. /// <summary>
  88. /// 获取物料基础数据
  89. /// </summary>
  90. protected void GetMaterialData()
  91. {
  92. bool bSuccess;
  93. string strMsg;
  94. var ds = ClsDataAccessPack.GetMaterialData(out bSuccess, out strMsg, ob);
  95. if (bSuccess) _materialData = ds.Tables[0];
  96. }
  97. protected void RefreStoveQuery()
  98. {
  99. ucStoveQuery1.QueryStovePlan();
  100. }
  101. protected virtual void Queryother()
  102. {
  103. }
  104. // 获取指定炉次岗位实绩信息
  105. /// <summary>
  106. /// 获取指定炉次岗位实绩信息
  107. /// </summary>
  108. /// <param name="strHeatProcessNo"></param>
  109. /// <param name="strHeatNo"></param>
  110. /// <param name="strStationCode"></param>
  111. /// <param name="strDisposalTime"></param>
  112. /// <param name="strCastNo"></param>
  113. protected void GetHeatResult(PlnSteelforfurnaceEntity PlnSteelforfurnaceEntity,bool refresh)
  114. {
  115. CurrentEntity = PlnSteelforfurnaceEntity;
  116. if (refresh)
  117. {
  118. QueryPlan();
  119. ucNewChemelEment.RefreshData(CurrentEntity.StoveNo, CurrentEntity.EfPlineCode, Process, CurrentEntity.CraftNo, ob);
  120. }
  121. else
  122. {
  123. Query();
  124. }
  125. }
  126. // 忽略实绩修改
  127. /// <summary>
  128. /// 忽略实绩修改
  129. /// </summary>
  130. /// <returns></returns>
  131. protected bool GiveupResult()
  132. {
  133. if (ValueChanged && CurrentEntity!=null)
  134. if (
  135. MessageBox.Show(@"炉次:" + CurrentEntity.StoveNo + @"\n" + DeviceName + @"实绩已修改,还未保存!\n放弃修改点击【是】,返回请按【否】", @"提示",
  136. MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  137. return false;
  138. return true;
  139. }
  140. #region 属性
  141. /// <summary>
  142. /// 实绩数据发生修改
  143. /// </summary>
  144. protected virtual bool ValueChanged
  145. {
  146. get { return false; }
  147. }
  148. protected virtual bool DataOver
  149. {
  150. get { return false; }
  151. }
  152. protected virtual bool CanSave
  153. {
  154. get { return true; }
  155. }
  156. /// <summary>
  157. /// 用户名
  158. /// </summary>
  159. protected string UserName
  160. {
  161. get { return CoreUserInfo.UserInfo.GetUserName(); }
  162. }
  163. /// <summary>
  164. /// 用户名
  165. /// </summary>
  166. protected string ShifCode
  167. {
  168. get { return UserInfo.GetUserGroup() + UserInfo.GetUserOrder(); }
  169. }
  170. #endregion
  171. #region 工具栏事件
  172. // 刷新实绩
  173. /// <summary>
  174. /// 刷新实绩
  175. /// </summary>
  176. /// <param name="ignoreChanges"></param>
  177. protected void RefreshData(bool ignoreChanges)
  178. {
  179. try
  180. {
  181. if (!ignoreChanges)
  182. {
  183. if (!GiveupResult()) return;
  184. }
  185. Query();
  186. }
  187. catch
  188. {
  189. }
  190. }
  191. // 保存实绩修改
  192. /// <summary>
  193. /// 保存实绩修改
  194. /// </summary>
  195. protected void SaveData()
  196. {
  197. // if (string.IsNullOrEmpty(HeatProcessNo)) return;
  198. if (CurrentEntity == null) return;
  199. if (!ValueChanged)
  200. {
  201. MessageBox.Show("炉次:" + CurrentEntity.StoveNo + "\n" + DeviceName + "实绩未发生变化,无需保存!", "提示");
  202. return;
  203. }
  204. if (!CanSave)
  205. {
  206. MessageBox.Show("数据有错误,请修正后再保存!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  207. return;
  208. }
  209. if (
  210. MessageBox.Show("确定要修改炉次[" + CurrentEntity.StoveNo + "]信息吗?", "提示", MessageBoxButtons.YesNo,
  211. MessageBoxIcon.Question) == DialogResult.No)
  212. return;
  213. string Msg = "";
  214. Msg = SaveAllData(Msg);
  215. RefreStoveQuery();
  216. if (Msg == "")
  217. {
  218. if (DataOver)
  219. {
  220. if (MessageBox.Show("炉次:" + CurrentEntity.StoveNo + "信息保存成功,是否跳入下个未维护信息的炉号!", "提示", MessageBoxButtons.YesNo,
  221. MessageBoxIcon.Question) == DialogResult.Yes)
  222. {
  223. ucStoveQuery1.GoNext();
  224. }
  225. }
  226. else
  227. //RefreshData(true);
  228. MessageBox.Show("炉次:" + CurrentEntity.StoveNo + "信息保存成功!", "提示", MessageBoxButtons.OK,
  229. MessageBoxIcon.Asterisk);
  230. }
  231. else
  232. {
  233. MessageBox.Show("炉次:" + CurrentEntity.StoveNo + Msg + "!", "提示", MessageBoxButtons.OK,
  234. MessageBoxIcon.Asterisk);
  235. }
  236. }
  237. protected virtual string SaveAllData(string Msg)
  238. {
  239. if (!SavePerformance()) Msg = Msg + "操作界面数据保存失败";
  240. return Msg;
  241. }
  242. protected virtual bool SavePerformance()
  243. {
  244. return false;
  245. }
  246. protected virtual void Query()
  247. {
  248. QueryPlan();
  249. QueryChemeEment();
  250. if (CurrentEntity.EfPlineCode != CurrentPline)
  251. {
  252. RestPline();
  253. }
  254. QueryOperation();
  255. QueryTemperature();
  256. Queryother();
  257. }
  258. protected virtual void QueryTemperature()
  259. {
  260. }
  261. /// <summary>
  262. /// 查询炒作界面
  263. /// </summary>
  264. protected virtual void QueryOperation()
  265. {
  266. }
  267. protected virtual void QueryPlan()
  268. {
  269. }
  270. protected virtual void RestPline()
  271. {
  272. CurrentPline = CurrentEntity.EfPlineCode;
  273. }
  274. private void QueryChemeEment()
  275. {
  276. ucNewChemelEment.SetData(CurrentEntity.StoveNo, CurrentEntity.EfPlineCode, Process, CurrentEntity.CraftNo, ob);
  277. }
  278. protected override void OnClosing(CancelEventArgs e)
  279. {
  280. base.OnClosing(e);
  281. try
  282. {
  283. if (!GiveupResult())
  284. e.Cancel = true;
  285. }
  286. catch
  287. {
  288. // ignored
  289. }
  290. }
  291. /// <summary>
  292. /// 功能按钮
  293. /// </summary>
  294. public override void ToolBar_Click(object sender, string ToolbarKey)
  295. {
  296. switch (ToolbarKey)
  297. {
  298. case "Refresh":
  299. RefreshData(!ValueChanged);
  300. break;
  301. case "Save":
  302. SaveData();
  303. break;
  304. case "Exit":
  305. Close();
  306. break;
  307. }
  308. }
  309. #endregion
  310. private void NewResultsBase_Shown(object sender, EventArgs e)
  311. {
  312. splitContainer1.SplitterDistance = Width1;
  313. spMain.SplitterDistance = spMain.Size.Height - Width3;
  314. if(splitContainer2.Panel2Collapsed) return;
  315. MainContainer.ExpandedStateChanging+=MainContainer_ExpandedStateChanged;
  316. MicContainer.ExpandedStateChanging += MicContainer_ExpandedStateChanged;
  317. egpChem.ExpandedStateChanging += egpChem_ExpandedStateChanged;
  318. if (Size.Width > 1300)
  319. {
  320. MicContainer.Expanded = true;
  321. splitContainer1.SplitterDistance = Size.Width - 700 - Width2 > Width1
  322. ? Width1
  323. : Size.Width - 700 - Width2;
  324. }
  325. else
  326. {
  327. MicContainer.Expanded = false;
  328. splitContainer2.SplitterDistance = splitContainer2.Size.Width - 25;
  329. }
  330. }
  331. private void MainContainer_ExpandedStateChanged(object sender, EventArgs e)
  332. {
  333. if (!MainContainer.Expanded)
  334. {
  335. splitContainer1.SplitterDistance = Width1;
  336. if (MicContainer.Expanded && !splitContainer2.Panel2Collapsed)
  337. {
  338. splitContainer2.SplitterDistance = splitContainer2.Size.Width - Width2;
  339. }
  340. }
  341. else
  342. {
  343. Width1 = splitContainer1.SplitterDistance;
  344. splitContainer1.SplitterDistance = 25;
  345. if (MicContainer.Expanded && !splitContainer2.Panel2Collapsed)
  346. {
  347. splitContainer2.SplitterDistance = splitContainer2.Size.Width - Width2;
  348. }
  349. }
  350. }
  351. private void MicContainer_ExpandedStateChanged(object sender, EventArgs e)
  352. {
  353. if (splitContainer2.Panel2Collapsed) return;
  354. if (!MicContainer.Expanded)
  355. {
  356. splitContainer2.SplitterDistance = splitContainer2.Size.Width - Width2;
  357. /* if (MainContainer.Expanded)
  358. {
  359. splitContainer1.SplitterDistance = Width1;
  360. }*/
  361. }
  362. else
  363. {
  364. Width2 = splitContainer2.Panel2.Size.Width;
  365. splitContainer2.SplitterDistance = splitContainer2.Size.Width - 25;
  366. }
  367. }
  368. private void egpChem_ExpandedStateChanged(object sender, EventArgs e)
  369. {
  370. if (spMain.Panel2Collapsed) return;
  371. if (!egpChem.Expanded)
  372. {
  373. spMain.SplitterDistance = spMain.Size.Height - Width3;
  374. }
  375. else
  376. {
  377. Width3 = spMain.Panel2.Size.Height;
  378. spMain.SplitterDistance = spMain.Size.Height - 25;
  379. }
  380. }
  381. }
  382. }