FrmComBaseCustomRPline.cs 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. using com.steering.pss.qcm.model;
  2. using Core.Mes.Client.Comm.Control;
  3. using Core.Mes.Client.Comm.Server;
  4. using Core.Mes.Client.Comm.Tool;
  5. using CoreFS.CA06;
  6. using Infragistics.Win.UltraWinGrid;
  7. using System;
  8. using System.Collections;
  9. using System.Data;
  10. using System.Drawing;
  11. using System.Linq;
  12. using System.Windows.Forms;
  13. namespace Core.StlMes.Client.Qcm
  14. {
  15. public partial class FrmComBaseCustomRPline : FrmBase
  16. {
  17. private DataTable _dt = null;
  18. private String _finallUser = "";
  19. private String _produc = "";
  20. public FrmComBaseCustomRPline()
  21. {
  22. InitializeComponent();
  23. }
  24. public override void ToolBar_Click(object sender, string ToolbarKey)
  25. {
  26. switch (ToolbarKey)
  27. {
  28. case "Query":
  29. try
  30. {
  31. this.Cursor = Cursors.WaitCursor;
  32. Query();
  33. }
  34. finally
  35. {
  36. this.Cursor = Cursors.Default;
  37. }
  38. break;
  39. case "Save":
  40. Save();
  41. break;
  42. case "Close":
  43. this.Close();
  44. break;
  45. }
  46. }
  47. public void Query()
  48. {
  49. QueryFinaluser();
  50. QueryProduc();
  51. getCustPline();
  52. setGridRowColor();
  53. }
  54. public void QueryFinaluser()
  55. {
  56. String finallUser = "";
  57. if (ultraCheckUser.Checked)
  58. {
  59. finallUser = ultraTextUser.Text.Trim();
  60. }
  61. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreComBaseCustomRPline.getFinallUser", new Object[] { finallUser }, this.ob);
  62. GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
  63. }
  64. public void QueryProduc()
  65. {
  66. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreComBaseCustomRPline.getProDuc", new Object[] { }, this.ob);
  67. GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable2, true);
  68. }
  69. public void QueryProline()
  70. {
  71. UltraGridRow ugrUser = ultraGridUser.ActiveRow;
  72. UltraGridRow ugrProDuc = ultraGridProDuc.ActiveRow;
  73. if (ugrUser != null && ugrProDuc != null)
  74. {
  75. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreComBaseCustomRPline.getProline", new Object[] { ugrUser.Cells["CUSTOMER_NO"].Text.ToString(), ugrProDuc.Cells["PRODUCCODE"].Text.ToString() }, this.ob);
  76. GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable3, true);
  77. }
  78. }
  79. public void Save()
  80. {
  81. UltraGridRow ugrUser = ultraGridUser.ActiveRow;
  82. UltraGridRow ugrProDuc = ultraGridProDuc.ActiveRow;
  83. ultraGridPline.UpdateData();
  84. IQueryable<UltraGridRow> checkedRows = ultraGridPline.Rows.AsQueryable().Where(" CHC = 'True'");
  85. ArrayList list = new ArrayList();
  86. foreach (UltraGridRow ugr in checkedRows)
  87. {
  88. if (ugrUser != null && ugrProDuc != null)
  89. {
  90. ComBaseCustomRPlineEntity entity = new ComBaseCustomRPlineEntity();
  91. entity.CreateName = UserInfo.GetUserName();
  92. entity.CustomerNm = ugrUser.Cells["CUSTOMER_NM"].Text.Trim();
  93. entity.CustomerNo = ugrUser.Cells["CUSTOMER_NO"].Text.Trim();
  94. entity.PlineCode = ugr.Cells["PLINE_CODE"].Text.Trim();
  95. entity.PlineName = ugr.Cells["PLINE_NAME"].Text.Trim();
  96. entity.ProcessCdoe = ugr.Cells["PROCESS_CODE"].Text.Trim();
  97. entity.ProcessDesc = ugr.Cells["PROCESS_DESC"].Text.Trim();
  98. entity.Produccode = ugrProDuc.Cells["PRODUCCODE"].Text.Trim();
  99. entity.Producname = ugrProDuc.Cells["PRODUCNAME"].Text.Trim();
  100. list.Add(entity);
  101. }
  102. }
  103. if (MessageUtil.ShowYesNoAndQuestion("是否保存?") == DialogResult.No)
  104. {
  105. return;
  106. }
  107. _finallUser = ugrUser.Cells["CUSTOMER_NO"].Text.Trim();
  108. _produc = ugrProDuc.Cells["PRODUCCODE"].Text.Trim();
  109. CoreClientParam ccp = new CoreClientParam();
  110. ccp.ServerName = "com.steering.pss.qcm.CoreComBaseCustomRPline";
  111. ccp.MethodName = "saveCustomRPline";
  112. ccp.ServerParams = new object[] { list, ugrUser.Cells["CUSTOMER_NO"].Text.Trim(), ugrProDuc.Cells["PRODUCCODE"].Text.Trim() };
  113. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  114. if (ccp.ReturnCode != -1)
  115. {
  116. MessageUtil.ShowTips("保存成功!");
  117. QueryProline();
  118. Query();
  119. getCustPline();
  120. setGridRowColor();
  121. setUltraGridActive();
  122. }
  123. }
  124. private void ultraCheckUser_CheckedChanged(object sender, EventArgs e)
  125. {
  126. if (ultraCheckUser.Checked)
  127. {
  128. ultraTextUser.Enabled = true;
  129. }
  130. else
  131. {
  132. ultraTextUser.Enabled = false;
  133. }
  134. }
  135. private void ultraGridUser_AfterRowActivate(object sender, EventArgs e)
  136. {
  137. QueryProline();
  138. if (ultraGridUser.ActiveRow != null)
  139. {
  140. setGridRowColor(ultraGridUser.ActiveRow.Cells["CUSTOMER_NO"].Text);
  141. }
  142. }
  143. private void ultraGridProDuc_AfterRowActivate(object sender, EventArgs e)
  144. {
  145. QueryProline();
  146. }
  147. private void getCustPline()
  148. {
  149. _dt = ServerHelper.GetData("com.steering.pss.qcm.CoreComBaseCustomRPline.getCustPline", new Object[] { }, this.ob);
  150. }
  151. private void setGridRowColor()
  152. {
  153. if (_dt == null || _dt.Rows.Count == 0)
  154. {
  155. return;
  156. }
  157. ArrayList finalUsers = new ArrayList();
  158. foreach (DataRow dr in _dt.Rows)
  159. {
  160. finalUsers.Add(dr["CUSTOMER_NO"].ToString());
  161. }
  162. foreach (UltraGridRow ugr in ultraGridUser.Rows)
  163. {
  164. if (finalUsers.Contains(ugr.Cells["CUSTOMER_NO"].Text))
  165. {
  166. ugr.Appearance.BackColor = Color.Orange;
  167. }
  168. else
  169. {
  170. ugr.Appearance.BackColor = Color.White;
  171. }
  172. }
  173. }
  174. private void setGridRowColor(String customerNo)
  175. {
  176. if (_dt == null || _dt.Rows.Count == 0)
  177. {
  178. return;
  179. }
  180. ArrayList producs = new ArrayList();
  181. foreach (DataRow dr in _dt.Rows)
  182. {
  183. if (dr["CUSTOMER_NO"].ToString().Equals(customerNo))
  184. {
  185. producs.Add(dr["PRODUCCODE"].ToString());
  186. }
  187. }
  188. foreach (UltraGridRow ugr in ultraGridProDuc.Rows)
  189. {
  190. if (producs.Contains(ugr.Cells["PRODUCCODE"].Text))
  191. {
  192. ugr.Appearance.BackColor = Color.Orange;
  193. }
  194. else
  195. {
  196. ugr.Appearance.BackColor = Color.White;
  197. }
  198. }
  199. }
  200. private void FrmComBaseCustomRPline_Load(object sender, EventArgs e)
  201. {
  202. Query();
  203. }
  204. private void setUltraGridActive()
  205. {
  206. foreach (UltraGridRow ugr in ultraGridUser.Rows)
  207. {
  208. if (ugr.Cells["CUSTOMER_NO"].Text.Equals(_finallUser))
  209. {
  210. ugr.Activate();
  211. break;
  212. }
  213. }
  214. foreach (UltraGridRow ugr in ultraGridProDuc.Rows)
  215. {
  216. if (ugr.Cells["PRODUCCODE"].Text.Equals(_produc))
  217. {
  218. ugr.Activate();
  219. }
  220. }
  221. _finallUser = "";
  222. _produc = "";
  223. }
  224. }
  225. }