| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487 |
- 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);
- }
- /// <summary>
- /// 保存
- /// </summary>
- 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();
- }
- }
- /// <summary>
- /// 修改
- /// </summary>
- 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();
- }
- }
- /// <summary>
- /// 作废/恢复
- /// </summary>
- 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();
- }
- }
-
- /// <summary>
- /// 指定工艺
- /// </summary>
- private void doSpecCraft()
- {
- //UltraGridRow row=
- }
- /// <summary>
- /// 生成工艺
- /// </summary>
- 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<FileBean> listPdf = new List<FileBean>();
- 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<FileBean> list = new List<FileBean>();
- 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<FileBean> 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();
- }
-
- }
- /// <summary>
- /// 调用报表服务器生成PDF并上传到FTP服务器。
- /// </summary>
- /// <param name="craftOrdDesignList"></param>
- /// <returns></returns>
- 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();
- }
- }
- }
- }
|