| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- 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
- {
- /// <summary>
- /// 绑定combobox
- /// </summary>
- /// <param name="cmbx">控件名</param>
- /// <param name="dset">数据源ds</param>
- /// <param name="strVal">值</param>
- /// <param name="strName">显示名</param>
- /// <param name="filCondition">筛选条件</param>
- /// <param name="tips">是否新增</param>
- /// <param name="addItem">新增itemName</param>
- 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";
- }
- }
- /// <summary>
- /// 激活输入当前值行数据
- /// </summary>
- /// <param name="ug">ultragrid</param>
- /// <param name="strColumn">列名</param>
- /// <param name="strKey">列值</param>
- 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();
- }
- }
- /// <summary>
- /// 设置UltraComboEditor中的中文和非中文统一高度。
- /// </summary>
- /// <param name="cmb"></param>
- 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;
- }
- }
- }
- /// <summary>
- /// 获取产线
- /// </summary>
- /// <param name="arr1"></param>
- /// <returns></returns>
- 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<PortMchBatchSampleResultEntity> PortData, string gx, int NUM, int Count1)
- {
- if (PortData == null || !PortData.Any()) return 0;
- List<PortMchBatchSampleResultEntity> 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<PortMchBatchSampleResultEntity> PortData, string gx, int NUM, int Count1)
- {
- if (PortData == null || !PortData.Any()) return 0;
- List<PortMchBatchSampleResultEntity> 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;
- }
- }
- }
|