| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183 |
- using System;
- using System.Collections;
- using System.Data;
- using System.Drawing;
- using System.Windows.Forms;
- using Core.StlMes.Client.LgClassModel;
- using Infragistics.Win;
- using Infragistics.Win.UltraWinGrid;
- namespace Core.StlMes.Client.LgCommon
- {
- public partial class ucResAdditiveScheme : UserControl
- {
- public ucResAdditiveScheme()
- {
- InitializeComponent();
- }
- protected override void OnLoad(System.EventArgs e)
- {
- base.OnLoad(e);
- SetAdditiveProcessData(null, null);
- _MATERIALTYPE = ClsBusinessPack.GetValuelistMaterialType();
- }
- private ValueList _MATERIALTYPE = null;
- private ArrayList _ITEMS = null;
- private void InitItems()
- {
- if (_ITEMS == null)
- _ITEMS = new ArrayList();
- else
- _ITEMS.Clear();
- }
- public void SetAdditiveProcessData(CommonAdditive additiveBuffer, DataTable tbMaterial)
- {
- InitItems();
- ultraGrid1.BeginUpdate();
- this.dataTable1.Rows.Clear();
- this.dataTable1.Columns.Clear();
- try
- {
- DataColumn column = null;
- column = new DataColumn("MATERIELTYPE", typeof(string));
- column.Caption = "物料类型";
- this.dataTable1.Columns.Add(column);
- column = new DataColumn("JMDATE", typeof(string));
- column.Caption = "物料名称";
- this.dataTable1.Columns.Add(column);
- column = new DataColumn("HOPPERNUMID", typeof(string));
- column.Caption = "下限";
- this.dataTable1.Columns.Add(column);
- column = new DataColumn("column1", typeof(string));
- column.Caption = "上限";
- this.dataTable1.Columns.Add(column);
- column = new DataColumn("column3", typeof(string));
- column.Caption = "单位";
- this.dataTable1.Columns.Add(column);
- column = new DataColumn("column2", typeof(string));
- column.Caption = "备注";
- this.dataTable1.Columns.Add(column);
-
- string strCode = "", strName = "";
- UltraGridRow row = null;
- for (int idx = 0; idx < additiveBuffer.hList.Count; idx++)
- {
- JOB_COMMON_ADDITIVES obj = (JOB_COMMON_ADDITIVES)additiveBuffer.hList[idx];
- if (obj == null) continue;
- try
- {
- strCode = obj.MATERIELCODE;
- if (!_ITEMS.Contains(strCode))
- {
- try
- {
- strName = "";
- if (tbMaterial != null)
- {
- DataRow[] rows = tbMaterial.Select("MATERIELCODE = '" + strCode + "'");
- if (rows.Length > 0)
- {
- strName = Convert.ToString(rows[0]["MATERIELFORSHORT"]);
- }
- }
- if (string.IsNullOrEmpty(strName)) strName = obj.MATERIELCODE;
- }
- catch
- {
- strName = obj.MATERIELCODE;
- }
- column = new DataColumn(strCode, typeof(string));
- column.Caption = strName;
- this.dataTable1.Columns.Add(column);
- _ITEMS.Add(strCode);
- }
- row = ultraGrid1.DisplayLayout.Bands[0].AddNew();
- try
- {
- row.Cells[strCode].Value = obj.JMWGT;
- row.Cells["JMDATE"].Value = obj.JMDATE.ToString("yyyy-MM-dd HH:mm:ss");
- row.Cells["HOPPERNUMID"].Value = obj.HOPPERNUMID.ToString();
- row.Cells["MATERIELTYPE"].Value = obj.MATERIELTYPE.ToString();
- }
- catch { }
- }
- catch { }
- }
- }
- catch { }
- finally
- {
- try
- {
- ClsControlPack.SetGridValuelist(ref ultraGrid1, "MATERIELTYPE", ref _MATERIALTYPE);
- // SetAdditiveDataSummary();
- this.SetReadOnly();
- ClsControlPack.SetUltraGridAppearance(this);
- ClsControlPack.RefreshAndAutoSize(ultraGrid1);
- ultraGrid1.EndUpdate();
- }
- catch { }
- }
- }
- private void SetAdditiveDataSummary()
- {
- try
- {
- UltraGridBand band = this.ultraGrid1.DisplayLayout.Bands[0];
- band.Summaries.Clear();
- SummarySettings summary = band.Summaries.Add(SummaryType.Count, band.Columns[0]);
- summary.SummaryDisplayArea = SummaryDisplayAreas.TopFixed;
- summary.SummaryPosition = SummaryPosition.UseSummaryPositionColumn;
- summary.Appearance.ForeColor = Color.DarkBlue;
- summary.Appearance.BackColor = Color.White;
- summary.Appearance.TextVAlign = VAlign.Middle;
- summary.Appearance.TextHAlign = HAlign.Center;
- summary.Appearance.FontData.Bold = DefaultableBoolean.True;
- summary.DisplayFormat = "投料合计:";
- string strCode = "";
- if (_ITEMS != null && _ITEMS.Count > 0)
- {
- for (int idx = 0; idx < _ITEMS.Count; idx++)
- {
- try
- {
- strCode = _ITEMS[idx].ToString();
- summary = band.Summaries.Add(SummaryType.Sum, band.Columns[strCode]);
- summary.SummaryDisplayArea = SummaryDisplayAreas.TopFixed;
- summary.SummaryPosition = SummaryPosition.UseSummaryPositionColumn;
- summary.Appearance.FontData.Bold = DefaultableBoolean.True;
- summary.DisplayFormat = " {0:#####}";
- summary.Appearance.TextVAlign = VAlign.Middle;
- summary.Appearance.TextHAlign = HAlign.Right;
- summary.Appearance.ForeColor = Color.DarkBlue;
- summary.Appearance.BackColor = Color.White;
- }
- catch { }
- }
- }
- band.Override.SummaryFooterCaptionVisible = DefaultableBoolean.False;
- }
- catch { }
- }
- private void SetReadOnly()
- {
- try
- {
- for (int idx = 0; idx < ultraGrid1.DisplayLayout.Bands[0].Columns.Count; idx++)
- {
- ultraGrid1.DisplayLayout.Bands[0].Columns[idx].CellActivation = Activation.ActivateOnly;
- }
- }
- catch { }
- }
- }
- }
|