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 FrmGPRule : FrmBase { public FrmGPRule() { InitializeComponent(); } private void Frm_Load(object sender, EventArgs e) { GridHelper.SetColumnsActivateAndColor(ultraGrid1.Rows.Band, "CHK"); 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; } } private void doUpdate() { //List rows = UltraGridGetChooseRows(this.ultraGrid1); //if (rows.Count==0) //{ // MessageUtil.ShowTips("请选择需要返库的数据!"); // return; //} //List list = new List(); //foreach (UltraGridRow row in rows) { // FrmGPRuleEntity entity = row.ListObject as FrmGPRuleEntity; // list.Add(entity); //} //FrmGPLocationDlog frm = new FrmGPLocationDlog(list); //frm.ob = this.ob; //frm.ShowDialog(); //if (frm.CloseEvent.Equals("update")) // this.doQuery(); 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) { strEntity.Add(JSONFormat.Format(row.ListObject as FrmGPRuleEntity)); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmGPRule"; ccp.MethodName = "insertYdmGpOutList"; ccp.ServerParams = new object[] { strEntity,this.UserInfo.GetUserName() }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp != null) { if (ccp.ReturnCode != -1) { MessageUtil.ShowWarning(ccp.ReturnInfo); return; } if (ccp.ReturnInfo.Equals("返库成功!")) { MessageUtil.ShowWarning("返库成功!"); doQuery(); } } } catch (System.Exception ex) { MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } 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.query", new object[] { arr,dic },this.ob); } 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; } } } }