comm.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Text.RegularExpressions;
  8. using Infragistics.Win;
  9. using Infragistics.Win.UltraWinEditors;
  10. using Infragistics.Win.UltraWinGrid;
  11. using Core.Mes.Client.Comm.Server;
  12. using CoreFS.CA06;
  13. namespace Core.StlMes.Client.Mcp.Treatment.HeatTreatment
  14. {
  15. public class comm
  16. {
  17. /// <summary>
  18. /// 绑定combobox
  19. /// </summary>
  20. /// <param name="cmbx">控件名</param>
  21. /// <param name="dset">数据源ds</param>
  22. /// <param name="strVal">值</param>
  23. /// <param name="strName">显示名</param>
  24. /// <param name="filCondition">筛选条件</param>
  25. /// <param name="tips">是否新增</param>
  26. /// <param name="addItem">新增itemName</param>
  27. public static void FilComboboxAdd(UltraComboEditor cmbx, DataTable dt, string strVal, string strName, string filCondition, Boolean tips, String addItemName, String addItemValue)
  28. {
  29. if (dt.Columns.Count > 1)
  30. {
  31. DataView dvw = dt.DefaultView;
  32. //dvw.RowFilter = filCondition;
  33. ArrayList aryTmp = new ArrayList();
  34. if (tips == true)
  35. {
  36. aryTmp.Add(new ValueListItem(addItemValue, addItemName));
  37. }
  38. for (int i = 0; i < dvw.Count; i++)
  39. {
  40. aryTmp.Add(new ValueListItem(dvw[i][strVal].ToString(), dvw[i][strName].ToString()));
  41. }
  42. cmbx.DataSource = aryTmp;
  43. cmbx.DisplayMember = "DisplayText";
  44. cmbx.ValueMember = "DataValue";
  45. }
  46. }
  47. /// <summary>
  48. /// 激活输入当前值行数据
  49. /// </summary>
  50. /// <param name="ug">ultragrid</param>
  51. /// <param name="strColumn">列名</param>
  52. /// <param name="strKey">列值</param>
  53. public static string doActiveSelRow(UltraGrid ug, string strColumn, string strKey)
  54. {
  55. try
  56. {
  57. if (strKey != "")
  58. {
  59. foreach (UltraGridRow row in ug.Rows)
  60. {
  61. if (row.Cells[strColumn].Text.ToString() == strKey)
  62. {
  63. row.Activated = true;
  64. if (row.ChildBands != null)
  65. row.Expanded = true;
  66. }
  67. }
  68. }
  69. return "";
  70. }
  71. catch (Exception ex)
  72. {
  73. return ex.ToString();
  74. }
  75. }
  76. /// <summary>
  77. /// 设置UltraComboEditor中的中文和非中文统一高度。
  78. /// </summary>
  79. /// <param name="cmb"></param>
  80. public static void SetComboItemHeight(UltraComboEditor cmb)
  81. {
  82. foreach (Infragistics.Win.ValueListItem item in cmb.Items)
  83. {
  84. if (Regex.IsMatch(item.DisplayText, @"[\u4e00-\u9fa5]+"))
  85. {
  86. item.Appearance.FontData.SizeInPoints = 9.0F;
  87. }
  88. else
  89. {
  90. item.Appearance.FontData.SizeInPoints = 10.5F;
  91. }
  92. }
  93. }
  94. /// <summary>
  95. /// 获取产线
  96. /// </summary>
  97. /// <param name="arr1"></param>
  98. /// <returns></returns>
  99. public static string[] GetPlineCode(string[] arr1,OpeBase ob)
  100. {
  101. string[] arr = null;
  102. DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Vrp.FrmComm.getPlineCode", new Object[] { arr1 }, ob);
  103. if (dt != null && dt.Rows.Count > 0)
  104. {
  105. arr = new string[dt.Rows.Count];
  106. for (int i = 0; i < dt.Rows.Count; i++)
  107. {
  108. arr[i] = dt.Rows[i][0].ToString();
  109. }
  110. return arr;
  111. }
  112. else
  113. {
  114. return new string[1] { "" };
  115. }
  116. }
  117. /// <summary>
  118. /// 获取产线
  119. /// </summary>
  120. /// <param name="arr1"></param>
  121. /// <returns></returns>
  122. public static string[] GetPlineCodeWithOther(string[] arr1, OpeBase ob)
  123. {
  124. List<string> arr = new List<string>();
  125. DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Vrp.FrmComm.getPlineCode", new Object[] { arr1 }, ob);
  126. if (dt != null && dt.Rows.Count > 0)
  127. {
  128. for (int i = 0; i < dt.Rows.Count; i++)
  129. {
  130. arr.Add(dt.Rows[i][0].ToString());
  131. }
  132. }
  133. else
  134. {
  135. }
  136. if (arr1.Any(p => p.StartsWith("002001042001")))
  137. {
  138. arr.Add("100101");
  139. }
  140. if (arr1.Any(p => p.StartsWith("002001042002")))
  141. {
  142. arr.Add("100102");
  143. }
  144. return arr.ToArray();
  145. }
  146. /// <summary>
  147. /// 获取产线
  148. /// </summary>
  149. /// <param name="arr1"></param>
  150. /// <returns></returns>
  151. public static string[] GetPlineCode(string[] arr1,string ProcessCode, OpeBase ob)
  152. {
  153. string[] arr = null;
  154. DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Vrp.FrmComm.getPlineCode", new Object[] { arr1, ProcessCode }, ob);
  155. if (dt != null && dt.Rows.Count > 0)
  156. {
  157. arr = new string[dt.Rows.Count];
  158. for (int i = 0; i < dt.Rows.Count; i++)
  159. {
  160. arr[i] = dt.Rows[i][0].ToString();
  161. }
  162. return arr;
  163. }
  164. else
  165. {
  166. return new string[1] { "" };
  167. }
  168. }
  169. public static string[] InitDropPlinePowerW(UltraComboEditor ugc, string[] validDataPurviewIds, OpeBase ob)
  170. {
  171. DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Vrp.FrmComm.getPlineCodeW", new object[] { validDataPurviewIds }, ob);
  172. if (dt != null && dt.Rows.Count > 0)
  173. {
  174. ugc.DataSource = dt;
  175. ugc.ValueMember = "PLINE_CODE";
  176. ugc.DisplayMember = "PLINE_NAME";
  177. string[] plineArr = new string[dt.Rows.Count];
  178. for (int i = 0; i < dt.Rows.Count; i++)
  179. {
  180. plineArr[i] = dt.Rows[i]["PLINE_CODE"].ToString();
  181. }
  182. return plineArr;
  183. }
  184. else
  185. {
  186. return null;
  187. }
  188. }
  189. public static string[] InitDropPlinePower(string processCode, UltraComboEditor ugc, string[] validDataPurviewIds, OpeBase ob)
  190. {
  191. DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Vrp.FrmComm.getPlineCode", new object[] {validDataPurviewIds, processCode }, ob);
  192. if (dt != null && dt.Rows.Count > 0)
  193. {
  194. ugc.DataSource = dt;
  195. ugc.ValueMember = "PLINE_CODE";
  196. ugc.DisplayMember = "PLINE_NAME";
  197. string[] plineArr = new string[dt.Rows.Count];
  198. for (int i = 0; i < dt.Rows.Count; i++)
  199. {
  200. plineArr[i] = dt.Rows[i]["PLINE_CODE"].ToString();
  201. }
  202. return plineArr;
  203. }
  204. else
  205. {
  206. return null;
  207. }
  208. }
  209. /// <summary>
  210. /// 刷新Grid数据并根据数据调整Grid列宽
  211. /// </summary>
  212. /// <param name="ultraGrid">需要处理的Grid</param>
  213. public static void RefreshAndAutoSize(Infragistics.Win.UltraWinGrid.UltraGrid ultraGrid,string[] unSizeColumns=null)
  214. {
  215. try
  216. {
  217. ultraGrid.DataBind();
  218. foreach (Infragistics.Win.UltraWinGrid.UltraGridBand band in ultraGrid.DisplayLayout.Bands)
  219. {
  220. foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn column in band.Columns )
  221. {
  222. if (unSizeColumns==null || !unSizeColumns.Contains(column.Key))
  223. column.PerformAutoResize(Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand);
  224. }
  225. }
  226. ultraGrid.Refresh();
  227. }
  228. catch { }
  229. }
  230. /// <summary>
  231. /// 刷新Grid数据并根据数据调整Grid列宽
  232. /// </summary>
  233. /// <param name="ultraGrid">需要处理的Grid</param>
  234. public static void RefreshAndAutoSize(Infragistics.Win.UltraWinGrid.UltraGrid ultraGrid, bool IncludHeader )
  235. {
  236. try
  237. {
  238. ultraGrid.DataBind();
  239. foreach (Infragistics.Win.UltraWinGrid.UltraGridBand band in ultraGrid.DisplayLayout.Bands)
  240. {
  241. foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn column in band.Columns)
  242. {
  243. column.PerformAutoResize(Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand, IncludHeader);
  244. }
  245. }
  246. ultraGrid.Refresh();
  247. }
  248. catch { }
  249. }
  250. /// <summary>
  251. /// UltraGrid可读(非主从结构)
  252. /// </summary>
  253. /// <param name="ugr">UltraGrid</param>
  254. /// <param name="keys">可编辑列</param>
  255. public static void setOtherColumnReadOnly(UltraGrid ugr, string[] keys)
  256. {
  257. if (keys == null || keys.Length == 0)
  258. {
  259. foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[0].Columns)
  260. {
  261. ugc.CellActivation = Activation.ActivateOnly;
  262. }
  263. }
  264. else
  265. {
  266. keys.ToArray();
  267. foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[0].Columns)
  268. {
  269. if (!keys.Contains(ugc.Key))
  270. {
  271. ugc.CellActivation = Activation.ActivateOnly;
  272. }
  273. }
  274. }
  275. }
  276. /// <summary>
  277. /// 查询结转控制标识
  278. /// </summary>
  279. /// <param name="Code"></param>
  280. /// <param name="ob"></param>
  281. /// <returns></returns>
  282. public static string GetState( string Code, OpeBase ob)
  283. {
  284. string State = "";
  285. DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Vrp.FrmComm.getState", new Object[] { Code }, ob);
  286. if (dt != null && dt.Rows.Count > 0)
  287. {
  288. State = dt.Rows[0][0].ToString();
  289. }
  290. return State;
  291. }
  292. }
  293. }