FrmMaterialInout.cs.svn-base 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Core.Mes.Client.Common;
  10. using Infragistics.Win.UltraWinGrid;
  11. using Infragistics.Win.UltraWinGrid.ExcelExport;
  12. using Infragistics.Win;
  13. using System.Collections;
  14. using CoreFS.CA06;
  15. using System.Diagnostics;
  16. using System.IO;
  17. using Core.LgMes.Client.Report;
  18. namespace Core.LgMes.Client.lgIntegrationQuery
  19. {
  20. public partial class FrmMaterialInout : frmStyleBase
  21. {
  22. private bool bAddNow, bEditNow, bDelNow;
  23. private UltraGridRow currRow = null;
  24. public FrmMaterialInout()
  25. {
  26. InitializeComponent();
  27. }
  28. private void FrmMaterialInout_Load(object sender, EventArgs e)
  29. {
  30. ultraDateTimeEditor1.DateTime = DateTime.Today;
  31. ultraDateTimeEditor2.DateTime = DateTime.Today;
  32. ValueList vl = new ValueList();
  33. vl.ValueListItems.Add("4#LF", "4#LF");
  34. vl.ValueListItems.Add("5#LF", "5#LF");
  35. vl.ValueListItems.Add("RH", "RH");
  36. vl.ValueListItems.Add("VD", "VD");
  37. vl.ValueListItems.Add("中包班", "中包班");
  38. vl.ValueListItems.Add("钢包班", "钢包班");
  39. this.ultraGrid1.DisplayLayout.Bands[0].Columns["STATIONCODE"].ValueList = vl;
  40. proc_SetToolbarButtons();
  41. }
  42. public override void ToolBar_Click(object sender, string ToolbarKey)
  43. {
  44. switch (ToolbarKey)
  45. {
  46. case "Query":
  47. {
  48. if (bAddNow || bEditNow || bDelNow)
  49. return;
  50. proc_Query();
  51. proc_SetToolbarButtons();
  52. break;
  53. }
  54. case "Add":
  55. {
  56. if (bAddNow || bEditNow || bDelNow)
  57. return;
  58. currRow = this.ultraGrid1.DisplayLayout.Bands[0].AddNew();
  59. this.proc_setCellReadOnly(currRow, false);
  60. bAddNow = true;
  61. this.proc_SetToolbarButtons();
  62. break;
  63. }
  64. case "Edit":
  65. {
  66. if (ultraGrid1.ActiveRow == null || (bAddNow || bEditNow || bDelNow))
  67. return;
  68. currRow = ultraGrid1.ActiveRow;
  69. this.proc_setCellReadOnly(currRow, false);
  70. bEditNow = true;
  71. this.proc_SetToolbarButtons();
  72. break;
  73. }
  74. case "Save":
  75. {
  76. if (bAddNow)
  77. {
  78. proc_Add("Add");
  79. }
  80. else if (bEditNow)
  81. {
  82. proc_Add("Edit");
  83. }
  84. proc_Query();
  85. break;
  86. }
  87. case "Delete":
  88. {
  89. if (ultraGrid1.ActiveRow == null || (bAddNow || bEditNow || bDelNow))
  90. return;
  91. bDelNow = true;
  92. this.proc_SetToolbarButtons();
  93. proc_Delete();
  94. bDelNow = false;
  95. proc_Query();
  96. this.proc_SetToolbarButtons();
  97. break;
  98. }
  99. case "Export":
  100. {
  101. try
  102. {
  103. if (ultraGrid1.Rows.Count == 0) return;
  104. string strFileName = "精二作业区物料申报记录"+DateTime.Now.ToString("yyyyMMdd");
  105. SaveFileDialog dlg = new SaveFileDialog();
  106. dlg.Title = "保存";
  107. dlg.OverwritePrompt = true;
  108. dlg.Filter = "Excel文件(*.xls)|*.xls";
  109. dlg.AddExtension = true;
  110. dlg.FileName = strFileName;
  111. if (dlg.ShowDialog() == DialogResult.OK)
  112. {
  113. strFileName = dlg.FileName;
  114. ultraGridExcelExporter1.Export(ultraGrid1, strFileName);
  115. if (MessageBox.Show("数据导出成功!\r\n需要打开所导出文件吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
  116. {
  117. ultraGridExcelExporter1.Export(ultraGrid1, strFileName);
  118. ProcessStartInfo p = new ProcessStartInfo(strFileName);
  119. p.WorkingDirectory = Path.GetDirectoryName(strFileName);
  120. Process.Start(p);
  121. }
  122. }
  123. }
  124. catch (Exception ex)
  125. {
  126. MessageBox.Show(ex.Message);
  127. }
  128. break;
  129. }
  130. case "Cancel":
  131. {
  132. if (!(bAddNow || bEditNow)) return;
  133. string strOpt = " [" + (bAddNow ? "新增" : (bEditNow ? "修改" : "")) + "]";
  134. if (MessageBox.Show("确定要取消" + strOpt + "操作吗?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  135. return;
  136. if (bAddNow)
  137. {
  138. currRow.Delete(false);
  139. currRow = null;
  140. if (ultraGrid1.Rows.Count > 0)
  141. {
  142. ultraGrid1.ActiveCell = ultraGrid1.Rows[ultraGrid1.Rows.Count - 1].Cells["STATIONCODE"];
  143. ultraGrid1.Rows[ultraGrid1.Rows.Count - 1].Cells["STATIONCODE"].Selected = false;
  144. }
  145. bAddNow = false;
  146. }
  147. else if (bEditNow)
  148. {
  149. this.proc_setCellReadOnly(currRow, true);
  150. currRow = null;
  151. bEditNow = false;
  152. }
  153. this.proc_SetToolbarButtons();
  154. break;
  155. }
  156. case "Close":
  157. {
  158. this.Close();
  159. break;
  160. }
  161. }
  162. }
  163. public void proc_Query()
  164. {
  165. Cursor oldCursor = this.Cursor;
  166. this.Cursor = Cursors.WaitCursor;
  167. try
  168. {
  169. this.dataTable1.Clear();
  170. string sqlStr = @"SELECT * FROM DEV_MATERIAL_REPORT WHERE
  171. OPTDATE BETWEEN TO_DATE('{0}','YYYY-MM-DD HH24:MI:SS') AND TO_DATE('{1}','YYYY-MM-DD HH24:MI:SS')";
  172. if (ultraDateTimeEditor1.DateTime.Date > ultraDateTimeEditor2.DateTime.Date)
  173. {
  174. MessageBox.Show("查询开始日期不能大于结束日期!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  175. return;
  176. }
  177. string strFrom = ultraDateTimeEditor1.DateTime.ToString("yyyy-MM-dd") + " 00:00:00";
  178. string strTo = ultraDateTimeEditor2.DateTime.ToString("yyyy-MM-dd") + " 23:59:59";
  179. sqlStr = string.Format(sqlStr, strFrom, strTo);
  180. //调用服务端方法
  181. CoreClientParam CCP_LgEts = new CoreClientParam();
  182. DataTable dt = new DataTable();
  183. CCP_LgEts.ServerName = "Core.LgMes.Server.Common.ComDBExecute";
  184. CCP_LgEts.MethodName = "doSimpleQuery";
  185. CCP_LgEts.ServerParams = new object[] { sqlStr };
  186. CCP_LgEts.SourceDataTable = dt;
  187. this.ExecuteQueryToDataTable(CCP_LgEts, CoreInvokeType.Internal);
  188. DataSet ds = new DataSet();
  189. if (dt != null && dt.Rows.Count > 0)
  190. {
  191. this.dataTable1.Rows.Clear();
  192. DataRow dr;
  193. for (int iRow = 0; iRow < dt.Rows.Count; iRow++)
  194. {
  195. dr = this.dataTable1.NewRow();
  196. for (int jCol = 0; jCol < dt.Columns.Count; jCol++)
  197. {
  198. if (this.dataTable1.Columns.Contains(dt.Columns[jCol].ColumnName))
  199. {
  200. dr[dt.Columns[jCol].ColumnName] = dt.Rows[iRow][jCol];
  201. }
  202. }
  203. this.dataTable1.Rows.Add(dr);
  204. }
  205. }
  206. ultraGrid1.UpdateData();
  207. if (ultraGrid1.Rows.Count > 0)
  208. {
  209. ultraGrid1.ActiveCell = ultraGrid1.Rows[0].Cells["STATIONCODE"];
  210. ultraGrid1.Rows[0].Cells["STATIONCODE"].Selected = false;
  211. }
  212. this.proc_SetUltraGridReadOnly(ultraGrid1);
  213. ArrayList alistColumns = new ArrayList();
  214. for (int i = 0; i < this.dataTable1.Columns.Count; i++)
  215. {
  216. if (this.dataTable1.Columns[i].ColumnName != "OPTDATE" && this.dataTable1.Columns[i].ColumnName != "OPTMAN" &&
  217. this.dataTable1.Columns[i].ColumnName != "UUID_" && this.dataTable1.Columns[i].ColumnName != "STATIONCODE")
  218. alistColumns.Add(this.dataTable1.Columns[i].ColumnName);
  219. }
  220. proc_Statics(ref ultraGrid1, alistColumns, true, " {0:############0.0}");
  221. }
  222. catch
  223. { }
  224. finally
  225. {
  226. this.Cursor = oldCursor;
  227. }
  228. }
  229. public void proc_Add(string flag)
  230. {
  231. try
  232. {
  233. this.ultraGrid1.UpdateData();
  234. if (dataTable1.Rows.Count > 0)
  235. {
  236. string strErr = "";
  237. string strMess = "";
  238. if (flag == "Add")
  239. {
  240. ArrayList arry = new ArrayList();
  241. arry.Add("frmMaterial.Insert");
  242. string str1 = ultraGrid1.ActiveRow.Cells["STATIONCODE"].Text;
  243. string str2 = ultraGrid1.ActiveRow.Cells["ZTJ"].Text;
  244. string str3 = ultraGrid1.ActiveRow.Cells["RHGZJ"].Text;
  245. string str4 = ultraGrid1.ActiveRow.Cells["LG"].Text;
  246. string str5 = ultraGrid1.ActiveRow.Cells["LX"].Text;
  247. string str6 = ultraGrid1.ActiveRow.Cells["WFCGX"].Text;
  248. string str7 = ultraGrid1.ActiveRow.Cells["CGX"].Text;
  249. string str8 = ultraGrid1.ActiveRow.Cells["LT"].Text;
  250. string str9 = ultraGrid1.ActiveRow.Cells["XL"].Text;
  251. string str10 = ultraGrid1.ActiveRow.Cells["NT"].Text;
  252. string str11 = ultraGrid1.ActiveRow.Cells["FT"].Text;
  253. string str12 = ultraGrid1.ActiveRow.Cells["NB"].Text;
  254. string str13 = ultraGrid1.ActiveRow.Cells["TB"].Text;
  255. string str14 = ultraGrid1.ActiveRow.Cells["TT"].Text;
  256. string str15 = ultraGrid1.ActiveRow.Cells["GT"].Text;
  257. string str16 = ultraGrid1.ActiveRow.Cells["PT"].Text;
  258. string str17 = ultraGrid1.ActiveRow.Cells["XT"].Text;
  259. string str18 = ultraGrid1.ActiveRow.Cells["LHT"].Text;
  260. string str19 = ultraGrid1.ActiveRow.Cells["FDHJ"].Text;
  261. string str20 = ultraGrid1.ActiveRow.Cells["JSM"].Text;
  262. string str21 = ultraGrid1.ActiveRow.Cells["DJ"].Text;
  263. string str22 = ultraGrid1.ActiveRow.Cells["DJT"].Text;
  264. string str23 = ultraGrid1.ActiveRow.Cells["DJDJ"].Text;
  265. string str24 = ultraGrid1.ActiveRow.Cells["DJX"].Text;
  266. string str25 = ultraGrid1.ActiveRow.Cells["XBLLZ"].Text;
  267. string str26 = ultraGrid1.ActiveRow.Cells["GBZZ"].Text;
  268. string str27 = ultraGrid1.ActiveRow.Cells["TQZ"].Text;
  269. string str28 = ultraGrid1.ActiveRow.Cells["FJG"].Text;
  270. //string str29 = ultraGrid1.ActiveRow.Cells["ZBZZ"].Text;
  271. //string str30 = ultraGrid1.ActiveRow.Cells["ZBSK"].Text;
  272. //string str31 = ultraGrid1.ActiveRow.Cells["SB"].Text;
  273. //string str32 = ultraGrid1.ActiveRow.Cells["MFD"].Text;
  274. //string str33 = ultraGrid1.ActiveRow.Cells["GLQ"].Text;
  275. string str34 = this.UserInfo.GetUserName();
  276. string str35 = ultraGrid1.ActiveRow.Cells["BM_LX"].Text;
  277. string str36 = ultraGrid1.ActiveRow.Cells["BM_WFCGX"].Text;
  278. string str37 = ultraGrid1.ActiveRow.Cells["BM_CGX"].Text;
  279. string str38 = ultraGrid1.ActiveRow.Cells["PTTQZ"].Text;
  280. string str39 = ultraGrid1.ActiveRow.Cells["JLLG"].Text;
  281. //string str39 = ultraGrid1.ActiveRow.Cells["ZBZZ1"].Text;
  282. //string str40 = ultraGrid1.ActiveRow.Cells["PTZBSK"].Text;
  283. //string str41 = ultraGrid1.ActiveRow.Cells["CDTZBSK"].Text;
  284. //string str42 = ultraGrid1.ActiveRow.Cells["PTSB"].Text;
  285. //string str43 = ultraGrid1.ActiveRow.Cells["CDTSB"].Text;
  286. arry.Add(str1);
  287. arry.Add(str2);
  288. arry.Add(str3);
  289. arry.Add(str4);
  290. arry.Add(str5);
  291. arry.Add(str6);
  292. arry.Add(str7);
  293. arry.Add(str8);
  294. arry.Add(str9);
  295. arry.Add(str10);
  296. arry.Add(str11);
  297. arry.Add(str12);
  298. arry.Add(str13);
  299. arry.Add(str14);
  300. arry.Add(str15);
  301. arry.Add(str16);
  302. arry.Add(str17);
  303. arry.Add(str18);
  304. arry.Add(str19);
  305. arry.Add(str20);
  306. arry.Add(str21);
  307. arry.Add(str22);
  308. arry.Add(str23);
  309. arry.Add(str24);
  310. arry.Add(str25);
  311. arry.Add(str26);
  312. arry.Add(str27);
  313. arry.Add(str28);
  314. /*arry.Add(str29);
  315. arry.Add(str30);
  316. arry.Add(str31);
  317. arry.Add(str32);
  318. arry.Add(str33);*/
  319. arry.Add(str34);
  320. arry.Add(str35);
  321. arry.Add(str36);
  322. arry.Add(str37);
  323. arry.Add(str38);
  324. arry.Add(str39);
  325. /*arry.Add(str40);
  326. arry.Add(str41);
  327. arry.Add(str42);
  328. arry.Add(str43);*/
  329. CommonClientToServer cctos = new CommonClientToServer();
  330. cctos.ob = this.ob;
  331. cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBSave",
  332. "doSimpleSave", arry, out strErr);
  333. this.proc_setCellReadOnly(currRow, true);
  334. currRow = null;
  335. bAddNow = false;
  336. }
  337. else if (flag == "Edit")
  338. {
  339. ArrayList arry = new ArrayList();
  340. arry.Add("frmMaterial.Update");
  341. string str1 = ultraGrid1.ActiveRow.Cells["STATIONCODE"].Text;
  342. string str2 = ultraGrid1.ActiveRow.Cells["ZTJ"].Text;
  343. string str3 = ultraGrid1.ActiveRow.Cells["RHGZJ"].Text;
  344. string str4 = ultraGrid1.ActiveRow.Cells["LG"].Text;
  345. string str5 = ultraGrid1.ActiveRow.Cells["LX"].Text;
  346. string str6 = ultraGrid1.ActiveRow.Cells["WFCGX"].Text;
  347. string str7 = ultraGrid1.ActiveRow.Cells["CGX"].Text;
  348. string str8 = ultraGrid1.ActiveRow.Cells["LT"].Text;
  349. string str9 = ultraGrid1.ActiveRow.Cells["XL"].Text;
  350. string str10 = ultraGrid1.ActiveRow.Cells["NT"].Text;
  351. string str11 = ultraGrid1.ActiveRow.Cells["FT"].Text;
  352. string str12 = ultraGrid1.ActiveRow.Cells["NB"].Text;
  353. string str13 = ultraGrid1.ActiveRow.Cells["TB"].Text;
  354. string str14 = ultraGrid1.ActiveRow.Cells["TT"].Text;
  355. string str15 = ultraGrid1.ActiveRow.Cells["GT"].Text;
  356. string str16 = ultraGrid1.ActiveRow.Cells["PT"].Text;
  357. string str17 = ultraGrid1.ActiveRow.Cells["XT"].Text;
  358. string str18 = ultraGrid1.ActiveRow.Cells["LHT"].Text;
  359. string str19 = ultraGrid1.ActiveRow.Cells["FDHJ"].Text;
  360. string str20 = ultraGrid1.ActiveRow.Cells["JSM"].Text;
  361. string str21 = ultraGrid1.ActiveRow.Cells["DJ"].Text;
  362. string str22 = ultraGrid1.ActiveRow.Cells["DJT"].Text;
  363. string str23 = ultraGrid1.ActiveRow.Cells["DJDJ"].Text;
  364. string str24 = ultraGrid1.ActiveRow.Cells["DJX"].Text;
  365. string str25 = ultraGrid1.ActiveRow.Cells["XBLLZ"].Text;
  366. string str26 = ultraGrid1.ActiveRow.Cells["GBZZ"].Text;
  367. string str27 = ultraGrid1.ActiveRow.Cells["TQZ"].Text;
  368. string str28 = ultraGrid1.ActiveRow.Cells["FJG"].Text;
  369. //string str29 = ultraGrid1.ActiveRow.Cells["ZBZZ"].Text;
  370. //string str30 = ultraGrid1.ActiveRow.Cells["ZBSK"].Text;
  371. //string str31 = ultraGrid1.ActiveRow.Cells["SB"].Text;
  372. //string str32 = ultraGrid1.ActiveRow.Cells["MFD"].Text;
  373. //string str33 = ultraGrid1.ActiveRow.Cells["GLQ"].Text;
  374. string str34 = this.UserInfo.GetUserName();
  375. string uuid = ultraGrid1.ActiveRow.Cells["UUID_"].Text;
  376. string str35 = ultraGrid1.ActiveRow.Cells["BM_LX"].Text;
  377. string str36 = ultraGrid1.ActiveRow.Cells["BM_WFCGX"].Text;
  378. string str37 = ultraGrid1.ActiveRow.Cells["BM_CGX"].Text;
  379. string str38 = ultraGrid1.ActiveRow.Cells["PTTQZ"].Text;
  380. string str39 = ultraGrid1.ActiveRow.Cells["JLLG"].Text;
  381. //string str39 = ultraGrid1.ActiveRow.Cells["ZBZZ1"].Text;
  382. //string str40 = ultraGrid1.ActiveRow.Cells["PTZBSK"].Text;
  383. //string str41 = ultraGrid1.ActiveRow.Cells["CDTZBSK"].Text;
  384. //string str42 = ultraGrid1.ActiveRow.Cells["PTSB"].Text;
  385. //string str43 = ultraGrid1.ActiveRow.Cells["CDTSB"].Text;
  386. arry.Add(str1);
  387. arry.Add(str2);
  388. arry.Add(str3);
  389. arry.Add(str4);
  390. arry.Add(str5);
  391. arry.Add(str6);
  392. arry.Add(str7);
  393. arry.Add(str8);
  394. arry.Add(str9);
  395. arry.Add(str10);
  396. arry.Add(str11);
  397. arry.Add(str12);
  398. arry.Add(str13);
  399. arry.Add(str14);
  400. arry.Add(str15);
  401. arry.Add(str16);
  402. arry.Add(str17);
  403. arry.Add(str18);
  404. arry.Add(str19);
  405. arry.Add(str20);
  406. arry.Add(str21);
  407. arry.Add(str22);
  408. arry.Add(str23);
  409. arry.Add(str24);
  410. arry.Add(str25);
  411. arry.Add(str26);
  412. arry.Add(str27);
  413. arry.Add(str28);
  414. /*arry.Add(str29);
  415. arry.Add(str30);
  416. arry.Add(str31);
  417. arry.Add(str32);
  418. arry.Add(str33);*/
  419. arry.Add(str34);
  420. arry.Add(str35);
  421. arry.Add(str36);
  422. arry.Add(str37);
  423. arry.Add(str38);
  424. arry.Add(str39);
  425. /*arry.Add(str40);
  426. arry.Add(str41);
  427. arry.Add(str42);
  428. arry.Add(str43);*/
  429. arry.Add(uuid);
  430. CommonClientToServer cctos = new CommonClientToServer();
  431. cctos.ob = this.ob;
  432. cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBSave",
  433. "doSimpleSave", arry, out strErr);
  434. this.proc_setCellReadOnly(currRow, true);
  435. currRow = null;
  436. bEditNow = false;
  437. }
  438. if (strErr == "")
  439. {
  440. dataTable1.AcceptChanges();
  441. //JJBStaticFunction.SetRowEdit(ultraGrid1);
  442. if (!string.IsNullOrEmpty(strMess))
  443. MessageBox.Show(strMess, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
  444. }
  445. else
  446. {
  447. MessageBox.Show("保存失败!输入信息已经存在或数据无效。", "错误");
  448. }
  449. if (ultraGrid1.ActiveCell != null)
  450. ultraGrid1.ActiveCell.Activated = false;
  451. this.proc_SetToolbarButtons();
  452. }
  453. }
  454. catch (System.Exception ex)
  455. {
  456. Console.WriteLine(ex.ToString());
  457. }
  458. }
  459. public void proc_Delete()
  460. {
  461. try
  462. {
  463. string strErr = "";
  464. ArrayList arry = new ArrayList();
  465. if (this.ultraGrid1.ActiveRow == null) return;
  466. string uuid_ = ultraGrid1.ActiveRow.Cells["UUID_"].Text.Trim();
  467. arry.Add("frmMaterial.Delete");
  468. arry.Add(uuid_);
  469. CommonClientToServer cctos = new CommonClientToServer();
  470. cctos.ob = this.ob;
  471. cctos.ExecuteQueryFunctions("Core.LgMes.Server.Common.ComDBSave",
  472. "doSimpleSave", arry, out strErr);
  473. if (!string.IsNullOrEmpty(strErr))
  474. {
  475. MessageBox.Show("删除错误:" + strErr);
  476. }
  477. else
  478. {
  479. MessageBox.Show("删除成功:" + strErr);
  480. }
  481. }
  482. catch { }
  483. }
  484. private void proc_SetToolbarButtons()
  485. {
  486. try
  487. {
  488. this.ToolBarItemEnable(this, "Query",!(bAddNow || bEditNow || bDelNow));
  489. this.ToolBarItemEnable(this, "Add", !(bAddNow || bEditNow || bDelNow));
  490. this.ToolBarItemEnable(this, "Edit", (!(bAddNow || bEditNow || bDelNow) && (ultraGrid1.ActiveRow != null)));
  491. this.ToolBarItemEnable(this, "Delete", (!(bAddNow || bEditNow || bDelNow) && (ultraGrid1.ActiveRow != null)));
  492. this.ToolBarItemEnable(this, "Export", (!(bAddNow || bEditNow || bDelNow) && ultraGrid1.Rows.Count > 0));
  493. this.ToolBarItemEnable(this, "Save", (bAddNow || bEditNow));
  494. this.ToolBarItemEnable(this, "Cancel", (bAddNow || bEditNow));
  495. //this.ToolBarVisible(this, "Save");
  496. //this.Toolbars[0].Tools["Save"].SharedProps.Visible = (bAddNow || bEditNow);
  497. //this.Toolbars[0].Tools["Cancel"].SharedProps.Visible = (bAddNow || bEditNow);
  498. }
  499. catch { }
  500. }
  501. private void proc_setCellReadOnly(UltraGridRow row, bool bReadOnly)
  502. {
  503. try
  504. {
  505. if (row == null)
  506. return;
  507. if (bReadOnly)
  508. {
  509. row.Activation = Activation.ActivateOnly;
  510. row.CellAppearance.BackColor = Color.White;
  511. foreach (Infragistics.Win.UltraWinGrid.UltraGridCell cell in row.Cells)
  512. {
  513. cell.CancelUpdate();
  514. }
  515. }
  516. else
  517. {
  518. row.Activation = Activation.AllowEdit;
  519. row.CellAppearance.BackColor = Color.Khaki;
  520. }
  521. }
  522. catch (Exception ex)
  523. {
  524. MessageBox.Show(ex.Message);
  525. }
  526. }
  527. private void proc_SetUltraGridReadOnly(Infragistics.Win.UltraWinGrid.UltraGridBase ultGrid)
  528. {
  529. foreach (UltraGridRow row in ultGrid.Rows)
  530. {
  531. row.Activation = Activation.ActivateOnly;
  532. }
  533. }
  534. public void proc_Statics(ref UltraGrid ultraGrid, ArrayList alistColumns, bool clearExists, string strFormat)
  535. {
  536. try
  537. {
  538. if (alistColumns == null)
  539. {
  540. return;
  541. }
  542. UltraGridBand band = ultraGrid.DisplayLayout.Bands[0];
  543. if (clearExists)
  544. band.Summaries.Clear();
  545. SummarySettings summary = null;
  546. UltraGridColumn cl = null;
  547. foreach (UltraGridColumn column in ultraGrid.DisplayLayout.Bands[0].Columns)
  548. {
  549. if (column.RowLayoutColumnInfo.OriginX == 0)
  550. {
  551. cl = column;
  552. break;
  553. }
  554. }
  555. summary = band.Summaries.Add(SummaryType.Count, cl);
  556. summary.SummaryDisplayArea = SummaryDisplayAreas.BottomFixed;
  557. summary.SummaryPosition = SummaryPosition.UseSummaryPositionColumn;
  558. summary.DisplayFormat = "合计:";
  559. summary.Appearance.TextHAlign = Infragistics.Win.HAlign.Center;
  560. summary.Appearance.TextVAlign = Infragistics.Win.VAlign.Middle;
  561. summary.Appearance.FontData.Bold = DefaultableBoolean.True;
  562. if (string.IsNullOrEmpty(strFormat.Trim()))
  563. {
  564. strFormat = " {0:############0.00}";
  565. }
  566. for (int i = 0; i < alistColumns.Count; i++)
  567. {
  568. try
  569. {
  570. summary = band.Summaries.Add(SummaryType.Sum, band.Columns[alistColumns[i].ToString()]);
  571. summary.SummaryDisplayArea = SummaryDisplayAreas.BottomFixed;
  572. summary.SummaryPosition = SummaryPosition.UseSummaryPositionColumn;
  573. summary.DisplayFormat = strFormat;
  574. summary.Appearance.TextHAlign = Infragistics.Win.HAlign.Right;
  575. summary.Appearance.TextVAlign = Infragistics.Win.VAlign.Middle;
  576. summary.Appearance.FontData.Bold = DefaultableBoolean.True;
  577. summary.Appearance.ForeColor = Color.DarkBlue;
  578. summary.Appearance.BackColor = Color.White;
  579. }
  580. catch { }
  581. }
  582. band.Override.SummaryFooterCaptionVisible = Infragistics.Win.DefaultableBoolean.False;
  583. }
  584. catch { }
  585. }
  586. }
  587. }