using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Format; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.Mcp.Treatment.Entity; using CoreFS.CA06; using Infragistics.Win; using Infragistics.Win.UltraWinGrid; using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Windows.Forms; namespace Core.StlMes.Client.Mcp.Treatment.HeatTreatment { public partial class HttSignature : FrmBase { public HttSignature() { InitializeComponent(); } private string[] plineCode = null; private string fileName = "";//路径 private void HttSignature_Load(object sender, EventArgs e) { EntityHelper.ShowGridCaption(ultraGrid1.DisplayLayout.Bands[0]); plineCode = Core.StlMes.Client.Mcp.Treatment.HeatTreatment.comm.GetPlineCode(ValidDataPurviewIds, CustomInfo, ob); comm.InitDropPlinePower(CustomInfo, txtPline, this.ValidDataPurviewIds, this.ob); if (this.CustomInfo.ToUpper() == "G") { ultraGrid1.DisplayLayout.Bands[0].Columns["ProcessNo"].EditorComponent = processNoG; } } /// /// 重写基类方法 /// /// /// public override void ToolBar_Click(object sender, string ToolbarKey) { switch (ToolbarKey) { case "DoQuery": QuerySinglePlan(); break; //case "DoQueryInList": // doQueryInList(); // break; case "DoSave": doSave(); break; case "DoUpdate": doUpdate(); break; case "CancelSignature": cancelSignature(); break; //case "CancelPipe": // cancelPipe(); // break; case "Close": this.Close(); break; } } private void QuerySinglePlan() { List listSource = EntityHelper.GetData( "com.steering.mes.mcp.heatTreatment.HttSignature.doQuery", new object[] { plineCode }, this.ob); HttSignatureEntitybindingSource1.DataSource = listSource; foreach (UltraGridRow ugr in ultraGrid1.Rows) { ugr.Cells["PlineCode"].Appearance.BackColor = Color.Transparent; ugr.Cells["PlineCode"].Appearance.BackHatchStyle = BackHatchStyle.Default; ugr.Cells["PlineCode"].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly; ugr.Cells["ColGroup"].Appearance.BackColor = Color.Transparent; ugr.Cells["ColGroup"].Appearance.BackHatchStyle = BackHatchStyle.Default; ugr.Cells["ColGroup"].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly; } } private void doSave() { this.ultraGrid1.UpdateData(); ArrayList list = new ArrayList(); IQueryable checkRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); if(checkRows.Count()==0) { MessageUtil.ShowTips("请勾选要新增的信息"); return; } foreach(UltraGridRow row in checkRows) { HttSignatureEntity hsEntity = (HttSignatureEntity)row.ListObject; if(hsEntity.PlineCode.Equals("")) { MessageUtil.ShowTips("产线不能为空"); return; } if(hsEntity.ColGroup.Equals("")) { MessageUtil.ShowTips("班组不能为空"); return; }else if(hsEntity.ColGroup.Equals("甲")) { hsEntity.ColGroup = "1"; }else if(hsEntity.ColGroup.Equals("乙")) { hsEntity.ColGroup = "2"; }else if(hsEntity.ColGroup.Equals("丙")) { hsEntity.ColGroup = "3"; }else if(hsEntity.ColGroup.Equals("丁")) { hsEntity.ColGroup = "4"; } if(hsEntity.UserName.Equals("")) { MessageUtil.ShowTips("姓名不能为空"); return; } if(hsEntity.ProcessNo.Equals("")) { MessageUtil.ShowTips("工序不能为空"); return; }else if(hsEntity.ProcessNo.Equals("上料")) { hsEntity.ProcessNo = "0"; }else if(hsEntity.ProcessNo.Equals("热处理")) { hsEntity.ProcessNo = "1"; }else if(hsEntity.ProcessNo.Equals("定径热矫冷矫")) { hsEntity.ProcessNo = "2"; }else if(hsEntity.ProcessNo.Equals("表面检验")) { hsEntity.ProcessNo = "3"; }else if(hsEntity.ProcessNo.Equals("探伤")) { hsEntity.ProcessNo = "4"; }else if(hsEntity.ProcessNo.Equals("下线")) { hsEntity.ProcessNo = "5"; } //hsEntity.SignRoute = FileHelper.FileToArray(row.Cells["SignRoute"].Text.ToString()).ToString(); hsEntity.UserId = this.UserInfo.GetUserID(); string httEntity = JSONFormat.Format(hsEntity); list.Add(httEntity); DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.heatTreatment.HttSignature.getSameData", new object[] { hsEntity.PlineCode,hsEntity.ProcessNo,hsEntity.UserName,hsEntity.ColGroup }, ob); if (dt.Rows.Count > 0) { MessageUtil.ShowTips("已存在数据,不能进行此操作!"); return; } } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.heatTreatment.HttSignature"; ccp.MethodName = "doSave"; ccp.ServerParams = new object[] { list }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("新增成功!")) { QuerySinglePlan(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } private void doUpdate() { this.ultraGrid1.UpdateData(); ArrayList list = new ArrayList(); IQueryable checkRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkRows.Count() == 0) { MessageUtil.ShowTips("请勾选要修改的信息"); return; } foreach (UltraGridRow row in checkRows) { HttSignatureEntity hsEntity = (HttSignatureEntity)row.ListObject; if (hsEntity.PlineCode.Equals("")) { MessageUtil.ShowTips("产线不能为空"); return; } if (hsEntity.ColGroup.Equals("")) { MessageUtil.ShowTips("班组不能为空"); return; } else if (hsEntity.ColGroup.Equals("甲")) { hsEntity.ColGroup = "1"; } else if (hsEntity.ColGroup.Equals("乙")) { hsEntity.ColGroup = "2"; } else if (hsEntity.ColGroup.Equals("丙")) { hsEntity.ColGroup = "3"; } else if (hsEntity.ColGroup.Equals("丁")) { hsEntity.ColGroup = "4"; } if (hsEntity.UserName.Equals("")) { MessageUtil.ShowTips("姓名不能为空"); return; } if (hsEntity.ProcessNo.Equals("")) { MessageUtil.ShowTips("工序不能为空"); return; } else if (hsEntity.ProcessNo.Equals("上料")) { hsEntity.ProcessNo = "0"; } else if (hsEntity.ProcessNo.Equals("热处理")) { hsEntity.ProcessNo = "1"; } else if (hsEntity.ProcessNo.Equals("定径热矫冷矫")) { hsEntity.ProcessNo = "2"; } else if (hsEntity.ProcessNo.Equals("表面检验")) { hsEntity.ProcessNo = "3"; } else if (hsEntity.ProcessNo.Equals("探伤")) { hsEntity.ProcessNo = "4"; } else if (hsEntity.ProcessNo.Equals("下线")) { hsEntity.ProcessNo = "5"; } string httEntity = JSONFormat.Format(hsEntity); list.Add(httEntity); //DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.heatTreatment.HttSignature.getSameData", new object[] { hsEntity.PlineCode, hsEntity.ProcessNo,hsEntity.UserName,hsEntity.ColGroup }, ob); //if (dt.Rows.Count > 0) { MessageUtil.ShowTips("已存在数据,不能进行此操作!"); return; } } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.heatTreatment.HttSignature"; ccp.MethodName = "doUpdate"; ccp.ServerParams = new object[] { list }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("修改成功!")) { QuerySinglePlan(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } private void cancelSignature() { this.ultraGrid1.UpdateData(); ArrayList list = new ArrayList(); IQueryable checkRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'"); if (checkRows.Count() == 0) { MessageUtil.ShowTips("请勾选要修改的信息"); return; } foreach (UltraGridRow row in checkRows) { HttSignatureEntity hsEntity = (HttSignatureEntity)row.ListObject; if (hsEntity.PlineCode.Equals("")) { MessageUtil.ShowTips("产线不能为空"); return; } if (hsEntity.ColGroup.Equals("")) { MessageUtil.ShowTips("班组不能为空"); return; } else if (hsEntity.ColGroup.Equals("甲")) { hsEntity.ColGroup = "1"; } else if (hsEntity.ColGroup.Equals("乙")) { hsEntity.ColGroup = "2"; } else if (hsEntity.ColGroup.Equals("丙")) { hsEntity.ColGroup = "3"; } else if (hsEntity.ColGroup.Equals("丁")) { hsEntity.ColGroup = "4"; } if (hsEntity.UserName.Equals("")) { MessageUtil.ShowTips("姓名不能为空"); return; } if (hsEntity.ProcessNo.Equals("")) { MessageUtil.ShowTips("工序不能为空"); return; } else if (hsEntity.ProcessNo.Equals("上料")) { hsEntity.ProcessNo = "0"; } else if (hsEntity.ProcessNo.Equals("热处理")) { hsEntity.ProcessNo = "1"; } else if (hsEntity.ProcessNo.Equals("定径热矫冷矫")) { hsEntity.ProcessNo = "2"; } else if (hsEntity.ProcessNo.Equals("表面检验")) { hsEntity.ProcessNo = "3"; } else if (hsEntity.ProcessNo.Equals("探伤")) { hsEntity.ProcessNo = "4"; } else if (hsEntity.ProcessNo.Equals("下线")) { hsEntity.ProcessNo = "5"; } string httEntity = JSONFormat.Format(hsEntity); list.Add(httEntity); } CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.mes.mcp.heatTreatment.HttSignature"; ccp.MethodName = "doDelete"; ccp.ServerParams = new object[] { list }; ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); if (ccp.ReturnCode != -1) { if (ccp.ReturnInfo.Equals("删除成功!")) { QuerySinglePlan(); MessageUtil.ShowTips(ccp.ReturnInfo); } else { MessageUtil.ShowTips(ccp.ReturnInfo); } } } /// /// /// 上传 /// /// /// private void craftImg_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { this.ultraGrid1.UpdateData(); UltraGridRow row = ultraGrid1.ActiveRow; string PlineCode = row.Cells["PlineCode"].Value.ToString(); string userId = row.Cells["UserId"].Value.ToString(); string filePath = "JGMESServer/" + this.CustomInfo + "/" + PlineCode + "/"; if (e.Button.Key.ToLower().Equals("select")) { FormFileDown down = new FormFileDown(this.ob, row.Cells["SignRoute"].Text); down.CtrlFileDown1.Button3.Visible = false; down.ShowDialog(); } if (e.Button.Key.ToLower().Equals("insert")) { if (userId.Equals("")) { MessageUtil.ShowTips("没有用户不允许上传!"); return; } FormFileDown down = new FormFileDown(this.ob, filePath); down.CtrlFileDown1.FilePath = filePath; List list = new List(); FileBean bean = new FileBean(); OpenFileDialog file = new OpenFileDialog(); file.Multiselect = false; DialogResult drStat; drStat = file.ShowDialog(); if (drStat == DialogResult.OK) { fileName = file.FileName; FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); long s = fs.Length; if (s / 1024.0 > 50) { MessageUtil.ShowTips("图片大于50KB,请重新上传!"); return; } string filena = System.IO.Path.GetFileName(fileName); bean = new FileBean(); 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) { MessageBox.Show("上传成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question); } else { MessageBox.Show("上传失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question); } ultraGrid1.ActiveCell.Value = filena; ultraGrid1.ActiveRow.Cells["SignRoute"].Value = filePath + filena; } } } } }