using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using CoreFS.CA06; using Core.Mes.Client.Comm.Tool; using Core.Mes.Client.Comm.Server; using Core.StlMes.Client.YdmStuffManage.Entity; using System.Collections; using Infragistics.Win.UltraWinGrid; using Core.Mes.Client.Comm.Format; using Infragistics.Win; using Core.Mes.Client.Comm.Control; using System.Threading; namespace Core.StlMes.Client.YdmStuffManage { public partial class FrmGPInRule : FrmBase { public FrmGPInRule() { InitializeComponent(); } private void Frm_Load(object sender, EventArgs e) { GridHelper.SetColumnsActivateAndColor(ultraGrid1.Rows.Band, "CHK","InActCount"); EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); arr = BaseMethod.WarehousePermissionsStore(this.ValidDataPurviewIds, ob); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "doQuery": doQuery(); break; case "doUpdate": doUpdate(); break; case "Close": this.Close(); break; } } public static List UltraGridGetChooseRows(UltraGrid grid, string columnName = "CHK") { grid.UpdateData(); List list = new List(); RowsCollection rows = grid.Rows; foreach (var item in rows) { try { if (Convert.ToBoolean(item.Cells[columnName].Value) == true && item.Hidden == false && item.IsFilteredOut == false) { list.Add(item); } } catch { } } return list; } private string[] arr = null;//仓库权限 private void doQuery() { var dic = new Dictionary(); if (chkStoveNo.Checked) dic.Add("txtStoveNo", txtStoveNo.Text); if (chkFurnace.Checked) dic.Add("txtFurnace", txtFurnace.Text); ultraGrid1.DataSource = EntityHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmGPRule.queryInList", new object[] { arr,dic },this.ob); } private void doUpdate() { try { this.ultraGrid1.UpdateData(); List rows = UltraGridGetChooseRows(this.ultraGrid1); if (rows.Count == 0) { MessageUtil.ShowTips("请选择需要红冲的数据!"); return; } ArrayList strEntity = new ArrayList(); foreach (UltraGridRow row in rows) { if (row.Cells["inActCount"].Value.ToString().Equals("")) { MessageUtil.ShowTips("请输入红冲支数!"); return; } if (Int32.Parse(row.Cells["ActCount"].Value.ToString()) < Int32.Parse(row.Cells["inActCount"].Value.ToString())) { MessageUtil.ShowTips("红冲支数不能大于总支数!"); return; } strEntity.Add(JSONFormat.Format(row.ListObject as FrmGPRuleEntity)); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmGPRule"; ccp.MethodName = "insertYdmGpInList"; ccp.ServerParams = new object[] { strEntity,UserInfo.GetUserName() }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp != null) { if (ccp.ReturnCode == -1) { MessageUtil.ShowWarning(ccp.ReturnInfo); return; } MessageUtil.ShowTips("入库成功!"); } } catch (System.Exception ex) { MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } private void chkStoveNo_CheckedChanged(object sender, EventArgs e) { if (chkStoveNo.Checked) { this.txtStoveNo.Enabled = true; } else { this.txtStoveNo.Enabled = false; } } private void chkFurnace_CheckedChanged(object sender, EventArgs e) { if (chkFurnace.Checked) { this.txtFurnace.Enabled = true; } else { this.txtFurnace.Enabled = false; } } } }