BaseMethod.cs 34 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Infragistics.Win.UltraWinGrid;
  6. using System.Drawing;
  7. using System.Data;
  8. using Core.Mes.Client.Comm.Server;
  9. using CoreFS.CA06;
  10. using Infragistics.Win.UltraWinEditors;
  11. using Infragistics.Win.UltraWinMaskedEdit;
  12. using System.Windows.Forms;
  13. using System.Collections;
  14. using Core.Mes.Client.Comm.Control;
  15. using System.IO;
  16. namespace Core.StlMes.Client.YdmPipeManage.Tool
  17. {
  18. public class BaseMethod
  19. {
  20. /// <summary>
  21. /// UltraGrid可读
  22. /// </summary>
  23. /// <param name="ugr">UltraGrid</param>
  24. /// <param name="keys">可编辑列</param>
  25. public static void setOtherColumnReadOnly(UltraGrid ugr, string[] keys)
  26. {
  27. keys.ToArray();
  28. foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[0].Columns)
  29. {
  30. if (!keys.Contains(ugc.Key))
  31. {
  32. ugc.CellActivation = Activation.ActivateOnly;
  33. }
  34. }
  35. }
  36. /// <summary>
  37. /// UltraGrid激活某行
  38. /// </summary>
  39. /// <param name="ug">UltraGrid</param>
  40. /// <param name="keys">列名</param>
  41. /// <param name="values">对应的值</param>
  42. public static void UltraGridLocation(UltraGrid ug, String[] keys, String[] values)
  43. {
  44. if (ug.Rows.Count == 0)
  45. {
  46. return;
  47. }
  48. if (keys.Length == 0 || values.Length == 0 || values.Length != keys.Length)
  49. {
  50. return;
  51. }
  52. foreach (UltraGridRow ugr in ug.Rows)
  53. {
  54. Boolean flag = true;
  55. for (int i = 0; i < keys.Length; i++)
  56. {
  57. if (!ugr.Cells[keys[i]].ToString().Equals(values[i]))
  58. {
  59. flag = false;
  60. }
  61. }
  62. if (flag == true)
  63. {
  64. ugr.Activate();
  65. return;
  66. }
  67. }
  68. }
  69. /// <summary>
  70. /// 设置列字段显示位置在右
  71. /// </summary>
  72. /// <param name="ug">UltraGrid</param>
  73. /// <param name="columnsKeys">要设置的列</param>
  74. public static void InitCellPosition(UltraGrid ug, string[] columnsKeys)
  75. {
  76. columnsKeys.ToArray();
  77. foreach (UltraGridColumn ugc in ug.DisplayLayout.Bands[0].Columns)
  78. {
  79. if (columnsKeys.Contains(ugc.Key.ToString()))
  80. {
  81. ugc.CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right;
  82. }
  83. }
  84. }
  85. /// <summary>
  86. /// 列求和
  87. /// </summary>
  88. /// <param name="ug">UltraGrid</param>
  89. /// <param name="columnKeys">列数组</param>
  90. public static void GridColumnSum(UltraGrid ug, string[] columnKeys)
  91. {
  92. if (columnKeys.Length == 0)
  93. {
  94. return;
  95. }
  96. for (int i = 0; i < columnKeys.Length; i++)
  97. {
  98. ug.DisplayLayout.Bands[0].Summaries.Add(SummaryType.Sum, ug.DisplayLayout.Bands[0].Columns[columnKeys[i]], SummaryPosition.UseSummaryPositionColumn);
  99. }
  100. }
  101. /// <summary>
  102. /// 设置UltraGrid行颜色
  103. /// </summary>
  104. /// <param name="ug">UltraGrid</param>
  105. /// <param name="columnKeys">列</param>
  106. /// <param name="values">值</param>
  107. /// <param name="color">颜色</param>
  108. public static void SetUltraGridRowColor(UltraGrid ug, string[] columnKeys, string[] values, Color color)
  109. {
  110. if (ug.Rows.Count == 0 || columnKeys.Length == 0 || values.Length == 0 || color == null || values.Length != columnKeys.Length)
  111. {
  112. return;
  113. }
  114. foreach (UltraGridRow ugr in ug.Rows)
  115. {
  116. Boolean flag = true;
  117. for (int i = 0; i < columnKeys.Length; i++)
  118. {
  119. if (!ugr.Cells[columnKeys[i]].Value.ToString().Equals(values[i]))
  120. {
  121. flag = false;
  122. }
  123. }
  124. if (flag)
  125. {
  126. ugr.Appearance.BackColor = color;
  127. }
  128. }
  129. }
  130. /// <summary>
  131. /// 合并单元格
  132. /// </summary>
  133. /// <param name="ug"></param>
  134. /// <param name="columnKeys"></param>
  135. public static void MergedCell(UltraGrid ug, string[] columnKeys)
  136. {
  137. if (columnKeys.Length == 0)
  138. {
  139. return;
  140. }
  141. ug.DisplayLayout.Override.MergedCellStyle = MergedCellStyle.Never;
  142. for (int i = 0; i < columnKeys.Length; i++)
  143. {
  144. ug.DisplayLayout.Bands[0].Columns[columnKeys[i]].MergedCellStyle = MergedCellStyle.Always;
  145. }
  146. }
  147. /// <summary>
  148. /// 仓库数据权限
  149. /// </summary>
  150. /// <param name="customInfo">页面配制信息(自定义参数)</param>
  151. /// <param name="validDataPurviewIds">用户数据权限</param>
  152. /// <returns>可查看仓库组成的字符串</returns>
  153. public static string[] WarehousePermissions(String customInfo, String[] validDataPurviewIds, OpeBase ob)
  154. {
  155. string storageType = "";//仓库类别
  156. string storageAttr = "";//仓库类型
  157. //if (customInfo.Length >= 0 && customInfo.Contains(","))
  158. //{
  159. // string[] strflg = customInfo.ToString().Split(new char[] { ',' });
  160. // storageType = strflg[0];
  161. // storageAttr = strflg[1];
  162. //}
  163. if (customInfo.Length >= 0 )
  164. {
  165. //string[] strflg = customInfo.ToString().Split(new char[] { ',' });
  166. //storageType = strflg[0];
  167. //storageAttr = strflg[1];
  168. storageAttr = customInfo.ToString();
  169. }
  170. //DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.WarehousePermissions.getWarehousePermissions", new object[] { storageType, storageAttr, validDataPurviewIds }, ob);
  171. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.WarehousePermissions.getWarehousePermissionsStore", new object[] { validDataPurviewIds }, ob);
  172. if (dt != null && dt.Rows.Count > 0)
  173. {
  174. string[] storages = new string[dt.Rows.Count];
  175. for (int i = 0; i < dt.Rows.Count; i++)
  176. {
  177. storages[i] = dt.Rows[i]["STORAGE_NO"].ToString();
  178. }
  179. return storages;
  180. }
  181. else
  182. {
  183. return new string[1] { "" };
  184. }
  185. }
  186. /// <summary>
  187. /// 销售组织权限
  188. /// </summary>
  189. /// <param name="validDataPurviewIds">数据权限</param>
  190. /// <param name="ob"></param>
  191. /// <returns>字符串数组</returns>
  192. public static string[] InitPermissions(string[] validDataPurviewIds, OpeBase ob)
  193. {
  194. string[] arr = null;
  195. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.WarehousePermissions.getSalgPermissions", new object[] { validDataPurviewIds }, ob);
  196. if (dt != null && dt.Rows.Count > 0)
  197. {
  198. arr = new string[dt.Rows.Count];
  199. for (int i = 0; i < dt.Rows.Count; i++)
  200. {
  201. arr[i] = dt.Rows[i][0].ToString();
  202. }
  203. return arr;
  204. }
  205. else
  206. {
  207. return new string[1] { "" };
  208. }
  209. }
  210. /// <summary>
  211. /// 通过数据权限找产线
  212. /// </summary>
  213. /// <param name="pCode"></param>
  214. /// <param name="ob"></param>
  215. /// <returns></returns>
  216. public static string[] getPlineValid(string[] validDataPurviewIds, OpeBase ob)
  217. {
  218. string[] arr = null;
  219. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.WarehousePermissions.getPlineValiData", new object[] { validDataPurviewIds }, ob);
  220. if (dt != null && dt.Rows.Count > 0)
  221. {
  222. arr = new string[dt.Rows.Count];
  223. for (int i = 0; i < dt.Rows.Count; i++)
  224. {
  225. arr[i] = dt.Rows[i][0].ToString();
  226. }
  227. return arr;
  228. }
  229. else
  230. {
  231. return new string[1] { "" };
  232. }
  233. }
  234. /// <summary>
  235. /// 仓库数据权限(用于报表)
  236. /// </summary>
  237. /// <param name="customInfo">页面配制信息(自定义参数)</param>
  238. /// <param name="validDataPurviewIds">用户数据权限</param>
  239. /// <returns>可查看仓库组成的字符串</returns>
  240. public static string[] WarehousePermissionsStore(String[] validDataPurviewIds, OpeBase ob)
  241. {
  242. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.WarehousePermissions.getWarehousePermissionsStore", new object[] { validDataPurviewIds }, ob);
  243. if (dt != null && dt.Rows.Count > 0)
  244. {
  245. string[] storages = new string[dt.Rows.Count];
  246. for (int i = 0; i < dt.Rows.Count; i++)
  247. {
  248. storages[i] = dt.Rows[i]["STORAGE_NO"].ToString();
  249. }
  250. return storages;
  251. }
  252. else
  253. {
  254. return new string[1] { "" };
  255. }
  256. }
  257. /// <summary>
  258. /// 把角色集合转换成数组
  259. /// </summary>
  260. /// <param name="list"></param>
  261. /// <returns></returns>
  262. public static string[] getRole(List<String> list)
  263. {
  264. string str = "";
  265. string[] roles = new string[list.Count];
  266. for (int i = 0; i < list.Count;i++)
  267. {
  268. str += list[i] + ',';
  269. }
  270. if (str.Length > 2)
  271. {
  272. str = str.Substring(0, str.LastIndexOf(','));
  273. roles = str.Split(',');
  274. }
  275. return roles;
  276. }
  277. ///// <summary>
  278. ///// 通过角色获取数据权限(仓库)
  279. ///// </summary>
  280. ///// <param name="roleId"></param>
  281. ///// <param name="ob"></param>
  282. ///// <returns></returns>
  283. //public static string[] getRoleValidPurviewStore(string[] roleId, String[] validDataPurviewIds, OpeBase ob)
  284. //{
  285. // DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.WarehousePermissions.isGetVaild", new object[] { roleId }, ob);
  286. // if (dt != null && dt.Rows.Count > 0)
  287. // {
  288. // DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.base.WarehousePermissions.getWarehousePermissionsStore", new object[] { validDataPurviewIds }, ob);
  289. // if (ds != null && ds.Rows.Count > 0)
  290. // {
  291. // string[] storages = new string[ds.Rows.Count];
  292. // for (int i = 0; i < ds.Rows.Count; i++)
  293. // {
  294. // storages[i] = ds.Rows[i]["STORAGE_NO"].ToString();
  295. // }
  296. // return storages;
  297. // }
  298. // else
  299. // {
  300. // return new string[1] { "" };
  301. // }
  302. // }
  303. // else
  304. // {
  305. // return new string[1] { "" };
  306. // }
  307. //}
  308. /// <summary>
  309. /// 通过角色获数据权限(所属权)
  310. /// </summary>
  311. /// <param name="roleId"></param>
  312. /// <param name="ob"></param>
  313. /// <returns></returns>
  314. public static string[] getRoleValidPurviewBelong(string mangementNo,string departMentId, OpeBase ob)
  315. {
  316. //DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.WarehousePermissions.isGetVaildBelong", new object[] { roleId }, ob);
  317. //if (dt != null && dt.Rows.Count > 0)
  318. //{
  319. DataTable ds = ServerHelper.GetData("com.steering.pss.ydm.base.WarehousePermissions.getBelongVaild", new object[] { mangementNo, departMentId }, ob);
  320. if (ds != null && ds.Rows.Count > 0)
  321. {
  322. string[] storages = new string[ds.Rows.Count];
  323. for (int i = 0; i < ds.Rows.Count; i++)
  324. {
  325. storages[i] = ds.Rows[i]["BELONG_ID"].ToString();
  326. }
  327. return storages;
  328. }
  329. else
  330. {
  331. return new string[1] { "" };
  332. }
  333. //}
  334. //else
  335. //{
  336. // return new string[1] { "" };
  337. //}
  338. }
  339. //调用本地程序打开查看服务器文件
  340. /// <summary>
  341. /// 调用本地程序打开查看服务器文件
  342. /// </summary>
  343. /// <param name="pathName"></param>
  344. public static void ViewCarft_No(string pathName)
  345. {
  346. try
  347. {
  348. //删除本地文件
  349. string tmpPath = Environment.CurrentDirectory + "\\Tmp\\";
  350. DirectoryInfo di = new DirectoryInfo(tmpPath);
  351. if (di.Exists == false)
  352. {
  353. di.Create();
  354. return;
  355. }
  356. foreach (FileInfo fi in di.GetFiles())
  357. {
  358. try
  359. {
  360. fi.Delete();
  361. }
  362. catch { continue; }
  363. }
  364. //下载写入本地Tmp目录
  365. if (pathName == "" || pathName == null) return;
  366. List<FileBean> list = Core.Mes.Client.Comm.Server.FileHelper.Download(pathName);
  367. foreach (FileBean bean in list)
  368. {
  369. FileStream fs = new FileStream(tmpPath + bean.getFileName(), FileMode.Create);
  370. fs.Write(bean.getFile(), 0, bean.getFile().Length);
  371. fs.Flush();
  372. fs.Close();
  373. System.Diagnostics.Process MyProcess = new System.Diagnostics.Process();
  374. MyProcess.StartInfo.FileName = tmpPath + bean.getFileName();
  375. MyProcess.StartInfo.Verb = "Open";
  376. MyProcess.StartInfo.CreateNoWindow = true;
  377. MyProcess.Start();
  378. return;
  379. }
  380. }
  381. catch { }
  382. }
  383. /// <summary>
  384. /// 初始化仓库号下拉框
  385. /// </summary>
  386. /// <param name="uce"></param>
  387. /// <param name="customInfo"></param>
  388. /// <param name="validDataPurviewIds"></param>
  389. /// <param name="ob"></param>
  390. public static void InitStorage(UltraComboEditor uce, String customInfo, String[] validDataPurviewIds, OpeBase ob)
  391. {
  392. string storageType = "";//仓库类别
  393. string storageAttr = "";//仓库类型
  394. if (customInfo.Length >= 0 && customInfo.Contains(","))
  395. {
  396. string[] strflg = customInfo.ToString().Split(new char[] { ',' });
  397. storageType = strflg[0];
  398. storageAttr = strflg[1];
  399. }
  400. //if (customInfo.Length >= 0)
  401. //{
  402. // string[] strflg = customInfo.ToString().Split(new char[] { ',' });
  403. // storageType = strflg[0];
  404. // storageAttr = strflg[1];
  405. // //storageAttr = customInfo.ToString();
  406. //}
  407. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.WarehousePermissions.getWarehousePermissions", new object[] { storageType, storageAttr, validDataPurviewIds }, ob);
  408. if (dt != null && dt.Rows.Count > 0)
  409. {
  410. uce.DataSource = dt;
  411. uce.DisplayMember = "STORAGE_NAME";
  412. uce.ValueMember = "STORAGE_NO";
  413. uce.SelectedIndex = 0;
  414. }
  415. else
  416. {
  417. uce.DataSource = null;
  418. }
  419. }
  420. /// <summary>
  421. /// 初始化仓库号下拉框
  422. /// </summary>
  423. /// <param name="uce"></param>
  424. /// <param name="customInfo"></param>
  425. /// <param name="validDataPurviewIds"></param>
  426. /// <param name="ob"></param>
  427. public static void InitStorage(UltraComboEditor uce,String[] validDataPurviewIds, OpeBase ob)
  428. {
  429. string storageType = "";//仓库类别
  430. string storageAttr = "";//仓库类型
  431. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.WarehousePermissions.getWarehousePermissionsStore", new object[] { validDataPurviewIds }, ob);
  432. if (dt != null && dt.Rows.Count > 0)
  433. {
  434. uce.DataSource = dt;
  435. uce.DisplayMember = "STORAGE_NAME";
  436. uce.ValueMember = "STORAGE_NO";
  437. uce.SelectedIndex = 0;
  438. }
  439. else
  440. {
  441. uce.DataSource = null;
  442. }
  443. }
  444. /// <summary>
  445. /// 初始化仓库号下拉框
  446. /// </summary>
  447. /// <param name="uce"></param>
  448. /// <param name="customInfo"></param>
  449. /// <param name="validDataPurviewIds"></param>
  450. /// <param name="ob"></param>
  451. public static void InitStorageCom(UltraComboEditor uce, DataTable dataTable, String[] validDataPurviewIds, OpeBase ob)
  452. {
  453. string storageType = "";//仓库类别
  454. string storageAttr = "";//仓库类型
  455. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.WarehousePermissions.getWarehousePermissionsStore", new object[] { validDataPurviewIds }, ob);
  456. GridHelper.CopyDataToDatatable(ref dt, ref dataTable, true);
  457. }
  458. /// <summary>
  459. /// 初始化数据权限(科室)下拉框
  460. /// </summary>
  461. /// <param name="uce"></param>
  462. /// <param name="customInfo"></param>
  463. /// <param name="validDataPurviewIds"></param>
  464. /// <param name="ob"></param>
  465. public static void InitStorageBelog(UltraComboEditor uce, DataTable dataTable, String[] validDataPurviewIds, OpeBase ob)
  466. {
  467. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.WarehousePermissions.getWarehousePermissionsBelog", new object[] { validDataPurviewIds }, ob);
  468. GridHelper.CopyDataToDatatable(ref dt, ref dataTable, true);
  469. }
  470. /// <summary>
  471. /// 初始化下拉框材料类别
  472. /// </summary>
  473. /// <param name="uce"></param>
  474. /// <param name="ob"></param>
  475. public static void InitProducFlagCom(UltraComboEditor uce, OpeBase ob)
  476. {
  477. DataTable dtProducFlag = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeMagement.queryMaterialSTyle", new object[] { }, ob);
  478. BaseMethod.InitComboEditor(uce, dtProducFlag, "BASENAME", "BASECODE");
  479. }
  480. /// <summary>
  481. /// 初始化下拉框材料状态
  482. /// </summary>
  483. /// <param name="uce"></param>
  484. /// <param name="ob"></param>
  485. public static void InitMapStatusCom(UltraComboEditor uce, OpeBase ob)
  486. {
  487. DataTable dtMapStatus = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeMagement.queryMaterialStatus", new object[] { }, ob);
  488. BaseMethod.InitComboEditor(uce, dtMapStatus, "BASENAME", "BASECODE");
  489. }
  490. /// <summary>
  491. /// 初始化下拉框材料状态
  492. /// </summary>
  493. /// <param name="uce"></param>
  494. /// <param name="ob"></param>
  495. public static void InitMapStatusCom(UltraComboEditor uce, OpeBase ob,string flag)
  496. {
  497. DataTable dtMapStatus = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeMagement.queryMaterialStatus", new object[] { flag }, ob);
  498. BaseMethod.InitComboEditor(uce, dtMapStatus, "BASENAME", "BASECODE");
  499. }
  500. /// <summary>
  501. /// 初始下拉框
  502. /// </summary>
  503. /// <param name="uce"></param>
  504. /// <param name="dt"></param>
  505. /// <param name="showName"></param>
  506. /// <param name="hideValue"></param>
  507. public static void InitComboEditor(UltraComboEditor uce, DataTable dt, String showName, String hideValue)
  508. {
  509. uce.DataSource = dt;
  510. uce.DisplayMember = showName;
  511. uce.ValueMember = hideValue;
  512. }
  513. /// <summary>
  514. /// 初始下拉框
  515. /// </summary>
  516. /// <param name="uce"></param>
  517. /// <param name="dt"></param>
  518. /// <param name="showName"></param>
  519. /// <param name="hideValue"></param>
  520. public static void InitComboEditor1(UltraComboEditor uce, DataTable dt, String showName, String hideValue)
  521. {
  522. uce.DataSource = dt;
  523. uce.DisplayMember = showName;
  524. uce.ValueMember = hideValue;
  525. uce.SelectedIndex = 1;
  526. }
  527. /// <summary>
  528. /// 初始化下拉框产线
  529. /// </summary>
  530. /// <param name="uce"></param>
  531. /// <param name="ob"></param>
  532. public static void InitPline(UltraComboEditor uce, OpeBase ob)
  533. {
  534. DataTable dtPline = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn.getPline", new object[] { }, ob);
  535. BaseMethod.InitComboEditor(uce, dtPline, "PLINE_NAME", "PLINE_CODE");
  536. }
  537. /// <summary>
  538. /// 初始化下拉框产线
  539. /// </summary>
  540. /// <param name="uce"></param>
  541. /// <param name="ob"></param>
  542. public static void InitPline1(UltraComboEditor uce, OpeBase ob,string custom)
  543. {
  544. DataTable dtPline = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn.getPline1", new object[] { custom }, ob);
  545. BaseMethod.InitComboEditor(uce, dtPline, "PLINE_NAME", "PLINE_CODE");
  546. }
  547. /// <summary>
  548. /// 初始化下拉框材料来源
  549. /// </summary>
  550. /// <param name="uce"></param>
  551. /// <param name="ob"></param>
  552. public static void InitSourse(UltraComboEditor uce, OpeBase ob)
  553. {
  554. InitSourse(uce, ob, "8013");
  555. }
  556. /// <summary>
  557. /// 初始化下拉框材料来源
  558. /// </summary>
  559. /// <param name="uce"></param>
  560. /// <param name="ob"></param>
  561. public static void InitSourse(UltraComboEditor uce, OpeBase ob,string value)
  562. {
  563. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn.getSourse", new object[] { value }, ob);
  564. BaseMethod.InitComboEditor1(uce, dt, "BASENAME", "BASECODE");
  565. }
  566. /// <summary>
  567. /// 初始化下拉框钢种
  568. /// </summary>
  569. /// <param name="uce"></param>
  570. /// <param name="ob"></param>
  571. public static void InitGrade(UltraComboEditor uce, OpeBase ob)
  572. {
  573. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeEnter.getGrade", new object[] { }, ob);
  574. BaseMethod.InitComboEditor(uce, dt, "GRADENAME", "GRADECODE");
  575. }
  576. /// <summary>
  577. /// 获取规格
  578. /// </summary>
  579. /// <param name="uce"></param>
  580. /// <param name="ob"></param>
  581. public static void InitSpec(UltraComboEditor uce, OpeBase ob)
  582. {
  583. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeEnter.getSpec", new object[] { }, ob);
  584. BaseMethod.InitComboEditor(uce, dt, "SPEC_NAME", "SPEC_CODE");
  585. }
  586. /// <summary>
  587. /// 获取扣型
  588. /// </summary>
  589. /// <param name="uce"></param>
  590. /// <param name="ob"></param>
  591. public static void InitModel(UltraComboEditor uce, OpeBase ob)
  592. {
  593. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeEnter.getModel", new object[] { }, ob);
  594. BaseMethod.InitComboEditor(uce, dt, "MODEL_DESC", "MODEL_CODE");
  595. }
  596. /// <summary>
  597. /// 获取品名
  598. /// </summary>
  599. /// <param name="uce"></param>
  600. /// <param name="ob"></param>
  601. public static void InitProcduce(UltraComboEditor uce, OpeBase ob)
  602. {
  603. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.BaseOperations.getProcduce", new object[] { }, ob);
  604. BaseMethod.InitComboEditor(uce, dt, "PRODUC_JX", "PRODUCCODE");
  605. }
  606. /// <summary>
  607. /// 获取钢级
  608. /// </summary>
  609. /// <param name="uce"></param>
  610. /// <param name="ob"></param>
  611. public static void InitSteel(UltraComboEditor uce, OpeBase ob)
  612. {
  613. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.BaseOperations.getSteel", new object[] { }, ob);
  614. BaseMethod.InitComboEditor(uce, dt, "STEELNAME", "STEELCODE");
  615. }
  616. /// <summary>
  617. /// 获取标准类别
  618. /// </summary>
  619. /// <param name="uce"></param>
  620. /// <param name="ob"></param>
  621. public static void InitStdStyle(UltraComboEditor uce, OpeBase ob)
  622. {
  623. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.BaseOperations.getStdStyle", new object[] { }, ob);
  624. BaseMethod.InitComboEditor(uce, dt, "STD_STYLE_DESC", "STD_STYLE");
  625. }
  626. /// <summary>
  627. /// 获取标准名称
  628. /// </summary>
  629. public static void InitStdName(UltraComboEditor uce, OpeBase ob)
  630. {
  631. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.BaseOperations.getStdName", new object[] { }, ob);
  632. BaseMethod.InitComboEditor(uce, dt, "STD_NAME", "STD_CODE");
  633. }
  634. /// <summary>
  635. /// 获取轧管物料码
  636. /// </summary>
  637. public static void InitMaterial(UltraComboEditor uce, OpeBase ob)
  638. {
  639. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.BaseOperations.getMaterial", new object[] { }, ob);
  640. BaseMethod.InitComboEditor(uce, dt, "OUT_MATERIAL_DESC", "OUT_MATERIAL_NO");
  641. }
  642. /// <summary>
  643. /// 初始化下拉框原因
  644. /// </summary>
  645. /// <param name="uce"></param>
  646. /// <param name="ob"></param>
  647. public static void InitReason(UltraComboEditor uce, OpeBase ob)
  648. {
  649. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn.getSourse", new object[] { "8012" }, ob);
  650. BaseMethod.InitComboEditor(uce, dt, "BASENAME", "BASECODE");
  651. }
  652. /// <summary>
  653. /// 初始化下拉框综合判断结果
  654. /// </summary>
  655. /// <param name="uce"></param>
  656. /// <param name="ob"></param>
  657. public static void InitJustResult(UltraComboEditor uce, OpeBase ob)
  658. {
  659. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn.getSourse", new object[] { "407407" }, ob);
  660. BaseMethod.InitComboEditor(uce, dt, "BASENAME", "BASECODE");
  661. }
  662. /// <summary>
  663. /// 初始化下拉框所属权单位
  664. /// </summary>
  665. /// <param name="uce"></param>
  666. /// <param name="ob"></param>
  667. public static void InitBelongCode(UltraComboEditor uce, OpeBase ob)
  668. {
  669. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn.getBelongCode", new object[] { }, ob);
  670. BaseMethod.InitComboEditor(uce, dt, "DEPARTNAME", "DEPARTID");
  671. }
  672. /// <summary>
  673. /// 设置列显示位数
  674. /// </summary>
  675. /// <param name="ug"></param>
  676. /// <param name="arr"></param>
  677. public static void setUltraGridColumnMaxInput(UltraGrid ug, string[] arr)
  678. {
  679. if (ug == null || arr == null || arr.Length == 0)
  680. {
  681. return;
  682. }
  683. arr.ToArray();
  684. foreach (UltraGridColumn ugc in ug.DisplayLayout.Bands[0].Columns)
  685. {
  686. if (arr.Contains(ugc.Key.ToString()))
  687. {
  688. ugc.MaskClipMode = MaskMode.IncludeLiterals;
  689. ugc.MaskInput = "{LOC}nn,nnn,nnn.nnn";
  690. }
  691. }
  692. }
  693. /// <summary>
  694. /// 键盘按下Ctrl+D,拷贝活动单元格的数据到所有已勾选的此列的单元格中
  695. /// </summary>
  696. /// <param name="ugrid">UltraGrid</param>
  697. /// <param name="e"></param>
  698. /// <param name="strs">可以进行列名称</param>
  699. public static void setGridCopyActColumn(UltraGrid ugrid, KeyEventArgs e, params string[] strs)
  700. {
  701. if (e.Control && e.KeyCode == Keys.D)
  702. {
  703. if (ugrid != null && ugrid.ActiveRow != null)
  704. {
  705. UltraGridRow ugr = ugrid.ActiveRow;
  706. foreach (string colName in strs)
  707. {
  708. if (ugrid.ActiveCell.Column.Key == null)
  709. {
  710. return;
  711. }
  712. if (ugrid.ActiveCell.Column.Key.Equals(colName))
  713. {
  714. if (ugr.Cells[colName].Activation != Activation.AllowEdit)
  715. {
  716. return;
  717. }
  718. ugrid.UpdateData();
  719. ArrayList list = new ArrayList();
  720. IQueryable<UltraGridRow> checkRows = ugrid.Rows.AsQueryable().Where("CHK = 'True' ");
  721. if (checkRows.Count() == 0)
  722. {
  723. return;
  724. }
  725. foreach (UltraGridRow uRow in checkRows)
  726. {
  727. if (uRow != ugr && uRow.Cells[colName].Activation == Activation.AllowEdit)
  728. {
  729. uRow.Cells[colName].Value = ugr.Cells[colName].Value;
  730. }
  731. }
  732. }
  733. }
  734. }
  735. }
  736. }/// <summary>
  737. /// 初始年份
  738. /// </summary>
  739. /// <param name="uce"></param>
  740. public static void InitYear(UltraComboEditor uce)
  741. {
  742. DataTable dtYear = new DataTable();
  743. dtYear.Columns.Add("YEAR");
  744. for (int i = 2000; i < 2200; i++)
  745. {
  746. DataRow dr = dtYear.NewRow();
  747. dr["YEAR"] = i.ToString();
  748. dtYear.Rows.Add(dr);
  749. }
  750. uce.DataSource = dtYear;
  751. uce.DisplayMember = "YEAR";
  752. uce.ValueMember = "YEAR";
  753. }
  754. /// <summary>
  755. /// 初始月份
  756. /// </summary>
  757. /// <param name="uce"></param>
  758. public static void InitMonth(UltraComboEditor uce)
  759. {
  760. DataTable dtMonth = new DataTable();
  761. dtMonth.Columns.Add("MONTH");
  762. for (int i = 1; i < 13; i++)
  763. {
  764. DataRow dr = dtMonth.NewRow();
  765. dr["MONTH"] = string.Format("{0:00}", i);
  766. dtMonth.Rows.Add(dr);
  767. }
  768. uce.DataSource = dtMonth;
  769. uce.DisplayMember = "MONTH";
  770. uce.ValueMember = "MONTH";
  771. }
  772. /// <summary>
  773. /// 通过科室查找对应的部门
  774. /// </summary>
  775. /// <param name="sectionName">科室ID</param>
  776. /// <param name="ob"></param>
  777. /// <returns>部门ID</returns>
  778. public static string GetDepartIdBySectionId(string sectionId, OpeBase ob)
  779. {
  780. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.PipeManageClassInfo.getDeptBySection", new object[] { sectionId }, ob);
  781. if (dt.Rows.Count > 0)
  782. {
  783. return dt.Rows[0]["DEPARTID"].ToString();
  784. }
  785. else
  786. {
  787. return "";
  788. }
  789. }
  790. /// <summary>
  791. /// 通过科室查找对应的部门
  792. /// </summary>
  793. /// <param name="sectionName">科室ID</param>
  794. /// <param name="ob"></param>
  795. /// <returns>部门名称</returns>
  796. public static string GetDepartBySectionId(string sectionId, OpeBase ob)
  797. {
  798. DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.PipeManageClassInfo.getDeptBySection", new object[] { sectionId }, ob);
  799. if (dt.Rows.Count > 0)
  800. {
  801. return dt.Rows[0]["DEPARTNAME"].ToString();
  802. }
  803. else
  804. {
  805. return "";
  806. }
  807. }
  808. /// <summary>
  809. /// 键盘按下Ctrl+D,拷贝活动单元格的数据到所有已勾选的此列的单元格中
  810. /// </summary>
  811. /// <param name="ugrid">UltraGrid</param>
  812. /// <param name="e"></param>
  813. /// <param name="strs">可以进行列名称</param>
  814. public static void setGridCopyActColumn1(UltraGrid ugrid, KeyEventArgs e, params string[] strs)
  815. {
  816. if (e.Control && e.KeyCode == Keys.D)
  817. {
  818. if (ugrid != null && ugrid.ActiveRow != null)
  819. {
  820. UltraGridRow ugr = ugrid.ActiveRow;
  821. foreach (string colName in strs)
  822. {
  823. if (ugrid.ActiveCell.Column.Key.Equals(colName))
  824. {
  825. if (ugr.Cells[colName].Activation != Activation.AllowEdit)
  826. {
  827. return;
  828. }
  829. ugrid.UpdateData();
  830. ArrayList list = new ArrayList();
  831. IQueryable<UltraGridRow> checkRows = ugrid.Rows.AsQueryable().Where("CHOOSE = 'True' ");
  832. if (checkRows.Count() == 0)
  833. {
  834. return;
  835. }
  836. foreach (UltraGridRow uRow in checkRows)
  837. {
  838. if (uRow != ugr && uRow.Cells[colName].Activation == Activation.AllowEdit)
  839. {
  840. uRow.Cells[colName].Value = ugr.Cells[colName].Value;
  841. }
  842. }
  843. }
  844. }
  845. }
  846. }
  847. }
  848. }
  849. }