comm.cs 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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 Core.Mes.Client.Comm.Server;
  9. using Core.StlMes.Client.Mcp.Control.Entity;
  10. using CoreFS.CA06;
  11. using Infragistics.Win;
  12. using Infragistics.Win.UltraWinEditors;
  13. using Infragistics.Win.UltraWinGrid;
  14. namespace Core.StlMes.Client.Mcp.Control
  15. {
  16. class comm
  17. {
  18. /// <summary>
  19. /// 绑定combobox
  20. /// </summary>
  21. /// <param name="cmbx">控件名</param>
  22. /// <param name="dset">数据源ds</param>
  23. /// <param name="strVal">值</param>
  24. /// <param name="strName">显示名</param>
  25. /// <param name="filCondition">筛选条件</param>
  26. /// <param name="tips">是否新增</param>
  27. /// <param name="addItem">新增itemName</param>
  28. public static void FilComboboxAdd(UltraComboEditor cmbx, DataTable dt, string strVal, string strName, string filCondition, Boolean tips, String addItemName, String addItemValue)
  29. {
  30. if (dt.Columns.Count > 1)
  31. {
  32. DataView dvw = dt.DefaultView;
  33. //dvw.RowFilter = filCondition;
  34. ArrayList aryTmp = new ArrayList();
  35. if (tips == true)
  36. {
  37. aryTmp.Add(new ValueListItem(addItemValue, addItemName));
  38. }
  39. for (int i = 0; i < dvw.Count; i++)
  40. {
  41. aryTmp.Add(new ValueListItem(dvw[i][strVal].ToString(), dvw[i][strName].ToString()));
  42. }
  43. cmbx.DataSource = aryTmp;
  44. cmbx.DisplayMember = "DisplayText";
  45. cmbx.ValueMember = "DataValue";
  46. }
  47. }
  48. /// <summary>
  49. /// 激活输入当前值行数据
  50. /// </summary>
  51. /// <param name="ug">ultragrid</param>
  52. /// <param name="strColumn">列名</param>
  53. /// <param name="strKey">列值</param>
  54. public static string doActiveSelRow(UltraGrid ug, string strColumn, string strKey)
  55. {
  56. try
  57. {
  58. if (strKey != "")
  59. {
  60. foreach (UltraGridRow row in ug.Rows)
  61. {
  62. if (row.Cells[strColumn].Text.ToString() == strKey)
  63. {
  64. row.Activated = true;
  65. if (row.ChildBands != null)
  66. row.Expanded = true;
  67. }
  68. }
  69. }
  70. return "";
  71. }
  72. catch (Exception ex)
  73. {
  74. return ex.ToString();
  75. }
  76. }
  77. /// <summary>
  78. /// 设置UltraComboEditor中的中文和非中文统一高度。
  79. /// </summary>
  80. /// <param name="cmb"></param>
  81. public static void SetComboItemHeight(UltraComboEditor cmb)
  82. {
  83. foreach (ValueListItem item in cmb.Items)
  84. {
  85. if (Regex.IsMatch(item.DisplayText, @"[\u4e00-\u9fa5]+"))
  86. {
  87. item.Appearance.FontData.SizeInPoints = 9.0F;
  88. }
  89. else
  90. {
  91. item.Appearance.FontData.SizeInPoints = 10.5F;
  92. }
  93. }
  94. }
  95. /// <summary>
  96. /// 获取产线
  97. /// </summary>
  98. /// <param name="arr1"></param>
  99. /// <returns></returns>
  100. public static string[] GetPlineCode(string[] arr1, string ProcessCode, OpeBase ob)
  101. {
  102. string[] arr = null;
  103. DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Vrp.FrmComm.getPlineCode", new Object[] { arr1, ProcessCode }, ob);
  104. if (dt != null && dt.Rows.Count > 0)
  105. {
  106. arr = new string[dt.Rows.Count];
  107. for (int i = 0; i < dt.Rows.Count; i++)
  108. {
  109. arr[i] = dt.Rows[i][0].ToString();
  110. }
  111. return arr;
  112. }
  113. else
  114. {
  115. return new string[1] { "" };
  116. }
  117. }
  118. public static decimal GetWeight(List<PortMchBatchSampleResultEntity> PortData, string gx, int NUM, int Count1)
  119. {
  120. if (PortData == null || !PortData.Any()) return 0;
  121. List<PortMchBatchSampleResultEntity> OkList = PortData.Where(
  122. p =>
  123. (p.MatStatus == "00" || p.MatStatus == "合格") ||
  124. String.CompareOrdinal(p.OpProcess, gx) >= 0).ToList();
  125. if (!OkList.Any()) return 0;
  126. decimal AllWeight = (decimal)OkList.Sum(p => p.ActTheoryWeight);
  127. decimal Weight1 = (decimal)(NUM % OkList.Count > (OkList.Count - Count1 % OkList.Count)
  128. ? (OkList.Skip(Count1 % OkList.Count).Take(OkList.Count - Count1 % OkList.Count).Sum(p => p.ActTheoryWeight) +
  129. OkList.Take(NUM % OkList.Count - (OkList.Count - Count1 % OkList.Count))
  130. .Sum(p => p.ActTheoryWeight))
  131. : OkList.Skip(Count1 % OkList.Count).Take(NUM % OkList.Count).Sum(p => p.ActTheoryWeight));
  132. return AllWeight * (NUM / OkList.Count) + Weight1;
  133. }
  134. public static decimal GetWeight1(List<PortMchBatchSampleResultEntity> PortData, string gx, int NUM, int Count1)
  135. {
  136. if (PortData == null || !PortData.Any()) return 0;
  137. List<PortMchBatchSampleResultEntity> OkList = PortData.Where(
  138. p =>
  139. (p.MatStatus == "00" || p.MatStatus == "合格") ||
  140. String.CompareOrdinal(p.OpProcess, gx) >= 0).ToList();
  141. if (!OkList.Any()) return 0;
  142. decimal AllWeight = (decimal)OkList.Sum(p => p.ActWeight);
  143. decimal Weight1 = (decimal)(NUM % OkList.Count > (OkList.Count - Count1 % OkList.Count)
  144. ? (OkList.Skip(Count1 % OkList.Count).Take(OkList.Count - Count1 % OkList.Count).Sum(p => p.ActWeight) +
  145. OkList.Take(NUM % OkList.Count - (OkList.Count - Count1 % OkList.Count))
  146. .Sum(p => p.ActWeight))
  147. : OkList.Skip(Count1 % OkList.Count).Take(NUM % OkList.Count).Sum(p => p.ActWeight));
  148. return AllWeight * (NUM / OkList.Count) + Weight1;
  149. }
  150. }
  151. }