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.StlMes.Client.ZGMil.Entity; using Core.Mes.Client.Comm.Server; using Infragistics.Win.UltraWinEditors; using Infragistics.Win.UltraWinGrid; using System.Collections; using Core.Mes.Client.Comm.Format; using Infragistics.Win; using System.Text.RegularExpressions; using Core.StlMes.Client.ZGMil.Common; namespace Core.StlMes.Client.ZGMil.Result { public partial class FrmQueryRidResult :FrmBase { private string Departm = "";//部门 private string PlineCode = "";//产线 private string[] plineCodes = { }; private string[] arrId = { }; public FrmQueryRidResult() { InitializeComponent(); this.IsLoadUserView = true; } private void FrmQueryRidResult_Load(object sender, EventArgs e) { DateTime now = DateTime.Now; DateTime dt1 = new DateTime(now.Year, now.Month, 1);//当月第一天 DateTime dt2 = dt1.AddMonths(1).AddDays(-1);//当月最后一天 NativeMethodNew na = new NativeMethodNew(this.ob); Departm = UserInfo.GetDepartment(); PlineCode = na.GetPCode(Departm);//获取 用户 对应的产线 plineCodes = BaseMethod.GetPlineCode(ValidDataPurviewIds, ob); arrId = this.ValidDataPurviewIds; RegStartTime.Value = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 00:00:00"); RegEndTime.Value = DateTime.Parse(dt2.ToString("yyyy-MM-dd") + " 23:59:59"); EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); DataTable ds = ServerHelper.GetData("com.steering.mes.signature.WarehousePermissions.getWarehousePermissionsStore", new object[] { arrId }, ob); if (ds != null && ds.Rows.Count > 0) { ultraSTORAGE_NO.DataSource = ds; ultraSTORAGE_NO.ValueMember = "STORAGE_NO"; ultraSTORAGE_NO.DisplayMember = "STORAGE_NAME"; } InitBaseResult(); } /// /// 将下拉框绑定到GRID列 /// /// 下拉框(已经初始化完成) /// 列名 /// 空间集合(每次只需填入this.Controls) /// GRID /// GRID的第几层结构 static void BindColumn(UltraComboEditor uce, string ColumnName, System.Windows.Forms.Control.ControlCollection con, UltraGrid ug, int i) { con.Add(uce); uce.Visible = false; ug.DisplayLayout.Bands[i].Columns[ColumnName].EditorComponent = uce; ug.DisplayLayout.Bands[i].Columns[ColumnName].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDown; SetComboItemHeight(uce); } /// /// 设置UltraComboEditor中的中文和非中文统一高度。 /// /// 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; } } } UltraComboEditor ridResult = new UltraComboEditor(); /// /// 加载处理结果 /// private void InitBaseResult() { ClsBaseInfo.FillComBaseInfo(ridResult, "5002", ob, true); FrmQueryRidResult.BindColumn(ridResult, "handleResult", this.Controls, this.ultraGrid1, 0); } /// /// 重写基类方法 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": doQueryData(); break; case "Update": updateRidResult(); break; case "Back": RegoodBack(); break; case "doSaveMemo": doSaveMemo(); break; case "Close": this.Close(); break; } } /// private void doSaveMemo() { this.ultraGrid1.UpdateData(); int m = 0; IQueryable checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMagRows.Count() == 0) { MessageUtil.ShowTips("请选择需要修改的信息!"); return; } ArrayList parm = new ArrayList(); foreach (UltraGridRow uRow in checkMagRows) { MilSlabScrapEntity milSlabEntity = (MilSlabScrapEntity)uRow.ListObject; string milSlabTity = JSONFormat.Format(milSlabEntity); parm.Add(milSlabTity); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.zgmil.coup.FrmQueryRidResult"; ccp.MethodName = "doSaveMemo"; ccp.ServerParams = new object[] { parm }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("操作成功!")) { doQueryData(); } MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } /// /// 查询 /// private void doQueryData() { string regStartTim = ""; string regEndTim = ""; string heatNo = ""; string processName = ""; NativeMethodNew na = new NativeMethodNew(this.ob); string plinCode = na.GetPCode(this.UserInfo.GetDepartment()); if (this.chkRegTime.Checked) { regStartTim = RegStartTime.Value.ToString(); regEndTim = RegEndTime.Value.ToString(); } if (this.chkFurnace.Checked) { heatNo = this.txtFurnace.Text.Trim(); } if (this.chkProcess.Checked) { processName = this.cmbProcess.Value.ToString(); } ArrayList parm = new ArrayList(); parm.Add(heatNo); parm.Add(processName); List listSource = EntityHelper.GetData( "com.steering.mes.zgmil.coup.FrmQueryRidResult.doQueryData", new object[] { parm, regStartTim, regEndTim, this.ultraOptionSet2.CheckedItem.DataValue.ToString(), plineCodes }, this.ob); MilSlabScrapEntitybindingSource.DataSource = listSource; } /// /// 撤销返库 /// private void RegoodBack() { this.ultraGrid1.UpdateData(); int m = 0; IQueryable checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMagRows.Count() == 0) { MessageUtil.ShowTips("请选择需要撤销返库的信息!"); return; } ArrayList parm = new ArrayList(); foreach (UltraGridRow uRow in checkMagRows) { if (uRow.Cells["HandleResult"].Text.Trim().Equals("返库") && uRow.Cells["Flag"].Text.Trim().Equals("已处理")) { m = m + 1; } MilSlabScrapEntity milSlabEntity = (MilSlabScrapEntity)uRow.ListObject; string milSlabTity = JSONFormat.Format(milSlabEntity); parm.Add(milSlabTity); } //if (m == 0) //{ // MessageUtil.ShowTips("请选择需要撤销返库的信息!"); // return; //} if (MessageUtil.ShowYesNoAndQuestion("是否确认撤销返库?") == DialogResult.No) { return; } ArrayList parm2 = new ArrayList(); parm2.Add(this.UserInfo.GetUserName()); parm2.Add(this.UserInfo.GetUserGroup()); parm2.Add(this.UserInfo.GetUserOrder()); parm2.Add(PlineCode); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.zgmil.coup.FrmQueryRidResult"; ccp.MethodName = "regoodBack"; ccp.ServerParams = new object[] { parm, parm2 }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("撤销返库成功!")) { doQueryData(); } MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } /// /// 返库 /// private void updateRidResult() { this.ultraGrid1.UpdateData(); int m = 0; IQueryable checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMagRows.Count() == 0) { MessageUtil.ShowTips("请选择需要修改的信息!"); return; } ArrayList parm = new ArrayList(); foreach(UltraGridRow uRow in checkMagRows) { if (uRow.Cells["HandleResult"].Text.Trim().Equals("")) { m = m + 1; } if (uRow.Cells["Flag"].Text.Trim().Equals("已处理")) { MessageUtil.ShowTips("已处理的数据不能修改!"); return; } //if (!uRow.Cells["ProcessNo"].Text.Trim().Contains("锯切") && !uRow.Cells["ActLen"].Text.Trim().Equals("")) //{ // MessageUtil.ShowTips("不是掉队坯不能写返库长度!"); // return; //} PlineCode = uRow.Cells["PlineCode"].Text.Trim(); MilSlabScrapEntity milSlabEntity = (MilSlabScrapEntity)uRow.ListObject; string milSlabTity = JSONFormat.Format(milSlabEntity); parm.Add(milSlabTity); } //if (m > 0) //{ // MessageUtil.ShowTips("请选择处理结果!"); // return; //} if (MessageUtil.ShowYesNoAndQuestion("是否确认返库?") == DialogResult.No) { return; } String STORAGE_NO = ""; String LOCATION_NO = ""; String LOCATION_NAME = ""; if (ultraCheckEditor1.Checked) { if (ultraSTORAGE_NO.SelectedIndex == -1) { MessageUtil.ShowTips("没有选择返库仓库,不能返库!"); return; } STORAGE_NO = ultraSTORAGE_NO.Value.ToString(); LOCATION_NO = cmbLocationNo.Tag.ToString(); LOCATION_NAME = cmbLocationNo.Text.ToString(); } else { if (PlineCode.Equals("C008")) { STORAGE_NO = "TCC7"; LOCATION_NO = "TCC710101"; LOCATION_NAME = "回库料架1-1"; } else if (PlineCode.Equals("C009")) { STORAGE_NO = "TCC5"; LOCATION_NO = "TCC510104"; LOCATION_NAME = "管坯库A区四号料架"; } else if (PlineCode.Equals("C010")) { STORAGE_NO = "TCC6"; LOCATION_NO = "TCC611202"; LOCATION_NAME = "虚拟库位"; } else if (PlineCode.Equals("C017")) { STORAGE_NO = "TCC8"; LOCATION_NO = "TCC811502"; LOCATION_NAME = "虚拟库位一号"; } else if (PlineCode.Equals("C072")) { STORAGE_NO = "TTH1"; LOCATION_NO = "TTH100001"; LOCATION_NAME = "S1A"; } } if (ultraBACK_FLAG.SelectedIndex == -1) { MessageUtil.ShowTips("没有选择坯料类型,不能返库!"); return; } ArrayList parm2 = new ArrayList(); parm2.Add(this.UserInfo.GetUserName()); parm2.Add(this.UserInfo.GetUserGroup()); parm2.Add(this.UserInfo.GetUserOrder()); parm2.Add(PlineCode); parm2.Add(STORAGE_NO); parm2.Add(LOCATION_NO); parm2.Add(LOCATION_NAME); parm2.Add(ultraBACK_FLAG.Value.ToString()); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.zgmil.coup.FrmQueryRidResult"; ccp.MethodName = "updateResult"; ccp.ServerParams = new object[] { parm, parm2 }; ccp = ob.ExecuteNonQuery(ccp,CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("返库成功!")) { MessageUtil.ShowTips(ccp.ReturnInfo); doQueryData(); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } private void chkFurnace_CheckedChanged(object sender, EventArgs e) { this.txtFurnace.Enabled = this.chkFurnace.Checked; } private void chkProcess_CheckedChanged(object sender, EventArgs e) { this.cmbProcess.Enabled = this.chkProcess.Checked; } private void ultraGrid1_AfterSelectChange(object sender, AfterSelectChangeEventArgs e) { foreach (UltraGridRow uRow in ultraGrid1.Selected.Rows) { if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow)) { uRow.Cells["CHK"].Value = true; } } } private void chkRegTime_CheckedChanged(object sender, EventArgs e) { this.RegStartTime.Enabled = this.chkRegTime.Checked; this.RegEndTime.Enabled = this.chkRegTime.Checked; } private void ultraCheckEditor1_CheckedChanged(object sender, EventArgs e) { this.ultraSTORAGE_NO.Enabled = ultraCheckEditor1.Checked; this.cmbLocationNo.Enabled = ultraCheckEditor1.Checked; } private void cmbLocationNo_EditorButtonClick(object sender, EditorButtonEventArgs e) { DataTable dt = ServerHelper.GetData("com.steering.mes.signature.WarehousePermissions.getLocationNoByStorageNo", new object[] { ultraSTORAGE_NO.Value.ToString() }, ob); dt.Columns["LOCATION_NAME"].Caption = "料位名称"; BaseInfoPopup baseInfo = new BaseInfoPopup(dt, "LOCATION_NAME", "LOCATION_NO"); baseInfo.Shown += new EventHandler((a, b) => { var actRow = baseInfo.UltraGrid1.Rows.AsQueryable().Where( c => c.GetValue("LOCATION_NO") == this.cmbLocationNo.Tag.ToString2()).FirstOrDefault(); if (actRow != null) actRow.Activate(); }); if (baseInfo.ShowDialog() == System.Windows.Forms.DialogResult.OK) { cmbLocationNo.Tag = baseInfo.ChoicedRow.GetValue("LOCATION_NO"); cmbLocationNo.Text = baseInfo.ChoicedRow.GetValue("LOCATION_NAME"); //this.ultraGrid3.ActiveCell.Value = baseInfo.ChoicedRow.GetValue("LOCATION_NAME"); //this.ultraGrid3.ActiveCell.Row.Cells["LOCATION_NO"].Value = baseInfo.ChoicedRow.GetValue("LOCATION_NO"); } } } }