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 System.Collections; using CoreFS.CA06; using com.steering.pss.plan.order.model; using Core.Mes.Client.Comm.Tool; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm; using Infragistics.Win.UltraWinGrid; namespace Core.StlMes.Client.Plan.Order.PopupWindow { public partial class FrmReqRequest : FrmBase { /// /// 合同订货量 /// private double orderQty = 0; /// /// 米单重 /// private double weightPerM = 0; private PlnSaleorderRNumEntity reqEntity = null; public FrmReqRequest() { InitializeComponent(); } public FrmReqRequest(OpeBase opeBase, PlnSaleorderRNumEntity reqentity, double qty, double weightM) { orderQty = qty; weightPerM = weightM; reqEntity = reqentity; this.ob = opeBase; InitializeComponent(); } private void FrmReqRequest_Load(object sender, EventArgs e) { ultraTextOrderNo.Value = reqEntity.OrderNo + "/" + reqEntity.OrderSeq; ultraTextOrderUnit.Value = reqEntity.OrderUnit; ultraNumericOrderQty.Value = orderQty; EntityHelper.ShowGridCaption(ultraGridReqApply.DisplayLayout.Bands[0]); DoQuery(); } private void ultraToolbarsReq_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { switch (e.Tool.Key) { case "doQuery": DoQuery(); break; case "doAdd": DoAdd(); break; case "doModify": DoModify(); break; case "doDelete": DoDelete(); break; case "Close": this.Close(); break; } } /// /// 查询 /// private void DoQuery() { List listSource = EntityHelper.GetData( "com.steering.pss.plan.order.CoreReqRequest.getOrdRNum", new object[] { reqEntity.OrdLnDlyPk }, this.ob); slmPlnSaleorderRNumEntitybindingSource.DataSource = listSource; PlanComm.setGridActivation(ultraGridReqApply.DisplayLayout.Bands[0], "CHC"); } /// /// 新增补量申请 /// private void DoAdd() { try { ArrayList list = new ArrayList(); if (Convert.ToDecimal(this.ultraNumericReq.Value) <= 0) { MessageUtil.ShowTips("申请量不能小于零!"); return; } reqEntity.RepQty = this.ultraNumericReq.Value.ToString(); reqEntity.RepReason = this.ultraTextReqReason.Text.Trim(); reqEntity.ReqName = UserInfo.GetUserName(); switch (reqEntity.OrderUnit) { case "米": reqEntity.Reqweight = Math.Round(weightPerM * Convert.ToDouble(ultraNumericReq.Value), 3).ToString(); break; case "英尺": reqEntity.Reqweight = Math.Round(weightPerM * PlanComm.FootoMi(Convert.ToDouble(ultraNumericReq.Value)), 3).ToString(); break; default: reqEntity.Reqweight = this.ultraNumericReq.Value.ToString(); break; } list.Add(reqEntity); int succed = ServerHelper.SetData("com.steering.pss.plan.order.CoreReqRequest.addOrderRNum", new Object[] { list }, this.ob); if (succed > 0) { MessageUtil.ShowTips("新增成功!"); } else { MessageUtil.ShowTips("新增失败!"); } } catch (Exception ex) { if (ex is MESException) { } else { MessageBox.Show(ex.Message); } } DoQuery(); } /// /// 修改申请 /// private void DoModify() { try { UltraGridRow ugr = ultraGridReqApply.ActiveRow; if (ugr == null) { return; } PlnSaleorderRNumEntity rNumEntity = new PlnSaleorderRNumEntity(); rNumEntity.RNumId = ugr.Cells["RNumId"].Value.ToString(); rNumEntity.RepQty = ultraNumericReq.Value.ToString(); rNumEntity.RepReason = ultraTextReqReason.Text.Trim(); switch (ugr.Cells["OrderUnit"].Value.ToString()) { case "米": rNumEntity.Reqweight = Math.Round(weightPerM * Convert.ToDouble(ultraNumericReq.Value), 3).ToString(); break; case "英尺": rNumEntity.Reqweight = Math.Round(weightPerM * PlanComm.FootoMi(Convert.ToDouble(ultraNumericReq.Value)), 3).ToString(); break; default: rNumEntity.Reqweight = this.ultraNumericReq.Value.ToString(); break; } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.plan.order.CoreReqRequest"; ccp.MethodName = "doModify"; ccp.ServerParams = new object[] { rNumEntity }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("")) { MessageUtil.ShowTips("修改成功!"); } else { MessageUtil.ShowError("修改失败:" + ccp.ReturnInfo); } } else { MessageUtil.ShowError("修改失败:" + ccp.ReturnInfo); } } catch (Exception ex) { MessageBox.Show(ex.Message); } DoQuery(); } /// /// 删除申请 /// private void DoDelete() { try { ArrayList list = new ArrayList(); ultraGridReqApply.UpdateData(); IQueryable checkRows = ultraGridReqApply.Rows.AsQueryable().Where(" CHC = 'True' "); if (checkRows.Count() == 0) { MessageUtil.ShowTips("未勾选任何行!"); return; } foreach (UltraGridRow uRow in checkRows) { list.Add(uRow.Cells["RNumId"].Value.ToString()); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.plan.order.CoreReqRequest"; ccp.MethodName = "deleteOrderRNum"; ccp.ServerParams = new object[] { list }; ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("")) { MessageUtil.ShowTips("删除成功!"); } else { MessageUtil.ShowError("删除失败:" + ccp.ReturnInfo); } } else { MessageUtil.ShowError("删除失败:" + ccp.ReturnInfo); } } catch (Exception ex) { MessageBox.Show(ex.Message); } DoQuery(); } private void ultraGridReqApply_BeforeRowActivate(object sender, Infragistics.Win.UltraWinGrid.RowEventArgs e) { if (e.Row != null && e.Row.Cells["RepQty"].Value != null) { this.ultraNumericReq.Value = e.Row.Cells["RepQty"].Value.ToString(); this.ultraTextReqReason.Value = e.Row.Cells["RepReason"].Value.ToString(); } } } }