BaseMethod.cs 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102
  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 CoreFS.CA06;
  8. using Infragistics.Win.UltraWinEditors;
  9. using System.Data;
  10. using System.Windows.Forms;
  11. using Core.Mes.Client.Comm.Server;
  12. using Infragistics.Win.UltraWinMaskedEdit;
  13. using System.Collections;
  14. using Infragistics.Win;
  15. using System.Text.RegularExpressions;
  16. using System.IO;
  17. namespace Core.StlMes.Client.YdmBcPipeManage
  18. {
  19. public class BaseMethod
  20. {
  21. /// <summary>
  22. /// 初始化下拉框
  23. /// </summary>
  24. /// <param name="uce">下拉框</param>
  25. /// <param name="methodId">请求的服务</param>
  26. /// <param name="valueMember">值成员</param>
  27. /// <param name="ob">ob对象</param>
  28. /// <param name="isEmpty">是否有空行</param>
  29. public static void InitComboEditor(UltraComboEditor uce, string methodId, string valueMember, OpeBase ob, bool isEmpty)
  30. {
  31. DataTable dt = ServerHelper.GetData(methodId, null, ob);
  32. if (dt != null && dt.Rows.Count > 0)
  33. {
  34. if (isEmpty)
  35. {
  36. Object[] obj = new Object[] { "", "" };
  37. DataRow dr = dt.NewRow();
  38. dr.ItemArray = obj;
  39. dt.Rows.InsertAt(dr, 0);
  40. }
  41. uce.DataSource = dt;
  42. uce.ValueMember = valueMember;
  43. SetComboItemHeight(uce);
  44. }
  45. }
  46. /// <summary>
  47. /// 将下拉框绑定到GRID列
  48. /// </summary>
  49. /// <param name="uce">下拉框(已经初始化完成)</param>
  50. /// <param name="ColumnName">列名</param>
  51. /// <param name="con">空间集合(每次只需填入this.Controls)</param>
  52. /// <param name="ug">GRID</param>
  53. /// <param name="i">GRID的第几层结构</param>
  54. public static void BindColumn(UltraComboEditor uce, string ColumnName, System.Windows.Forms.Control.ControlCollection con, UltraGrid ug, int i)
  55. {
  56. con.Add(uce);
  57. uce.Visible = false;
  58. ug.DisplayLayout.Bands[i].Columns[ColumnName].EditorComponent = uce;
  59. ug.DisplayLayout.Bands[i].Columns[ColumnName].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  60. SetComboItemHeight(uce);
  61. }
  62. /// <summary>
  63. /// 初始化下拉框 --带参数的
  64. /// </summary>
  65. /// <param name="uce"></param>
  66. /// <param name="methodId"></param>
  67. /// <param name="valueMember"></param>
  68. /// <param name="ob"></param>
  69. /// <param name="isEmpty"></param>
  70. /// <param name="obj"></param>
  71. public static void InitComboEditorWithParmArr(UltraComboEditor uce, string methodId, string valueMember, OpeBase ob, bool isEmpty, params object[] parm)
  72. {
  73. DataTable dt = ServerHelper.GetData(methodId, parm, ob);
  74. if (dt != null && dt.Rows.Count > 0)
  75. {
  76. if (isEmpty)
  77. {
  78. Object[] obj = new Object[] { "", "" };
  79. DataRow dr = dt.NewRow();
  80. dr.ItemArray = obj;
  81. dt.Rows.InsertAt(dr, 0);
  82. }
  83. uce.DataSource = dt;
  84. uce.ValueMember = valueMember;
  85. uce.SelectedIndex = -1;
  86. SetComboItemHeight(uce);
  87. }
  88. }
  89. /// <summary>
  90. /// 设置UltraComboEditor中的中文和非中文统一高度。
  91. /// </summary>
  92. /// <param name="cmb"></param>
  93. public static void SetComboItemHeight(UltraComboEditor cmb)
  94. {
  95. foreach (ValueListItem item in cmb.Items)
  96. {
  97. if (Regex.IsMatch(item.DisplayText, @"[\u4e00-\u9fa5]+"))
  98. {
  99. item.Appearance.FontData.SizeInPoints = 9.0F;
  100. }
  101. else
  102. {
  103. item.Appearance.FontData.SizeInPoints = 10.5F;
  104. }
  105. }
  106. }
  107. /// <summary>
  108. /// UltraGrid可读
  109. /// </summary>
  110. /// <param name="ugr">UltraGrid</param>
  111. /// <param name="keys">可编辑列</param>
  112. public static void setOtherColumnReadOnly(UltraGrid ugr, string[] keys)
  113. {
  114. keys.ToArray();
  115. foreach (UltraGridColumn ugc in ugr.DisplayLayout.Bands[0].Columns)
  116. {
  117. if (!keys.Contains(ugc.Key))
  118. {
  119. ugc.CellActivation = Activation.ActivateOnly;
  120. }
  121. }
  122. }
  123. /// <summary>
  124. /// UltraGrid激活某行
  125. /// </summary>
  126. /// <param name="ug">UltraGrid</param>
  127. /// <param name="keys">列名</param>
  128. /// <param name="values">对应的值</param>
  129. public static void UltraGridLocation(UltraGrid ug, String[] keys, String[] values)
  130. {
  131. if (ug.Rows.Count == 0)
  132. {
  133. return;
  134. }
  135. if (keys.Length == 0 || values.Length == 0 || values.Length != keys.Length)
  136. {
  137. return;
  138. }
  139. foreach (UltraGridRow ugr in ug.Rows)
  140. {
  141. Boolean flag = true;
  142. for (int i = 0; i < keys.Length; i++)
  143. {
  144. if (!ugr.Cells[keys[i]].ToString().Equals(values[i]))
  145. {
  146. flag = false;
  147. }
  148. }
  149. if (flag == true)
  150. {
  151. ugr.Activate();
  152. return;
  153. }
  154. }
  155. }
  156. /// <summary>
  157. /// 设置列字段显示位置在右
  158. /// </summary>
  159. /// <param name="ug">UltraGrid</param>
  160. /// <param name="columnsKeys">要设置的列</param>
  161. public static void InitCellPosition(UltraGrid ug, string[] columnsKeys)
  162. {
  163. columnsKeys.ToArray();
  164. foreach (UltraGridColumn ugc in ug.DisplayLayout.Bands[0].Columns)
  165. {
  166. if (columnsKeys.Contains(ugc.Key.ToString()))
  167. {
  168. ugc.CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right;
  169. }
  170. }
  171. }
  172. /// <summary>
  173. /// 设置列字段显示位置在右
  174. /// </summary>
  175. /// <param name="ug">UltraGrid</param>
  176. /// <param name="columnsKeys">要设置的列</param>
  177. public static void InitCellPosition(UltraGrid ug, string[] columnsKeys,int dex)
  178. {
  179. columnsKeys.ToArray();
  180. foreach (UltraGridColumn ugc in ug.DisplayLayout.Bands[dex].Columns)
  181. {
  182. if (columnsKeys.Contains(ugc.Key.ToString()))
  183. {
  184. ugc.CellAppearance.TextHAlign = Infragistics.Win.HAlign.Right;
  185. }
  186. }
  187. }
  188. /// <summary>
  189. /// 列求和
  190. /// </summary>
  191. /// <param name="ug">UltraGrid</param>
  192. /// <param name="columnKeys">列数组</param>
  193. public static void GridColumnSum(UltraGrid ug, string[] columnKeys)
  194. {
  195. if (columnKeys.Length == 0)
  196. {
  197. return;
  198. }
  199. for (int i = 0; i < columnKeys.Length; i++)
  200. {
  201. ug.DisplayLayout.Bands[0].Summaries.Add(SummaryType.Sum, ug.DisplayLayout.Bands[0].Columns[columnKeys[i]], SummaryPosition.UseSummaryPositionColumn);
  202. }
  203. }
  204. /// <summary>
  205. /// 设置UltraGrid行颜色
  206. /// </summary>
  207. /// <param name="ug">UltraGrid</param>
  208. /// <param name="columnKeys">列</param>
  209. /// <param name="values">值</param>
  210. /// <param name="color">颜色</param>
  211. public static void SetUltraGridRowColor(UltraGrid ug, string[] columnKeys, string[] values, Color color)
  212. {
  213. if (ug.Rows.Count == 0 || columnKeys.Length == 0 || values.Length == 0 || color == null || values.Length != columnKeys.Length)
  214. {
  215. return;
  216. }
  217. foreach (UltraGridRow ugr in ug.Rows)
  218. {
  219. Boolean flag = true;
  220. for (int i = 0; i < columnKeys.Length; i++)
  221. {
  222. if (!ugr.Cells[columnKeys[i]].Value.ToString().Equals(values[i]))
  223. {
  224. flag = false;
  225. }
  226. }
  227. if (flag)
  228. {
  229. ugr.Appearance.BackColor = color;
  230. }
  231. }
  232. }
  233. /// <summary>
  234. /// 合并单元格
  235. /// </summary>
  236. /// <param name="ug"></param>
  237. /// <param name="columnKeys"></param>
  238. public static void MergedCell(UltraGrid ug, string[] columnKeys)
  239. {
  240. if (columnKeys.Length == 0)
  241. {
  242. return;
  243. }
  244. ug.DisplayLayout.Override.MergedCellStyle = MergedCellStyle.Never;
  245. for (int i = 0; i < columnKeys.Length; i++)
  246. {
  247. ug.DisplayLayout.Bands[0].Columns[columnKeys[i]].MergedCellStyle = MergedCellStyle.Always;
  248. }
  249. }
  250. /// <summary>
  251. /// 仓库数据权限
  252. /// </summary>
  253. /// <param name="customInfo">页面配制信息(自定义参数)</param>
  254. /// <param name="validDataPurviewIds">用户数据权限</param>
  255. /// <returns>可查看仓库组成的字符串</returns>
  256. public static string[] WarehousePermissions(String customInfo, String[] validDataPurviewIds, OpeBase ob)
  257. {
  258. string storageType = "";//仓库类别
  259. string storageAttr = "";//仓库类型
  260. if (customInfo.Length >= 0 && customInfo.Contains(","))
  261. {
  262. string[] strflg = customInfo.ToString().Split(new char[] { ',' });
  263. storageType = strflg[0];
  264. storageAttr = strflg[1];
  265. }
  266. DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.common.WarehousePermissions.getWarehousePermissions", new object[] { storageType, storageAttr, validDataPurviewIds }, ob);
  267. if (dt != null && dt.Rows.Count > 0)
  268. {
  269. string[] storages = new string[dt.Rows.Count];
  270. for (int i = 0; i < dt.Rows.Count; i++)
  271. {
  272. storages[i] = dt.Rows[i]["STORAGE_NO"].ToString();
  273. }
  274. return storages;
  275. }
  276. else
  277. {
  278. return new string[1] { "" };
  279. }
  280. }
  281. /// <summary>
  282. /// 仓库数据权限(用于报表)
  283. /// </summary>
  284. /// <param name="customInfo">页面配制信息(自定义参数)</param>
  285. /// <param name="validDataPurviewIds">用户数据权限</param>
  286. /// <returns>可查看仓库组成的字符串</returns>
  287. public static string[] WarehousePermissionsStore1(String[] validDataPurviewIds,string tt , OpeBase ob)
  288. {
  289. DataTable dt = ServerHelper.GetData("com.steering.mes.SendRecive.FrmFilpOutStorage.getWarehousePermissionsStore", new object[] { validDataPurviewIds ,""}, ob);
  290. if (dt != null && dt.Rows.Count > 0)
  291. {
  292. string[] storages = new string[dt.Rows.Count];
  293. for (int i = 0; i < dt.Rows.Count; i++)
  294. {
  295. storages[i] = dt.Rows[i]["STORAGE_NO"].ToString();
  296. }
  297. return storages;
  298. }
  299. else
  300. {
  301. return new string[1] { "" };
  302. }
  303. }
  304. /// <summary>
  305. /// 仓库数据权限(用于报表)
  306. /// </summary>
  307. /// <param name="customInfo">页面配制信息(自定义参数)</param>
  308. /// <param name="validDataPurviewIds">用户数据权限</param>
  309. /// <returns>可查看仓库组成的字符串</returns>
  310. public static string[] WarehousePermissionsStore1(String[] validDataPurviewIds, OpeBase ob)
  311. {
  312. DataTable dt = ServerHelper.GetData("com.steering.mes.SendRecive.FrmFilpOutStorage.getWarehousePermissionsStore", new object[] { validDataPurviewIds }, ob);
  313. if (dt != null && dt.Rows.Count > 0)
  314. {
  315. string[] storages = new string[dt.Rows.Count];
  316. for (int i = 0; i < dt.Rows.Count; i++)
  317. {
  318. storages[i] = dt.Rows[i]["STORAGE_NO"].ToString();
  319. }
  320. return storages;
  321. }
  322. else
  323. {
  324. return new string[1] { "" };
  325. }
  326. }
  327. /// <summary>
  328. /// 仓库数据权限(用于报表)
  329. /// </summary>
  330. /// <param name="customInfo">页面配制信息(自定义参数)</param>
  331. /// <param name="validDataPurviewIds">用户数据权限</param>
  332. /// <returns>可查看仓库组成的字符串</returns>
  333. public static string[] WarehousePermissionsStore(String[] validDataPurviewIds, OpeBase ob)
  334. {
  335. DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.common.WarehousePermissions.getWarehousePermissionsStore", new object[] { validDataPurviewIds }, ob);
  336. if (dt != null && dt.Rows.Count > 0)
  337. {
  338. string[] storages = new string[dt.Rows.Count];
  339. for (int i = 0; i < dt.Rows.Count; i++)
  340. {
  341. storages[i] = dt.Rows[i]["STORAGE_NO"].ToString();
  342. }
  343. return storages;
  344. }
  345. else
  346. {
  347. return new string[1] { "" };
  348. }
  349. }
  350. /// <summary>
  351. /// 数据权限查部门
  352. /// </summary>
  353. /// <param name="customInfo">页面配制信息(自定义参数)</param>
  354. /// <param name="validDataPurviewIds">用户数据权限</param>
  355. /// <returns>可查看仓库组成的字符串</returns>
  356. public static string[] WarehousePermissionsDepart(String[] validDataPurviewIds, OpeBase ob)
  357. {
  358. DataTable dt = ServerHelper.GetData("com.steering.mes.mcp.common.WarehousePermissions.getWarehousePermissionsDepart", new object[] { validDataPurviewIds }, ob);
  359. if (dt != null && dt.Rows.Count > 0)
  360. {
  361. string[] storages = new string[dt.Rows.Count];
  362. for (int i = 0; i < dt.Rows.Count; i++)
  363. {
  364. storages[i] = dt.Rows[i]["PID"].ToString();
  365. }
  366. return storages;
  367. }
  368. else
  369. {
  370. return new string[1] { "" };
  371. }
  372. }
  373. /// <summary>
  374. /// 初始化仓库号下拉框
  375. /// </summary>
  376. /// <param name="uce"></param>
  377. /// <param name="customInfo"></param>
  378. /// <param name="validDataPurviewIds"></param>
  379. /// <param name="ob"></param>
  380. //public static void InitStorage(UltraComboEditor uce, String customInfo, String[] validDataPurviewIds, OpeBase ob)
  381. //{
  382. // string storageType = "";//仓库类别
  383. // string storageAttr = "";//仓库类型
  384. // if (customInfo.Length >= 0 && customInfo.Contains(","))
  385. // {
  386. // string[] strflg = customInfo.ToString().Split(new char[] { ',' });
  387. // storageType = strflg[0];
  388. // storageAttr = strflg[1];
  389. // }
  390. // DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.WarehousePermissions.getWarehousePermissions", new object[] { storageType, storageAttr, validDataPurviewIds }, ob);
  391. // if (dt != null && dt.Rows.Count > 0)
  392. // {
  393. // uce.DataSource = dt;
  394. // uce.DisplayMember = "STORAGE_NAME";
  395. // uce.ValueMember = "STORAGE_NO";
  396. // uce.SelectedIndex = 0;
  397. // }
  398. // else
  399. // {
  400. // uce.DataSource = null;
  401. // }
  402. //}
  403. /// <summary>
  404. /// 初始化下拉框仓库名称
  405. /// </summary>
  406. /// <param name="uce"></param>
  407. /// <param name="ob"></param>
  408. //public static void InitGpStorage(UltraComboEditor uce, OpeBase ob)
  409. //{
  410. // DataTable dtMapStatus = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmBaseInformation.doQueryStorage", new object[] { }, ob);
  411. // BaseMethod.InitComboEditor(uce, dtMapStatus, "BASENAME", "BASECODE");
  412. //}
  413. /// <summary>
  414. /// 初始化下拉框材料类别
  415. /// </summary>
  416. /// <param name="uce"></param>
  417. /// <param name="ob"></param>
  418. //public static void InitProducFlagCom(UltraComboEditor uce, OpeBase ob)
  419. //{
  420. // DataTable dtProducFlag = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmBaseInformation.queryMaterialSTyle", new object[] { }, ob);
  421. // BaseMethod.InitComboEditor(uce, dtProducFlag, "BASENAME", "BASECODE");
  422. //}
  423. ///// <summary>
  424. ///// 初始化下拉框材料状态
  425. ///// </summary>
  426. ///// <param name="uce"></param>
  427. ///// <param name="ob"></param>
  428. //public static void InitMapStatusCom(UltraComboEditor uce, OpeBase ob)
  429. //{
  430. // DataTable dtMapStatus = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeMagement.queryMaterialStatus", new object[] { }, ob);
  431. // BaseMethod.InitComboEditor(uce, dtMapStatus, "BASENAME", "BASECODE");
  432. //}
  433. ///// <summary>
  434. ///// 初始化下拉框材料状态
  435. ///// </summary>
  436. ///// <param name="uce"></param>
  437. ///// <param name="ob"></param>
  438. //public static void InitMapStatusCom(UltraComboEditor uce, OpeBase ob, string flag)
  439. //{
  440. // DataTable dtMapStatus = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmBaseInformation.queryMaterialStatus", new object[] { flag }, ob);
  441. // BaseMethod.InitComboEditor(uce, dtMapStatus, "BASENAME", "BASECODE");
  442. //}
  443. ///// <summary>
  444. ///// 初始化下拉框管坯物料码
  445. ///// </summary>
  446. ///// <param name="uce"></param>
  447. ///// <param name="ob"></param>
  448. //public static void InitMaterialCom(UltraComboEditor uce, OpeBase ob)
  449. //{
  450. // DataTable dtMapStatus = ServerHelper.GetData("Core.LgMes.Server.Stuffmanage.FrmBaseInformation.doQueryMaterial", new object[] { }, ob);
  451. // BaseMethod.InitComboEditor(uce, dtMapStatus, "BASENAME", "BASECODE");
  452. //}
  453. /// <summary>
  454. /// 初始下拉框
  455. /// </summary>
  456. /// <param name="uce"></param>
  457. /// <param name="dt"></param>
  458. /// <param name="showName"></param>
  459. /// <param name="hideValue"></param>
  460. public static void InitComboEditor(UltraComboEditor uce, DataTable dt, String showName, String hideValue)
  461. {
  462. uce.DataSource = dt;
  463. uce.DisplayMember = showName;
  464. uce.ValueMember = hideValue;
  465. }
  466. /// <summary>
  467. /// 初始化下拉框仓库名称
  468. /// </summary>
  469. /// <param name="uce"></param>
  470. /// <param name="ob"></param>
  471. public static void InitStorageNoGp(UltraComboEditor uce, OpeBase ob)
  472. {
  473. DataTable dtStorageNo = ServerHelper.GetData("com.steering.ydm.bc.FrmDeleteMatBcM.getStorageNoGp", new object[] { }, ob);
  474. BaseMethod.InitComboEditor(uce, dtStorageNo, "STORAGE_NAME", "STORAGE_NO");
  475. }
  476. /// <summary>
  477. /// 初始化下拉框仓库名称
  478. /// </summary>
  479. /// <param name="uce"></param>
  480. /// <param name="ob"></param>
  481. public static void InitStorageNo(UltraComboEditor uce, OpeBase ob)
  482. {
  483. DataTable dtStorageNo = ServerHelper.GetData("com.steering.ydm.bc.FrmDeleteMatBcM.getStorageNo", new object[] { }, ob);
  484. BaseMethod.InitComboEditor(uce, dtStorageNo, "STORAGE_NAME", "STORAGE_NO");
  485. }
  486. /// <summary>
  487. /// 初始化下拉框装卸点
  488. /// </summary>
  489. /// <param name="uce"></param>
  490. /// <param name="ob"></param>
  491. public static void InitUnLoad(UltraComboEditor uce, OpeBase ob,string plineCode)
  492. {
  493. DataTable dtStorageNo = ServerHelper.GetData("com.steering.Demand.sever.FrmBcM.getUnLoad", new object[] { plineCode }, ob);
  494. BaseMethod.InitComboEditor(uce, dtStorageNo, "UNLOADING_DESC", "UNLOADING_CODE");
  495. }
  496. /// <summary>
  497. /// 初始化下拉框需求单位
  498. /// </summary>
  499. /// <param name="uce"></param>
  500. /// <param name="ob"></param>
  501. public static void InitDemandUser(UltraComboEditor uce, OpeBase ob,string[] plineCode)
  502. {
  503. DataTable dtStorageNo = ServerHelper.GetData("com.steering.Demand.sever.FrmBcM.getDemandUser", new object[] { plineCode }, ob);
  504. BaseMethod.InitComboEditor(uce, dtStorageNo, "PLINE_NAME", "PLINE_CODE");
  505. }
  506. /// <summary>
  507. /// 初始化下拉框工序判定结果
  508. /// </summary>
  509. /// <param name="uce"></param>
  510. /// <param name="ob"></param>
  511. public static void InitJudgeResult(UltraComboEditor uce, OpeBase ob)
  512. {
  513. DataTable dtStorageNo = ServerHelper.GetData("com.steering.ydm.bc.FrmApplyCode.getJudgeResult", new object[] { }, ob);
  514. BaseMethod.InitComboEditor(uce, dtStorageNo, "BASENAME", "BASECODE");
  515. }
  516. /// <summary>
  517. /// 初始下拉框
  518. /// </summary>
  519. /// <param name="uce"></param>
  520. /// <param name="dt"></param>
  521. /// <param name="showName"></param>
  522. /// <param name="hideValue"></param>
  523. public static void InitComboEditor1(UltraComboEditor uce, DataTable dt, String showName, String hideValue)
  524. {
  525. uce.DataSource = dt;
  526. uce.DisplayMember = showName;
  527. uce.ValueMember = hideValue;
  528. uce.SelectedIndex = 1;
  529. }
  530. /// <summary>
  531. /// 初始化下拉框产线
  532. /// </summary>
  533. /// <param name="uce"></param>
  534. /// <param name="ob"></param>
  535. //public static void InitPline(UltraComboEditor uce, OpeBase ob)
  536. //{
  537. // DataTable dtPline = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn.getPline", new object[] { }, ob);
  538. // BaseMethod.InitComboEditor(uce, dtPline, "PLINE_NAME", "PLINE_CODE");
  539. //}
  540. ///// <summary>
  541. ///// 初始化下拉框材料来源
  542. ///// </summary>
  543. ///// <param name="uce"></param>
  544. ///// <param name="ob"></param>
  545. //public static void InitSourse(UltraComboEditor uce, OpeBase ob)
  546. //{
  547. // DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn.getSourse", new object[] { "8013" }, ob);
  548. // BaseMethod.InitComboEditor1(uce, dt, "BASENAME", "BASECODE");
  549. //}
  550. ///// <summary>
  551. ///// 初始化下拉框钢种
  552. ///// </summary>
  553. ///// <param name="uce"></param>
  554. ///// <param name="ob"></param>
  555. //public static void InitGrade(UltraComboEditor uce, OpeBase ob)
  556. //{
  557. // DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeEnter.getGrade", new object[] { }, ob);
  558. // BaseMethod.InitComboEditor(uce, dt, "GRADENAME", "GRADECODE");
  559. //}
  560. ///// <summary>
  561. ///// 获取规格
  562. ///// </summary>
  563. ///// <param name="uce"></param>
  564. ///// <param name="ob"></param>
  565. //public static void InitSpec(UltraComboEditor uce, OpeBase ob)
  566. //{
  567. // DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeEnter.getSpec", new object[] { }, ob);
  568. // BaseMethod.InitComboEditor(uce, dt, "SPEC_NAME", "SPEC_CODE");
  569. //}
  570. ///// <summary>
  571. ///// 获取扣型
  572. ///// </summary>
  573. ///// <param name="uce"></param>
  574. ///// <param name="ob"></param>
  575. //public static void InitModel(UltraComboEditor uce, OpeBase ob)
  576. //{
  577. // DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeEnter.getModel", new object[] { }, ob);
  578. // BaseMethod.InitComboEditor(uce, dt, "MODEL_DESC", "MODEL_CODE");
  579. //}
  580. ///// <summary>
  581. ///// 获取品名
  582. ///// </summary>
  583. ///// <param name="uce"></param>
  584. ///// <param name="ob"></param>
  585. //public static void InitProcduce(UltraComboEditor uce, OpeBase ob)
  586. //{
  587. // DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.BaseOperations.getProcduce", new object[] { }, ob);
  588. // BaseMethod.InitComboEditor(uce, dt, "PRODUC_JX", "PRODUCCODE");
  589. //}
  590. ///// <summary>
  591. ///// 获取钢级
  592. ///// </summary>
  593. ///// <param name="uce"></param>
  594. ///// <param name="ob"></param>
  595. //public static void InitSteel(UltraComboEditor uce, OpeBase ob)
  596. //{
  597. // DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.BaseOperations.getSteel", new object[] { }, ob);
  598. // BaseMethod.InitComboEditor(uce, dt, "STEELNAME", "STEELCODE");
  599. //}
  600. ///// <summary>
  601. ///// 获取标准类别
  602. ///// </summary>
  603. ///// <param name="uce"></param>
  604. ///// <param name="ob"></param>
  605. //public static void InitStdStyle(UltraComboEditor uce, OpeBase ob)
  606. //{
  607. // DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.BaseOperations.getStdStyle", new object[] { }, ob);
  608. // BaseMethod.InitComboEditor(uce, dt, "STD_STYLE_DESC", "STD_STYLE");
  609. //}
  610. ///// <summary>
  611. ///// 初始化下拉框原因
  612. ///// </summary>
  613. ///// <param name="uce"></param>
  614. ///// <param name="ob"></param>
  615. //public static void InitReason(UltraComboEditor uce, OpeBase ob)
  616. //{
  617. // DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn.getSourse", new object[] { "8012" }, ob);
  618. // BaseMethod.InitComboEditor(uce, dt, "BASENAME", "BASECODE");
  619. //}
  620. ///// <summary>
  621. ///// 初始化下拉框综合判断结果
  622. ///// </summary>
  623. ///// <param name="uce"></param>
  624. ///// <param name="ob"></param>
  625. //public static void InitJustResult(UltraComboEditor uce, OpeBase ob)
  626. //{
  627. // DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn.getSourse", new object[] { "407407" }, ob);
  628. // BaseMethod.InitComboEditor(uce, dt, "BASENAME", "BASECODE");
  629. //}
  630. ///// <summary>
  631. ///// 初始化下拉框所属权单位
  632. ///// </summary>
  633. ///// <param name="uce"></param>
  634. ///// <param name="ob"></param>
  635. //public static void InitBelongCode(UltraComboEditor uce, OpeBase ob)
  636. //{
  637. // DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.pipemanage.FrmPipeInventoryIn.getBelongCode", new object[] { }, ob);
  638. // BaseMethod.InitComboEditor(uce, dt, "DEPARTNAME", "DEPARTID");
  639. //}
  640. ///// <summary>
  641. ///// 销售组织权限
  642. ///// </summary>
  643. ///// <param name="validDataPurviewIds">数据权限</param>
  644. ///// <param name="ob"></param>
  645. ///// <returns>字符串数组</returns>
  646. //public static string[] InitPermissions(string[] validDataPurviewIds, OpeBase ob)
  647. //{
  648. // string[] arr = null;
  649. // DataTable dt = ServerHelper.GetData("com.steering.pss.ydm.base.WarehousePermissions.getSalgPermissions", new object[] { validDataPurviewIds }, ob);
  650. // if (dt != null && dt.Rows.Count > 0)
  651. // {
  652. // arr = new string[dt.Rows.Count];
  653. // for (int i = 0; i < dt.Rows.Count; i++)
  654. // {
  655. // arr[i] = dt.Rows[i][0].ToString();
  656. // }
  657. // }
  658. // return arr;
  659. //}
  660. ///// <summary>
  661. ///// 炼钢权限
  662. ///// </summary>
  663. ///// <param name="validDataPurviewIds">数据权限</param>
  664. ///// <param name="ob"></param>
  665. ///// <returns>字符串数组</returns>
  666. //public static string[] InitLgPermissions(string[] validDataPurviewIds,string processNo, OpeBase ob)
  667. //{
  668. // string[] arr = null;
  669. // DataTable dt = ServerHelper.GetData("Core.LgMes.Server.Common.ComLgValidDataPurviewIds.getLgPermissions", new object[] { validDataPurviewIds, processNo }, ob);
  670. // if (dt != null && dt.Rows.Count > 0)
  671. // {
  672. // arr = new string[dt.Rows.Count];
  673. // for (int i = 0; i < dt.Rows.Count; i++)
  674. // {
  675. // arr[i] = dt.Rows[i][0].ToString();
  676. // }
  677. // }
  678. // return arr;
  679. //}
  680. ///// <summary>
  681. ///// 获取PCode
  682. ///// </summary>
  683. ///// <param name="Department">user_depatment</param>
  684. ///// <returns></returns>
  685. //public static string GetPCode(string Department, OpeBase ob)
  686. //{
  687. // string Pcode = "";
  688. // DataTable dt = ServerHelper.GetData("Core.LgMes.Server.Common.ComLgValidDataPurviewIds.getPCode", new Object[] { Department }, ob);
  689. // if (dt.Rows.Count > 0)
  690. // {
  691. // Pcode = dt.Rows[0]["pline_code"].ToString();
  692. // }
  693. // return Pcode;
  694. //}
  695. /// <summary>
  696. /// 获取产线
  697. /// </summary>
  698. /// <param name="validDataPurviewIds">数据权限</param>
  699. /// <param name="ob"></param>
  700. /// <returns>字符串数组</returns>
  701. public static string[] getPCodePline(string[] arr1,OpeBase _ob)
  702. {
  703. string[] arr = null;
  704. DataTable dt = ServerHelper.GetData("com.steering.ydm.bc.FrmFilpOutStorage.getPCode", new Object[] { arr1 },_ob);
  705. if (dt != null && dt.Rows.Count > 0)
  706. {
  707. arr = new string[dt.Rows.Count];
  708. for (int i = 0; i < dt.Rows.Count; i++)
  709. {
  710. arr[i] = dt.Rows[i][0].ToString();
  711. }
  712. return arr;
  713. }
  714. else
  715. {
  716. return new string[1] { "" };
  717. }
  718. }
  719. public static string[] InitDropPlineCodePower(UltraComboEditor ugc, string[] validDataPurviewIds, OpeBase ob)
  720. {
  721. DataTable dt = ServerHelper.GetData("com.steering.ydm.bc.FrmFilpOutStorage.getPCode", new object[] { validDataPurviewIds }, ob);
  722. if (dt != null && dt.Rows.Count > 0)
  723. {
  724. ugc.DataSource = dt;
  725. ugc.ValueMember = "PLINE_CODE";
  726. ugc.DisplayMember = "PLINE_NAME";
  727. string[] plineArr = new string[dt.Rows.Count];
  728. for (int i = 0; i < dt.Rows.Count; i++)
  729. {
  730. plineArr[i] = dt.Rows[i]["PLINE_CODE"].ToString();
  731. }
  732. return plineArr;
  733. }
  734. else
  735. {
  736. return null;
  737. }
  738. }
  739. public static string[] InitDropPlineCodePower(List<UltraComboEditor> ugc, string[] validDataPurviewIds, OpeBase ob)
  740. {
  741. DataTable dt = ServerHelper.GetData("com.steering.ydm.bc.FrmFilpOutStorage.getPCode", new object[] { validDataPurviewIds }, ob);
  742. if (dt != null && dt.Rows.Count > 0)
  743. {
  744. ugc.ForEach(p =>
  745. {
  746. p.DataSource = dt;
  747. p.ValueMember = "PLINE_CODE";
  748. p.DisplayMember = "PLINE_NAME";
  749. });
  750. string[] plineArr = new string[dt.Rows.Count];
  751. for (int i = 0; i < dt.Rows.Count; i++)
  752. {
  753. plineArr[i] = dt.Rows[i]["PLINE_CODE"].ToString();
  754. }
  755. return plineArr;
  756. }
  757. else
  758. {
  759. return null;
  760. }
  761. }
  762. /// <summary>
  763. /// 设置列显示位数
  764. /// </summary>
  765. /// <param name="ug"></param>
  766. /// <param name="arr"></param>
  767. public static void setUltraGridColumnMaxInput(UltraGrid ug, string[] arr)
  768. {
  769. if (ug == null || arr == null || arr.Length == 0)
  770. {
  771. return;
  772. }
  773. arr.ToArray();
  774. foreach (UltraGridColumn ugc in ug.DisplayLayout.Bands[0].Columns)
  775. {
  776. if (arr.Contains(ugc.Key.ToString()))
  777. {
  778. ugc.MaskClipMode = MaskMode.IncludeLiterals;
  779. ugc.MaskInput = "{LOC}nn,nnn,nnn.nnn";
  780. }
  781. }
  782. }
  783. /// <summary>
  784. /// 键盘按下Ctrl+D,拷贝活动单元格的数据到所有已勾选的此列的单元格中
  785. /// </summary>
  786. /// <param name="ugrid">UltraGrid</param>
  787. /// <param name="e"></param>
  788. /// <param name="strs">可以进行列名称</param>
  789. public static void setGridCopyActColumn(UltraGrid ugrid, KeyEventArgs e, params string[] strs)
  790. {
  791. if (e.Control && e.KeyCode == Keys.D)
  792. {
  793. if (ugrid != null && ugrid.ActiveRow != null)
  794. {
  795. UltraGridRow ugr = ugrid.ActiveRow;
  796. foreach (string colName in strs)
  797. {
  798. if (ugrid.ActiveCell.Column.Key.Equals(colName))
  799. {
  800. if (ugr.Cells[colName].Activation != Activation.AllowEdit)
  801. {
  802. return;
  803. }
  804. ugrid.UpdateData();
  805. ArrayList list = new ArrayList();
  806. IQueryable<UltraGridRow> checkRows = ugrid.Rows.AsQueryable().Where("CHK = 'True' ");
  807. if (checkRows.Count() == 0)
  808. {
  809. return;
  810. }
  811. foreach (UltraGridRow uRow in checkRows)
  812. {
  813. if (uRow != ugr && uRow.Cells[colName].Activation == Activation.AllowEdit)
  814. {
  815. uRow.Cells[colName].Value = ugr.Cells[colName].Value;
  816. }
  817. }
  818. }
  819. }
  820. }
  821. }
  822. }/// <summary>
  823. /// 初始年份
  824. /// </summary>
  825. /// <param name="uce"></param>
  826. public static void InitYear(UltraComboEditor uce)
  827. {
  828. DataTable dtYear = new DataTable();
  829. dtYear.Columns.Add("YEAR");
  830. for (int i = 2000; i < 2200; i++)
  831. {
  832. DataRow dr = dtYear.NewRow();
  833. dr["YEAR"] = i.ToString();
  834. dtYear.Rows.Add(dr);
  835. }
  836. uce.DataSource = dtYear;
  837. uce.DisplayMember = "YEAR";
  838. uce.ValueMember = "YEAR";
  839. }
  840. /// <summary>
  841. /// 初始月份
  842. /// </summary>
  843. /// <param name="uce"></param>
  844. public static void InitMonth(UltraComboEditor uce)
  845. {
  846. DataTable dtMonth = new DataTable();
  847. dtMonth.Columns.Add("MONTH");
  848. for (int i = 1; i < 13; i++)
  849. {
  850. DataRow dr = dtMonth.NewRow();
  851. dr["MONTH"] = string.Format("{0:00}", i);
  852. dtMonth.Rows.Add(dr);
  853. }
  854. uce.DataSource = dtMonth;
  855. uce.DisplayMember = "MONTH";
  856. uce.ValueMember = "MONTH";
  857. }
  858. /// <summary>
  859. /// 键盘按下Ctrl+D,拷贝活动单元格的数据到所有已勾选的此列的单元格中
  860. /// </summary>
  861. /// <param name="ugrid">UltraGrid</param>
  862. /// <param name="e"></param>
  863. /// <param name="strs">可以进行列名称</param>
  864. public static void setGridCopyActColumn1(UltraGrid ugrid, KeyEventArgs e, params string[] strs)
  865. {
  866. if (e.Control && e.KeyCode == Keys.D)
  867. {
  868. if (ugrid != null && ugrid.ActiveRow != null)
  869. {
  870. UltraGridRow ugr = ugrid.ActiveRow;
  871. foreach (string colName in strs)
  872. {
  873. if (ugrid.ActiveCell.Column.Key.Equals(colName))
  874. {
  875. if (ugr.Cells[colName].Activation != Activation.AllowEdit)
  876. {
  877. return;
  878. }
  879. ugrid.UpdateData();
  880. ArrayList list = new ArrayList();
  881. IQueryable<UltraGridRow> checkRows = ugrid.Rows.AsQueryable().Where("CHOOSE = 'True' ");
  882. if (checkRows.Count() == 0)
  883. {
  884. return;
  885. }
  886. foreach (UltraGridRow uRow in checkRows)
  887. {
  888. if (uRow != ugr && uRow.Cells[colName].Activation == Activation.AllowEdit)
  889. {
  890. uRow.Cells[colName].Value = ugr.Cells[colName].Value;
  891. }
  892. }
  893. }
  894. }
  895. }
  896. }
  897. }
  898. /// <summary>
  899. /// 获取表格中
  900. /// </summary>
  901. /// <typeparam name="T">返回类</typeparam>
  902. /// <param name="dt">数据表</param>
  903. /// <param name="t">输入类</param>
  904. /// <returns></returns>
  905. public static T GetTableToEntity<T>(DataTable dt, T t)
  906. {
  907. String[] strColumns = null;
  908. DataRow dr = dt.Rows[0];
  909. try
  910. {
  911. if (dt.Columns.Count > 0)
  912. {
  913. int columnNum = 0;
  914. columnNum = dt.Columns.Count;
  915. strColumns = new string[columnNum];
  916. for (int i = 0; i < dt.Columns.Count; i++)
  917. {
  918. strColumns[i] = dt.Columns[i].ColumnName.Replace("_", "");
  919. }
  920. System.Reflection.PropertyInfo[] pro = t.GetType().GetProperties();
  921. foreach (System.Reflection.PropertyInfo item in pro)
  922. {
  923. for (int i = 0; i < strColumns.Length; i++)
  924. {
  925. if (string.Compare(item.Name.ToString(), strColumns[i].ToString(), true) == 0)
  926. {
  927. if (item.PropertyType == typeof(int?))
  928. {
  929. item.SetValue(t, Convert.ToInt32(dr[i].ToString3()), null);
  930. }
  931. else if (item.PropertyType == typeof(decimal?))
  932. {
  933. item.SetValue(t, Convert.ToDecimal(dr[i].ToString3()), null);
  934. }
  935. else
  936. {
  937. item.SetValue(t, dr[i].ToString(), null);
  938. }
  939. }
  940. }
  941. }
  942. }
  943. else
  944. {
  945. }
  946. }
  947. catch (Exception e)
  948. {
  949. System.Windows.Forms.MessageBox.Show("出错:", e.ToString());
  950. }
  951. return t;
  952. }
  953. /// <summary>
  954. /// 获取数据源中第一行数据赋到类中(grid 带下划线)
  955. /// </summary>
  956. /// <typeparam name="T">返回类</typeparam>
  957. /// <param name="ds">输入带数据的数据源</param>
  958. /// <param name="t">输入类</param>
  959. /// <returns></returns>
  960. public static T GetUltraGridToEntityNEW<T>(UltraGrid _grid, T t)
  961. {
  962. String[] strColumns = null;
  963. String[] strColumnsNew = null;
  964. UltraGridRow dr = _grid.Rows[0];
  965. int columnNum = dr.Cells.Count;
  966. strColumns = new String[columnNum];
  967. strColumnsNew = new String[columnNum];
  968. for (int i = 0; i < columnNum; i++)
  969. {
  970. strColumns[i] = _grid.DisplayLayout.Bands[0].Columns[i].Key.ToString().Replace("_", "");
  971. strColumnsNew[i] = _grid.DisplayLayout.Bands[0].Columns[i].Key.ToString();
  972. }
  973. System.Reflection.PropertyInfo[] pro = t.GetType().GetProperties();
  974. foreach (System.Reflection.PropertyInfo item in pro)
  975. {
  976. for (int i = 0; i < strColumns.Length; i++)
  977. {
  978. if (string.Compare(item.Name.ToString(), strColumns[i].ToString(), true) == 0)
  979. {
  980. if (item.PropertyType == typeof(int?))
  981. {
  982. item.SetValue(t, Convert.ToInt32(dr.Cells[strColumnsNew[i]].Value.ToString3()), null);
  983. }
  984. else if (item.PropertyType == typeof(decimal?))
  985. {
  986. item.SetValue(t, Convert.ToDecimal(dr.Cells[strColumnsNew[i]].Value.ToString3()), null);
  987. }
  988. else
  989. {
  990. item.SetValue(t, Convert.ToString(dr.Cells[strColumnsNew[i]].Value.ToString()), null);
  991. }
  992. }
  993. }
  994. }
  995. return t;
  996. }
  997. //调用本地程序打开查看服务器文件
  998. /// <summary>
  999. /// 调用本地程序打开查看服务器文件
  1000. /// </summary>
  1001. /// <param name="pathName"></param>
  1002. public static void ViewCarft_No(string pathName)
  1003. {
  1004. try
  1005. {
  1006. //删除本地文件
  1007. string tmpPath = Environment.CurrentDirectory + "\\Tmp\\";
  1008. DirectoryInfo di = new DirectoryInfo(tmpPath);
  1009. if (di.Exists == false)
  1010. {
  1011. di.Create();
  1012. return;
  1013. }
  1014. foreach (FileInfo fi in di.GetFiles())
  1015. {
  1016. try
  1017. {
  1018. fi.Delete();
  1019. }
  1020. catch { continue; }
  1021. }
  1022. //下载写入本地Tmp目录
  1023. if (pathName == "" || pathName == null) return;
  1024. List<FileBean> list = Core.Mes.Client.Comm.Server.FileHelper.Download(pathName);
  1025. foreach (FileBean bean in list)
  1026. {
  1027. FileStream fs = new FileStream(tmpPath + bean.getFileName(), FileMode.Create);
  1028. fs.Write(bean.getFile(), 0, bean.getFile().Length);
  1029. fs.Flush();
  1030. fs.Close();
  1031. System.Diagnostics.Process MyProcess = new System.Diagnostics.Process();
  1032. MyProcess.StartInfo.FileName = tmpPath + bean.getFileName();
  1033. MyProcess.StartInfo.Verb = "Open";
  1034. MyProcess.StartInfo.CreateNoWindow = true;
  1035. MyProcess.Start();
  1036. return;
  1037. }
  1038. }
  1039. catch { }
  1040. }
  1041. }
  1042. }