ucCf.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using Core.Mes.Client.Comm.Tool;
  5. using Core.StlMes.Client.LgClassModel;
  6. using Core.StlMes.Client.LgCommon;
  7. using Core.StlMes.Client.PnCost.Models;
  8. using Infragistics.Win.UltraWinGrid;
  9. using Infragistics.Win;
  10. using System.Data;
  11. using Core.Mes.Client.Comm.Server;
  12. using CoreFS.CA06;
  13. using System.Windows.Forms;
  14. namespace Core.StlMes.Client.PnCost
  15. {
  16. public partial class ucCf : ucNewResBase
  17. {
  18. public ucCf()
  19. {
  20. InitializeComponent();
  21. ClsControlPack.SetUltraGridStyle(ugData, 1);
  22. }
  23. protected OpeBase Ob;
  24. public void SetBase(OpeBase ob)
  25. {
  26. Ob = ob;
  27. steelTypeCode();
  28. setSgSign();
  29. }
  30. public StlEafOptinfoEntity CurrentData = new StlEafOptinfoEntity();
  31. protected override void OnLoad(EventArgs e)
  32. {
  33. base.OnLoad(e);
  34. EntityHelper.ShowGridCaption<TqnqD01Entity>(ugData.DisplayLayout.Bands[0]);
  35. ugData.DisplayLayout.Bands[0].Override.HeaderClickAction = HeaderClickAction.Select;
  36. SetData(new List<object> { new TqnqD01Entity() });
  37. SetControlDelegate();
  38. // ugData.DisplayLayout.Bands[0].Columns["SgSign"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDown;
  39. // ValueList v1 = steelTypeCode();
  40. }
  41. protected virtual void SetControlDelegate()
  42. {
  43. ugData.AfterCellUpdate += new CellEventHandler(ugData_AfterCellUpdate);
  44. ugData.KeyDown += new KeyEventHandler(ugData_KeyDown);
  45. ugData.KeyPress += ugData_KeyPress;
  46. ugData.ClickCellButton += new CellEventHandler(ugData_ClickCellButton);
  47. }
  48. protected virtual void ugData_ClickCellButton(object sender, CellEventArgs e)
  49. {
  50. try
  51. {
  52. if (e.Cell.Column.DataType == typeof(Decimal) || e.Cell.Column.DataType == typeof(Decimal?))
  53. {
  54. frmInputDecimal frm = new frmInputDecimal(Convert.ToString(e.Cell.Text));
  55. frm.Location = ClsControlPack.GetChildWindowLocation(frm.Size);
  56. if (frm.ShowDialog() == DialogResult.OK)
  57. {
  58. if (!frm.ValueChanged) return;
  59. e.Cell.Value = frm.Value;
  60. ugData.UpdateData();
  61. }
  62. }
  63. }
  64. catch { }
  65. }
  66. private void ugData_KeyPress(object sender, KeyPressEventArgs e)
  67. {
  68. try
  69. {
  70. UltraGridCell cell = ugData.ActiveCell;
  71. string strKey = this.ugData.ActiveCell.Column.ToString();
  72. if (strKey.Equals("SgSign") || strKey.Equals("CIC") || strKey.Equals("CICGID") || strKey.Equals("InSteelTypeCode") || strKey.Equals("SmeltCode")) return;
  73. //if (e.KeyCode != Keys.Enter || cell.Column.CellActivation != Activation.AllowEdit) return;
  74. }
  75. catch { }
  76. }
  77. protected virtual void ugData_KeyDown(object sender, KeyEventArgs e)
  78. {
  79. try
  80. {
  81. UltraGridCell cell = ugData.ActiveCell;
  82. string strKey = this.ugData.ActiveCell.Column.ToString();
  83. if (strKey.Equals("SgSign") || strKey.Equals("CIC") || strKey.Equals("CICGID") || strKey.Equals("InSteelTypeCode") || strKey.Equals("SmeltCode")) return;
  84. if (e.KeyCode != Keys.Enter || cell.Column.CellActivation != Activation.AllowEdit) return;
  85. }
  86. catch { }
  87. }
  88. protected virtual void ugData_AfterCellUpdate(object sender, CellEventArgs e)
  89. {
  90. try
  91. {
  92. string strKey = this.ugData.ActiveCell.Column.ToString();
  93. if (!e.Cell.Column.Hidden && e.Cell.Column.CellActivation == Activation.AllowEdit)
  94. {
  95. UltraGridRow row = e.Cell.Row;
  96. if (strKey.Equals("SgSign", StringComparison.OrdinalIgnoreCase))
  97. {
  98. string siSign = row.Cells["SgSign"].Text.ToString();
  99. setCic(siSign);
  100. }
  101. else if (strKey.Equals("CIC", StringComparison.OrdinalIgnoreCase))
  102. {
  103. string siSign = row.Cells["SgSign"].Text.ToString();
  104. string cic = row.Cells["CiC"].Text.ToString();
  105. setCraftNo(siSign,cic);
  106. }
  107. else if (strKey.Equals("CICGID", StringComparison.OrdinalIgnoreCase))
  108. {
  109. string SmeltCode = row.Cells["SmeltCode"].Text.ToString();
  110. string SgSign = row.Cells["SgSign"].Text.ToString();
  111. string SgStd = row.Cells["SgStd"].Text.ToString();
  112. string InSteelTypeCode = row.Cells["InSteelTypeCode"].Text.ToString();
  113. string Cic = row.Cells["Cic"].Text.ToString();
  114. string cicGid = row.Cells["cicGid"].Text.ToString();
  115. // string cic = row.Cells["CiC"].Text.ToString();
  116. setCf(SmeltCode,SgSign,SgStd,InSteelTypeCode,Cic,cicGid);
  117. }
  118. }
  119. }
  120. catch { }
  121. }
  122. public TqnqD01Entity TqnqD01Entity() {
  123. UltraGridRow row = ugData.Rows[0];
  124. return (TqnqD01Entity)row.ListObject;
  125. }
  126. private void setCf(string SmeltCode,string SgSign,string SgStd,string InSteelTypeCode,string Cic,string cicGid)
  127. {
  128. if (cicGid.Equals("") || cicGid == null) return;
  129. if (SmeltCode.Equals("") || SmeltCode == null) return;
  130. if (SgSign.Equals("") || SgSign == null) return;
  131. if (SgStd.Equals("") || SgStd == null) return;
  132. if (InSteelTypeCode.Equals("") || InSteelTypeCode == null) return;
  133. if (Cic.Equals("") || Cic == null) return;
  134. if (cicGid.Equals("") || cicGid == null) return;
  135. List<TqnqD01Entity> data = EntityHelper.GetData<TqnqD01Entity>(
  136. "com.steering.mes.cost.FrmTqnqd01.QueryCf", new object[] { cicGid }, Ob);
  137. if (data != null && data.Count > 0)
  138. {
  139. ugData.DataSource = data;
  140. for (int i = 0; i < ugData.Rows.Count; i++)
  141. {
  142. ugData.Rows[i].Cells["SmeltCode"].Value = SmeltCode;
  143. ugData.Rows[i].Cells["SgSign"].Value = SgSign;
  144. ugData.Rows[i].Cells["SgStd"].Value = SgStd;
  145. ugData.Rows[i].Cells["InSteelTypeCode"].Value = InSteelTypeCode;
  146. ugData.Rows[i].Cells["Cic"].Value = Cic;
  147. ugData.Rows[i].Cells["cicGid"].Value = cicGid;
  148. }
  149. }
  150. // this.ugData.Rows[0].Activate();
  151. }
  152. /// <summary>
  153. /// 钢种分类
  154. /// </summary>
  155. private void steelTypeCode()
  156. {
  157. ValueList v1 = new ValueList();
  158. v1.ValueListItems.Add("不锈钢");
  159. v1.ValueListItems.Add("合金钢");
  160. v1.ValueListItems.Add("非合金钢");
  161. v1.ValueListItems.Add("高铬合金钢");
  162. v1.ValueListItems.Add("低合金钢");
  163. ugData.DisplayLayout.Bands[0].Columns["InSteelTypeCode"].ValueList = v1;
  164. ValueList v2 = new ValueList();
  165. v2.ValueListItems.Add("一电炉一连铸");
  166. v2.ValueListItems.Add("二电炉二连铸");
  167. v2.ValueListItems.Add("二电炉三连铸");
  168. ugData.DisplayLayout.Bands[0].Columns["SmeltCode"].ValueList = v2;
  169. }
  170. /// <summary>
  171. /// 牌号
  172. /// </summary>
  173. private void setSgSign()
  174. {
  175. DataTable dt = ServerHelper.GetData("com.steering.mes.cost.FrmTqnqd01.QuerySgSign", null, Ob);
  176. if (dt.Rows.Count > 0)
  177. {
  178. ValueList v1 = new ValueList();
  179. if (dt.Rows.Count > 0)
  180. {
  181. foreach (DataRow dr in dt.Rows)
  182. {
  183. v1.ValueListItems.Add(dr["BASECODE"].ToString(), dr["BASENAME"].ToString());
  184. }
  185. }
  186. ugData.DisplayLayout.Bands[0].Columns["SGSIGN"].ValueList = v1;
  187. }
  188. }
  189. /// <summary>
  190. /// 索引号
  191. /// </summary>
  192. private void setCic(string gradName)
  193. {
  194. ValueList v1 = new ValueList();
  195. DataTable dt = ServerHelper.GetData("com.steering.mes.cost.FrmTqnqd01.Querycic", new object[] { gradName }, Ob);
  196. if (dt.Rows.Count > 0)
  197. {
  198. foreach (DataRow dr in dt.Rows)
  199. {
  200. v1.ValueListItems.Add(dr["CIC"].ToString());
  201. }
  202. }
  203. ugData.DisplayLayout.Bands[0].Columns["CIC"].ValueList = v1;
  204. }
  205. /// <summary>
  206. /// 工艺卡号
  207. /// </summary>
  208. private void setCraftNo(string gradName,string cic)
  209. {
  210. ValueList v1 = new ValueList();
  211. DataTable dt = ServerHelper.GetData("com.steering.mes.cost.FrmTqnqd01.QueryCraftNo", new object[] { gradName, cic },Ob);
  212. if (dt.Rows.Count > 0)
  213. {
  214. foreach (DataRow dr in dt.Rows)
  215. {
  216. v1.ValueListItems.Add(dr["cicGid"].ToString());
  217. }
  218. }
  219. ugData.DisplayLayout.Bands[0].Columns["CICGID"].ValueList = v1;
  220. }
  221. public StlEafOptinfoEntity GetStlEafOptinfoEntity(string strStoveNo)
  222. {
  223. try
  224. {
  225. //var list =
  226. // EntityHelper.GetData<StlEafOptinfoEntity>(
  227. // "Core.LgMes.Server.LgDeviceManager.PerformanceManage.SelectStlEafOptinfoEntity",
  228. // new object[] {strStoveNo}, Ob);
  229. //if ((list == null) || (list.Count <= 0))
  230. // return new StlEafOptinfoEntity
  231. // {
  232. // StoveNo = strStoveNo,
  233. // Optdate = DateTime.Now
  234. // };
  235. //return list.FirstOrDefault();
  236. return null;
  237. }
  238. catch (Exception ex)
  239. {
  240. return new StlEafOptinfoEntity { StoveNo = strStoveNo, Optdate = DateTime.Now };
  241. }
  242. }
  243. }
  244. }