using System; using System.Collections; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Text.RegularExpressions; using Core.Mes.Client.Comm.Server; using Core.StlMes.Client.Mcp.Control.Entity; using CoreFS.CA06; using Infragistics.Win; using Infragistics.Win.UltraWinEditors; using Infragistics.Win.UltraWinGrid; namespace Core.StlMes.Client.Mcp.Control { class comm { /// /// 绑定combobox /// /// 控件名 /// 数据源ds /// 值 /// 显示名 /// 筛选条件 /// 是否新增 /// 新增itemName public static void FilComboboxAdd(UltraComboEditor cmbx, DataTable dt, string strVal, string strName, string filCondition, Boolean tips, String addItemName, String addItemValue) { if (dt.Columns.Count > 1) { DataView dvw = dt.DefaultView; //dvw.RowFilter = filCondition; ArrayList aryTmp = new ArrayList(); if (tips == true) { aryTmp.Add(new ValueListItem(addItemValue, addItemName)); } for (int i = 0; i < dvw.Count; i++) { aryTmp.Add(new ValueListItem(dvw[i][strVal].ToString(), dvw[i][strName].ToString())); } cmbx.DataSource = aryTmp; cmbx.DisplayMember = "DisplayText"; cmbx.ValueMember = "DataValue"; } } /// /// 激活输入当前值行数据 /// /// ultragrid /// 列名 /// 列值 public static string doActiveSelRow(UltraGrid ug, string strColumn, string strKey) { try { if (strKey != "") { foreach (UltraGridRow row in ug.Rows) { if (row.Cells[strColumn].Text.ToString() == strKey) { row.Activated = true; if (row.ChildBands != null) row.Expanded = true; } } } return ""; } catch (Exception ex) { return ex.ToString(); } } /// /// 设置UltraComboEditor中的中文和非中文统一高度。 /// /// public static void SetComboItemHeight(UltraComboEditor cmb) { foreach (ValueListItem item in cmb.Items) { if (Regex.IsMatch(item.DisplayText, @"[\u4e00-\u9fa5]+")) { item.Appearance.FontData.SizeInPoints = 9.0F; } else { item.Appearance.FontData.SizeInPoints = 10.5F; } } } /// /// 获取产线 /// /// /// public static string[] GetPlineCode(string[] arr1, string ProcessCode, OpeBase ob) { string[] arr = null; DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Vrp.FrmComm.getPlineCode", new Object[] { arr1, ProcessCode }, ob); if (dt != null && dt.Rows.Count > 0) { arr = new string[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { arr[i] = dt.Rows[i][0].ToString(); } return arr; } else { return new string[1] { "" }; } } public static decimal GetWeight(List PortData, string gx, int NUM, int Count1) { if (PortData == null || !PortData.Any()) return 0; List OkList = PortData.Where( p => (p.MatStatus == "00" || p.MatStatus == "合格") || String.CompareOrdinal(p.OpProcess, gx) >= 0).ToList(); if (!OkList.Any()) return 0; decimal AllWeight = (decimal)OkList.Sum(p => p.ActTheoryWeight); decimal Weight1 = (decimal)(NUM % OkList.Count > (OkList.Count - Count1 % OkList.Count) ? (OkList.Skip(Count1 % OkList.Count).Take(OkList.Count - Count1 % OkList.Count).Sum(p => p.ActTheoryWeight) + OkList.Take(NUM % OkList.Count - (OkList.Count - Count1 % OkList.Count)) .Sum(p => p.ActTheoryWeight)) : OkList.Skip(Count1 % OkList.Count).Take(NUM % OkList.Count).Sum(p => p.ActTheoryWeight)); return AllWeight * (NUM / OkList.Count) + Weight1; } public static decimal GetWeight1(List PortData, string gx, int NUM, int Count1) { if (PortData == null || !PortData.Any()) return 0; List OkList = PortData.Where( p => (p.MatStatus == "00" || p.MatStatus == "合格") || String.CompareOrdinal(p.OpProcess, gx) >= 0).ToList(); if (!OkList.Any()) return 0; decimal AllWeight = (decimal)OkList.Sum(p => p.ActWeight); decimal Weight1 = (decimal)(NUM % OkList.Count > (OkList.Count - Count1 % OkList.Count) ? (OkList.Skip(Count1 % OkList.Count).Take(OkList.Count - Count1 % OkList.Count).Sum(p => p.ActWeight) + OkList.Take(NUM % OkList.Count - (OkList.Count - Count1 % OkList.Count)) .Sum(p => p.ActWeight)) : OkList.Skip(Count1 % OkList.Count).Take(NUM % OkList.Count).Sum(p => p.ActWeight)); return AllWeight * (NUM / OkList.Count) + Weight1; } } }