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 Core.Mes.Client.Comm.Server; using CoreFS.CA06; using System.Collections; using Core.Mes.Client.Comm.Control; using Infragistics.Win.UltraWinGrid; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Mcp.Control; using com.steering.mes.mcp.entity; using Core.Mes.Client.Comm.Format; using Core.StlMes.Client.Mcp.Control.Base; using Infragistics.Win; namespace Core.StlMes.Client.Mcp.Report { public partial class FrmJGMatReport : FrmBase { public FrmJGMatReport() { InitializeComponent(); this.IsLoadUserView = true; } private void FrmJGMatReport_Load(object sender, EventArgs e) { EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGrid2.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGrid4.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGrid5.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGrid3.DisplayLayout.Bands[0]); DateTime t = DateTime.Now; DateTime t1 = new DateTime(t.Year, t.Month, 1); RegStartTime.Value = DateTime.Parse(t1.ToString("yyyy-MM-dd 00:00:00")); RegEndTime.Value = DateTime.Parse(t1.AddMonths(1).AddDays(-1).ToString("yyyy-MM-dd 23:59:59")); //框号 DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Report.FrmJGMatNoReport.getKepNo", null, this.ob); cmbMaterial.DataSource = dt; cmbMaterial.DisplayMember = "KEP_NO"; PipeManageClass.SetComboItemHeight(cmbMaterial); String[] str = this.ValidDataPurviewIds; ArrayList arList = new ArrayList(); //获取用户对应科室ID string User = this.UserInfo.GetDeptid(); string StorageType = "";//根据传递的参数获取仓库类别 string StorageAttr = "";////根据传递的参数获取仓库类型 if (CustomInfo != "") { string[] strflg = CustomInfo.ToString().Split(new char[] { ',' }); StorageType = strflg[0]; StorageAttr = strflg[1]; } DataTable dt1 = ServerHelper.GetData("com.steering.mes.mcp.common.WarehousePermissions.getStoreNo", new object[] { StorageType, StorageAttr, str }, this.ob); cmbWarehous.DataSource = dt1; cmbWarehous.DisplayMember = "STORAGE_NAME"; cmbWarehous.ValueMember = "STORAGE_NO"; PipeManageClass.SetComboItemHeight(cmbWarehous); } public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": doQuery(); break; case "Extinction": Extinction(); break; case "doUpdate": doUpdate(); break; case "Export": if (ultraTabControl1.SelectedTab.Key.Equals("0")) { GridHelper.ulGridToExcel(ultraGrid4, "库存信息"); } else if (ultraTabControl1.SelectedTab.Key.Equals("1")) { GridHelper.ulGridToExcel(ultraGrid1, "库存信息"); } else if (ultraTabControl1.SelectedTab.Key.Equals("2")) { GridHelper.ulGridToExcel(ultraGrid5, "库存信息"); } break; case "Close": this.Close(); break; } } /// /// 消亡 /// private void Extinction() { this.ultraGrid1.UpdateData(); 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) { CouplingMatButtressEntity matButtress = (CouplingMatButtressEntity)uRow.ListObject; string matButtressTity = JSONFormat.Format(matButtress); parm.Add(matButtressTity); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.Report.FrmJGMatNoReport"; ccp.MethodName = "Extinction"; ccp.ServerParams = new object[] { parm, UserInfo.GetUserName()}; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("消亡成功!")) { doQuery(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } /// /// 修改物料 /// private void doUpdate() { this.ultraGrid1.UpdateData(); 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) { CouplingMatButtressEntity matButtress = (CouplingMatButtressEntity)uRow.ListObject; string matButtressTity = JSONFormat.Format(matButtress); parm.Add(matButtressTity); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.Report.FrmJGMatNoReport"; ccp.MethodName = "doUpdate"; ccp.ServerParams = new object[] { parm }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("修改成功!")) { doQuery(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } /// /// 查询 /// private void doQuery() { if (!CheckQuery()) return; string strRegStart = ""; string strRegEnd = ""; string strWare = "";//仓库号 //string strMat = "";//框号 string strFurnace = "";//炉号 string strBatch = "";//批号 string strWoid = "";//工单号 string qcmStaus = ""; //交货状态 ArrayList pram = new ArrayList(); if (chkWarehous.Checked) { strWare = cmbWarehous.Value.ToString(); } //if (chkMaterial.Checked) //{ // strMat = cmbMaterial.Value.ToString(); //} if (chkRegTime.Checked) { strRegStart = RegStartTime.Value.ToString(); strRegEnd = RegEndTime.Value.ToString(); } else { strRegStart = "1"; } if (chkFurnace.Checked) { strFurnace = txtFurnace.Text.Trim(); } if (chkBatch.Checked) { strBatch = txtBatch.Text.Trim(); } if (chkQcmStaus.Checked) { qcmStaus = cmbQcmStaus.Text.Trim(); } pram.Add(strWare); pram.Add(""); pram.Add(strFurnace); pram.Add(strRegStart); pram.Add(strRegStart); pram.Add(strRegStart); pram.Add(strRegEnd); pram.Add(strRegEnd); pram.Add(strBatch); pram.Add(qcmStaus); //DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Report.FrmJGMatNoReport.doQueryInfoResult", new object[] { pram }, ob); //GridHelper.CopyDataToDatatable(dt, this.dateMat, true); List listSource = EntityHelper.GetData ("com.steering.mes.mcp.Report.FrmJGMatNoReport.getQueryCouplingMatTogether", new object[] { pram }, this.ob); bindingSource1.DataSource = listSource; GridHelper.RefreshAndAutoSize(ultraGrid4); List listSource1 = EntityHelper.GetData ("com.steering.mes.mcp.Report.FrmJGMatNoReport.getQueryCouplingMat", new object[] { pram }, this.ob); CouplingMatButtEntitybindingSource1.DataSource = listSource1; GridHelper.RefreshAndAutoSize(ultraGrid1); List listSource2 = EntityHelper.GetData ("com.steering.mes.mcp.Report.FrmJGMatNoReport.getQueryCouplingMat2", new object[] { pram }, this.ob); bindingSource2.DataSource = listSource2; GridHelper.RefreshAndAutoSize(ultraGrid5); } private void chkRegTime_CheckedChanged(object sender, EventArgs e) { if (chkBatch.Checked) { txtBatch.Enabled = true; } else { txtBatch.Enabled = false; } if (chkWarehous.Checked) { cmbWarehous.Enabled = true; } else { cmbWarehous.Enabled = false; } if (chkMaterial.Checked) { cmbMaterial.Enabled = true; } else { cmbMaterial.Enabled = false; } if (chkFurnace.Checked) { txtFurnace.Enabled = true; } else { txtFurnace.Enabled = false; } if (chkRegTime.Checked) { RegStartTime.Enabled = true; RegEndTime.Enabled = true; } else { RegStartTime.Enabled = false; RegEndTime.Enabled = false; } } ///查询时验证必填项 private bool CheckQuery() { if (DataTimeUtil.JudgeTime(DateTime.Parse(RegStartTime.Value.ToString()), DateTime.Parse(RegEndTime.Value.ToString())) == 0) { MessageUtil.ShowTips("开始时间不能大于结束时间!"); return false; } if (chkFurnace.Checked && string.IsNullOrEmpty(txtFurnace.Text.Trim())) { MessageBox.Show("请输入炉号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } if (chkBatch.Checked && string.IsNullOrEmpty(txtBatch.Text.Trim())) { MessageBox.Show("请输入批号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } if (chkWarehous.Checked && string.IsNullOrEmpty(cmbWarehous.Text.Trim())) { MessageBox.Show("请选择仓库号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } if (chkMaterial.Checked && string.IsNullOrEmpty(cmbMaterial.Text.Trim())) { MessageBox.Show("请选择框号!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return false; } return true; } private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { UltraGridRow urg = ultraGrid1.ActiveRow; if (urg == null) return; string woid = urg.Cells["WoId"].Text; string matNo = urg.Cells["MatNo"].Text; string judgeNo = urg.Cells["JudgeStoveNo"].Text; //查询框号信息 getQueryLocation(matNo); //查询合同相关信息 getQueryOrder(woid,judgeNo); } //查询框号信息 public void getQueryLocation(string matNo) { List listSource1 = EntityHelper.GetData ("com.steering.mes.mcp.Report.FrmJGMatNoReport.getQueryLocation", new object[] { matNo }, this.ob); CouplingButtbindingSource1.DataSource = listSource1; GridHelper.RefreshAndAutoSize(ultraGrid2); } //查询合同相关信息 public void getQueryOrder(string woid,string judgeNo) { List listSource1 = EntityHelper.GetData ("com.steering.mes.mcp.Report.FrmJGMatNoReport.getQueryOrder", new object[] { woid,judgeNo }, this.ob); PlnZyJgMiddlebindingSource1.DataSource = listSource1; GridHelper.RefreshAndAutoSize(ultraGrid3); } private void ultraGrid1_AfterSelectChange(object sender, AfterSelectChangeEventArgs e) { foreach (UltraGridRow uRow in ultraGrid1.Selected.Rows) { if (uRow.GetType() != typeof(UltraGridGroupByRow)) { uRow.Cells["CHK"].Value = true; } } } private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { this.ultraGrid1.UpdateData(); DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.Report.FrmJGMatNoReport.getBaseMaterialForChoose", new object[] { }, ob); dt.Columns["BASENAME"].Caption = "物料名称"; BaseInfoPopup baseInfo = new BaseInfoPopup(dt, "BASENAME", "BASECODE"); baseInfo.Shown += new EventHandler((a, b) => { var actRow = baseInfo.UltraGrid1.Rows.AsQueryable().Where( c => c.GetValue("BASECODE") == this.cmbMaterial.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.ultraGrid1.ActiveCell.Value = baseInfo.ChoicedRow.GetValue("BASENAME"); this.ultraGrid1.ActiveCell.Row.Cells["BlWlId"].Value = baseInfo.ChoicedRow.GetValue("BASECODE"); } } private void FrmJGMatReport_Shown(object sender, EventArgs e) { toolMenu.Toolbars[0].Tools["Extinction"].InstanceProps.Visible = DefaultableBoolean.False; toolMenu.Toolbars[0].Tools["doUpdate"].InstanceProps.Visible = DefaultableBoolean.False; } private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e) { if (toolMenu == null) return; if (ultraTabControl1.SelectedTab.Key.Equals("0")) { toolMenu.Toolbars[0].Tools["Extinction"].InstanceProps.Visible = DefaultableBoolean.False; toolMenu.Toolbars[0].Tools["doUpdate"].InstanceProps.Visible = DefaultableBoolean.False; } if (ultraTabControl1.SelectedTab.Key.Equals("1")) { toolMenu.Toolbars[0].Tools["Extinction"].InstanceProps.Visible = DefaultableBoolean.True; toolMenu.Toolbars[0].Tools["doUpdate"].InstanceProps.Visible = DefaultableBoolean.True; } if (ultraTabControl1.SelectedTab.Key.Equals("2")) { toolMenu.Toolbars[0].Tools["Extinction"].InstanceProps.Visible = DefaultableBoolean.False; toolMenu.Toolbars[0].Tools["doUpdate"].InstanceProps.Visible = DefaultableBoolean.False; } } } }