| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279 |
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Windows.Forms;
- using Infragistics.Win.UltraWinGrid;
- using Core.Mes.Client.Comm.Tool;
- using Core.Mes.Client.Comm.Server;
- using com.steering.mes.mcp.entity;
- using Core.Mes.Client.Comm.Control;
- using Core.Mes.Client.Comm.Format;
- using Core.StlMes.Client.Mcp.Control.Common;
- using Core.StlMes.Client.Mcp.Control.Machining;
- using CoreFS.CA06;
- using Infragistics.Win;
- using FrmMchBase = Core.StlMes.Client.Mcp.Mch.MchResult.FrmMchBase;
- using System.IO;
- using System.Threading;
- namespace Core.StlMes.Client.Mcp.Mch
- {
- public partial class FrmMcpLoading : FrmMchBase
- {
- public FrmMcpLoading()
- {
- InitializeComponent();
- IsLoadUserView = true;
- mchControlBase1 = new InstructionCardControl
- {
- Dock = DockStyle.Fill
- };
- plnEdit.Controls.Add(mchControlBase1);
- }
- private string fileName = "";//路径
- protected override UltraGridRow ActitveResultRow { get { return LoadGrid.ActiveRow; } }
- protected override object Value { get { return (mchControlBase1 as InstructionCardControl).Value; } }
- protected override void OnLoad(EventArgs e)
- {
- base.OnLoad(e);
- base.ultraGrid1.DisplayLayout.Bands[0].Columns["OperateCount"].Hidden = true;
- base.ultraGrid1.DisplayLayout.Bands[0].Columns["OperateWeight"].Hidden = true;
- base.ultraGrid1.DisplayLayout.Bands[0].Columns["PerStatus"].Header.Caption = "库存位置";
- EntityHelper.ShowGridCaption<MchLoadingResultEntity>(LoadGrid.DisplayLayout.Bands[0]);
- LoadGrid.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False;
- LoadGrid.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.Default;
- IsViewDelete = true;
- }
- protected override void DoAdd()
- {
- if (ActiveRow != null)
- {
- if (MessageUtil.ShowYesNoAndQuestion("是否上料?") == DialogResult.No)
- return;
- var ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.mes.mcp.Mch.FrmMcpLoading";
- ccp.MethodName = "DoAdd";
- ccp.ServerParams = new object[]
- {
- ActiveRow.HeatPlanNo,
- ActiveRow.HeatPlanSqe,
- JSONFormat.Format(Value), Gx,
- mchControlBase1.ScrappedList.Select(JSONFormat.Format).ToList(),
- mchControlBase1.SuspiciousList.Select(JSONFormat.Format).ToList()
- };
- ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- if (ccp.ReturnInfo.Equals("上料成功!"))
- {
- Query();
- doOver();
- }
- }
- }
- }
- protected override void DoDelete()
- {
- {
- if (ActiveRow != null && ActitveResultRow!=null)
- {
- //查询是否存在上料之后的数据
- var dt =
- ServerHelper.GetData("com.steering.mes.mcp.heatTreatment.HttLoadingService.getQueryInfoPlan",
- new object[] {Gx, ActiveRow.HeatPlanNo}, ob);
- if (dt.Rows.Count > 0)
- {
- MessageBox.Show("已存在后工序实绩,请先删除实绩");
- }
-
- if (MessageUtil.ShowYesNoAndQuestion("是否确认撤销上料?") == DialogResult.No)
- return;
- var ccp = new CoreClientParam();
- ccp.ServerName = "com.steering.mes.mcp.Mch.FrmMcpLoading";
- ccp.MethodName = "DoDelete";
- ccp.ServerParams = new object[]
- {
- JSONFormat.Format(ActitveResultRow.ListObject), Gx, UserInfo.GetUserName()
- };
- ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1)
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- if (ccp.ReturnInfo.Equals("删除上料成功!"))
- Query();
- }
- }
- }
- }
- public void doOver()
- {
- if (ActiveRow == null) return;
- var dt1 = ServerHelper.GetData("com.steering.mes.mcp.Mch.FrmMcpLoading.getquerymaternum",
- new object[] { ActiveRow.HeatPlanNo, ActiveRow.BatchNo}, ob);
- if ((dt1.Rows[0]["NUM"].ToString() == "0") || (dt1.Rows[0]["WT"].ToString() == "0.000"))
- if (MessageUtil.ShowYesNoAndQuestion("待上料量或重量为0,是否结炉?") == DialogResult.No)
- return;
- else
- DoBeside();
- }
- protected override void GetResultData()
- {
- base.GetResultData();
- mchLoadingResultEntityBindingSource.DataSource = EntityHelper.GetData<MchLoadingResultEntity>(
- "com.steering.mes.mcp.Mch.FrmMcpLoading.getLoadResult",
- new object[] { ActiveRow.HeatPlanNo, ActiveRow.BatchNo },
- ob);
- commHelper.RefreshAndAutoSize(LoadGrid);
- if (ActiveRow == null) return;
- var result = new MchLoadingResultEntity
- {
- HeatPlanNo = ActiveRow.HeatPlanNo,
- ZyBatchId = ActiveRow.ZyBatchId,
- ProPlanId = ActiveRow.ProPlanId,
- GxPlanNo = ActiveRow.GxPlanNo,
- JudgeStoveNo = ActiveRow.JudgeStoveNo,
- BatchNo = ActiveRow.BatchNo,
- BatchGroudNo = ActiveRow.BatchGroudNo,
- PlineCode = ActiveRow.PlineCode,
- PlineName = ActiveRow.PlineName,
- IfMonitorRcl = ActiveRow.IfMonitor,
- PrdcrNo = ActiveRow.PrdcrNo,
- ProducerTime = ActiveRow.IfMonitor.Equals("1") ? DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") : null,
- ProNum = ActiveRow.ActCount,
- ProWt = ActiveRow.ActWeight,
- FailNum = 0,
- FailWt = 0,
- LoadShift = UserInfo.GetUserOrder(),
- LoadGroup = UserInfo.GetUserGroup(),
- CreatetUser = UserInfo.GetUserName(),
- LoadTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
- OutnumCut = ActiveRow.OutnumCut,
- LengthIn = ActiveRow.LengthIn,
- LengthmaxIn = ActiveRow.LengthmaxIn,
- LengthminIn = ActiveRow.LengthminIn,
- HeatPlanSqe = ActiveRow.HeatPlanSqe,
- MatSource = ActiveRow.MatSource
- };
- var instructionCardControl = mchControlBase1 as InstructionCardControl;
- if (instructionCardControl != null) instructionCardControl.Value = result;
- }
- protected override void UpLoadDelete()
- {
- if (ActiveRow != null && ActitveResultRow != null)
- {
- DoUpdateFilePath("",false);
- }
- }
- protected override void UpLoad()
- {
- if (ActiveRow != null && ActitveResultRow != null)
- {
- string filePath = "JGMESServer/" + "SC" + "/" + ActiveRow.PlineCode + "/" + ActiveRow.JudgeStoveNo + "/";
- FormFileDown down = new FormFileDown(this.ob, filePath);
- down.CtrlFileDown1.FilePath = filePath;
- List<FileBean> list = new List<FileBean>();
- FileBean bean = new FileBean();
- OpenFileDialog file = new OpenFileDialog();
- file.Multiselect = true;
- DialogResult drStat;
- drStat = file.ShowDialog();
- if (drStat == DialogResult.OK)
- {
- foreach (string fileName in file.FileNames)
- {
- bean = new FileBean();
- string filena = System.IO.Path.GetFileName(fileName);
- bean.setFileName(filena);
- bean.setPathName(filePath);
- bean.setFile(FileHelper.FileToArray(fileName));
- list.Add(bean);
- }
- bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list);
- if (isSuccess)
- {
- Thread.Sleep(100); //等待一下下
- DoUpdateFilePath(filePath,true);
- }
- else
- {
- MessageBox.Show("上传失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
- }
- }
- }
- }
- public void DoUpdateFilePath(string filePath, bool showTips)
- {
- var ccp = new CoreClientParam
- {
- ServerName = "com.steering.mes.mcp.Mch.FrmMcpLoading",
- MethodName = "DoUpdateFilePath",
- ServerParams = new object[]
- {
- ActiveRow.HeatPlanNo,
- filePath
- }
- };
- ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
- if (ccp.ReturnCode != -1 && showTips)
- {
- MessageUtil.ShowTips(ccp.ReturnInfo);
- if (ccp.ReturnInfo.Contains("成功!"))
- Query(true);
- }
- else if (!showTips)
- {
- Query(true);
- }
- }
- private void uteCard_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
- {
- MchLoadingResultEntity entity = LoadGrid.ActiveRow.ListObject as MchLoadingResultEntity;
- string strurl =
- "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMchDeliveryCard.cpt&op=view&RESULT_NO=" +
- entity.ResultNo;
- var fre = new FrmRepExcel(ob, strurl);
- fre.AutoSize = true;
- fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width,
- Screen.PrimaryScreen.WorkingArea.Height);
- fre.WindowState = FormWindowState.Maximized;
- fre.Show();
- }
- }
- }
|