PublicResource.cs 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using CoreFS.CA06;
  6. using System.Data;
  7. using Infragistics.Win.UltraWinGrid;
  8. using Core.Mes.Client.Comm;
  9. using System.Windows.Forms;
  10. using Infragistics.Win.UltraWinEditors;
  11. using System.Collections;
  12. using Core.Mes.Client.Comm.Control;
  13. using Core.Mes.Client.Comm.Server;
  14. using Core.Mes.Client.Comm.Tool;
  15. namespace Core.StlMes.Client.Lims.Resource
  16. {
  17. /// <summary>
  18. /// 自定义公共方法类
  19. /// </summary>
  20. class PublicResource
  21. {
  22. //状态位
  23. //CHECKCONSIGN_BASEINFO 0委托单位未取样,1委托单位正在送样,2加工已确认
  24. //CHECKCONSIGN_DETAIL '0', '未下发', '1', '加工已下发', '2', '试验室已确认', '3', '试验室已录入', '4', '试验室已审核'
  25. public const string chemMax = "ANA_C ANA_SI ANA_MN ANA_P ANA_S ANA_NI ANA_CR ANA_MO ANA_CU ANA_AL ANA_ALS ANA_CA ANA_V ANA_NB ANA_TI ANA_O ANA_N ANA_H ANA_ZN ANA_B ANA_ZR ANA_W ANA_CO ANA_FE ANA_PB ANA_SN ANA_AS ANA_SB ANA_BI";
  26. public const string chemMin = "C Si Mn P S Ni Cr Mo Cu Al Als Ca V Nb Ti O N H Zn B Zr W Co Fe Pb Sn As Sb Bi";
  27. /// <summary>
  28. /// 筛选符合条件的DataTable
  29. /// </summary>
  30. /// <param name="dt"></param>源dt
  31. /// <returns></returns>
  32. public static DataTable GetSelectDt(DataTable dtSource, string sql)
  33. {
  34. if (dtSource != null)
  35. {
  36. DataTable dtReturn = dtSource.Clone();
  37. DataRow[] arrDrSelect = dtSource.Select(sql);
  38. if (arrDrSelect != null && arrDrSelect.Length > 0)
  39. {
  40. foreach (DataRow row in arrDrSelect)
  41. {
  42. dtReturn.Rows.Add(row.ItemArray);
  43. }
  44. }
  45. return dtReturn;
  46. }
  47. else
  48. {
  49. return null;
  50. }
  51. }
  52. /// <summary>
  53. /// 筛选符合条件的DataTable加入排序
  54. /// </summary>
  55. /// <param name="dt"></param>源dt
  56. /// <returns></returns>
  57. public static DataTable GetSelectDt(DataTable dtSource, string sql, string sort)
  58. {
  59. if (dtSource != null)
  60. {
  61. DataTable dtReturn = dtSource.Clone();
  62. DataRow[] arrDrSelect;
  63. if (sort != "")
  64. {
  65. arrDrSelect = dtSource.Select(sql, sort);
  66. }
  67. else
  68. {
  69. arrDrSelect = dtSource.Select(sql);
  70. }
  71. if (arrDrSelect != null && arrDrSelect.Length > 0)
  72. {
  73. foreach (DataRow row in arrDrSelect)
  74. {
  75. dtReturn.Rows.Add(row.ItemArray);
  76. }
  77. }
  78. return dtReturn;
  79. }
  80. else
  81. {
  82. return null;
  83. }
  84. }
  85. /// <summary>
  86. /// 比较字符串是否含某元素
  87. /// </summary>
  88. /// <param name="chemName"></param>元素名称
  89. /// <returns></returns>
  90. public static bool IsHaveChemItems(string chemName, string[] arrChems)
  91. {
  92. if (chemName == "" || arrChems.Length == 0)
  93. {
  94. return false;
  95. }
  96. else
  97. {
  98. foreach (string row in arrChems)
  99. {
  100. if (chemName == row)
  101. {
  102. return true;
  103. }
  104. }
  105. }
  106. return false;
  107. }
  108. /// <summary>
  109. /// 激活当前操作的列
  110. ///
  111. /// </summary>
  112. /// <param name="ultraGrid"></param>
  113. /// <param name="strPK"></param>主键
  114. public static void ActiveOperateRow(UltraGrid ultraGrid, string strPK, string strPKText)
  115. {
  116. for (int i = 0; i < ultraGrid.Rows.Count; i++)
  117. {
  118. if (ultraGrid.Rows[i].Cells[strPK].Text == strPKText)
  119. {
  120. ultraGrid.Rows[i].Activated = true;
  121. }
  122. }
  123. }
  124. /// <summary>
  125. /// 激活当前操作的列
  126. ///
  127. /// </summary>
  128. /// <param name="ultraGrid"></param>
  129. /// <param name="strPK"></param>多主键
  130. public static void ActiveOperateRow(UltraGrid ultraGrid, object[] strPK, object[] strPKText)
  131. {
  132. bool isEquals;
  133. for (int i = 0; i < ultraGrid.Rows.Count; i++)
  134. {
  135. isEquals = true;
  136. for (int j = 0; j < strPK.Length; j++)
  137. {
  138. if (ultraGrid.Rows[i].Cells[strPK[j].ToString()].Text != strPKText[j].ToString())
  139. {
  140. isEquals = false;
  141. break;
  142. }
  143. }
  144. if (isEquals == true)
  145. {
  146. ultraGrid.Rows[i].Activated = true;
  147. return;
  148. }
  149. }
  150. }
  151. //点击Grid编辑区显示基本信息
  152. public static void ShowBaseInfo(UltraGridRow ur, Panel panel)
  153. {
  154. if (ur != null)
  155. {
  156. foreach (UltraGridCell uc in ur.Cells)
  157. {
  158. if (panel.Controls.ContainsKey("txt" + uc.Column.Key) == true && panel.Controls["txt" + uc.Column.Key] is UltraTextEditor)//判定是否存在text
  159. {
  160. ((UltraTextEditor)panel.Controls["txt" + uc.Column.Key]).Text = uc.Text.Trim();
  161. }
  162. else if (panel.Controls.ContainsKey("ultra" + uc.Column.Key) == true && panel.Controls["ultra" + uc.Column.Key] is UltraComboEditor)//判定是否存在text
  163. {
  164. ((UltraComboEditor)panel.Controls["ultra" + uc.Column.Key]).Text = uc.Text.Trim();
  165. }
  166. else if (panel.Controls.ContainsKey("ttxt" + uc.Column.Key) == true && panel.Controls["ttxt" + uc.Column.Key] is UltraDateTimeEditor)//判定是否存在text
  167. {
  168. ((UltraDateTimeEditor)panel.Controls["ttxt" + uc.Column.Key]).Text = uc.Text.Trim();
  169. }
  170. }
  171. }
  172. }
  173. //点击Grid编辑区显示基本信息
  174. public static void ShowDataTaleInfo(DataTable dt, Panel panel)
  175. {
  176. foreach (DataColumn dc in dt.Columns)
  177. {
  178. if (panel.Controls.ContainsKey("txt" + dc.ColumnName) == true)//判定是否存在text
  179. {
  180. }
  181. if (panel.Controls.ContainsKey("txt" + dc.ColumnName) == true)//判定是否存在text
  182. {
  183. ((UltraTextEditor)panel.Controls["txt" + dc.ColumnName]).Text = dt.Rows[0][dc.ColumnName].ToString();
  184. }
  185. else if (panel.Controls.ContainsKey("ultra" + dc.ColumnName) == true)//判定是否存在text
  186. {
  187. ((UltraComboEditor)panel.Controls["ultra" + dc.ColumnName]).Text = dt.Rows[0][dc.ColumnName].ToString();
  188. }
  189. }
  190. }
  191. //点击Grid编辑区显示基本信息
  192. public static void ClearBaseInfo(Panel panel, string[] cols)
  193. {
  194. if (cols != null)
  195. {
  196. foreach (string col in cols)
  197. {
  198. if (panel.Controls.ContainsKey("txt" + col) == true && panel.Controls["txt" + col] is UltraTextEditor)//判定是否存在text && panel.Controls.ContainsKey("txt" + col).GetType(). == UltraTextEditor
  199. {
  200. ((UltraTextEditor)panel.Controls["txt" + col]).Text = "";
  201. }
  202. else if (panel.Controls.ContainsKey("ultra" + col) == true && panel.Controls["ultra" + col] is UltraComboEditor)//判定是否存在text && panel.Controls.ContainsKey("txt" + col).GetType(). == UltraTextEditor
  203. {
  204. ((UltraComboEditor)panel.Controls["ultra" + col]).Text = "";
  205. }
  206. }
  207. }
  208. }
  209. /// <summary>
  210. /// 隐藏空列
  211. /// </summary>
  212. /// <param name="strHidden"></param>本来就隐藏的列名集合
  213. /// <param name="ug"></param>需要操作的UltraGrid
  214. /// <param name="dt"></param>需要操作的dt
  215. private void HideNullColumn(string strHidden, UltraGrid ultraGrid, DataTable dataTable)
  216. {
  217. if (strHidden != "")
  218. {
  219. foreach (DataColumn dc in dataTable.Columns)
  220. {
  221. if (strHidden.IndexOf(dc.ColumnName) >= 0)
  222. {
  223. continue;
  224. }
  225. foreach (DataRow dr in dataTable.Rows)
  226. {
  227. if (dr[dc].ToString() != "")
  228. {
  229. ultraGrid.DisplayLayout.Bands[0].Columns[dc.ColumnName].Hidden = false;
  230. break;
  231. }
  232. else
  233. {
  234. ultraGrid.DisplayLayout.Bands[0].Columns[dc.ColumnName].Hidden = true;
  235. }
  236. }
  237. }
  238. }
  239. else
  240. {
  241. foreach (DataColumn dc in dataTable.Columns)
  242. {
  243. foreach (DataRow dr in dataTable.Rows)
  244. {
  245. if (dr[dc].ToString() != "")
  246. {
  247. ultraGrid.DisplayLayout.Bands[0].Columns[dc.ColumnName].Hidden = false;
  248. break;
  249. }
  250. else
  251. {
  252. ultraGrid.DisplayLayout.Bands[0].Columns[dc.ColumnName].Hidden = true;
  253. }
  254. }
  255. }
  256. }
  257. }
  258. /// <summary>
  259. /// UltraGrid可读
  260. /// </summary>
  261. /// <param name="ugr">UltraGrid</param>
  262. /// <param name="keys">可编辑列</param>
  263. public static void setOtherColumnReadOnly(UltraGrid ugr, string[] keys)
  264. {
  265. if (keys == null || keys.Length == 0)
  266. {
  267. foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[0].Columns)
  268. {
  269. ugc.CellActivation = Activation.ActivateOnly;
  270. }
  271. }
  272. else
  273. {
  274. keys.ToArray();
  275. foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[0].Columns)
  276. {
  277. if (!keys.Contains(ugc.Key))
  278. {
  279. ugc.CellActivation = Activation.ActivateOnly;
  280. }
  281. //else
  282. //{
  283. // ugc.CellActivation = Activation.AllowEdit;
  284. //}
  285. }
  286. }
  287. if (ugr.DisplayLayout.Bands[0].Columns.Exists("CHK"))
  288. {
  289. ugr.DisplayLayout.Bands[0].Columns["CHK"].DefaultCellValue = "False";
  290. ugr.DisplayLayout.Bands[0].Columns["CHK"].Header.CheckBoxVisibility = Infragistics.Win.UltraWinGrid.HeaderCheckBoxVisibility.Always;
  291. ugr.DisplayLayout.Bands[0].Columns["CHK"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox;
  292. }
  293. }
  294. /// <summary>
  295. /// UltraGrid可读
  296. /// </summary>
  297. /// <param name="ugr">UltraGrid</param>
  298. /// <param name="keys">可编辑列</param>
  299. public static void setOtherColumnReadOnly(UltraGrid ugr, string[] keys, int bandNum)
  300. {
  301. if (bandNum < 0 || ugr.DisplayLayout.Bands.Count < bandNum + 1)
  302. {
  303. return;
  304. }
  305. if (keys == null || keys.Length == 0)
  306. {
  307. foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[bandNum].Columns)
  308. {
  309. ugc.CellActivation = Activation.ActivateOnly;
  310. }
  311. }
  312. else
  313. {
  314. keys.ToArray();
  315. foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[bandNum].Columns)
  316. {
  317. if (!keys.Contains(ugc.Key))
  318. {
  319. ugc.CellActivation = Activation.ActivateOnly;
  320. }
  321. }
  322. }
  323. if (ugr.DisplayLayout.Bands[bandNum].Columns.Exists("CHK"))
  324. {
  325. ugr.DisplayLayout.Bands[bandNum].Columns["CHK"].DefaultCellValue = "False";
  326. ugr.DisplayLayout.Bands[bandNum].Columns["CHK"].Header.CheckBoxVisibility = Infragistics.Win.UltraWinGrid.HeaderCheckBoxVisibility.Always;
  327. ugr.DisplayLayout.Bands[bandNum].Columns["CHK"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.CheckBox;
  328. }
  329. }
  330. /// <summary>
  331. /// UltraGrid列是否隐藏
  332. /// </summary>isShow 为true则显示其他隐藏,false则隐藏其他显示
  333. /// <param name="ugr">UltraGrid</param>
  334. /// <param name="keys">隐藏列</param>
  335. public static void setColumnShowOrHidden(UltraGrid ugr, string[] keys, bool isShow)
  336. {
  337. if (keys == null || keys.Length == 0)
  338. {
  339. foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[0].Columns)
  340. {
  341. ugc.Hidden = false;
  342. }
  343. }
  344. else
  345. {
  346. keys.ToArray();
  347. foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[0].Columns)
  348. {
  349. if (keys.Contains(ugc.Key))
  350. {
  351. if (isShow)
  352. {
  353. ugc.Hidden = false;
  354. }
  355. else
  356. {
  357. ugc.Hidden = true;
  358. }
  359. }
  360. else
  361. {
  362. if (isShow)
  363. {
  364. ugc.Hidden = true;
  365. }
  366. }
  367. }
  368. }
  369. }
  370. /// <summary>
  371. /// UltraGrid列是否隐藏
  372. /// </summary>isShow 为true则显示其他隐藏,false则隐藏其他显示
  373. /// <param name="ugr">UltraGrid</param>
  374. /// <param name="keys">隐藏列</param>
  375. public static void setColumnShowOrHidden(UltraGrid ugr, string[] keys, bool isShow, int bandNum)
  376. {
  377. if (bandNum < 0 || ugr.DisplayLayout.Bands.Count < bandNum + 1)
  378. {
  379. return;
  380. }
  381. if (keys == null || keys.Length == 0)
  382. {
  383. foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[bandNum].Columns)
  384. {
  385. ugc.Hidden = false;
  386. }
  387. }
  388. else
  389. {
  390. keys.ToArray();
  391. foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[bandNum].Columns)
  392. {
  393. if (keys.Contains(ugc.Key))
  394. {
  395. if (isShow)
  396. {
  397. ugc.Hidden = false;
  398. }
  399. else
  400. {
  401. ugc.Hidden = true;
  402. }
  403. }
  404. else
  405. {
  406. if (isShow)
  407. {
  408. ugc.Hidden = true;
  409. }
  410. }
  411. }
  412. }
  413. }
  414. //初始化列
  415. public static void InitColumns(string[] arrColumns, string[] arrCaption, DataTable dataTable1)
  416. {
  417. if (arrColumns.Length == 0 || arrColumns.Length != arrCaption.Length)
  418. {
  419. return;
  420. }
  421. dataTable1.Columns.Clear();//先清除
  422. DataColumn dc;
  423. for (int i = 0; i < arrColumns.Length; i++)
  424. {
  425. try
  426. {
  427. dc = new DataColumn(arrColumns[i]);
  428. dc.Caption = arrCaption[i];
  429. dataTable1.Columns.Add(dc);
  430. if (dc.ColumnName == "CHK")
  431. {
  432. dc.DataType = typeof(bool);
  433. dc.DefaultValue = "False";
  434. }
  435. }
  436. catch
  437. {
  438. continue;
  439. }
  440. }
  441. }
  442. //初始化列
  443. public static void InitColumns(string[] arrColumns, string[] chemMax, object[] arrCaption, string[] chemMin, DataTable dataTable1)
  444. {
  445. if (arrColumns.Length == 0 || arrColumns.Length != arrCaption.Length || chemMax.Length != chemMin.Length)
  446. {
  447. return;
  448. }
  449. dataTable1.Columns.Clear();//先清除
  450. DataColumn dc;
  451. for (int i = 0; i < arrColumns.Length; i++)
  452. {
  453. try
  454. {
  455. dc = new DataColumn(arrColumns[i].ToString());
  456. dc.Caption = arrCaption[i].ToString();
  457. dataTable1.Columns.Add(dc);
  458. if (dc.ColumnName == "CHK")
  459. {
  460. dc.DataType = typeof(bool);
  461. dc.DefaultValue = "False";
  462. }
  463. }
  464. catch
  465. {
  466. continue;
  467. }
  468. }
  469. for (int i = 0; i < chemMax.Length; i++)
  470. {
  471. try
  472. {
  473. dc = new DataColumn(chemMax[i]);
  474. dc.Caption = chemMin[i];
  475. dataTable1.Columns.Add(dc);
  476. }
  477. catch
  478. {
  479. continue;
  480. }
  481. }
  482. }
  483. public static void InitColumns(string[] arrColumns, string[] arrCaption, DataTable dataTable, UltraGrid ultraGrid, string[] show, bool isShow, string[] ope)
  484. {
  485. InitColumns(arrColumns, arrCaption, dataTable);
  486. setColumnShowOrHidden(ultraGrid, show, isShow);
  487. setOtherColumnReadOnly(ultraGrid, ope);
  488. }
  489. //隐藏空列
  490. /// <summary>
  491. ///
  492. ///
  493. /// </summary>
  494. /// <param name="strHidden"></param>需要判断的列
  495. /// <param name="ug"></param>
  496. public static void HideNullColumn(string strHidden, UltraGrid ug)
  497. {
  498. string[] arr = strHidden.Split(',');
  499. for (int i = 0; i < arr.Length; i++)
  500. {
  501. if (!ug.DisplayLayout.Bands[0].Columns.Exists(arr[i]))
  502. {
  503. continue;
  504. }
  505. foreach (UltraGridRow ur in ug.Rows)
  506. {
  507. if (ur.Cells[arr[i]].Text != "")
  508. {
  509. ug.DisplayLayout.Bands[0].Columns[arr[i]].Hidden = false;
  510. break;
  511. }
  512. else
  513. {
  514. ug.DisplayLayout.Bands[0].Columns[arr[i]].Hidden = true;
  515. }
  516. }
  517. }
  518. }
  519. //选择事件
  520. /// <summary>
  521. ///
  522. ///
  523. /// </summary>
  524. /// <param name="strHidden"></param>
  525. /// <param name="ug"></param>
  526. public static void SelectRow(UltraGrid ultraGrid)
  527. {
  528. if (ultraGrid.DisplayLayout.Bands[0].Columns.Exists("CHK"))
  529. {
  530. foreach (UltraGridRow uRow in ultraGrid.Selected.Rows)
  531. {
  532. if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow))
  533. {
  534. uRow.Cells["CHK"].Value = true;
  535. }
  536. }
  537. }
  538. }
  539. public static void ReMoveColumns(DataTable dataTable, int position)
  540. {
  541. //从0开始
  542. int dcNum = dataTable.Columns.Count;
  543. if (dcNum > position)
  544. {
  545. for (int i = 0; i < dcNum - position; i++)
  546. {
  547. dataTable.Columns.RemoveAt(position);
  548. }
  549. }
  550. }
  551. //自适应
  552. private void RefreshAutoSize(UltraGrid ultraGrid1)
  553. {
  554. ultraGrid1.DisplayLayout.Bands[0].Columns[0].Width = 80;
  555. for (int i = 1; i < ultraGrid1.DisplayLayout.Bands[0].Columns.Count; i++)
  556. {
  557. ultraGrid1.DisplayLayout.Bands[0].Columns[i].Width = 60;//设置列宽
  558. }
  559. }
  560. /// <summary>
  561. /// 设置列宽
  562. /// </summary>
  563. /// <param name="dt"></param>需要设置的UltraGrid
  564. /// <param name="haveNum"></param>不需要清除的列
  565. /// /// <param name="width"></param>宽度
  566. public static void ColumnsWidth(UltraGrid ultraGrid, int haveNum, int width)
  567. {
  568. int col = ultraGrid.DisplayLayout.Bands[0].Columns.Count;
  569. for (int i = haveNum; i < col; i++)
  570. {
  571. ultraGrid.DisplayLayout.Bands[0].Columns[i].Width = width;//设置列宽
  572. }
  573. }
  574. /// <summary>
  575. /// 设置列宽
  576. /// </summary>
  577. /// <param name="dt"></param>需要设置的UltraGrid
  578. /// <param name="haveNum"></param>不需要清除的列
  579. /// /// <param name="width"></param>宽度
  580. public static void ColumnsWidth(UltraGrid ultraGrid, int haveNum, int width, string[] noSet)
  581. {
  582. ArrayList al = new ArrayList();
  583. for (int i = 0; i < noSet.Length; i++)
  584. {
  585. al.Add(noSet[i]);
  586. }
  587. int col = ultraGrid.DisplayLayout.Bands[0].Columns.Count;
  588. for (int i = haveNum; i < col; i++)
  589. {
  590. if (!al.Contains(ultraGrid.DisplayLayout.Bands[0].Columns[i].ToString()))
  591. {
  592. ultraGrid.DisplayLayout.Bands[0].Columns[i].Width = width;//设置列宽
  593. }
  594. }
  595. }
  596. /// <summary>
  597. /// 刷新Grid数据并根据数据调整Grid列宽
  598. /// </summary>
  599. /// <param name="ultraGrid">需要处理的Grid</param>
  600. /// <param name="cols">需要调整的列</param>
  601. /// <param name="is调整">true则自适应,false则不自适应</param>
  602. public static void RefreshAndAutoSizeColumns(Infragistics.Win.UltraWinGrid.UltraGrid ultraGrid, object[] cols, bool isMove)
  603. {
  604. try
  605. {
  606. ultraGrid.DataBind();
  607. foreach (Infragistics.Win.UltraWinGrid.UltraGridBand band in ultraGrid.DisplayLayout.Bands)
  608. {
  609. foreach (Infragistics.Win.UltraWinGrid.UltraGridColumn column in band.Columns)
  610. {
  611. if (cols != null && cols.Contains(column.Key))
  612. {
  613. if (!isMove)
  614. {
  615. continue;
  616. }
  617. column.PerformAutoResize(Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand);//AllRowsInBand
  618. }
  619. else
  620. {
  621. if (!isMove)
  622. {
  623. column.PerformAutoResize(Infragistics.Win.UltraWinGrid.PerformAutoSizeType.AllRowsInBand);
  624. }
  625. }
  626. }
  627. }
  628. ultraGrid.Refresh();
  629. }
  630. catch { }
  631. }
  632. //改变splitContainer1.Panel1
  633. public static void ChangeSplit(SplitContainer splitContainer, DataTable dtPhyMax)
  634. {
  635. if (dtPhyMax != null && dtPhyMax.Rows.Count > 0)
  636. {
  637. splitContainer.Panel1Collapsed = false;
  638. }
  639. else
  640. {
  641. splitContainer.Panel1Collapsed = true; ;
  642. }
  643. }
  644. //如果用户为admin默认试验室数据权限
  645. public static string[] ValidData()
  646. {
  647. string[] arrId = new string[7] { "002001007009", "002001007015", "002001007013", "002001007014", "002001007010", "002001020001", "002001020002" };
  648. //DECODE(T.DEPT_ID,
  649. // '002001007009',
  650. // '力学',
  651. // '002001007015',
  652. // '金相',
  653. // '002001007013',
  654. // '腐蚀',
  655. // '002001007014',
  656. // '工程',
  657. // '002001007010',
  658. // '化学',
  659. // '002001020001',
  660. // '一快分',
  661. // '002001020002',
  662. // '二快分')
  663. return arrId;
  664. }
  665. //解析数据权限
  666. public static string ValidDataString(string[] arrId)
  667. {
  668. string strId = "";
  669. if (arrId != null)
  670. {
  671. foreach (string str in arrId)
  672. {
  673. strId += "'" + str + "',";
  674. }
  675. }
  676. strId = strId.Remove(0, 1);
  677. strId = strId.Remove(strId.Length - 2);
  678. return strId;
  679. }
  680. // 路径组成 Lims + 界面名称 + 文件名 "Lims/data/base/";
  681. public static string GetFilePath(string strPath)
  682. {
  683. return "";
  684. }
  685. /// <summary>
  686. /// 更改文件路径
  687. /// </summary>
  688. /// <param name="Department">user_depatment</param>
  689. /// <returns></returns>
  690. public static void UpdateFilePosition(string strTableName, string strPath, string strPk, string strPkValue, OpeBase ob)
  691. {
  692. try
  693. {
  694. string sql = "UPDATE " + strTableName + " SET FILE_POSITION = '" + strPath + "' WHERE " + strPk + " = '" + strPkValue + "'";
  695. PublicServer.SetData("com.steering.BaseInfo.UpdateFilePosition", new Object[] { sql }, ob);
  696. }
  697. catch
  698. {
  699. }
  700. }
  701. /// <summary>
  702. /// 查看文件路径
  703. /// </summary>
  704. /// <param name="Department">user_depatment</param>
  705. /// <returns></returns>
  706. public static bool ViewFilePosition(OpeBase _ob, string path)
  707. {
  708. bool isSucc = true;
  709. FormFileDown down = new FormFileDown(_ob, path);
  710. down.ShowDialog();
  711. if (down.CtrlFileDown1.List.Count == 0)
  712. {
  713. isSucc = false;//删除了则更新FILE_POSITION
  714. }
  715. return isSucc;
  716. }
  717. /// <summary>
  718. /// 上传文件路径
  719. /// </summary>
  720. /// <param name="Department">user_depatment</param>
  721. /// <returns></returns>
  722. public static bool UploadFilePosition(OpeBase _ob, string path)
  723. {
  724. //var serverFileList = FileHelper.Download(path);
  725. //if (serverFileList.Count > 0)
  726. //{
  727. // MessageUtil.ShowWarning("该记录已存在一份文件,请删除后再重新上传!");
  728. // return false;
  729. //}
  730. List<FileBean> list = new List<FileBean>();
  731. FileBean bean = new FileBean();
  732. OpenFileDialog file = new OpenFileDialog();
  733. file.Multiselect = false;
  734. DialogResult drStat;
  735. drStat = file.ShowDialog();
  736. if (drStat == DialogResult.OK)
  737. {
  738. string filePath = file.FileName;
  739. string fileName = System.IO.Path.GetFileName(filePath);
  740. bean = new FileBean();
  741. bean.setFileName(fileName);
  742. bean.setPathName(path);
  743. bean.setFile(FileHelper.FileToArray(filePath));
  744. list.Add(bean);
  745. bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list);
  746. if (isSuccess)
  747. {
  748. MessageUtil.ShowTips("上传成功!");
  749. }
  750. else
  751. {
  752. MessageUtil.ShowTips("上传失败,请重试!");
  753. }
  754. return isSuccess;//成功了则更新FILE_POSITION
  755. }
  756. return false;
  757. }
  758. }
  759. }