FrmTpopi25.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. using Core.Mes.Client.Comm.Format;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using Core.StlMes.Client.Lims.Data.PipeAndOutdec.封装类.实体类;
  5. using CoreFS.CA06;
  6. using Infragistics.Win.UltraWinEditors;
  7. using Infragistics.Win.UltraWinGrid;
  8. using System;
  9. using System.Collections;
  10. using System.Collections.Generic;
  11. using System.ComponentModel;
  12. using System.Data;
  13. using System.Drawing;
  14. using System.Linq;
  15. using System.Text;
  16. using System.Windows.Forms;
  17. namespace Core.StlMes.Client.Lims.Data.PipeAndOutdec
  18. {
  19. public partial class FrmTpopi25 : FrmBase
  20. {
  21. public FrmTpopi25()
  22. {
  23. InitializeComponent();
  24. EntityHelper.ShowGridCaption<Tpopi26Entity>(ultraGrid1.DisplayLayout.Bands[0]);
  25. EntityHelper.ShowGridCaption<Tpopi25Entity>(ultraGrid2.DisplayLayout.Bands[0]);
  26. EntityHelper.ShowGridCaption<Tpopi26Entity>(ultraGrid3.DisplayLayout.Bands[0]);
  27. }
  28. /// <summary>
  29. /// 重写基类方法
  30. /// </summary>
  31. /// <param name="sender"></param>
  32. /// <param name="ToolbarKey"></param>
  33. public override void ToolBar_Click(object sender, string ToolbarKey)
  34. {
  35. switch (ToolbarKey)
  36. {
  37. case "Query":
  38. doQuery();
  39. break;
  40. case "Add":
  41. doSave("ADD");
  42. break;
  43. case "Update":
  44. doSave("Update");
  45. break;
  46. case "Delete":
  47. doDelete();
  48. break;
  49. //case "Recover":
  50. // doNullifyOrRecover("0");
  51. // break;
  52. //case "StdCopy":
  53. // StdCopy();
  54. // break;
  55. case "Close":
  56. if (MessageUtil.ShowYesNoAndQuestion("是否确认关闭页面?") == DialogResult.Yes)
  57. {
  58. this.Close();
  59. }
  60. break;
  61. }
  62. }
  63. private void doQuery()
  64. {
  65. try
  66. {
  67. List<Tpopi26Entity> listSource = EntityHelper.GetData<Tpopi26Entity>(
  68. "com.steering.lims.data.pipe.Tpopi26.doQuery", new object[] { text_code.Text, "", "", text_name.Text }, this.ob);
  69. Tpopi26bindingSource.DataSource = listSource;
  70. //Tpopi26bindingSourceDetails.DataSource = listSource;
  71. //for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  72. //{
  73. // UltraGridRow row = ultraGrid1.Rows[i];
  74. //}
  75. }
  76. catch (Exception ex)
  77. {
  78. MessageBox.Show(ex.Message, "提示");
  79. }
  80. }
  81. private void doQueryDetail()
  82. {
  83. var ugr = ultraGrid2.ActiveRow;
  84. if (ugr != null) ugr.RowSelectorAppearance.Reset();
  85. string InspectStandCode = ugr.Cells["InspectStandCode"].Value.ToString();
  86. List<Tpopi25Entity> listSource25 = EntityHelper.GetData<Tpopi25Entity>(
  87. "com.steering.lims.data.pipe.Tpopi25.doQuery", new object[] { InspectStandCode }, this.ob);
  88. Tpopi25bindingSource.DataSource = listSource25;
  89. }
  90. private void doSave(string ToolbarKey)
  91. {
  92. try
  93. {
  94. if (ultraGrid2.Rows.Count == 0)
  95. return;
  96. if (ultraGrid2.ActiveRow == null)
  97. {
  98. MessageBox.Show("请选择要修改的使用记录!", "提示");
  99. return;
  100. }
  101. if (text_itemName.Text == null || text_itemName.Text.Equals(""))
  102. {
  103. MessageUtil.ShowTips("物料名称不能为空!");
  104. return;
  105. }
  106. if (text_itemCode.Text == null || text_itemCode.Text.Equals(""))
  107. {
  108. MessageUtil.ShowTips("物料代码不能为空!");
  109. return;
  110. }
  111. if (text_itemUom.Text == null || text_itemUom.Text.Equals(""))
  112. {
  113. MessageUtil.ShowTips("采购物料单位不能为空!");
  114. return;
  115. }
  116. if (text_leafCode.Text == null || text_leafCode.Text.Equals(""))
  117. {
  118. MessageUtil.ShowTips("采购叶类代码不能为空!");
  119. return;
  120. }
  121. if (text_inspectStandCode.Text == null || text_inspectStandCode.Text.Equals(""))
  122. {
  123. MessageUtil.ShowTips("质检标准号不能为空!");
  124. return;
  125. }
  126. Tpopi25Entity entity = new Tpopi25Entity();
  127. entity.ItemName = text_itemName.Text;
  128. entity.ItemId = text_itemCode.Text;
  129. entity.ItemUom = text_itemUom.Text;
  130. entity.LeafCode = text_leafCode.Text;
  131. entity.InspectStandCode = text_inspectStandCode.Text;
  132. entity.ItemDesc = text_itemDesc.Text;
  133. entity.UnitWeight = text_unitWeight.Text;
  134. entity.Class1 = text_calss1.Text;
  135. entity.Class2 = text_calss2.Text;
  136. entity.Class3 = text_calss3.Text;
  137. entity.RecCreator = UserInfo.GetUserName();
  138. entity.RecRevisor = UserInfo.GetUserName();
  139. entity.CompanyCode = Convert.ToString(ultraGrid2.ActiveRow.Cells["CompanyCode"].Value);
  140. entity.SeqNo = Convert.ToString(ultraGrid2.ActiveRow.Cells["SeqNo"].Value);
  141. string baseEntity = JSONFormat.Format(entity);
  142. if (ToolbarKey.Equals("ADD"))
  143. {
  144. CoreClientParam ccp = new CoreClientParam();
  145. ccp.ServerName = "com.steering.lims.data.pipe.Tpopi25";
  146. ccp.MethodName = "doAdd";
  147. ccp.ServerParams = new object[] { new ArrayList { baseEntity } };
  148. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  149. if (ccp.ReturnCode != -1)
  150. {
  151. doQueryDetail();
  152. MessageUtil.ShowTips("新增成功!");
  153. }
  154. }
  155. if (ToolbarKey.Equals("Update"))
  156. {
  157. CoreClientParam ccp = new CoreClientParam();
  158. ccp.ServerName = "com.steering.lims.data.pipe.Tpopi25";
  159. ccp.MethodName = "doUpdate";
  160. ccp.ServerParams = new object[] { new ArrayList { baseEntity } };
  161. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  162. if (ccp.ReturnCode != -1)
  163. {
  164. doQueryDetail();
  165. MessageUtil.ShowTips("保存成功!");
  166. }
  167. }
  168. }
  169. catch (Exception ex)
  170. {
  171. MessageBox.Show(ex.Message, "提示");
  172. }
  173. }
  174. private void doUpdate()
  175. {
  176. try
  177. {
  178. this.ultraGrid1.UpdateData();
  179. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  180. if (checkMagRows.Count() == 0)
  181. {
  182. MessageUtil.ShowTips("请选择需要修改的信息!");
  183. return;
  184. }
  185. ArrayList parmList = new ArrayList();
  186. foreach (UltraGridRow row in checkMagRows)
  187. {
  188. Tpopi26Entity entity = row.ListObject as Tpopi26Entity;
  189. if (String.IsNullOrEmpty(entity.InspectStandCode) || String.IsNullOrEmpty(entity.JdeLevel) || String.IsNullOrEmpty(entity.ElmCode))
  190. continue;
  191. //entity.RecRevisor = UserInfo.GetUserName();
  192. string baseEntity = JSONFormat.Format(entity);
  193. parmList.Add(baseEntity);
  194. }
  195. if (parmList.Count > 0)
  196. {
  197. CoreClientParam ccp = new CoreClientParam();
  198. ccp.ServerName = "com.steering.lims.data.pipe.Tpopi26";
  199. ccp.MethodName = "doUpdate";
  200. ccp.ServerParams = new object[] { parmList };
  201. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  202. if (ccp.ReturnCode != -1)
  203. {
  204. doQuery();
  205. MessageUtil.ShowTips("修改成功!");
  206. }
  207. }
  208. }
  209. catch (Exception ex)
  210. {
  211. MessageBox.Show(ex.Message, "提示");
  212. }
  213. }
  214. private void doDelete()
  215. {
  216. try
  217. {
  218. if (ultraGrid2.Rows.Count == 0)
  219. return;
  220. if (ultraGrid2.ActiveRow == null)
  221. {
  222. MessageBox.Show("请选择要删除的使用记录!", "提示");
  223. return;
  224. }
  225. ArrayList parmList = new ArrayList();
  226. Tpopi25Entity entity = new Tpopi25Entity();
  227. entity.CompanyCode = Convert.ToString(ultraGrid2.ActiveRow.Cells["CompanyCode"].Value);
  228. entity.SeqNo = Convert.ToString(ultraGrid2.ActiveRow.Cells["SeqNo"].Value);
  229. entity.ItemId = Convert.ToString(ultraGrid2.ActiveRow.Cells["ItemId"].Value);
  230. string baseEntity = JSONFormat.Format(entity);
  231. CoreClientParam ccp = new CoreClientParam();
  232. ccp.ServerName = "com.steering.lims.data.pipe.Tpopi25";
  233. ccp.MethodName = "doDelete";
  234. ccp.ServerParams = new object[] { new ArrayList { baseEntity } };
  235. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  236. if (ccp.ReturnCode != -1)
  237. {
  238. doQueryDetail();
  239. MessageUtil.ShowTips("删除成功!");
  240. }
  241. }
  242. catch (Exception ex)
  243. {
  244. MessageBox.Show(ex.Message, "提示");
  245. }
  246. }
  247. private void FrmTpopi24_Load(object sender, EventArgs e)
  248. {
  249. doQuery();
  250. }
  251. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  252. {
  253. try
  254. {
  255. var ugr = ultraGrid1.ActiveRow;
  256. if (ugr != null) ugr.RowSelectorAppearance.Reset();
  257. string InspectStandCode = ugr.Cells["InspectStandCode"].Value.ToString();
  258. string JdeLevel = ugr.Cells["JdeLevel"].Value.ToString();
  259. string ElmCode = ugr.Cells["ElmCode"].Value.ToString();
  260. if (!String.IsNullOrEmpty(InspectStandCode))
  261. {
  262. if (!String.IsNullOrEmpty(JdeLevel) && !String.IsNullOrEmpty(ElmCode))
  263. {
  264. List<Tpopi26Entity> listSource = EntityHelper.GetData<Tpopi26Entity>(
  265. "com.steering.lims.data.pipe.Tpopi26.doQuery", new object[] { InspectStandCode, JdeLevel, ElmCode,"" }, this.ob);
  266. Tpopi26bindingSourceDetails.DataSource = listSource;
  267. }
  268. List<Tpopi25Entity> listSource25 = EntityHelper.GetData<Tpopi25Entity>(
  269. "com.steering.lims.data.pipe.Tpopi25.doQuery", new object[] { InspectStandCode }, this.ob);
  270. Tpopi25bindingSource.DataSource = listSource25;
  271. }
  272. }
  273. catch (Exception ex)
  274. {
  275. MessageBox.Show(ex.Message, "提示");
  276. }
  277. }
  278. private void text_unitWeight_KeyPress(object sender, KeyPressEventArgs e)
  279. {
  280. if (e.KeyChar == '.' && this.text_unitWeight.Text.IndexOf(".") != -1)
  281. {
  282. e.Handled = true;
  283. }
  284. if (!((e.KeyChar >= 48 && e.KeyChar <= 57) || e.KeyChar == '.' || e.KeyChar == 8))
  285. {
  286. e.Handled = true;
  287. }
  288. }
  289. private void ultraGrid2_DoubleClick(object sender, EventArgs e)
  290. {
  291. }
  292. private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
  293. {
  294. try
  295. {
  296. if (ultraGrid2.ActiveRow == null)
  297. return;
  298. Infragistics.Win.UltraWinGrid.UltraGridRow ulRow = ultraGrid2.ActiveRow;
  299. text_itemName.Text = Convert.ToString(ulRow.Cells["ItemName"].Value);
  300. text_itemCode.Text = Convert.ToString(ulRow.Cells["ItemID"].Value);
  301. text_itemDesc.Text = Convert.ToString(ulRow.Cells["ItemDesc"].Value);
  302. text_itemUom.Text = Convert.ToString(ulRow.Cells["ItemUom"].Value);
  303. text_unitWeight.Text = Convert.ToString(ulRow.Cells["UnitWeight"].Value);
  304. text_leafCode.Text = Convert.ToString(ulRow.Cells["LeafCode"].Value);
  305. text_calss1.Text = Convert.ToString(ulRow.Cells["Class1"].Value);
  306. text_calss2.Text = Convert.ToString(ulRow.Cells["Class2"].Value);
  307. text_calss3.Text = Convert.ToString(ulRow.Cells["Class3"].Value);
  308. text_inspectStandCode.Text = Convert.ToString(ulRow.Cells["InspectStandCode"].Value);
  309. }
  310. catch (Exception ex)
  311. {
  312. MessageBox.Show(ex.Message, "提示");
  313. }
  314. }
  315. }
  316. }