| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452 |
- 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 FrmSubContractAffrim : FrmBase
- {
- public FrmSubContractAffrim()
- {
- InitializeComponent();
- }
- private void FrmSubContractAffrim_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<StlLgEntrustBillEntity>(ultraGrid1.DisplayLayout.Bands[0]);
- EntityHelper.ShowGridCaption<StlLgEntrustBillDetialEntity>(ultraGrid2.DisplayLayout.Bands[0]);
- }
- /// <summary>
- /// 重写基类方法
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="ToolbarKey"></param>
- public override void ToolBar_Click(object sender, string ToolbarKey)
- {
- switch (ToolbarKey)
- {
- case"Query":
- doQueryEntrustBill();
- break;
- case "subcontractComplete":
- subcontractComplete();
- break;
- case "cancelSubcontractComplete":
- cancelSubcontractComplete();
- break;
- case"doAffrim":
- doAffrim();
- break;
- case"cancelDoAffrim":
- cancelDoAffrim();
- break;
- case "Close":
- this.Close();
- break;
- }
- }
- /// <summary>
- /// 确认实绩
- /// </summary>
- private void doAffrim()
- {
- this.ultraGrid1.UpdateData();
- UltraGridRow uRow = this.ultraGrid1.ActiveRow;
- if (uRow == null) return;
- if (uRow.Cells["SubcontractFlag"].Value.Equals("未完成"))
- {
- MessageUtil.ShowTips("请先回报实绩,完成委托!");
- return;
- }
- StlLgEntrustBillEntity stlLgEntity = (StlLgEntrustBillEntity)uRow.ListObject;
- string stlLgTity = JSONFormat.Format(stlLgEntity);
- if (MessageUtil.ShowYesNoAndQuestion("是否确认该委托实绩?") == DialogResult.No) return;
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmSubContractAffrim";
- ccp.MethodName = "doAffrim";
- ccp.ServerParams = new object[] { stlLgTity,UserInfo.GetUserName() };
- ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- if (ccp.ReturnInfo.Equals("确认成功!"))
- {
- doQueryEntrustBill();
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- else
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- }
- }
- /// <summary>
- /// 撤销确认
- /// </summary>
- private void cancelDoAffrim()
- {
- this.ultraGrid1.UpdateData();
- UltraGridRow uRow = this.ultraGrid1.ActiveRow;
- if (uRow == null) return;
- StlLgEntrustBillEntity stlLgEntity = (StlLgEntrustBillEntity)uRow.ListObject;
- string stlLgTity = JSONFormat.Format(stlLgEntity);
- if (MessageUtil.ShowYesNoAndQuestion("是否撤销确认?") == DialogResult.No) return;
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmSubContractAffrim";
- ccp.MethodName = "cancelDoAffrim";
- ccp.ServerParams = new object[] { stlLgTity,this.UserInfo.GetUserName() };
- ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- if (ccp.ReturnInfo.Equals("撤销成功!"))
- {
- doQueryEntrustBill();
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- else
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- }
- }
- /// <summary>
- /// 委外完成
- /// </summary>
- private void subcontractComplete()
- {
- this.ultraGrid2.UpdateData();
- int toalNum = 0;
- string dbWgt = "";//单倍尺重量
- decimal quailToalWgt = 0;//合格总重量
- 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 (!CheckQuerySub()) return;
- StlLgEntrustBillEntity stlEntrust = (StlLgEntrustBillEntity)uRow.ListObject;
- string stlLgEntrustTity = JSONFormat.Format(stlEntrust);
- DataTable ds = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmSubContractAffrim.doQueryDbWgt", new object[] { stlLgEntrustTity }, ob);
- if(ds.Rows.Count>0)
- {
- dbWgt = ds.Rows[0]["WEIGHT_GP_ONE"].ToString();
- }
- ArrayList parm = new ArrayList();
- foreach (UltraGridRow row in checkMags)
- {
- StlLgEntrustBillDetialEntity stlLgEntrustDetial = (StlLgEntrustBillDetialEntity)row.ListObject;
- if (int.Parse(stlLgEntrustDetial.ComFixNum.ToString3()) > int.Parse(uRow.Cells["FixNum"].Text))
- {
- MessageUtil.ShowTips("回报的倍尺数不允许比原倍尺大");
- return;
- }
- if (stlLgEntrustDetial.SubcontractcompleteNum * stlLgEntrustDetial.ComFixNum == stlEntrust.FixNum * stlEntrust.SubcontractNum)
- {
- stlLgEntrustDetial.SubcontractCompleteWgt = stlEntrust.SubcontractWgt;
- }
- else
- {
- stlLgEntrustDetial.SubcontractCompleteWgt = int.Parse(stlLgEntrustDetial.ComFixNum.ToString()) * int.Parse(stlLgEntrustDetial.SubcontractcompleteNum.ToString()) * decimal.Parse(dbWgt);
- }
-
- stlLgEntrustDetial.ComLength = int.Parse(stlEntrust.Length.ToString()) * int.Parse(stlLgEntrustDetial.ComFixNum.ToString()) / int.Parse(stlEntrust.FixNum.ToString());
- string stlLgEntrustDetialTity = JSONFormat.Format(stlLgEntrustDetial);
- parm.Add(stlLgEntrustDetialTity);
- toalNum = toalNum + int.Parse(row.Cells["SubcontractcompleteNum"].Text.Trim().ToString3()) * int.Parse(row.Cells["ComFixNum"].Text.Trim().ToString3())
- + int.Parse(row.Cells["SubcontractscrapNum"].Text.Trim().ToString3()) * int.Parse(row.Cells["ComFixNum"].Text.Trim().ToString3());
- quailToalWgt = quailToalWgt + decimal.Parse(stlLgEntrustDetial.SubcontractCompleteWgt.ToString());
- }
- //int subToalNum = int.Parse(stlEntrust.SubcontractNum.ToString())*int.Parse(stlEntrust.FixNum.ToString());//委托单倍坯支数
- DataTable subToalNumDs = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmSubContractAffrim.doQueryDbTrust", new object[] { stlLgEntrustTity }, ob);
- int subToalNum = int.Parse(subToalNumDs.Rows[0][0].ToString3());
- if (subToalNum >= toalNum)
- {
- StlLgEntrustBillDetialEntity stlLgEntrustDetialScrap = new StlLgEntrustBillDetialEntity();
- stlLgEntrustDetialScrap.SubcontractscrapNum = subToalNum - toalNum;
- stlLgEntrustDetialScrap.SubcontractscrapWgt = decimal.Parse(stlEntrust.SubcontractWgt.ToString()) - quailToalWgt;
- stlLgEntrustDetialScrap.ComFixNum = 1;
- stlLgEntrustDetialScrap.ComLength = stlEntrust.FixLen;
- string stlLgDetialScrap = JSONFormat.Format(stlLgEntrustDetialScrap);
- parm.Add(stlLgDetialScrap);
- }
- else
- {
- MessageUtil.ShowTips("回报的单倍尺支数不能比原单倍尺支数多!");
- return;
- }
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmSubContractAffrim";
- ccp.MethodName = "subcontractComplete";
- ccp.ServerParams = new object[] { stlLgEntrustTity,parm };
- ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- if (ccp.ReturnInfo.Equals("回报成功!"))
- {
- doQueryEntrustBill();
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- else
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- }
- }
- /// <summary>
- /// 撤销委外完成
- /// </summary>
- private void cancelSubcontractComplete()
- {
- this.ultraGrid1.UpdateData();
- UltraGridRow uRow = this.ultraGrid1.ActiveRow;
- if (uRow == null)
- {
- MessageUtil.ShowTips("请选择需要撤销回报实绩的委托信息!");
- return;
- }
- StlLgEntrustBillEntity stlEntrust = (StlLgEntrustBillEntity)uRow.ListObject;
- string stlLgEntrustTity = JSONFormat.Format(stlEntrust);
- if (MessageUtil.ShowYesNoAndQuestion("是否确认撤销?") == DialogResult.No) return;
- CoreClientParam ccp = new CoreClientParam();
- ccp.ServerName = "Core.LgMes.Server.Stuffmanage.FrmSubContractAffrim";
- ccp.MethodName = "cancelSubcontractComplete";
- ccp.ServerParams = new object[] { stlLgEntrustTity };
- ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- if (ccp.ReturnInfo.Equals("撤销成功!"))
- {
- doQueryEntrustBill();
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- else
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- }
- }
- }
- /// <summary>
- /// 查询委托
- /// </summary>
- private void doQueryEntrustBill()
- {
- string startTim = "";
- string endTim = "";
- string judgeNo = "";
- string subContractNo = "";
- string[] arr = BaseMethod.InitLgPermissions(this.ValidDataPurviewIds,"B", this.ob);
- if (!CheckQuery()) return;
- if (this.chkTim2.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.chkJugeNo.Checked)
- {
- judgeNo = this.txtJugeNo.Text.Trim();
- }
- if (this.chkSubContractNo.Checked)
- {
- subContractNo = this.txtSubContractNo.Text.Trim();
- }
- ArrayList parm = new ArrayList();
- parm.Add(subContractNo);
- parm.Add(judgeNo);
- List<StlLgEntrustBillEntity> listSource = EntityHelper.GetData<StlLgEntrustBillEntity>(
- "Core.LgMes.Server.Stuffmanage.FrmSubContractAffrim.doQueryEntrustBill", new object[] { parm, startTim, endTim, arr }, this.ob);
- StlLgEntrustBillEntitybindingSource.DataSource = listSource;
- }
- /// <summary>
- /// 数据验证
- /// </summary>
- /// <returns></returns>
- private bool CheckQuery()
- {
- if (this.chkSubContractNo.Checked && string.IsNullOrEmpty(this.txtSubContractNo.Text.Trim()))
- {
- MessageUtil.ShowWarning("请输入委托单号!");
- return false;
- }
- if (this.chkJugeNo.Checked && string.IsNullOrEmpty(this.txtJugeNo.Text.Trim()))
- {
- MessageUtil.ShowWarning("请输入判定炉号!");
- return false;
- }
- return true;
- }
- /// <summary>
- /// 对录入数据验证
- /// </summary>
- /// <returns></returns>
- private bool CheckQuerySub()
- {
- this.ultraGrid2.UpdateData();
- UltraGridRow uRow = this.ultraGrid1.ActiveRow;
- var checkMags = this.ultraGrid2.Rows.Where(a=>a.GetValue("CHK") == "True");
- int groupCnt = checkMags.GroupBy(a => a.GetValue("ComFixNum")).Count();
- if (groupCnt != checkMags.Count())
- {
- MessageUtil.ShowTips("同样倍尺数的需回报在一行!");
- return false;
- }
- int toalNum = 0;//回报的总单倍支数
- foreach (UltraGridRow row in checkMags)
- {
- if(!StringUtil.IsInt(row.Cells["ComFixNum"].Text.Trim()))
- {
- MessageUtil.ShowTips("倍尺请输入整数!");
- return false;
- }
- //if (!StringUtil.IsInt(row.Cells["ComLength"].Text.Trim()))
- //{
- // MessageUtil.ShowTips("坯长度请输整数!");
- // return false;
- //}
- //if (row.Cells["SubcontractcompleteNum"].Text.Trim() != ""&& row.Cells["SubcontractcompleteNum"].Text.Trim() !="0")
- //{
- // if (row.Cells["SubcontractCompleteWgt"].Text.Trim() == "" || row.Cells["SubcontractCompleteWgt"].Text.Trim() == "0")
- // {
- // MessageUtil.ShowTips("合格支数有时,不允许无合格重量!");
- // return false;
- // }
- //}
- //if (row.Cells["SubcontractCompleteWgt"].Text.Trim() != "" && row.Cells["SubcontractCompleteWgt"].Text.Trim() != "0")
- //{
- // if (row.Cells["SubcontractcompleteNum"].Text.Trim() == "" || row.Cells["SubcontractcompleteNum"].Text.Trim() == "0")
- // {
- // MessageUtil.ShowTips("合格重量有时,不允许无合格支数!");
- // return false;
- // }
- //}
- //if (row.Cells["SubcontractscrapNum"].Text.Trim() != "" && row.Cells["SubcontractscrapNum"].Text.Trim() != "0")
- //{
- // if (row.Cells["SubcontractscrapWgt"].Text.Trim() == "" || row.Cells["SubcontractscrapWgt"].Text.Trim() == "0")
- // {
- // MessageUtil.ShowTips("废品支数有时,不允许无废品重量!");
- // return false;
- // }
- //}
- //if (row.Cells["SubcontractscrapWgt"].Text.Trim() != "" && row.Cells["SubcontractscrapWgt"].Text.Trim() != "0")
- //{
- // if (row.Cells["SubcontractscrapNum"].Text.Trim() == "" || row.Cells["SubcontractscrapNum"].Text.Trim() == "0")
- // {
- // MessageUtil.ShowTips("废品重量有时,不允许无废品支数!");
- // return false;
- // }
- //}
- if (row.Cells["SubcontractcompleteNum"].Text.Trim() != "")
- {
- if (!StringUtil.IsInt(row.Cells["SubcontractcompleteNum"].Text.Trim()))
- {
- MessageUtil.ShowTips("合格支数请输入整数!");
- return false;
- }
- }
- //if (row.Cells["SubcontractCompleteWgt"].Text.Trim() != "")
- //{
- // if (!StringUtil.IsDouble(row.Cells["SubcontractCompleteWgt"].Text.Trim()))
- // {
- // MessageUtil.ShowTips("合格重量请输入小数或者整数!");
- // return false;
- // }
- //}
- //if (row.Cells["SubcontractscrapNum"].Text.Trim() != "")
- //{
- // if (!StringUtil.IsInt(row.Cells["SubcontractscrapNum"].Text.Trim()))
- // {
- // MessageUtil.ShowTips("废品支数请输入整数!");
- // return false;
- // }
- //}
- //if (row.Cells["SubcontractscrapWgt"].Text.Trim() != "")
- //{
- // if (!StringUtil.IsDouble(row.Cells["SubcontractscrapWgt"].Text.Trim()))
- // {
- // MessageUtil.ShowTips("废品重量请输入小数或者整数!");
- // return false;
- // }
- //}
- toalNum = toalNum + int.Parse(row.Cells["SubcontractcompleteNum"].Text.Trim().ToString3()) * int.Parse(row.Cells["ComFixNum"].Text.Trim().ToString3())
- + int.Parse(row.Cells["SubcontractscrapNum"].Text.Trim().ToString3()) * int.Parse(row.Cells["ComFixNum"].Text.Trim().ToString3());
- }
- //if (int.Parse(uRow.Cells["SubcontractNum"].Text.Trim()) * int.Parse(uRow.Cells["FixNum"].Text.Trim()) != toalNum)
- //{
- // MessageUtil.ShowTips("委外加工支数与回报实绩支数不符!");
- // return false;
- //}
- return true;
- }
- private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
- {
- UltraGridRow uRow = this.ultraGrid1.ActiveRow;
- if (uRow == null) return;
- ArrayList list = new ArrayList();
- list.Add(uRow.Cells["SubcontractNo"].Text);
- list.Add(uRow.Cells["StoveNo"].Text);
- list.Add(uRow.Cells["JudgeStoveNoSeq"].Text);
- list.Add(uRow.Cells["SubcontractNoSeq"].Text);
- StlLgEntrustBillDetialEntitybindingSource.Clear();
- List<StlLgEntrustBillDetialEntity> listSource = EntityHelper.GetData<StlLgEntrustBillDetialEntity>(
- "Core.LgMes.Server.Stuffmanage.FrmSubContractAffrim.doQueryEntrustBillDetial", new object[] { list }, this.ob);
- StlLgEntrustBillDetialEntitybindingSource.DataSource = listSource;
-
- }
- private void chkTim2_CheckedChanged(object sender, EventArgs e)
- {
- this.StartTime.Enabled = this.EndTime.Enabled = this.chkTim2.Checked;
- }
- private void chkJugeNo_CheckedChanged(object sender, EventArgs e)
- {
- this.txtJugeNo.Enabled = this.chkJugeNo.Checked;
- }
- private void chkSubContractNo_CheckedChanged(object sender, EventArgs e)
- {
- this.txtSubContractNo.Enabled = this.chkSubContractNo.Checked;
- }
- private void txtJugeNo_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyValue == 13)
- {
- doQueryEntrustBill();
- }
- }
- }
- }
|