using Core.Mes.Client.Comm.Control; using CoreFS.CA06; using Infragistics.Win.UltraWinGrid; using System; using System.Data; using System.Linq; using System.Windows.Forms; namespace Core.StlMes.Client.Qcm { public partial class PopupProductName : FrmBase { private FrmProductName _frmProductName; private DataTable _dt; private bool _isQuerying = false; private string _productNames = ""; private string _productCodes = ""; public string ProductCodes { get { return _productCodes; } set { _productCodes = value; } } public string ProductNames { get { return _productNames; } set { _productNames = value; } } private void PopupProductName_Load(object sender, EventArgs e) { } public PopupProductName(string productCodes, OpeBase ob) { InitializeComponent(); this.ob = ob; _productCodes = productCodes; _frmProductName = new FrmProductName(); _frmProductName.UltraGrid2.InitializeRow += UltraGrid2_InitializeRow; _frmProductName.UltraGrid2.CellChange += UltraGrid2_CellChange; _frmProductName.PopupLoad(ob); panel2.Controls.Add(_frmProductName.UltraGrid2); _frmProductName.UltraGrid2.DisplayLayout.Bands[0].Columns["CHK"].Hidden = false; foreach (UltraGridColumn column in _frmProductName.UltraGrid2.DisplayLayout.Bands[0].Columns) { column.SortIndicator = SortIndicator.Disabled; } _isQuerying = true; _frmProductName.ToolBar_Click(null, "doQuery"); _dt = ((DataSet)_frmProductName.UltraGrid2.DataSource).Tables[_frmProductName.UltraGrid2.DataMember]; foreach (DataRow dr in _dt.Rows) { string productCode = dr["PRODUCCODE"].ToString(); if (_productCodes.Contains(productCode)) { dr["CHK"] = true; } } SortRows(); _isQuerying = false; InitDefaultProduct(); } private void SortRows() { DataTable dtSort = _dt.Copy(); dtSort.DefaultView.Sort = "CHK DESC, PRODUCNAME ASC"; _frmProductName.UltraGrid2.BeginUpdate(); GridHelper.CopyDataToDatatable(dtSort.DefaultView.ToTable(), _dt, true); _frmProductName.UltraGrid2.EndUpdate(); } void UltraGrid2_InitializeRow(object sender, InitializeRowEventArgs e) { } void UltraGrid2_CellChange(object sender, CellEventArgs e) { _frmProductName.UltraGrid2.UpdateData(); } private void InitDefaultProduct() { _frmProductName.UltraGrid2.UpdateData(); } private void btnOk_Click(object sender, EventArgs e) { _productCodes = ""; _frmProductName.UltraGrid2.UpdateData(); UltraGridRow[] rows = _frmProductName.UltraGrid2.Rows.AsQueryable().Where("CHK = 'True'").ToArray(); foreach (UltraGridRow row in rows) { if (_productCodes == "") { _productCodes += row.GetValue("PRODUCCODE"); _productNames += row.GetValue("PRODUCNAME"); } else { _productNames += ";" + row.GetValue("PRODUCNAME"); _productCodes += ";" + row.GetValue("PRODUCCODE"); } } //ServerHelper.SetData("com.steering.pss.qcm.CoreChemStandard.insertComMscStdCicRProduct", // new object[] { list, _cic, CoreUserInfo.UserInfo.GetUserName()}, ob); //MessageUtil.ShowTips("保存成功!"); this.DialogResult = DialogResult.OK; } private void btnCanCel_Click(object sender, EventArgs e) { this.DialogResult = DialogResult.Cancel; } } }