QcmZbsQueryFrmYuLan.cs 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Server;
  3. using Core.Mes.Client.Comm.Tool;
  4. using Core.StlMes.Client.Judge.Commons;
  5. using Core.StlMes.Client.Judge.ViewModels;
  6. using CoreFS.CA06;
  7. using Infragistics.Win;
  8. using Infragistics.Win.UltraWinEditors;
  9. using Infragistics.Win.UltraWinGrid;
  10. using System;
  11. using System.Collections;
  12. using System.Collections.Generic;
  13. using System.Data;
  14. using System.Diagnostics;
  15. using System.Drawing;
  16. using System.Drawing.Printing;
  17. //using Spire.Pdf;
  18. using System.IO;
  19. using System.Linq;
  20. using System.Net;
  21. using System.Windows.Forms;
  22. namespace Core.StlMes.Client.Judge.Forms
  23. {
  24. public partial class QcmZbsQueryFrmYuLan : FrmBase
  25. {
  26. /// <summary>
  27. /// 登入用户的销售组织权限
  28. /// </summary>
  29. //private string[] _salgPermissions;
  30. public QcmZbsQueryFrmYuLan()
  31. {
  32. InitializeComponent();
  33. this.IsLoadUserView = true;
  34. }
  35. private void QcmZbsQueryFrmYuLan_Load(object sender, EventArgs e)
  36. {
  37. InitDate();
  38. //_salgPermissions = BaseMethod.InitPermissions(this.ValidDataPurviewIds, ob);
  39. EntityHelper.ShowGridCaption<YdmZcBillMyEntity>(ultraGridOrder.DisplayLayout.Bands[0]);
  40. EntityHelper.ShowGridCaption<YdmZcBillCyEntity>(ultraGridJustNo.DisplayLayout.Bands[0]);
  41. BaseMethod.setOtherColumnReadOnly(ultraGridOrder, new string[] { "CHC", "ZbsFlag", "AskSubItmeVal", "MetricSystem", "LicenseNo", "CraftNo", "CheckNo", "ZbsName" });
  42. BaseMethod.InitCellPosition(ultraGridOrder, new string[] { "PlanWt", "PlanNum", "ActWt", "ActNum", "DelvryQty", "WgtEstmt" });
  43. BaseMethod.InitCellPosition(ultraGridJustNo, new string[] { "ActLenMin", "ActLenMax", "ActCount", "ActWeight", "ActCountLoad", "ActWeightLoad", "ActCountKc", "ActWeightKc", "SendNum" });
  44. UltraComboEditor uceAbc = new UltraComboEditor();
  45. ultraGridOrder.DisplayLayout.Bands[0].Columns["ZbsFlag"].EditorComponent = uceAbc;
  46. ultraGridOrder.DisplayLayout.Bands[0].Columns["ZbsFlag"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  47. ValueList vlistSteel = new ValueList();
  48. vlistSteel.ValueListItems.Insert(0, "2", "老系统打印");
  49. vlistSteel.ValueListItems.Insert(1, "0", "未打印");
  50. vlistSteel.ValueListItems.Insert(2, "1", "已打印");
  51. ultraGridOrder.DisplayLayout.Bands[0].Columns["ZbsFlag"].ValueList = vlistSteel;
  52. //查询语言要求
  53. DataTable dt1 = ServerHelper.GetData("com.steering.pss.judge.DAL.QcmZbsQueryFrm.getOrderAskSub", new object[] { "12100704" }, ob);
  54. comAsk.DataSource = dt1;
  55. comAsk.DisplayMember = "ASK_ITEM_DESC";
  56. comAsk.ValueMember = "ASK_ITEM_NO";
  57. //查询许可证号
  58. DataTable dt2 = ServerHelper.GetData("com.steering.pss.judge.DAL.QcmZbsQueryFrm.querySendPlan", new object[] { "4102" }, ob);
  59. ultraComboEditor2.DataSource = dt2;
  60. ultraComboEditor2.DisplayMember = "BASENAME";
  61. ultraComboEditor2.ValueMember = "BASECODE";
  62. //查询检验号
  63. DataTable dt3 = ServerHelper.GetData("com.steering.pss.judge.DAL.QcmZbsQueryFrm.querySendPlan", new object[] { "4103" }, ob);
  64. ultraComboEditor4.DataSource = dt3;
  65. ultraComboEditor4.DisplayMember = "BASENAME";
  66. ultraComboEditor4.ValueMember = "BASECODE";
  67. }
  68. private void ChcCheckedChanged(object sender, EventArgs e)
  69. {
  70. if (ChcLadingSeq.Checked)
  71. {
  72. TxtLadingSeq.Enabled = true;
  73. }
  74. else
  75. {
  76. TxtLadingSeq.Enabled = false;
  77. }
  78. if (ChcOrderNo.Checked)
  79. {
  80. TxtOrderNo.Enabled = true;
  81. }
  82. else
  83. {
  84. TxtOrderNo.Enabled = false;
  85. }
  86. if (ChcTime.Checked)
  87. {
  88. TimeBegin.Enabled = true;
  89. TimeEnd.Enabled = true;
  90. }
  91. else
  92. {
  93. TimeEnd.Enabled = false;
  94. TimeBegin.Enabled = false;
  95. }
  96. if (ChcStatus.Checked) { ComStatus.Enabled = true; } else { ComStatus.Enabled = false; }
  97. }
  98. /// <summary>
  99. /// 初始时间
  100. /// </summary>
  101. private void InitDate()
  102. {
  103. DateTime now = DateTime.Now;
  104. DateTime dt1 = new DateTime(now.Year, now.Month, 1);//当月第一天
  105. DateTime dt2 = dt1.AddMonths(1).AddDays(-1);//当月最后一天
  106. TimeBegin.Value = DateTime.Parse(dt1.ToString("yyyy-MM-dd") + " 00:00:00");
  107. TimeEnd.Value = DateTime.Parse(dt2.ToString("yyyy-MM-dd") + " 23:59:59");
  108. }
  109. public override void ToolBar_Click(object sender, string ToolbarKey)
  110. {
  111. switch (ToolbarKey)
  112. {
  113. case "Query":
  114. DoQuery();
  115. break;
  116. case "Update":
  117. DoUpdate();
  118. break;
  119. case "Print":
  120. printData();
  121. break;
  122. case "UpdateLin":
  123. DoUpdateLin();
  124. break;
  125. case "Close":
  126. this.Close();
  127. break;
  128. }
  129. }
  130. private ArrayList ingname = new ArrayList();
  131. /// <summary>
  132. /// 质保书打印
  133. /// </summary>
  134. private void printData()
  135. {
  136. UltraGridRow row = ultraGridOrder.ActiveRow;
  137. if (row == null) return;
  138. string billNo = row.Cells["BillNo"].Text.ToString();
  139. string ordLnDlyPk = row.Cells["OrdLnDlyPk"].Text.ToString();
  140. DataTable dt = ServerHelper.GetData("com.steering.pss.judge.DAL.QcmZbsQueryFrm.doQuerLanguage", new object[] { billNo, ordLnDlyPk }, ob);
  141. if (dt.Rows.Count <= 0)
  142. {
  143. MessageUtil.ShowTips("请维护质保书!");
  144. return;
  145. }
  146. ArrayList list1 = new ArrayList();
  147. for (int k = 0; k < dt.Rows.Count; k++)
  148. {
  149. string zbsName = dt.Rows[k]["ZBS_PATH"].ToString() + "/" + dt.Rows[k]["ZBS_NAME"].ToString() + ".pdf";
  150. List<FileBean> list = Core.Mes.Client.Comm.Server.FileHelper.Download(zbsName);
  151. ShowByListFileBean(list);
  152. string filePath = Environment.CurrentDirectory + "\\Tmp\\" + ingname[i];
  153. pdfPrint(filePath);
  154. list1.Add(dt.Rows[k]["ZBS_NAME"].ToString());
  155. }
  156. CoreClientParam ccp = new CoreClientParam();
  157. ccp.ServerName = "com.steering.pss.judge.DAL.QcmZbsQueryFrm";
  158. ccp.MethodName = "doUpdatePrintDataAll";
  159. ccp.ServerParams = new object[] { row.Cells["BillNoSeq"].Text.ToString().Trim(), this.UserInfo.GetUserName(), billNo, ordLnDlyPk, list1 };
  160. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  161. if (ccp.ReturnCode == -1) return;
  162. MessageUtil.ShowTips(ccp.ReturnInfo);
  163. if (ccp.ReturnInfo.Equals("打印成功!"))
  164. {
  165. DoQuery();
  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. if (row == null) return;
  296. int countM = 0;
  297. ArrayList list = new ArrayList();
  298. foreach (UltraGridRow item in ultraGridOrder.Rows)
  299. {
  300. if (Convert.ToBoolean(item.Cells["CHC"].Text) == true)
  301. {
  302. countM++;
  303. ArrayList list1 = new ArrayList();
  304. list1.Add(item.Cells["ZbsFlag"].Value.ToString().Trim());
  305. list1.Add(item.Cells["BillNoSeq"].Text.ToString().Trim());
  306. list.Add(list1);
  307. }
  308. }
  309. if (countM == 0)
  310. {
  311. MessageUtil.ShowTips("请勾选需要修改的出库合同信息!");
  312. return;
  313. }
  314. if (MessageUtil.ShowYesNoAndQuestion("是否确认修改打印状态?") ==
  315. DialogResult.No)
  316. return;
  317. CoreClientParam ccp = new CoreClientParam();
  318. ccp.ServerName = "com.steering.pss.judge.DAL.QcmZbsQueryFrm";
  319. ccp.MethodName = "doUpdate";
  320. ccp.ServerParams = new object[] { list, this.UserInfo.GetUserName() };
  321. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  322. if (ccp.ReturnCode == -1) return;
  323. MessageUtil.ShowTips(ccp.ReturnInfo);
  324. if (ccp.ReturnInfo.Equals("修改成功!"))
  325. {
  326. DoQuery();
  327. }
  328. }
  329. /// <summary>
  330. /// 修改许可证号
  331. /// </summary>
  332. private void DoUpdateLin()
  333. {
  334. ultraGridOrder.UpdateData();
  335. UltraGridRow row = ultraGridOrder.ActiveRow;
  336. if (row == null) return;
  337. int countM = 0;
  338. ArrayList list = new ArrayList();
  339. foreach (UltraGridRow item in ultraGridOrder.Rows)
  340. {
  341. if (Convert.ToBoolean(item.Cells["CHC"].Text) == true)
  342. {
  343. countM++;
  344. ArrayList list1 = new ArrayList();
  345. list1.Add(item.Cells["LicenseNo"].Value.ToString().Trim());
  346. list1.Add(item.Cells["CheckNo"].Value.ToString().Trim());
  347. list1.Add(item.Cells["BillNo"].Value.ToString().Trim());
  348. list1.Add(item.Cells["BillNoSeq"].Text.ToString().Trim());
  349. list.Add(list1);
  350. }
  351. }
  352. if (countM == 0)
  353. {
  354. MessageUtil.ShowTips("请勾选需要修改的出库合同信息!");
  355. return;
  356. }
  357. if (MessageUtil.ShowYesNoAndQuestion("是否确认修改?") ==
  358. DialogResult.No)
  359. return;
  360. CoreClientParam ccp = new CoreClientParam();
  361. ccp.ServerName = "com.steering.pss.judge.DAL.QcmZbsQueryFrm";
  362. ccp.MethodName = "doUpdateLin";
  363. ccp.ServerParams = new object[] { list, this.UserInfo.GetUserName() };
  364. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  365. if (ccp.ReturnCode == -1) return;
  366. MessageUtil.ShowTips(ccp.ReturnInfo);
  367. if (ccp.ReturnInfo.Equals("修改成功!"))
  368. {
  369. DoQuery();
  370. }
  371. }
  372. /// <summary>
  373. /// 查询
  374. /// </summary>
  375. private void DoQuery()
  376. {
  377. ArrayList param = new ArrayList();
  378. string billNo = "";
  379. if (ChcLadingSeq.Checked)
  380. {
  381. billNo = TxtLadingSeq.Text.Trim();
  382. }
  383. string orderNo = "";
  384. if (ChcOrderNo.Checked)
  385. {
  386. orderNo = TxtOrderNo.Text.Trim();
  387. }
  388. string strBegin = "1900-01-01 00:00:00";
  389. string strEnd = "9900-01-01 00:00:00";
  390. if (ChcTime.Checked)
  391. {
  392. if (TimeBegin.Value == null || TimeEnd.Value == null)
  393. {
  394. MessageUtil.ShowWarning("请选择正确的时间");
  395. return;
  396. }
  397. strBegin = TimeBegin.Value.ToString();
  398. strEnd = TimeEnd.Value.ToString();
  399. }
  400. string status = "";
  401. if (ChcStatus.Checked)
  402. {
  403. status = ComStatus.Value.ToString();
  404. }
  405. //string[] arr = BaseMethod.InitPermissions(this.ValidDataPurviewIds,this.ob);
  406. //string[] arr = this.ValidDataPurviewIds;
  407. param.Add(billNo);
  408. param.Add(orderNo);
  409. param.Add(strBegin);
  410. param.Add(strEnd);
  411. List<YdmZcBillMyEntity> listSource = EntityHelper.GetData<YdmZcBillMyEntity>(
  412. "com.steering.pss.judge.DAL.QcmZbsQueryFrm.getOrderInfoByBiltNoYuLan", new object[] { param, status,this.UserInfo.GetDeptid() }, this.ob);
  413. ydmZcBillMyEntityBindingSource.DataSource = listSource;
  414. //DataTable dt = ServerHelper.GetData("com.steering.pss.judge.DAL.QcmZbsQueryFrm.getBiltNo", new Object[] { param, arr}, this.ob);
  415. //GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
  416. //if (dt == null || dt.Rows.Count == 0)
  417. //{
  418. // QueryJustStoveInfo("");
  419. //}
  420. //BaseMethod.SetUltraGridRowColor(ultraGridBillNo, new string[] { "LOADVEHICLE_TYPE" }, new string[] { "虚拟" }, Color.GreenYellow);
  421. }
  422. private void QueryJustStoveInfo(string billNo, string ordLnDlyPk)
  423. {
  424. ultraGridJustNo.UpdateData();
  425. List<YdmZcBillCyEntity> listSource = EntityHelper.GetData<YdmZcBillCyEntity>(
  426. "com.steering.pss.judge.DAL.QcmZbsQueryFrm.getJustStoveNoInfoByBiltNo", new object[] { billNo }, this.ob);
  427. ydmZcBillCyEntityBindingSource.DataSource = listSource;
  428. foreach (UltraGridRow row in ultraGridJustNo.Rows)
  429. {
  430. //理货在途量
  431. row.Cells["ActCountKc"].Value = (double.Parse(row.Cells["ActTallCount"].Value.ToString()) - double.Parse(row.Cells["ActCountLoad"].Value.ToString())).ToString();
  432. if (double.Parse(row.Cells["ActCountKc"].Value.ToString()) != 0.0)
  433. {
  434. row.Cells["ActWeightKc"].Value = (double.Parse(row.Cells["ActTallWt"].Value.ToString()) - double.Parse(row.Cells["ActWeightLoad"].Value.ToString())).ToString("f3");
  435. }
  436. else
  437. {
  438. row.Cells["ActWeightKc"].Value = "0.000";
  439. }
  440. //提单在途量
  441. row.Cells["ActCountZy"].Value = (double.Parse(row.Cells["ActCount"].Value.ToString()) - double.Parse(row.Cells["ActCountLoad"].Value.ToString())).ToString();
  442. if (double.Parse(row.Cells["ActCountZY"].Value.ToString()) != 0.0)
  443. {
  444. row.Cells["ActWeightZy"].Value = (double.Parse(row.Cells["ActWeight"].Value.ToString()) - double.Parse(row.Cells["ActWeightLoad"].Value.ToString())).ToString("f3");
  445. }
  446. else
  447. {
  448. row.Cells["ActWeightZY"].Value = "0.000";
  449. }
  450. if (row.Cells["OrdLnDlyPk"].Text.Equals(ordLnDlyPk))
  451. {
  452. row.Appearance.BackColor = Color.Wheat;
  453. }
  454. else
  455. {
  456. row.Appearance.BackColor = Color.White;
  457. }
  458. }
  459. }
  460. DataTable dtzbs = new DataTable();
  461. private void ultraGridOrder_AfterRowActivate(object sender, EventArgs e)
  462. {
  463. UltraGridRow ugr = ultraGridOrder.ActiveRow;
  464. if (ugr == null)
  465. {
  466. return;
  467. }
  468. QueryJustStoveInfo(ugr.Cells["BillNo"].Text.ToString(), ugr.Cells["OrdLnDlyPk"].Text.ToString());
  469. //接箍信息
  470. DataTable dt = ServerHelper.GetData("com.steering.pss.judge.DAL.QcmZbsQueryFrm.QueryCoupling", new object[] { ugr.Cells["BillNo"].Text.ToString() }, this.ob);
  471. if (dt.Rows.Count > 0 && dt != null)
  472. {
  473. GridHelper.CopyDataToDatatable(dt, this.dataTable2, true);
  474. //GridHelper.RefreshAndAutoSize(this.ultraGrid1);
  475. }
  476. string billNo = ugr.Cells["BillNo"].Text.ToString();
  477. string ordLnDlyPk = ugr.Cells["OrdLnDlyPk"].Text.ToString();
  478. //查询多语言质保书
  479. dtzbs.Clear();
  480. dtzbs = ServerHelper.GetData("com.steering.pss.judge.DAL.QcmZbsQueryFrm.doQuerLanguage1", new object[] { billNo, ordLnDlyPk }, ob);
  481. ultraComboEditor3.DataSource = dtzbs;
  482. ultraComboEditor3.DisplayMember = "质保书";
  483. if (dtzbs.Rows.Count > 0)
  484. {
  485. ugr.Cells["ZbsName"].Value = dtzbs.Rows[0]["质保书"].ToString();
  486. }
  487. }
  488. /// <summary>
  489. /// 按回车键触发查询按钮
  490. /// </summary>
  491. /// <param name="sender"></param>
  492. /// <param name="e"></param>
  493. private void ContPublic_KeyDown(object sender, KeyEventArgs e)
  494. {
  495. if (e.KeyCode == Keys.Enter)
  496. {
  497. DoQuery();
  498. }
  499. }
  500. private int splitterDistance = 0;
  501. private void ultraExpandableGroupBox1_ExpandedStateChanged(object sender, EventArgs e)
  502. {
  503. if (ultraExpandableGroupBox1.Expanded == false)
  504. {
  505. this.splitContainer2.SplitterDistance = splitContainer2.Size.Height - 26;
  506. }
  507. else
  508. {
  509. this.splitContainer2.SplitterDistance = splitterDistance == 0 ? splitContainer2.Size.Height / 2 : splitterDistance;
  510. }
  511. }
  512. private void ultraGridOrder_AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
  513. {
  514. foreach (UltraGridRow uRow in ultraGridOrder.Selected.Rows)
  515. {
  516. if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow))
  517. {
  518. uRow.Cells["CHC"].Value = true;
  519. }
  520. }
  521. }
  522. /// <summary>
  523. /// 质保书查看,上传,删除
  524. /// </summary>
  525. /// <param name="sender"></param>
  526. /// <param name="e"></param>
  527. private void craftImg1_EditorButtonClick(object sender, EditorButtonEventArgs e)
  528. {
  529. UltraGridRow row = ultraGridOrder.ActiveRow;
  530. if (row == null) return;
  531. string billNo = row.Cells["BillNo"].Text.ToString();
  532. string billNoSeq = row.Cells["BillNoSeq"].Text.ToString();
  533. string orderNoSeq = row.Cells["OrderSeqNo"].Text.ToString();
  534. string ordLnDlyPk = row.Cells["OrdLnDlyPk"].Text.ToString();
  535. string ordLnPk = row.Cells["OrdLnPk"].Text.ToString();
  536. string askSubItmeVal = row.Cells["AskSubItmeVal"].Text.ToString();
  537. string filePath = row.GetValue("ZbsPath");
  538. string metricSystem = row.Cells["MetricSystem"].Text.ToString();
  539. if (e.Button.Key.ToLower().Equals("select"))
  540. {
  541. if (filePath.Equals(""))
  542. {
  543. if (askSubItmeVal.Equals(""))
  544. {
  545. MessageUtil.ShowTips("请选择语言要求!");
  546. return;
  547. }
  548. string askSubItmeValNo = row.Cells["AskSubItmeVal"].Value.ToString();
  549. if (metricSystem.Equals(""))
  550. {
  551. MessageUtil.ShowTips("请选择公英制!");
  552. return;
  553. }
  554. string metricSystemNo = row.Cells["MetricSystem"].Value.ToString();
  555. string strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepCertificateOfProductQuality.cpt"
  556. + "&BILL_NO=" + billNo + "&ORD_LN_PK=" + ordLnPk + "&ASK_ITEM_NO=" + askSubItmeValNo + "&METRIC_SYSTEM=" + metricSystemNo + "&USER=" + this.UserInfo.GetUserID() + "&ORD_LN_DLY_PK=" + ordLnDlyPk;
  557. FrmRepExcel down = new FrmRepExcel(ob, strurl);
  558. down.Text = "质保书";
  559. down.Visible = false;
  560. down.Size = new Size(740, this.Height);
  561. down.WindowState = FormWindowState.Maximized;
  562. down.ShowDialog();
  563. }
  564. else
  565. {
  566. FormFileDown askDown = new FormFileDown(this.ob, filePath);
  567. askDown.CtrlFileDown1.Button3.Visible = false;
  568. askDown.Show();
  569. }
  570. //dlgOrderAskDown askDown = new dlgOrderAskDown(ob, filePath);
  571. //askDown.Show();
  572. }
  573. else if (e.Button.Key.ToLower().Equals("add"))
  574. {
  575. string pdfName = billNoSeq;
  576. string filePathNew = "Qcm/ZbsPdf/" + orderNoSeq + "/";
  577. var serverFileList = FileHelper.Download(filePathNew);
  578. if (serverFileList.Count > 0)
  579. {
  580. MessageUtil.ShowWarning("该记录已存在一份文件,请删除后再重新上传!");
  581. return;
  582. }
  583. if (askSubItmeVal.Equals(""))
  584. {
  585. MessageUtil.ShowTips("请选择语言要求!");
  586. return;
  587. }
  588. string askSubItmeValNo = row.Cells["AskSubItmeVal"].Value.ToString();
  589. if (metricSystem.Equals(""))
  590. {
  591. MessageUtil.ShowTips("请选择公英制!");
  592. return;
  593. }
  594. string metricSystemNo = row.Cells["MetricSystem"].Value.ToString();
  595. //保存
  596. CoreClientParam ccp = new CoreClientParam();
  597. ccp.ServerName = "com.steering.pss.judge.DAL.QcmZbsQueryFrm";
  598. ccp.MethodName = "doAdd";
  599. ccp.ServerParams = new object[] { pdfName, filePathNew, billNoSeq, billNo, ordLnDlyPk, this.UserInfo.GetUserName(), askSubItmeValNo, metricSystemNo };
  600. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  601. if (ccp.ReturnCode == -1) return;
  602. MessageUtil.ShowTips(ccp.ReturnInfo);
  603. if (ccp.ReturnInfo.Equals("保存成功!"))
  604. {
  605. WebClient webClient = new WebClient();
  606. List<FileBean> listPdf = new List<FileBean>();
  607. string craftPath = filePathNew + pdfName + ".pdf";
  608. string strurl = "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepCertificateOfProductQuality.cpt&format=pdf"
  609. + "&BILL_NO=" + billNo + "&ORD_LN_PK=" + ordLnPk + "&ASK_ITEM_NO=" + askSubItmeValNo + "&METRIC_SYSTEM=" + metricSystemNo + "&USER=" + this.UserInfo.GetUserID() + "&ORD_LN_DLY_PK=" + ordLnDlyPk;
  610. byte[] pdf = webClient.DownloadData(strurl);
  611. if (pdf.Length <= 10000)
  612. {
  613. MessageUtil.ShowError("生成PDF ,请重新生成!");
  614. return;
  615. }
  616. FileBean fileBean = new FileBean();
  617. fileBean.setFile(pdf);
  618. fileBean.setFileName(pdfName + ".pdf");
  619. fileBean.setPathName(filePathNew);
  620. listPdf.Add(fileBean);
  621. webClient.Dispose();
  622. var a = FileHelper.Upload(listPdf);
  623. if (a)
  624. {
  625. //MessageUtil.ShowTips("上传成功!");
  626. row.Cells["ZbsName"].Value = pdfName + ".pdf";
  627. row.Cells["ZbsPath"].Value = filePathNew;
  628. DoQuery();
  629. }
  630. }
  631. }
  632. else
  633. {
  634. //删除
  635. CoreClientParam ccp = new CoreClientParam();
  636. ccp.ServerName = "com.steering.pss.judge.DAL.QcmZbsQueryFrm";
  637. ccp.MethodName = "doDelete";
  638. ccp.ServerParams = new object[] { row.Cells["ZbsName"].Text.ToString(), billNoSeq, billNo, ordLnDlyPk };
  639. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  640. if (ccp.ReturnCode == -1) return;
  641. MessageUtil.ShowTips(ccp.ReturnInfo);
  642. if (ccp.ReturnInfo.Equals("删除成功!"))
  643. {
  644. var a = FileHelper.Delete(filePath);
  645. if (a)
  646. {
  647. DoQuery();
  648. }
  649. }
  650. }
  651. }
  652. private void ultraTextEditor1_EditorButtonClick(object sender, EditorButtonEventArgs e)
  653. {
  654. UltraGridRow row = ultraGridOrder.ActiveRow;
  655. if (row == null) return;
  656. string CraftPath = row.Cells["CraftPath"].Text.ToString();
  657. FormFileDown askDown = new FormFileDown(this.ob, CraftPath);
  658. askDown.CtrlFileDown1.Button3.Visible = false;
  659. askDown.Show();
  660. }
  661. private void ultraComboEditor3_EditorButtonClick(object sender, EditorButtonEventArgs e)
  662. {
  663. UltraGridRow row = ultraGridOrder.ActiveRow;
  664. if (row == null) return;
  665. string billNo = row.Cells["BillNo"].Text.ToString();
  666. string billNoSeq = row.Cells["BillNoSeq"].Text.ToString();
  667. string orderNo = row.Cells["OrderSeqNo"].Text.ToString();
  668. string ordLnDlyPk = row.Cells["OrdLnDlyPk"].Text.ToString();
  669. string ordLnPk = row.Cells["OrdLnPk"].Text.ToString();
  670. string askSubItmeVal = "";
  671. if (!row.Cells["AskSubItmeVal"].Text.ToString().Equals(""))
  672. {
  673. askSubItmeVal = row.Cells["AskSubItmeVal"].Value.ToString();
  674. }
  675. string metricSystem = "";
  676. if (!row.Cells["MetricSystem"].Text.ToString().Equals(""))
  677. {
  678. metricSystem = row.Cells["MetricSystem"].Value.ToString();
  679. }
  680. if (e.Button.Key.ToLower().Equals("select"))
  681. {
  682. string filePath = row.GetValue("ZbsPath");
  683. FormFileDown askDown = new FormFileDown(this.ob, filePath);
  684. askDown.CtrlFileDown1.Button3.Visible = false;
  685. askDown.Show();
  686. }
  687. else if (e.Button.Key.ToLower().Equals("add"))
  688. { //维护
  689. IQueryable<UltraGridRow> checkMagRows = this.ultraGridJustNo.Rows.AsQueryable().Where(" CHK = 'True'");
  690. ArrayList parm = new ArrayList();
  691. if (checkMagRows.Count() > 0)
  692. {
  693. foreach (UltraGridRow row2 in checkMagRows)
  694. { //招标质保书选择的炉批
  695. row2.Cells["JudgeStoveNo"].Value.ToString();
  696. row2.Cells["BatchNo"].Value.ToString();
  697. parm.Add(row2.Cells["JudgeStoveNo"].Value.ToString() + row2.Cells["BatchNo"].Value.ToString());
  698. }
  699. }
  700. QcmZbsLanguageYuLan lan = new QcmZbsLanguageYuLan(billNo, orderNo, ordLnDlyPk, metricSystem, askSubItmeVal, billNoSeq, parm, ob);
  701. lan.ShowDialog();
  702. }
  703. else
  704. {
  705. if (row.Cells["ZbsName"].Text.ToString().Equals(""))
  706. {
  707. MessageUtil.ShowTips("质保书为空,请选择或维护!");
  708. return;
  709. }
  710. string zbsName = row.Cells["ZbsPath"].Text.ToString() + "/" + row.Cells["ZbsName"].Text.ToString() + ".pdf";
  711. List<FileBean> list = Core.Mes.Client.Comm.Server.FileHelper.Download(zbsName);
  712. ShowByListFileBean(list);
  713. string filePath = Environment.CurrentDirectory + "\\Tmp\\" + ingname[i];
  714. pdfPrint(filePath);
  715. //实例化PdfDocument类对象,并加载PDF文档
  716. //PdfDocument doc = new PdfDocument();
  717. //加载的打印PDF文件
  718. //doc.LoadFromFile(filePath);
  719. ////选择默认打印机打印所有页面
  720. //doc.PrintDocument.Print();
  721. //选择打印机并设置打印页面范围
  722. //PrintDialog dialogPrint = new PrintDialog();
  723. //dialogPrint.AllowPrintToFile = true;
  724. //dialogPrint.AllowSomePages = true;
  725. //dialogPrint.PrinterSettings.MinimumPage = 1;
  726. //dialogPrint.PrinterSettings.MaximumPage = doc.Pages.Count;
  727. //dialogPrint.PrinterSettings.FromPage = 1;
  728. //dialogPrint.PrinterSettings.ToPage = doc.Pages.Count;
  729. //if (dialogPrint.ShowDialog() == DialogResult.OK)
  730. //{
  731. // doc.PrintFromPage = dialogPrint.PrinterSettings.FromPage;
  732. // doc.PrintToPage = dialogPrint.PrinterSettings.ToPage;
  733. // doc.PrinterName = dialogPrint.PrinterSettings.PrinterName;
  734. // PrintDocument printDoc = doc.PrintDocument;
  735. // dialogPrint.Document = printDoc;
  736. // printDoc.Print();
  737. //}
  738. CoreClientParam ccp = new CoreClientParam();
  739. ccp.ServerName = "com.steering.pss.judge.DAL.QcmZbsQueryFrm";
  740. ccp.MethodName = "doUpdatePrintData";
  741. ccp.ServerParams = new object[] { row.Cells["BillNoSeq"].Text.ToString().Trim(), this.UserInfo.GetUserName(), row.Cells["ZbsName"].Text.ToString(), billNo, ordLnDlyPk };
  742. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  743. if (ccp.ReturnCode == -1) return;
  744. MessageUtil.ShowTips(ccp.ReturnInfo);
  745. if (ccp.ReturnInfo.Equals("打印成功!"))
  746. {
  747. DoQuery();
  748. }
  749. }
  750. }
  751. private void ultraComboEditor3_ValueChanged(object sender, EventArgs e)
  752. {
  753. UltraGridRow row = ultraGridOrder.ActiveRow;
  754. if (row == null) return;
  755. if (row.Cells["ZbsName"].Text.Equals("")) return;
  756. if (dtzbs.Rows.Count > 0)
  757. {
  758. DataRow[] dr = dtzbs.Select("质保书='" + row.Cells["ZbsName"].Text.ToString() + "'");
  759. DataTable dt = ToDataTable(dr);
  760. if (dt.Rows.Count > 0)
  761. {
  762. row.Cells["ZbsPath"].Value = dt.Rows[0]["质保书路径"].ToString();
  763. }
  764. }
  765. }
  766. public DataTable ToDataTable(DataRow[] rows)
  767. {
  768. if (rows == null || rows.Length == 0) return null;
  769. DataTable tmp = rows[0].Table.Clone(); // 复制DataRow的表结构
  770. foreach (DataRow row in rows)
  771. tmp.Rows.Add(row.ItemArray); // 将DataRow添加到DataTable中
  772. return tmp;
  773. }
  774. private void ultraGridJustNo_ClickCellButton(object sender, CellEventArgs e)
  775. {
  776. this.ultraGridJustNo.UpdateData();
  777. if (e.Cell.Column.Key == "JudgeStoveNo")
  778. {
  779. string batchNo = ultraGridJustNo.ActiveRow.Cells["BatchNo"].Value.ToString();
  780. string judgeStoveNo = ultraGridJustNo.ActiveRow.Cells["JudgeStoveNo"].Value.ToString();
  781. FrmCoupling orderZg = new FrmCoupling(judgeStoveNo, batchNo, this.ob);
  782. orderZg.ShowDialog();
  783. }
  784. }
  785. }
  786. }