FrmGBXXInfo.cs.svn-base 27 KB

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