using Core.Mes.Client.Comm.Format; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.YdmStuffManage.Entity; using CoreFS.CA06; using Infragistics.Win.UltraWinGrid; using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Core.StlMes.Client.YdmStuffManage { public partial class FrmSubContractResult : FrmBase { public FrmSubContractResult() { InitializeComponent(); } private string[] arr = null; private void FrmSubContractResult_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);//当月最后一天 this.StartTime.Value = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 00:00:00"); this.EndTime.Value = DateTime.Parse(dt2.ToString("yyyy-MM-dd") + " 23:59:59"); EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); EntityHelper.ShowGridCaption(ultraGrid2.DisplayLayout.Bands[0]); arr = BaseMethod.InitLgPermissions(this.ValidDataPurviewIds, "C", this.ob); } /// /// 重写基类方法 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "Query": doQueryEntrust(); break; case "SubContractComplete": subContractComplete(); break; case "CancelSubContractComplete": cancelSubContractComplete(); break; case "Close": this.Close(); break; } } /// /// 数据验证 /// /// private bool CheckQuery() { if (this.chkSubContractNo.Checked && string.IsNullOrEmpty(this.txtSubContractNo.Text.Trim())) { MessageUtil.ShowWarning("请输入委托单号!"); return false; } if (this.chkSubContractLog.Checked && string.IsNullOrEmpty(this.cmbSubContractLog.Text.Trim())) { MessageUtil.ShowTips("请选择委托单状态!"); return false; } return true; } /// /// 查询委托信息 /// private void doQueryEntrust() { string subContractNo = ""; string subContractLog = ""; string startTim = ""; string endTim = ""; if (!CheckQuery()) { return; } if (this.chkTim.Checked) { startTim = this.StartTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); endTim = this.EndTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); } if (this.chkSubContractNo.Checked) { subContractNo = this.txtSubContractNo.Text.Trim(); } if (this.chkSubContractLog.Checked) { subContractLog = this.cmbSubContractLog.Value.ToString(); } ArrayList parmList = new ArrayList(); parmList.Add(subContractNo); parmList.Add(subContractLog); List listSource = EntityHelper.GetData( "Core.LgMes.Server.Stuffmanage.FrmSubContractResult.doQueryEntrustDz", new object[] { parmList, startTim, endTim, arr }, this.ob); FrgEntrustedBillEntitybindingSource.DataSource = listSource; } /// /// 委托回报完成 /// private void subContractComplete() { this.ultraGrid2.UpdateData(); string storeNo = ""; string strInBound = "800701"; string departId = ClsLoad.GetDepartIdBySectionId(this.UserInfo.GetDeptid(), this.ob); string departMent = ClsLoad.GetDepartBySectionId(this.UserInfo.GetDeptid(), this.ob); string[] storeType = new string[4]; UltraGridRow uRow = this.ultraGrid1.ActiveRow; if (uRow == null) { MessageUtil.ShowTips("请选择需要回报实绩的委托信息!"); return; } IQueryable checkMags = this.ultraGrid2.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkMags.Count() == 0) { MessageUtil.ShowTips("请勾选需要回报的实绩信息!"); return; } if (uRow.Cells["PlineCode"].Text.Equals("C005")) { storeNo = "XED1"; } else { MessageUtil.ShowTips("未获取到所在科室,无法交库!"); return; } storeType = getStoreType(storeNo); ArrayList parmList = new ArrayList(); int chCount = 0; int trCount = 0; foreach (UltraGridRow row in checkMags) { FrgEntrustedBillResultEntity frgEntity = (FrgEntrustedBillResultEntity)row.ListObject; if (!checkResult(frgEntity)) { return; } chCount = chCount + int.Parse(frgEntity.ActCount.ToString()) * int.Parse(frgEntity.OutnumCut.ToString()); string frgEntrustResultTity = JSONFormat.Format(frgEntity); parmList.Add(frgEntrustResultTity); } FrgEntrustedBillEntity frgBillTity = (FrgEntrustedBillEntity)uRow.ListObject; trCount = int.Parse(frgBillTity.SubcontractNum.ToString()) * int.Parse(frgBillTity.InnumCut.ToString()); string frgEntrsutBillTity = JSONFormat.Format(frgBillTity); //if (chCount > trCount) //{ // MessageUtil.ShowTips("回报的产出单倍坯支数大于委托的单倍坯支数,请核实!"); // return; //} CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmSubContractResult"; ccp.MethodName = "subContractComplete"; ccp.ServerParams = new object[] { frgEntrsutBillTity, parmList, UserInfo.GetUserName(), storeNo, strInBound, storeType, this.UserInfo.GetDeptid(), this.UserInfo.GetDepartment(), departId, departMent }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("回报成功!")) { doQueryEntrust(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } /// /// 查询仓库类型 /// /// /// private string[] getStoreType(string storeNo) { string[] storeType = new string[4]; DataTable dt = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmStuffInputStore.getStoreType", new object[] { storeNo }, ob); if (dt.Rows.Count > 0) { storeType[0] = dt.Rows[0]["STORAGE_ATTR"].ToString(); storeType[1] = dt.Rows[0]["STORAGE_ATTR_NAME"].ToString(); storeType[2] = dt.Rows[0]["STORAGE_TYPE_NO"].ToString(); storeType[3] = dt.Rows[0]["STORAGE_TYPE_NAME"].ToString(); } return storeType; } /// /// 验证实绩信息 /// /// private bool checkResult(FrgEntrustedBillResultEntity frgResultTity) { if (frgResultTity.JudgeStoveNo.ToString() == "") { MessageUtil.ShowTips("实绩回报时判定炉号不能为空!"); return false; } if (frgResultTity.DimaterOut.ToString() == ""|| !StringUtil.IsInt(frgResultTity.DimaterOut.ToString3())) { MessageUtil.ShowTips("实绩回报的产出直径需为正整数!"); return false; } if (frgResultTity.LenGpSingle.ToString() == "" || !StringUtil.IsInt(frgResultTity.LenGpSingle.ToString3())) { MessageUtil.ShowTips("实绩回报的单倍长度需为正整数!"); return false; } if (frgResultTity.OutnumCut.ToString() == "" || !StringUtil.IsInt(frgResultTity.OutnumCut.ToString3())) { MessageUtil.ShowTips("实绩回报的倍尺数需为正整数!"); return false; } if (frgResultTity.LengthOut.ToString() == "" || !StringUtil.IsInt(frgResultTity.LengthOut.ToString3())) { MessageUtil.ShowTips("实绩回报的坯料长度需为正整数!"); return false; } if (frgResultTity.ActCount.ToString() == "" || !StringUtil.IsInt(frgResultTity.ActCount.ToString3())) { MessageUtil.ShowTips("实绩回报的合格支数需为正整数!"); return false; } if (frgResultTity.ActWeight.ToString() == "" || !StringUtil.IsDouble(frgResultTity.ActCount.ToString3())) { MessageUtil.ShowTips("实绩回报的合格重量需为正浮点数!"); return false; } return true; } /// /// 撤销委托完成 /// private void cancelSubContractComplete() { this.ultraGrid1.UpdateData(); UltraGridRow uRow = this.ultraGrid1.ActiveRow; if (uRow == null) { MessageUtil.ShowTips("请选择需要撤销委外实绩的委托信息"); return; } FrgEntrustedBillEntity frgEntrustTity = (FrgEntrustedBillEntity)uRow.ListObject; string frgEntrustEntity = JSONFormat.Format(frgEntrustTity); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmSubContractResult"; ccp.MethodName = "cancelSubContractComplete"; ccp.ServerParams = new object[] { frgEntrustEntity }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("撤销成功!")) { doQueryEntrust(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } private void chkTim_CheckedChanged(object sender, EventArgs e) { this.StartTime.Enabled = this.EndTime.Enabled = this.chkTim.Checked; } private void chkSubContractNo_CheckedChanged(object sender, EventArgs e) { this.txtSubContractNo.Enabled = this.chkSubContractNo.Checked; } private void chkSubContractLog_CheckedChanged(object sender, EventArgs e) { this.cmbSubContractLog.Enabled = this.chkSubContractLog.Checked; } private void ultraGrid2_CellChange(object sender, CellEventArgs e) { UltraGridRow uRow = this.ultraGrid1.ActiveRow; UltraGridRow row = this.ultraGrid2.ActiveRow; if(uRow == null)return; //米单重 double mSingleWeight = (7.8 * 3.1415926 / 4 * int.Parse(row.Cells["DimaterOut"].Text.ToString3()) * int.Parse(row.Cells["DimaterOut"].Text.ToString3())) / 1000 / 1000;// 米单重 // 倍尺坯单支重=坯米单重*倍尺坯长/1000 double weightM = mSingleWeight * (int.Parse(row.Cells["LengthOut"].Text.ToString3()) / 1000d); if(e.Cell.Column.Key == "CHK") { e.Cell.Row.Cells["LenGpSingle"].Value = uRow.Cells["LenGpSingleOut"].Text.ToString(); e.Cell.Row.Cells["DimaterOut"].Value = uRow.Cells["DiameterOut"].Text.ToString(); } if (e.Cell.Column.Key == "OutnumCut") { e.Cell.Row.Cells["LengthOut"].Value = (int.Parse(row.Cells["LenGpSingle"].Text.ToString3()) * int.Parse(row.Cells["OutnumCut"].Text.Trim().ToString3())).ToString(); } if (e.Cell.Column.Key == "ActCount") { e.Cell.Row.Cells["ActWeight"].Value = Math.Round(int.Parse(row.Cells["ActCount"].Text) * weightM,3).ToString(); } if (e.Cell.Column.Key == "LenGpSingle") { e.Cell.Row.Cells["LengthOut"].Value = (int.Parse(row.Cells["LenGpSingle"].Text.ToString3()) * int.Parse(row.Cells["OutnumCut"].Text.Trim().ToString3())).ToString(); } } private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { UltraGridRow uRow = this.ultraGrid1.ActiveRow; if (uRow == null) return; List listSource = EntityHelper.GetData( "Core.LgMes.Server.Stuffmanage.FrmSubContractResult.doQueryEntrustBillResult", new object[] { uRow.Cells["subcontractNo"].Text, uRow.Cells["subcontractNoSeq"].Text }, this.ob); FrgEntrustedBillResultEntitybindingSource.DataSource = listSource; } private void txtDimter_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { this.ultraGrid2.UpdateData(); DataTable dt = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmBaseInformation.doQueryDimaterAll", new object[] { }, ob); dt.Columns["SPEC_NAME"].Caption = "直径"; BaseInfoPopup baseInfo = new BaseInfoPopup(dt, "SPEC_NAME", "SPEC_CODE"); baseInfo.Shown += new EventHandler((a, b) => { var actRow = baseInfo.UltraGrid1.Rows.AsQueryable().Where( c => c.GetValue("SPEC_CODE") == this.txtDimter.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.ultraGrid2.ActiveCell.Value = baseInfo.ChoicedRow.GetValue("SPEC_NAME"); this.ultraGrid2.ActiveCell.Row.Cells["DimaterOut"].Value = baseInfo.ChoicedRow.GetValue("SPEC_NAME").Replace(".00",""); } } } }