FrmMaterialInoutCCM.cs 28 KB

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