using Core.Mes.Client.Comm.Control; using Core.Mes.Client.Comm.Server; using Core.Mes.Client.Comm.Tool; using Core.StlMes.Client.PlnSaleOrd.Controls; using CoreFS.CA06; using Infragistics.Win.UltraWinEditors; 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.Net; using System.Text; using System.Windows.Forms; namespace Core.StlMes.Client.PlnSaleOrd.JGGXPln { public partial class FrmCraftJgNoSecond : FrmBase { private string _key = ""; private string _userName = ""; private OpeBase _ob = null; private string _orderNo = ""; private string _codeJg = ""; private string _orderNoJg = ""; private string _jgKey = ""; public FrmCraftJgNoSecond(string key, string userName, OpeBase ob, string orderNo, string codeJg, string orderNoJg, string jgKey) { InitializeComponent(); _key = key; _userName = userName; _ob = ob; _orderNo = orderNo; _codeJg = codeJg; _orderNoJg = orderNoJg; _jgKey = jgKey; } private void FrmCraftJgNoSecond_Load(object sender, EventArgs e) { DoQuery(); DataTable dt1 = ServerHelper.GetData("com.steering.pss.plnsaleord.jggxpln.FrmJgSecondProcess.initMemo", null, _ob); ultraComboEditor1.DataSource = dt1; ultraComboEditor1.DisplayMember = "BASENAME"; ultraComboEditor1.ValueMember = "BASECODE"; } private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e) { switch (e.Tool.Key) { case "AddCraft": // 新增 doAddCraft(); break; case "Update": //修改 doUpdate(); break; case "Delete": //作废 doDelete("0"); break; case "Restore": //恢复 doDelete("1"); break; case "SpecCraft": // 指定工艺 doSpecCraft(); break; case "Generate": // 生成工艺 doGenerate(); break; case "Close": // 关闭 this.Close(); break; default: break; } } private void DoQuery() { DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.jggxpln.FrmJgSecondProcess.doQueryCraftSeconed", new object[] { _key, "" }, _ob); GridHelper.CopyDataToDatatable(dt, dataTable1, true); } /// /// 保存 /// private void doAddCraft() { UltraGridRow row = ultraGrid1.ActiveRow; if (row == null) return; ArrayList list = new ArrayList(); int count = 0; foreach (UltraGridRow urg in ultraGrid1.Rows) { if (Convert.ToBoolean(row.Cells["CHC"].Text) == true) { if (row.Cells["CRAFT_NO_JG2"].Text.Equals("")) { MessageUtil.ShowTips("二级工艺文件为空,不能新增!"); return; } if (!row.Cells["PK"].Text.Equals("")) { MessageUtil.ShowTips("系统已存在该条工艺数据,不能新增!"); return; } count++; ArrayList list1 = new ArrayList(); list1.Add(_key); list1.Add(row.Cells["CRAFT_NO_JG2"].Text.ToString()); list1.Add(row.Cells["CRAFT_SEQ2"].Text.ToString()); list1.Add(row.Cells["CRAFT_PATH"].Text.ToString()); list1.Add(row.Cells["MEMO"].Text.ToString()); list1.Add(row.Cells["MEMO1"].Text.ToString()); list1.Add(row.Cells["CONTENT"].Text.ToString()); list1.Add(row.Cells["MEMO2"].Text.ToString()); list1.Add(row.Cells["NUMBERS"].Text.ToString()); list.Add(list1); } } if (count == 0) { MessageUtil.ShowTips("请勾选需要新增的二级工艺!"); return; } PlanComm.WaitFromOpen(this.Cursor); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.plnsaleord.jggxpln.FrmJgSecondProcess"; ccp.MethodName = "doAddCraft"; ccp.ServerParams = new object[] { list, this.UserInfo.GetUserName() }; ccp = _ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); PlanComm.WaitFromColse(this.Cursor); if (ccp.ReturnCode == -1) return; MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("新增成功!")) { DoQuery(); } } /// /// 修改 /// private void doUpdate() { UltraGridRow row = ultraGrid1.ActiveRow; if (row == null) return; ArrayList list = new ArrayList(); int count = 0; foreach (UltraGridRow urg in ultraGrid1.Rows) { if (Convert.ToBoolean(row.Cells["CHC"].Text) == true) { if (row.Cells["CRAFT_NO_JG2"].Text.Equals("")) { MessageUtil.ShowTips("二级工艺文件为空,不能修改!"); return; } if (row.Cells["PK"].Text.Equals("")) { MessageUtil.ShowTips("选择的该条工艺数据未新增不能修改!"); return; } count++; ArrayList list1 = new ArrayList(); list1.Add(row.Cells["CRAFT_NO_JG2"].Text.ToString()); list1.Add(row.Cells["CRAFT_PATH"].Text.ToString()); list1.Add(row.Cells["MEMO"].Text.ToString()); list1.Add(row.Cells["MEMO1"].Text.ToString()); list1.Add(row.Cells["CONTENT"].Text.ToString()); list1.Add(row.Cells["PK"].Text.ToString()); list1.Add(row.Cells["MEMO2"].Text.ToString()); list1.Add(row.Cells["NUMBERS"].Text.ToString()); list.Add(list1); } } if (count == 0) { MessageUtil.ShowTips("请勾选需要修改的二级工艺!"); return; } PlanComm.WaitFromOpen(this.Cursor); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.plnsaleord.jggxpln.FrmJgSecondProcess"; ccp.MethodName = "doUpdate"; ccp.ServerParams = new object[] { list, this.UserInfo.GetUserName() }; ccp = _ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); PlanComm.WaitFromColse(this.Cursor); if (ccp.ReturnCode == -1) return; MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("修改成功!")) { DoQuery(); } } /// /// 作废/恢复 /// private void doDelete(string falg) { UltraGridRow row = ultraGrid1.ActiveRow; if (row == null) return; ArrayList list = new ArrayList(); int count = 0; foreach (UltraGridRow urg in ultraGrid1.Rows) { if (Convert.ToBoolean(row.Cells["CHC"].Text) == true) { if (row.Cells["PK"].Text.Equals("")) { MessageUtil.ShowTips("选择的该条工艺数据未新增不能作废或恢复!"); return; } count++; ArrayList list1 = new ArrayList(); list1.Add(row.Cells["PK"].Text.ToString()); list.Add(list1); } } if (count == 0) { MessageUtil.ShowTips("请勾选需要作废或恢复的二级工艺!"); return; } PlanComm.WaitFromOpen(this.Cursor); CoreClientParam ccp = new CoreClientParam(); ccp.ServerName = "com.steering.pss.plnsaleord.jggxpln.FrmJgSecondProcess"; ccp.MethodName = "doDelete"; ccp.ServerParams = new object[] { list, this.UserInfo.GetUserName(),falg }; ccp = _ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal); PlanComm.WaitFromColse(this.Cursor); if (ccp.ReturnCode == -1) return; MessageUtil.ShowTips(ccp.ReturnInfo); if (ccp.ReturnInfo.Equals("成功!")) { DoQuery(); } } /// /// 指定工艺 /// private void doSpecCraft() { //UltraGridRow row= } /// /// 生成工艺 /// private void doGenerate() {//&format=pdf string strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilCouplingProcess2.cpt" + "&ORDER_NO=" + _orderNo; FrmRepExcel down = new FrmRepExcel(ob, strurl); down.Text = "接箍二级工艺"; down.Visible = false; down.Size = new Size(740, this.Height); down.WindowState = FormWindowState.Maximized; down.ShowDialog(); } private void craftImg1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { UltraGridRow row = ultraGrid1.ActiveRow; if (row == null) return; if (e.Button.Key.ToLower().Equals("upload")) { string pdfName = _codeJg + _jgKey; ////CreatePdfToFtp(_codeJg + _jgKey); //WebClient webClient = new WebClient(); //List listPdf = new List(); string craftSeq = row.Cells["CRAFT_SEQ2"].Value.ToString(); //////查询最大工艺序号 ////DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.jggxpln.FrmJgSecondProcess.doMaxCraftSeq", new object[] { _key }, _ob); ////if (dt.Rows.Count > 0) ////{ //// craftSeq = int.Parse(dt.Rows[0]["CRAFT_SEQ2"].ToString()) + 1; ////} string filePathNew = "Mcp/CraftLv2/" + _orderNoJg + "/" + craftSeq + "/"; //string craftPath = filePathNew + pdfName + ".pdf"; //string strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilCouplingProcess2.cpt&format=pdf" // + "&ORDER_NO=" + _orderNo; //byte[] pdf = webClient.DownloadData(strurl); //if (pdf.Length <= 10000) //{ // MessageUtil.ShowError("生成PDF出错,请重新生成!"); // return; //} //FileBean fileBean = new FileBean(); //fileBean.setFile(pdf); //fileBean.setFileName(pdfName + ".pdf"); //fileBean.setPathName(filePathNew); //listPdf.Add(fileBean); //webClient.Dispose(); //var a = FileHelper.Upload(listPdf); //if (a) //{ // MessageUtil.ShowTips("上传成功!"); // row.Cells["CRAFT_NO_JG2"].Value = pdfName+".pdf"; // row.Cells["CRAFT_PATH"].Value = filePathNew; // //row.Cells["CRAFT_SEQ2"].Value = craftSeq; //} var serverFileList = FileHelper.Download(filePathNew); //if (serverFileList.Count > 0) //{ // MessageUtil.ShowWarning("该记录已存在一份文件,请删除后再重新上传!"); // return; //} List list = new List(); FileBean bean = new FileBean(); OpenFileDialog file = new OpenFileDialog(); file.Multiselect = true; file.Title = "选择需要上传的PDF"; file.Filter = "PDF文件(*.pdf)|*.pdf"; DialogResult drStat; drStat = file.ShowDialog(); if (drStat == DialogResult.OK) { foreach (string fileName in file.FileNames) { string name = System.IO.Path.GetFileName(fileName); if (name.Contains(" ")) { MessageUtil.ShowWarning("上传的PDF名称不能包含空格!"); return; } bean = new FileBean(); bean.setFileName(pdfName+".pdf"); bean.setPathName(filePathNew); bean.setFile(FileHelper.FileToArray(fileName)); list.Add(bean); } bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list); if (isSuccess) { //string fileNames = ""; //List fileBeans = FileHelper.Download(filePathNew); //foreach (var fileBean in fileBeans) //{ // if (fileNames == "") // { // fileNames = filePathNew + fileBean.getFileName(); // } // else // { // fileNames += "#" + filePathNew + fileBean.getFileName(); // } //} //UpdatePath(row.GetValue("CODE_JG"), fileNames, UserInfo.GetUserName()); MessageUtil.ShowTips("上传成功!"); row.Cells["CRAFT_NO_JG2"].Value = pdfName + ".pdf"; row.Cells["CRAFT_PATH"].Value = filePathNew; //var redirectRow = ultraGrid1.Rows.Where(a => a.GetValue("CODE_JG") == codejg).FirstOrDefault(); //if (redirectRow != null) //{ // redirectRow.Activate(); //} } else { MessageUtil.ShowTips("上传失败,请重试!"); } } } else { //string filePath = row.GetValue("CRAFT_PATH"); //if (filePath.Equals("")) //{ // MessageUtil.ShowError("二级工艺文件不能为空!"); // return; //} //dlgOrderAskDown askDown = new dlgOrderAskDown(_ob, filePath); //askDown.Show(); string pk =row.Cells["PK"].Text.ToString(); if (pk.Equals("")) { MessageUtil.ShowTips("请先保存工艺文件!"); return; } string strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMilCouplingProcess3.cpt" + "&ORDER_NO=" + _orderNo; FrmRepExcel down = new FrmRepExcel(ob, strurl); down.Text = "接箍二级工艺"; down.Visible = false; down.Size = new Size(740, this.Height); down.WindowState = FormWindowState.Maximized; down.ShowDialog(); } } /// /// 调用报表服务器生成PDF并上传到FTP服务器。 /// /// /// public bool CreatePdfToFtp(string pdfName) { return true; } private void ultraGrid1_AfterRowActivate(object sender, EventArgs e) { UltraGridRow row = ultraGrid1.ActiveRow; string src = DateTime.Now.ToString("yy"); string str = "GY3-J-" + src + "-"; if (row == null) { row.Cells["CRAFT_SEQ2"].Value = "1"; } row.Cells["CRAFT_NO_JG2"].Value = _codeJg + _jgKey; if (row.Cells["PK"].Text.Equals("")) { //查询最大工艺序号 DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.jggxpln.FrmJgSecondProcess.doMaxCraftSeq", new object[] { _key }, _ob); if (dt.Rows.Count > 0) { row.Cells["CRAFT_SEQ2"].Value = int.Parse(dt.Rows[0]["CRAFT_SEQ2"].ToString()) + 1; } else { row.Cells["CRAFT_SEQ2"].Value = "1"; } //查询合同接箍一级备注 DataTable dt1 = ServerHelper.GetData("com.steering.pss.plnsaleord.jggxpln.FrmJgSecondProcess.doQueryOrderJgMemo", new object[] { _orderNo }, _ob); if (dt1.Rows.Count > 0) { row.Cells["MEMO2"].Value = dt1.Rows[0]["MEMO"].ToString(); } //查询最大编号 DataTable dt2 = ServerHelper.GetData("com.steering.pss.plnsaleord.jggxpln.FrmJgSecondProcess.doQueryNumBeiMax", new object[] { str }, _ob); if (dt2.Rows.Count > 0) { row.Cells["NUMBERS"].Value = dt2.Rows[0]["NUMBERS"].ToString(); } else { row.Cells["NUMBERS"].Value = str + "0001"; } } } private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e) { //string memo2 = ""; UltraGridRow row = ultraGrid1.ActiveRow; //if (row == null) //UltraTextEditor textEditor = (UltraTextEditor)sender; PopupTextBox popupText = new PopupTextBox(row.Cells["MEMO1"].Text.ToString(), 1000); if (popupText.ShowDialog() == System.Windows.Forms.DialogResult.OK) { row.Cells["MEMO1"].Value = popupText.TextInfo.Trim(); } } private void ultraTextEditor2_EditorButtonClick(object sender, EditorButtonEventArgs e) { UltraGridRow row = ultraGrid1.ActiveRow; //if (row == null) //UltraTextEditor textEditor = (UltraTextEditor)sender; PopupTextBox popupText = new PopupTextBox(row.Cells["CONTENT"].Text.ToString(), 1000); if (popupText.ShowDialog() == System.Windows.Forms.DialogResult.OK) { row.Cells["CONTENT"].Value = popupText.TextInfo.Trim(); } } private void ultraTextEditor3_EditorButtonClick(object sender, EditorButtonEventArgs e) { UltraGridRow row = ultraGrid1.ActiveRow; PopupTextBox popupText = new PopupTextBox(row.Cells["MEMO2"].Text.ToString(), 1000); if (popupText.ShowDialog() == System.Windows.Forms.DialogResult.OK) { row.Cells["MEMO2"].Value = popupText.TextInfo.Trim(); } } } }