| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360 |
- 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<FrgEntrustedBillEntity>(ultraGrid1.DisplayLayout.Bands[0]);
- EntityHelper.ShowGridCaption<FrgEntrustedBillResultEntity>(ultraGrid2.DisplayLayout.Bands[0]);
- arr = BaseMethod.InitLgPermissions(this.ValidDataPurviewIds, "C", this.ob);
- }
- /// <summary>
- /// 重写基类方法
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="ToolbarKey"></param>
- 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;
- }
- }
- /// <summary>
- /// 数据验证
- /// </summary>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 查询委托信息
- /// </summary>
- 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<FrgEntrustedBillEntity> listSource = EntityHelper.GetData<FrgEntrustedBillEntity>(
- "Core.LgMes.Server.Stuffmanage.FrmSubContractResult.doQueryEntrustDz", new object[] { parmList, startTim, endTim, arr }, this.ob);
- FrgEntrustedBillEntitybindingSource.DataSource = listSource;
- }
- /// <summary>
- /// 委托回报完成
- /// </summary>
- 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<UltraGridRow> 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);
- }
- }
- }
- /// <summary>
- /// 查询仓库类型
- /// </summary>
- /// <param name="storeNo"></param>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 验证实绩信息
- /// </summary>
- /// <returns></returns>
- 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;
- }
- /// <summary>
- /// 撤销委托完成
- /// </summary>
- 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<FrgEntrustedBillResultEntity> listSource = EntityHelper.GetData<FrgEntrustedBillResultEntity>(
- "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","");
- }
- }
- }
- }
|