QcmJyQueryFrm.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Format;
  3. using Core.Mes.Client.Comm.Server;
  4. using Core.Mes.Client.Comm.Tool;
  5. using Core.StlMes.Client.Judge.Commons;
  6. using Core.StlMes.Client.Judge.Models;
  7. using Core.StlMes.Client.Judge.ViewModels;
  8. using CoreFS.CA06;
  9. using Infragistics.Win;
  10. using Infragistics.Win.UltraWinEditors;
  11. using Infragistics.Win.UltraWinGrid;
  12. using System;
  13. using System.Collections;
  14. using System.Collections.Generic;
  15. using System.Data;
  16. using System.Diagnostics;
  17. using System.Drawing;
  18. using System.Drawing.Printing;
  19. //using Spire.Pdf;
  20. using System.IO;
  21. using System.Linq;
  22. using System.Net;
  23. using System.Windows.Forms;
  24. namespace Core.StlMes.Client.Judge.Forms
  25. {
  26. public partial class QcmJyQueryFrm : FrmBase
  27. {
  28. /// <summary>
  29. /// 登入用户的销售组织权限
  30. /// </summary>
  31. //private string[] _salgPermissions;
  32. public QcmJyQueryFrm()
  33. {
  34. InitializeComponent();
  35. this.IsLoadUserView = true;
  36. }
  37. private void QcmJyQueryFrm_Load(object sender, EventArgs e)
  38. {
  39. InitDate();
  40. //_salgPermissions = BaseMethod.InitPermissions(this.ValidDataPurviewIds, ob);
  41. EntityHelper.ShowGridCaption<YdmZcOutlistEntity>(ultraGridOrder.DisplayLayout.Bands[0]);
  42. EntityHelper.ShowGridCaption<YdmZcOutlistEntity>(ultraGridJustNo.DisplayLayout.Bands[0]);
  43. EntityHelper.ShowGridCaption<QcmJyPathEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  44. //BaseMethod.setOtherColumnReadOnly(ultraGridOrder, new string[] { "CHC", "ZbsFlag", "AskSubItmeVal", "MetricSystem", "LicenseNo", "CraftNo", "CheckNo", "ZbsName" });
  45. //BaseMethod.InitCellPosition(ultraGridOrder, new string[] { "PlanWt", "PlanNum", "ActWt", "ActNum", "DelvryQty", "WgtEstmt" });
  46. //BaseMethod.InitCellPosition(ultraGridJustNo, new string[] { "ActLenMin", "ActLenMax", "ActCount", "ActWeight", "ActCountLoad", "ActWeightLoad", "ActCountKc", "ActWeightKc", "SendNum" });
  47. //UltraComboEditor uceAbc = new UltraComboEditor();
  48. //ultraGridOrder.DisplayLayout.Bands[0].Columns["ZbsFlag"].EditorComponent = uceAbc;
  49. //ultraGridOrder.DisplayLayout.Bands[0].Columns["ZbsFlag"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  50. //ValueList vlistSteel = new ValueList();
  51. //vlistSteel.ValueListItems.Insert(0, "2", "老系统打印");
  52. //vlistSteel.ValueListItems.Insert(1, "0", "未打印");
  53. //vlistSteel.ValueListItems.Insert(2, "1", "已打印");
  54. //ultraGridOrder.DisplayLayout.Bands[0].Columns["ZbsFlag"].ValueList = vlistSteel;
  55. //查询语言要求
  56. //DataTable dt1 = ServerHelper.GetData("com.steering.pss.judge.DAL.QcmZbsQueryFrm.getOrderAskSub", new object[] { "12100704" }, ob);
  57. //comAsk.DataSource = dt1;
  58. //comAsk.DisplayMember = "ASK_ITEM_DESC";
  59. //comAsk.ValueMember = "ASK_ITEM_NO";
  60. //查询许可证号
  61. //DataTable dt2 = ServerHelper.GetData("com.steering.pss.judge.DAL.QcmZbsQueryFrm.querySendPlan", new object[] { "4102" }, ob);
  62. //ultraComboEditor2.DataSource = dt2;
  63. //ultraComboEditor2.DisplayMember = "BASENAME";
  64. //ultraComboEditor2.ValueMember = "BASECODE";
  65. ////查询检验号
  66. //DataTable dt3 = ServerHelper.GetData("com.steering.pss.judge.DAL.QcmZbsQueryFrm.querySendPlan", new object[] { "4103" }, ob);
  67. //ultraComboEditor4.DataSource = dt3;
  68. //ultraComboEditor4.DisplayMember = "BASENAME";
  69. //ultraComboEditor4.ValueMember = "BASECODE";
  70. }
  71. private void ChcCheckedChanged(object sender, EventArgs e)
  72. {
  73. if (ChcOrderNo.Checked)
  74. {
  75. TxtOrderNo.Enabled = true;
  76. }
  77. else
  78. {
  79. TxtOrderNo.Enabled = false;
  80. }
  81. if (ChcTime.Checked)
  82. {
  83. TimeBegin.Enabled = true;
  84. TimeEnd.Enabled = true;
  85. }
  86. else
  87. {
  88. TimeEnd.Enabled = false;
  89. TimeBegin.Enabled = false;
  90. }
  91. if (ChcStatus.Checked) { ComStatus.Enabled = true; } else { ComStatus.Enabled = false; }
  92. }
  93. /// <summary>
  94. /// 初始时间
  95. /// </summary>
  96. private void InitDate()
  97. {
  98. DateTime now = DateTime.Now;
  99. DateTime dt1 = new DateTime(now.Year, now.Month, 1);//当月第一天
  100. DateTime dt2 = dt1.AddMonths(1).AddDays(-1);//当月最后一天
  101. TimeBegin.Value = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 00:00:00");
  102. TimeEnd.Value = DateTime.Parse(dt2.ToString("yyyy-MM-dd") + " 23:59:59");
  103. }
  104. public override void ToolBar_Click(object sender, string ToolbarKey)
  105. {
  106. switch (ToolbarKey)
  107. {
  108. case "Query":
  109. DoQuery();
  110. break;
  111. case "Update":
  112. DoUpdate();
  113. break;
  114. case "Print":
  115. printData();
  116. break;
  117. case "Close":
  118. this.Close();
  119. break;
  120. }
  121. }
  122. private ArrayList ingname = new ArrayList();
  123. /// <summary>
  124. /// 检验报告打印预览
  125. /// </summary>
  126. private void printData()
  127. {
  128. ultraGridOrder.UpdateData();
  129. ultraGridJustNo.UpdateData();
  130. UltraGridRow row = ultraGridOrder.ActiveRow;
  131. string orderNo = row.Cells["OrderNo"].Text.ToString();
  132. string year = DateTime.Now.Year.ToString();
  133. string seq = "";
  134. if (row == null) return;
  135. DataTable ds = ServerHelper.GetData("com.steering.pss.judge.DAL.QcmJyQueryFrm.doQueryJyYearSeq", new object[] { year }, ob);
  136. seq = ds.Rows[0]["SEQ"].ToString();
  137. //保存
  138. ArrayList list = new ArrayList();
  139. list.Add(year);
  140. list.Add(seq);
  141. list.Add(orderNo);
  142. ArrayList parm = new ArrayList();
  143. IQueryable<UltraGridRow> checkMagRows = this.ultraGridJustNo.Rows.AsQueryable().Where(" CHK = 'True'");
  144. foreach (UltraGridRow uRow in checkMagRows)
  145. {
  146. YdmZcOutlistEntity matZcEntity = (YdmZcOutlistEntity)uRow.ListObject;
  147. string matZcTity = JSONFormat.Format(matZcEntity);
  148. parm.Add(matZcTity);
  149. }
  150. CoreClientParam ccp = new CoreClientParam();
  151. ccp.ServerName = "com.steering.pss.judge.DAL.QcmJyQueryFrm";
  152. ccp.MethodName = "doAddJyReport";
  153. ccp.ServerParams = new object[] { list, parm,"1" };
  154. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  155. //if (ccp.ReturnCode == -1) return;
  156. if (ccp.ReturnInfo.Equals("保存成功!"))
  157. {
  158. string strurl = "http://172.16.2.137:8081/webroot/decision/view/report?viewlet=RepCertificateOfProductQualityJY.cpt"
  159. + "&ORDER_NO=" + orderNo + "&YEAR_SEQ=" + year + seq;
  160. FrmRepExcel down = new FrmRepExcel(ob, strurl);
  161. down.Text = "检验报告";
  162. down.Visible = false;
  163. down.Size = new Size(740, this.Height);
  164. down.WindowState = FormWindowState.Maximized;
  165. down.ShowDialog();
  166. }
  167. }
  168. private void pdfPrint(string filePath)
  169. {
  170. PrintDocument pd = new PrintDocument();
  171. Process p = new Process();
  172. //ProcessStartInfo startInfo = new ProcessStartInfo();
  173. //startInfo.CreateNoWindow = true;
  174. //startInfo.WindowStyle = ProcessWindowStyle.Hidden;
  175. //startInfo.UseShellExecute = true;
  176. //startInfo.FileName = filePath;
  177. //startInfo.Verb = "print";
  178. //startInfo.Arguments = @"/p /h \" + filePath + "\"\"" + pd.PrinterSettings.PrinterName + "\"";
  179. //p.StartInfo = startInfo;
  180. //p.Start();
  181. //p.WaitForExit();
  182. //不现实调用程序窗口,但是对于某些应用无效
  183. p.StartInfo.CreateNoWindow = true;
  184. p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
  185. //采用操作系统自动识别的模式
  186. p.StartInfo.UseShellExecute = true;
  187. //要打印的文件路径,可以是WORD,EXCEL,PDF,TXT等等
  188. p.StartInfo.FileName = filePath;
  189. //指定执行的动作,是打印,即print,打开是 open
  190. p.StartInfo.Verb = "print";
  191. //pd.Print();
  192. p.StartInfo.Arguments = @"/p /h \" + filePath + "\"\"" + pd.PrinterSettings.PrinterName + "\"";
  193. //开始
  194. p.Start();
  195. p.WaitForExit(10000);
  196. }
  197. int i = 0;
  198. int j = 0;
  199. bool fal = false;
  200. public string spathName = "";
  201. private List<Image> ing = new List<Image>();
  202. private List<FileBean> list = new List<FileBean>();
  203. private string currentFileName = "";
  204. public event FileChange FileChangeEvent;
  205. /// <summary>
  206. /// 通过文件集合(图片)显示出来。
  207. /// </summary>
  208. /// <param name="list"></param>
  209. public void ShowByListFileBean(List<FileBean> list)
  210. {
  211. if (list == null) return;
  212. j = 0;
  213. i = 0;
  214. ing.Clear();
  215. ingname.Clear();
  216. this.list = list;
  217. ClearTmp();
  218. foreach (FileBean bean in list)
  219. {
  220. Image image;
  221. try
  222. {
  223. image = FileHelper.BytesToBitmap(bean.getFile());
  224. }
  225. catch
  226. {
  227. image = null;
  228. WriteBytesToTmp(bean.getFile(), bean.getFileName());
  229. }
  230. ing.Add(image);
  231. ingname.Add(bean.getFileName());
  232. //if (ing[0] != null)
  233. //{
  234. // PictureBoxHelper.LoadThumbnailImage((Bitmap)ing[0], pictureBox1);
  235. //}
  236. this.currentFileName = list[0].getFileName();
  237. if (FileChangeEvent != null)
  238. {
  239. FileChangeEvent(currentFileName);
  240. }
  241. //PictureBoxHelper.LoadThumbnailImage(pictureBox1);
  242. j = j + 1;
  243. }
  244. if (ing.Count == 0)
  245. {
  246. fal = false;
  247. this.currentFileName = "";
  248. if (FileChangeEvent != null)
  249. {
  250. FileChangeEvent(currentFileName);
  251. }
  252. }
  253. else
  254. {
  255. fal = true;
  256. }
  257. }
  258. private void ClearTmp()
  259. {
  260. string tmpPath = Environment.CurrentDirectory + "\\Tmp\\";
  261. DirectoryInfo di = new DirectoryInfo(tmpPath);
  262. if (di.Exists == fal)
  263. {
  264. di.Create();
  265. return;
  266. }
  267. foreach (FileInfo fi in di.GetFiles())
  268. {
  269. try
  270. {
  271. fi.Delete();
  272. }
  273. catch { continue; }
  274. }
  275. }
  276. private void WriteBytesToTmp(byte[] Bytes, string fileName)
  277. {
  278. try
  279. {
  280. string tmpPath = Environment.CurrentDirectory + "\\Tmp\\";
  281. FileStream fs = new FileStream(tmpPath + fileName, FileMode.Create);
  282. fs.Write(Bytes, 0, Bytes.Length);
  283. fs.Flush();
  284. fs.Close();
  285. }
  286. catch { }
  287. }
  288. /// <summary>
  289. /// 生成检验报告
  290. /// </summary>
  291. private void DoUpdate()
  292. {
  293. ultraGridOrder.UpdateData();
  294. UltraGridRow row = ultraGridOrder.ActiveRow;
  295. string orderNo = row.Cells["OrderNo"].Text.ToString();
  296. string orderNo2 = orderNo.Replace("/","");
  297. string year = DateTime.Now.Year.ToString();
  298. string seq = "";
  299. if (row == null) return;
  300. DataTable ds = ServerHelper.GetData("com.steering.pss.judge.DAL.QcmJyQueryFrm.doQueryJyYearSeq", new object[] { year }, ob);
  301. seq = ds.Rows[0]["SEQ"].ToString();
  302. string pdfName = year + seq + orderNo2;
  303. string filePathNew = "Qcm/JyPdf/" + year + "/" + seq + "/";
  304. string craftPath = filePathNew + pdfName + ".pdf";
  305. //保存
  306. ArrayList list = new ArrayList();
  307. list.Add(year);
  308. list.Add(seq);
  309. list.Add(orderNo);
  310. list.Add(pdfName);
  311. list.Add(craftPath);
  312. list.Add(this.UserInfo.GetUserName());
  313. ArrayList parm = new ArrayList();
  314. IQueryable<UltraGridRow> checkMagRows = this.ultraGridJustNo.Rows.AsQueryable().Where(" CHK = 'True'");
  315. foreach (UltraGridRow uRow in checkMagRows)
  316. {
  317. YdmZcOutlistEntity matZcEntity = (YdmZcOutlistEntity)uRow.ListObject;
  318. string matZcTity = JSONFormat.Format(matZcEntity);
  319. parm.Add(matZcTity);
  320. }
  321. CoreClientParam ccp = new CoreClientParam();
  322. ccp.ServerName = "com.steering.pss.judge.DAL.QcmJyQueryFrm";
  323. ccp.MethodName = "doAddJyReport";
  324. ccp.ServerParams = new object[] { list, parm, "2" };
  325. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  326. if (ccp.ReturnCode == -1) return;
  327. MessageUtil.ShowTips(ccp.ReturnInfo);
  328. if (ccp.ReturnInfo.Equals("保存成功!"))
  329. {
  330. WebClient webClient = new WebClient();
  331. List<FileBean> listPdf = new List<FileBean>();
  332. string strurl = "http://172.16.2.137:8081/webroot/decision/view/report?viewlet=RepCertificateOfProductQualityJY.cpt&format=pdf"
  333. + "&ORDER_NO=" + orderNo + "&YEAR_SEQ=" + year + seq;
  334. byte[] pdf = webClient.DownloadData(strurl);
  335. if (pdf.Length <= 10000)
  336. {
  337. MessageUtil.ShowError("生成PDF ,请重新生成!");
  338. return;
  339. }
  340. FileBean fileBean = new FileBean();
  341. fileBean.setFile(pdf);
  342. fileBean.setFileName(pdfName + ".pdf");
  343. fileBean.setPathName(filePathNew);
  344. listPdf.Add(fileBean);
  345. webClient.Dispose();
  346. var a = FileHelper.Upload(listPdf);
  347. if (a)
  348. {
  349. DoQuery();
  350. }
  351. }
  352. }
  353. /// <summary>
  354. /// 查询
  355. /// </summary>
  356. private void DoQuery()
  357. {
  358. ArrayList param = new ArrayList();
  359. string orderNo = "";
  360. if (ChcOrderNo.Checked)
  361. {
  362. orderNo = TxtOrderNo.Text.Trim();
  363. }
  364. string strBegin = "1900-01-01 00:00:00";
  365. string strEnd = "9900-01-01 00:00:00";
  366. if (ChcTime.Checked)
  367. {
  368. if (TimeBegin.Value == null || TimeEnd.Value == null)
  369. {
  370. MessageUtil.ShowWarning("请选择正确的时间");
  371. return;
  372. }
  373. strBegin = TimeBegin.Value.ToString();
  374. strEnd = TimeEnd.Value.ToString();
  375. }
  376. param.Add(orderNo);
  377. param.Add(strBegin);
  378. param.Add(strEnd);
  379. if (ultraTabControl2.SelectedTab.Index == 0)
  380. {
  381. List<YdmZcOutlistEntity> listSource = EntityHelper.GetData<YdmZcOutlistEntity>(
  382. "com.steering.pss.judge.DAL.QcmJyQueryFrm.getOrderInfo", new object[] { param }, this.ob);
  383. ydmZcOutlistEntityBindingSource1.DataSource = listSource;
  384. }
  385. else if (ultraTabControl2.SelectedTab.Index == 1)
  386. {
  387. List<QcmJyPathEntity> listSource = EntityHelper.GetData<QcmJyPathEntity>(
  388. "com.steering.pss.judge.DAL.QcmJyQueryFrm.getQcmJyPath", new object[] { param }, this.ob);
  389. qcmJyPathEntityBindingSource1.DataSource = listSource;
  390. }
  391. }
  392. private void QueryJustStoveInfo(string orderNo)
  393. {
  394. ultraGridJustNo.UpdateData();
  395. string beginTime = "";
  396. string endTime = "";
  397. ArrayList param = new ArrayList();
  398. param.Add(orderNo);
  399. if (ChcTime.Checked)
  400. {
  401. beginTime = TimeBegin.Value.ToString();
  402. endTime = TimeEnd.Value.ToString();
  403. }
  404. else
  405. {
  406. beginTime = "2010/8/1 0:00:00";
  407. endTime = DateTime.Now.ToString("yyyy/MM/dd") + " 23:59:59";
  408. }
  409. param.Add(beginTime);
  410. param.Add(endTime);
  411. List<YdmZcOutlistEntity> listSource = EntityHelper.GetData<YdmZcOutlistEntity>(
  412. "com.steering.pss.judge.DAL.QcmJyQueryFrm.getJustStoveNo", new object[] { param }, this.ob);
  413. ydmZcOutlistEntityBindingSource2.DataSource = listSource;
  414. }
  415. DataTable dtzbs = new DataTable();
  416. private void ultraGridOrder_AfterRowActivate(object sender, EventArgs e)
  417. {
  418. UltraGridRow ugr = ultraGridOrder.ActiveRow;
  419. if (ugr == null)
  420. {
  421. return;
  422. }
  423. QueryJustStoveInfo(ugr.Cells["OrderNo"].Text.ToString());
  424. }
  425. /// <summary>
  426. /// 按回车键触发查询按钮
  427. /// </summary>
  428. /// <param name="sender"></param>
  429. /// <param name="e"></param>
  430. private void ContPublic_KeyDown(object sender, KeyEventArgs e)
  431. {
  432. if (e.KeyCode == Keys.Enter)
  433. {
  434. DoQuery();
  435. }
  436. }
  437. private int splitterDistance = 0;
  438. private void ultraExpandableGroupBox1_ExpandedStateChanged(object sender, EventArgs e)
  439. {
  440. if (ultraExpandableGroupBox1.Expanded == false)
  441. {
  442. this.splitContainer2.SplitterDistance = splitContainer2.Size.Height - 26;
  443. }
  444. else
  445. {
  446. this.splitContainer2.SplitterDistance = splitterDistance == 0 ? splitContainer2.Size.Height / 2 : splitterDistance;
  447. }
  448. }
  449. private void ultraGridOrder_AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
  450. {
  451. foreach (UltraGridRow uRow in ultraGridOrder.Selected.Rows)
  452. {
  453. if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow))
  454. {
  455. uRow.Cells["CHC"].Value = true;
  456. }
  457. }
  458. }
  459. /// <summary>
  460. /// 质保书查看,上传,删除
  461. /// </summary>
  462. /// <param name="sender"></param>
  463. /// <param name="e"></param>
  464. private void craftImg1_EditorButtonClick(object sender, EditorButtonEventArgs e)
  465. {
  466. UltraGridRow row = ultraGridOrder.ActiveRow;
  467. if (row == null) return;
  468. string billNo = row.Cells["BillNo"].Text.ToString();
  469. string billNoSeq = row.Cells["BillNoSeq"].Text.ToString();
  470. string orderNoSeq = row.Cells["OrderSeqNo"].Text.ToString();
  471. string ordLnDlyPk = row.Cells["OrdLnDlyPk"].Text.ToString();
  472. string ordLnPk = row.Cells["OrdLnPk"].Text.ToString();
  473. string askSubItmeVal = row.Cells["AskSubItmeVal"].Text.ToString();
  474. string filePath = row.GetValue("ZbsPath");
  475. string metricSystem = row.Cells["MetricSystem"].Text.ToString();
  476. if (e.Button.Key.ToLower().Equals("select"))
  477. {
  478. if (filePath.Equals(""))
  479. {
  480. if (askSubItmeVal.Equals(""))
  481. {
  482. MessageUtil.ShowTips("请选择语言要求!");
  483. return;
  484. }
  485. string askSubItmeValNo = row.Cells["AskSubItmeVal"].Value.ToString();
  486. if (metricSystem.Equals(""))
  487. {
  488. MessageUtil.ShowTips("请选择公英制!");
  489. return;
  490. }
  491. string metricSystemNo = row.Cells["MetricSystem"].Value.ToString();
  492. string strurl = "http://172.16.2.137:8081/webroot/decision/view/report?viewlet=RepCertificateOfProductQuality.cpt"
  493. + "&BILL_NO=" + billNo + "&ORD_LN_PK=" + ordLnPk + "&ASK_ITEM_NO=" + askSubItmeValNo + "&METRIC_SYSTEM=" + metricSystemNo + "&USER=" + this.UserInfo.GetUserID() + "&ORD_LN_DLY_PK=" + ordLnDlyPk;
  494. FrmRepExcel down = new FrmRepExcel(ob, strurl);
  495. down.Text = "质保书";
  496. down.Visible = false;
  497. down.Size = new Size(740, this.Height);
  498. down.WindowState = FormWindowState.Maximized;
  499. down.ShowDialog();
  500. }
  501. else
  502. {
  503. FormFileDown askDown = new FormFileDown(this.ob, filePath);
  504. askDown.CtrlFileDown1.Button3.Visible = false;
  505. askDown.Show();
  506. }
  507. //dlgOrderAskDown askDown = new dlgOrderAskDown(ob, filePath);
  508. //askDown.Show();
  509. }
  510. else if (e.Button.Key.ToLower().Equals("add"))
  511. {
  512. string pdfName = billNoSeq;
  513. string filePathNew = "Qcm/ZbsPdf/" + orderNoSeq + "/";
  514. var serverFileList = FileHelper.Download(filePathNew);
  515. if (serverFileList.Count > 0)
  516. {
  517. MessageUtil.ShowWarning("该记录已存在一份文件,请删除后再重新上传!");
  518. return;
  519. }
  520. if (askSubItmeVal.Equals(""))
  521. {
  522. MessageUtil.ShowTips("请选择语言要求!");
  523. return;
  524. }
  525. string askSubItmeValNo = row.Cells["AskSubItmeVal"].Value.ToString();
  526. if (metricSystem.Equals(""))
  527. {
  528. MessageUtil.ShowTips("请选择公英制!");
  529. return;
  530. }
  531. string metricSystemNo = row.Cells["MetricSystem"].Value.ToString();
  532. //保存
  533. CoreClientParam ccp = new CoreClientParam();
  534. ccp.ServerName = "com.steering.pss.judge.DAL.QcmZbsQueryFrm";
  535. ccp.MethodName = "doAdd";
  536. ccp.ServerParams = new object[] { pdfName, filePathNew, billNoSeq, billNo, ordLnDlyPk, this.UserInfo.GetUserName(), askSubItmeValNo, metricSystemNo };
  537. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  538. if (ccp.ReturnCode == -1) return;
  539. MessageUtil.ShowTips(ccp.ReturnInfo);
  540. if (ccp.ReturnInfo.Equals("保存成功!"))
  541. {
  542. WebClient webClient = new WebClient();
  543. List<FileBean> listPdf = new List<FileBean>();
  544. string craftPath = filePathNew + pdfName + ".pdf";
  545. string strurl = "http://172.16.2.137:8081/webroot/decision/view/report?viewlet=RepCertificateOfProductQuality.cpt&format=pdf"
  546. + "&BILL_NO=" + billNo + "&ORD_LN_PK=" + ordLnPk + "&ASK_ITEM_NO=" + askSubItmeValNo + "&METRIC_SYSTEM=" + metricSystemNo + "&USER=" + this.UserInfo.GetUserID() + "&ORD_LN_DLY_PK=" + ordLnDlyPk;
  547. byte[] pdf = webClient.DownloadData(strurl);
  548. if (pdf.Length <= 10000)
  549. {
  550. MessageUtil.ShowError("生成PDF ,请重新生成!");
  551. return;
  552. }
  553. FileBean fileBean = new FileBean();
  554. fileBean.setFile(pdf);
  555. fileBean.setFileName(pdfName + ".pdf");
  556. fileBean.setPathName(filePathNew);
  557. listPdf.Add(fileBean);
  558. webClient.Dispose();
  559. var a = FileHelper.Upload(listPdf);
  560. if (a)
  561. {
  562. //MessageUtil.ShowTips("上传成功!");
  563. row.Cells["ZbsName"].Value = pdfName + ".pdf";
  564. row.Cells["ZbsPath"].Value = filePathNew;
  565. DoQuery();
  566. }
  567. }
  568. }
  569. else
  570. {
  571. //删除
  572. CoreClientParam ccp = new CoreClientParam();
  573. ccp.ServerName = "com.steering.pss.judge.DAL.QcmZbsQueryFrm";
  574. ccp.MethodName = "doDelete";
  575. ccp.ServerParams = new object[] { row.Cells["ZbsName"].Text.ToString(), billNoSeq, billNo, ordLnDlyPk };
  576. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  577. if (ccp.ReturnCode == -1) return;
  578. MessageUtil.ShowTips(ccp.ReturnInfo);
  579. if (ccp.ReturnInfo.Equals("删除成功!"))
  580. {
  581. var a = FileHelper.Delete(filePath);
  582. if (a)
  583. {
  584. DoQuery();
  585. }
  586. }
  587. }
  588. }
  589. private void ultraComboEditor3_EditorButtonClick(object sender, EditorButtonEventArgs e)
  590. {
  591. UltraGridRow row = ultraGrid1.ActiveRow;
  592. if (row == null) return;
  593. string orderNo = row.Cells["OrderNo"].Text.ToString();
  594. string year = row.Cells["Year"].Text.ToString();
  595. string seq = row.Cells["Seq"].Text.ToString();
  596. if (e.Button.Key.ToLower().Equals("select"))
  597. { //查看
  598. string filePath = row.GetValue("JyPath");
  599. FormFileDown askDown = new FormFileDown(this.ob, filePath);
  600. askDown.CtrlFileDown1.Button3.Visible = false;
  601. askDown.Show();
  602. }
  603. else
  604. { //打印
  605. string zbsName = row.Cells["JyPath"].Text.ToString();
  606. List<FileBean> list = Core.Mes.Client.Comm.Server.FileHelper.Download(zbsName);
  607. ShowByListFileBean(list);
  608. string filePath = Environment.CurrentDirectory + "\\Tmp\\" + ingname[i];
  609. pdfPrint(filePath);
  610. CoreClientParam ccp = new CoreClientParam();
  611. ccp.ServerName = "com.steering.pss.judge.DAL.QcmJyQueryFrm";
  612. ccp.MethodName = "doUpdatePrintData";
  613. ccp.ServerParams = new object[] { year, seq, this.UserInfo.GetUserName()};
  614. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  615. if (ccp.ReturnCode == -1) return;
  616. MessageUtil.ShowTips(ccp.ReturnInfo);
  617. if (ccp.ReturnInfo.Equals("打印成功!"))
  618. {
  619. DoQuery();
  620. }
  621. }
  622. }
  623. private void ultraComboEditor3_ValueChanged(object sender, EventArgs e)
  624. {
  625. }
  626. public DataTable ToDataTable(DataRow[] rows)
  627. {
  628. if (rows == null || rows.Length == 0) return null;
  629. DataTable tmp = rows[0].Table.Clone(); // 复制DataRow的表结构
  630. foreach (DataRow row in rows)
  631. tmp.Rows.Add(row.ItemArray); // 将DataRow添加到DataTable中
  632. return tmp;
  633. }
  634. private void ultraGridJustNo_ClickCellButton(object sender, CellEventArgs e)
  635. {
  636. this.ultraGridJustNo.UpdateData();
  637. if (e.Cell.Column.Key == "JudgeStoveNo")
  638. {
  639. string batchNo = ultraGridJustNo.ActiveRow.Cells["BatchNo"].Value.ToString();
  640. string judgeStoveNo = ultraGridJustNo.ActiveRow.Cells["JudgeStoveNo"].Value.ToString();
  641. FrmCoupling orderZg = new FrmCoupling(judgeStoveNo, batchNo, this.ob);
  642. orderZg.ShowDialog();
  643. }
  644. }
  645. private void RefreshSpotZbs()
  646. {
  647. if (ultraGridOrder.ActiveRow == null) return;
  648. var pRow = ultraGridOrder.ActiveRow;
  649. Dal d = new Dal(ob);
  650. DataRow drOrdHead = d.GetRowByXmlId("JdgSlmOrderHead.getByDlyPk", pRow.GetValue("OrdLnDlyPk"));
  651. if (drOrdHead != null && drOrdHead["orderTyp"].ToString() != "120102")
  652. {
  653. MessageUtil.ShowWarning("只能刷新现货提单!");
  654. return;
  655. }
  656. string process = d.GetRowByXmlId("JdgComBasePline.getProcessByPline", pRow.GetValue("PlineCode"))["processCode"].ToString();
  657. foreach (var row in ultraGridJustNo.Rows)
  658. {
  659. d.Set("com.steering.pss.judge.Bll.BllCreateZbsInfo.saveSpotInfo", row.GetValue("JudgeStoveNo"),
  660. row.GetValue("BatchNo"), row.GetValue("GroupNo"), process, pRow.GetValue("OrdLnDlyPk"));
  661. }
  662. //DataTable dt = d.GetTableByXmlId("JdgQcmZbsInfo.getxh");
  663. //foreach (DataRow dr in dt.Rows)
  664. //{
  665. // d.Set("com.steering.pss.judge.Bll.BllCreateZbsInfo.saveSpotInfo", dr["judgeStoveNo"].ToString(),
  666. // dr["batchNo"], "001", dr["processCode"].ToString(), dr["ordLnDlyPk"].ToString());
  667. //}
  668. MessageUtil.ShowTips("刷新成功");
  669. }
  670. }
  671. }