FrmComMSCStdDetection.cs 84 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Format;
  3. using Core.Mes.Client.Comm.Server;
  4. using Core.Mes.Client.Comm.Tool;
  5. using Core.StlMes.Client.Qcm.model;
  6. using CoreFS.CA06;
  7. using Infragistics.Win.UltraWinEditors;
  8. using Infragistics.Win.UltraWinGrid;
  9. using System;
  10. using System.Collections;
  11. using System.Collections.Generic;
  12. using System.Data;
  13. using System.Linq;
  14. using System.Windows.Forms;
  15. namespace Core.StlMes.Client.Qcm
  16. {
  17. /// <summary>
  18. /// 探伤要求
  19. /// </summary>
  20. public partial class FrmComMSCStdDetection : FrmBase
  21. {
  22. private bool isPasting = false;
  23. //全局变量 错误信息
  24. private string errMessage = "";
  25. //用于判断是否勾选
  26. //private int isSelect = 0;
  27. private string _dic = "";
  28. private bool _isEx = false;
  29. private string dic = "";
  30. public string Dic
  31. {
  32. get { return dic; }
  33. set { dic = value; }
  34. }
  35. private string msc = "";
  36. public string Msc
  37. {
  38. get { return msc; }
  39. set { msc = value; }
  40. }
  41. private string codeJg = "DefaultValue";
  42. public string CodeJg
  43. {
  44. get { return codeJg; }
  45. set { codeJg = value; }
  46. }
  47. private string stdCode = "";
  48. public string StdCode
  49. {
  50. get { return stdCode; }
  51. set { stdCode = value; }
  52. }
  53. //用于过滤内控适用标准集合
  54. private string stdCodesNk = "";
  55. public string StdCodesNk
  56. {
  57. get { return stdCodesNk; }
  58. set { stdCodesNk = value; }
  59. }
  60. private string stdStylesNk = "";
  61. public string StdStylesNk
  62. {
  63. get { return stdStylesNk; }
  64. set { stdStylesNk = value; }
  65. }
  66. //是否是内控维护界面
  67. private string isNkEdite = "0";
  68. public string IsNkEdite
  69. {
  70. get { return isNkEdite; }
  71. set { isNkEdite = value; }
  72. }
  73. private ArrayList steelCodes = new ArrayList();
  74. public ArrayList SteelCodes
  75. {
  76. get { return steelCodes; }
  77. set { steelCodes = value; }
  78. }
  79. private string produccodeNk = "";
  80. public string ProduccodeNk
  81. {
  82. get { return produccodeNk; }
  83. set { produccodeNk = value; }
  84. }
  85. private string steelcodeNk = "";
  86. public string SteelcodeNk
  87. {
  88. get { return steelcodeNk; }
  89. set { steelcodeNk = value; }
  90. }
  91. private string processCode = "";
  92. public string ProcessCode
  93. {
  94. get { return processCode; }
  95. set { processCode = value; }
  96. }
  97. private string modelCode = "";
  98. public string ModelCode
  99. {
  100. get { return modelCode; }
  101. set { modelCode = value; }
  102. }
  103. private string acceptBid = "";
  104. public string AcceptBid
  105. {
  106. get { return acceptBid; }
  107. set { acceptBid = value; }
  108. }
  109. private UltraComboEditor[] ultras = new UltraComboEditor[11];
  110. public FrmComMSCStdDetection()
  111. {
  112. IsLoadUserView = true;
  113. InitializeComponent();
  114. ExceptionHelper.RegistException();
  115. }
  116. public void PopupLoad(string customInfo, OpeBase ob)
  117. {
  118. this.CustomInfo = customInfo;
  119. this.ob = ob;
  120. FrmComMSCStdDetection_Load(null, null);
  121. }
  122. public void PopupRefresh()
  123. {
  124. UltraGridBand ugb = ultraGrid1.DisplayLayout.Bands[0];
  125. if (CustomInfo == "1")
  126. { //冶金规范码
  127. QcmBaseQuery.NitializeMSC(ultras[0], false, this.ob, msc);
  128. //QcmBaseCommon.InitDrop(ultras[0], "com.steering.pss.qcm.ComBaseQuery.getMsc", "MSC", "MSC", false, this.ob);
  129. ugb.Columns["MSC"].EditorComponent = ultras[0];
  130. ugb.Columns["MSC"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  131. }
  132. }
  133. /// <summary>
  134. /// 初始化下拉框
  135. /// </summary>
  136. private void InitDownList()
  137. {
  138. for (int i = 0; i < ultras.Length; i++)
  139. {
  140. ultras[i] = new UltraComboEditor();
  141. this.Controls.Add(ultras[i]);
  142. ultras[i].Visible = false;
  143. ultras[i].DropDownListWidth = -1;
  144. }
  145. //主表
  146. UltraGridBand ugb = ultraGrid1.DisplayLayout.Bands[0];
  147. //从表
  148. UltraGridBand ugbC = ultraGrid1.DisplayLayout.Bands[1];
  149. if (CustomInfo == "1")
  150. { //冶金规范码
  151. QcmBaseQuery.NitializeMSC(ultras[0], false, this.ob, msc);
  152. //QcmBaseCommon.InitDrop(ultras[0], "com.steering.pss.qcm.ComBaseQuery.getMsc", "MSC", "MSC", false, this.ob);
  153. ugb.Columns["MSC"].EditorComponent = ultras[0];
  154. ugb.Columns["MSC"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  155. }
  156. if (CustomInfo != "1")
  157. { //标准名称
  158. if (CustomInfo == "2")
  159. {
  160. QcmBaseCommon.InitDrop(ultras[1], "com.steering.pss.qcm.ComBaseQuery.geComBaseStdN", "STD_NAME", "STD_CODE", false, this.ob);
  161. InnerChange();
  162. }
  163. else if (CustomInfo == "3")
  164. QcmBaseCommon.InitDrop(ultras[1], "com.steering.pss.qcm.ComBaseQuery.geComBaseStdK", "STD_NAME", "STD_CODE", false, this.ob);
  165. else
  166. QcmBaseCommon.InitDrop(ultras[1], "com.steering.pss.qcm.ComBaseQuery.geComBaseStdS", "STD_NAME", "STD_CODE", false, this.ob);
  167. ugb.Columns["STD_CODE_NK"].EditorComponent = ultras[1];
  168. ugb.Columns["STD_CODE_NK"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  169. }
  170. //探伤位置
  171. QcmBaseCommon.InitDrop(ultras[2], "com.steering.pss.qcm.ComBaseQuery.geComBaseInfo4020", "BASENAME", "BASECODE", false, this.ob);
  172. ugbC.Columns["POSITION_CODE"].EditorComponent = ultras[2];
  173. ugbC.Columns["POSITION_CODE"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  174. //所有工序
  175. QcmBaseCommon.InitDrop(ultras[5], "com.steering.pss.qcm.ComBaseQuery.geComBaseProcessAll", "PROCESS_DESC", "PROCESS_CODE", true, this.ob);
  176. ugb.Columns["PROCESS_CODE"].EditorComponent = ultras[5];
  177. ugb.Columns["PROCESS_CODE"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  178. //检验项
  179. QcmBaseCommon.InitDrop(ultras[6], "com.steering.pss.qcm.ComBaseQuery.getComBasePhyD", "PHY_NAME", "PHY_CODE", true, this.ob);
  180. ugbC.Columns["PHY_CODE"].EditorComponent = ultras[6];
  181. ugbC.Columns["PHY_CODE"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  182. //刻槽位置
  183. QcmBaseCommon.InitDrop(ultras[7], "com.steering.pss.qcm.ComBaseQuery.geComBaseInfo4023", "BASENAME", "BASENAME", false, this.ob);
  184. ugbC.Columns["GROOVE_POS"].EditorComponent = ultras[7];
  185. ugbC.Columns["GROOVE_POS"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  186. //刻槽方向
  187. QcmBaseCommon.InitDrop(ultras[8], "com.steering.pss.qcm.ComBaseQuery.geComBaseInfo4024", "BASENAME", "BASENAME", false, this.ob);
  188. ugbC.Columns["GROOVE_DIR"].EditorComponent = ultras[8];
  189. ugbC.Columns["GROOVE_DIR"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  190. //检验频次
  191. QcmBaseCommon.InitDrop(ultras[9], "com.steering.pss.qcm.ComBaseQuery.geComBaseInfo4011", "BASENAME", "BASECODE", false, this.ob);
  192. ugbC.Columns["DESC_RATE"].EditorComponent = ultras[9];
  193. ugbC.Columns["DESC_RATE"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  194. QcmBaseQuery.NitializeProductBigType(ultras[10], false, ob);
  195. QcmBaseQuery.BindColumn(ultras[10], "PRODUC_HEAD", ugb);
  196. ClsBaseInfo.SetComboItemHeight(ultras[10]);
  197. }
  198. public override void ToolBar_Click(object sender, string ToolbarKey)
  199. {
  200. switch (ToolbarKey)
  201. {
  202. case "Query":
  203. this.DoQuery();
  204. break;
  205. case "Delete":
  206. DoUpdateOrResume(true);
  207. break;
  208. case "Resume":
  209. DoUpdateOrResume(false);
  210. break;
  211. case "Save":
  212. DoSave();
  213. break;
  214. case "Copy":
  215. Copy();
  216. break;
  217. case "Paste":
  218. isPasting = true;
  219. try
  220. {
  221. Paste();
  222. }
  223. finally
  224. {
  225. isPasting = false;
  226. }
  227. break;
  228. case "Refresh":
  229. InitDownList();
  230. break;
  231. case "Group":
  232. DoGroup();
  233. break;
  234. case "Cancel":
  235. CancelGroup();
  236. break;
  237. case "Close":
  238. this.Close();
  239. break;
  240. }
  241. }
  242. /// <summary>
  243. /// 复制
  244. /// </summary>
  245. private void Copy()
  246. {
  247. if (ultraGrid1.ActiveRow == null)
  248. {
  249. MessageUtil.ShowWarning("请选择记录后,再进行操作!");
  250. return;
  251. }
  252. ultraGrid1.UpdateData();
  253. DataTable copyTab = dataTable2.Copy();
  254. DataTable copyTab2 = dataTable1.Copy();
  255. copyTab.Clear();
  256. copyTab2.Clear();
  257. if (ultraGrid1.ActiveRow.HasParent())
  258. {
  259. foreach (UltraGridRow row in ultraGrid1.ActiveRow.ParentRow.ChildBands[0].Rows)
  260. {
  261. if (row.GetValue("CHC") != "True") continue;
  262. DataRow dr = copyTab.NewRow();
  263. CopyRowToRow(((DataRowView)row.ListObject).Row, dr);
  264. copyTab.Rows.Add(dr);
  265. }
  266. }
  267. else
  268. {
  269. foreach (UltraGridRow row in ultraGrid1.ActiveRow.ChildBands[0].Rows)
  270. {
  271. DataRow dr = copyTab.NewRow();
  272. CopyRowToRow(((DataRowView)row.ListObject).Row, dr);
  273. copyTab.Rows.Add(dr);
  274. }
  275. DataRow dr2 = copyTab2.NewRow();
  276. CopyRowToRow(((DataRowView)ultraGrid1.ActiveRow.ListObject).Row, dr2);
  277. copyTab2.Rows.Add(dr2);
  278. }
  279. DataTable[] copyTabs = new DataTable[] { copyTab, copyTab2 };
  280. Clipboard.SetData("Dic", copyTabs);
  281. }
  282. private void CopyRowToRow(DataRow srcRow, DataRow desRow)
  283. {
  284. for (int i = 0; i < srcRow.Table.Columns.Count; i++)
  285. {
  286. string columnName = srcRow.Table.Columns[i].ColumnName;
  287. desRow[columnName] = srcRow[columnName];
  288. }
  289. }
  290. /// <summary>
  291. /// 粘贴
  292. /// </summary>
  293. private void Paste()
  294. {
  295. DataTable[] copyTabs = (DataTable[])Clipboard.GetData("Dic");
  296. if (copyTabs == null)
  297. {
  298. MessageUtil.ShowWarning("没有数据,请复制后再进行操作!");
  299. return;
  300. }
  301. DataTable copyTab = copyTabs[0];
  302. DataTable copyTab2 = copyTabs[1];
  303. if (copyTab == null || copyTab.Rows.Count == 0)
  304. {
  305. MessageUtil.ShowWarning("没有数据,请复制后再进行操作!");
  306. return;
  307. }
  308. dataTable2.BeginInit();
  309. string dic = "";
  310. UltraGridRow rowParent;
  311. if (ultraGrid1.ActiveRow.HasParent())
  312. {
  313. //if (ultraGrid1.ActiveRow.ParentRow.ChildBands[0].Rows.Count > 0)
  314. //{
  315. // MessageUtil.ShowWarning("该记录下存在子记录,不能进行粘贴操作!");
  316. // return;
  317. //}
  318. dic = ultraGrid1.ActiveRow.ParentRow.GetValue("DIC");
  319. rowParent = ultraGrid1.ActiveRow.ParentRow;
  320. }
  321. else
  322. {
  323. //if (ultraGrid1.ActiveRow.ChildBands[0].Rows.Count > 0)
  324. //{
  325. // MessageUtil.ShowWarning("该记录下存在子记录,不能进行粘贴操作!");
  326. // return;
  327. //}
  328. dic = ultraGrid1.GetActiveRowValue("DIC");
  329. rowParent = ultraGrid1.ActiveRow;
  330. }
  331. List<string> notCopyColumns = new List<string>();
  332. notCopyColumns.AddRange("CHC", "CREATE_TIME", "CREATE_NAME", "UPDATE_TIME", "UPDATE_NAME",
  333. "DELETE_TIME", "DELETE_NAME", "VALIDFLAG", "DIC", "MSC", "PSC_DESC", "PSC", "STD_CODE_NK", "STD_NAME_NK",
  334. "STDSTYLE", "STD_NAME", "PRODUCNAME", "STEELNAME", "PROCESS_CODE", "STD_STYLE_DESC",
  335. "PRODUCCODE_NK", "PRODUCNAME_NK", "PROCESS_CODE", "PROCESS_DESC", "STEELCODE_NK", "STEELNAME_NK");
  336. if (copyTab2.Rows.Count > 0)
  337. {
  338. DataRow drParent = ((DataRowView)rowParent.ListObject).Row;
  339. foreach (DataColumn column in dataTable1.Columns)
  340. {
  341. string columnName = column.ColumnName;
  342. if (notCopyColumns.Contains(columnName) == true) continue;
  343. drParent[columnName] = copyTab2.Rows[0][columnName];
  344. }
  345. }
  346. foreach (DataRow row in copyTab.Rows)
  347. {
  348. DataRow tempRow = dataTable2.NewRow();
  349. foreach (DataColumn column in dataTable2.Columns)
  350. {
  351. string columnName = column.ColumnName;
  352. if (notCopyColumns.Contains(columnName) == true) continue;
  353. tempRow[columnName] = row[columnName];
  354. }
  355. tempRow["DIC"] = dic;
  356. dataTable2.Rows.Add(tempRow);
  357. }
  358. dataTable2.EndInit();
  359. if (copyTab.Rows.Count > 0 && ultraGrid1.ActiveRow != null)
  360. {
  361. ultraGrid1.ActiveRow.ExpandAll();
  362. }
  363. ultraGrid1.UpdateData();
  364. }
  365. /// <summary>
  366. /// 根据交付标准、内控标准和Alpha分别隐藏不同的列
  367. /// </summary>
  368. private void HideColumn()
  369. {
  370. if (CustomInfo == "1")//交付标准
  371. {
  372. ultraGrid1.DisplayLayout.Bands[0].Columns["STD_CODE_NK"].Hidden = true;
  373. ultraGrid1.DisplayLayout.Bands[0].Columns["PROCESS_DESC"].Hidden = true;
  374. this.ultraGrid1.DisplayLayout.Bands[0].Columns["STEELNAME_NK"].Hidden = true;
  375. this.ultraGrid1.DisplayLayout.Bands[0].Columns["MODEL_DESC_NK"].Hidden = true;
  376. this.ultraGrid1.DisplayLayout.Bands[0].Columns["PRODUCCODE_NK"].Hidden = true;
  377. this.ultraGrid1.DisplayLayout.Bands[0].Columns["PRODUCNAME_NK"].Hidden = true;
  378. this.ultraGrid1.DisplayLayout.Bands[0].Columns["STD_NAME_S_NK"].Hidden = true;
  379. this.ultraGrid1.DisplayLayout.Bands[0].Columns["STD_STYLE_DESC_S_NK"].Hidden = true;
  380. }
  381. if (CustomInfo == "2" || CustomInfo == "4")//内控
  382. {
  383. ultraGrid1.DisplayLayout.Bands[0].Columns["MSC"].Hidden = true;
  384. ultraGrid1.DisplayLayout.Bands[0].Columns["PSC_DESC"].Hidden = true;
  385. ultraGrid1.DisplayLayout.Bands[0].Columns["STD_NAME"].Hidden = true;
  386. ultraGrid1.DisplayLayout.Bands[0].Columns["STEELNAME"].Hidden = true;
  387. ultraGrid1.DisplayLayout.Bands[0].Columns["STD_STYLE_DESC"].Hidden = true;
  388. ultraGrid1.DisplayLayout.Bands[0].Columns["PRODUCNAME"].Hidden = true;
  389. if (CustomInfo == "2")
  390. {
  391. ultraGrid1.DisplayLayout.Bands[0].Columns["STD_CODE_NK"].Header.Caption = "内控管理编号";
  392. }
  393. ultraCheckMSC.Visible = false;
  394. ultraTextMSC.Visible = false;
  395. }
  396. if (CustomInfo == "3")//试验标准
  397. {
  398. ultraGrid1.DisplayLayout.Bands[0].Columns["PROCESS_CODE"].Hidden = true;
  399. ultraGrid1.DisplayLayout.Bands[0].Columns["MSC"].Hidden = true;
  400. ultraGrid1.DisplayLayout.Bands[0].Columns["PSC_DESC"].Hidden = true;
  401. ultraGrid1.DisplayLayout.Bands[0].Columns["STD_NAME"].Hidden = true;
  402. ultraGrid1.DisplayLayout.Bands[0].Columns["STEELNAME"].Hidden = true;
  403. ultraGrid1.DisplayLayout.Bands[0].Columns["STD_STYLE_DESC"].Hidden = true;
  404. ultraGrid1.DisplayLayout.Bands[0].Columns["PRODUCNAME"].Hidden = true;
  405. ultraCheckMSC.Visible = false;
  406. ultraTextMSC.Visible = false;
  407. ultraGrid1.DisplayLayout.Bands[0].Columns["PROCESS_DESC"].Hidden = true;
  408. this.ultraGrid1.DisplayLayout.Bands[0].Columns["STEELNAME_NK"].Hidden = true;
  409. this.ultraGrid1.DisplayLayout.Bands[0].Columns["MODEL_DESC_NK"].Hidden = true;
  410. this.ultraGrid1.DisplayLayout.Bands[0].Columns["PRODUCCODE_NK"].Hidden = true;
  411. this.ultraGrid1.DisplayLayout.Bands[0].Columns["PRODUCNAME_NK"].Hidden = true;
  412. this.ultraGrid1.DisplayLayout.Bands[0].Columns["STD_NAME_S_NK"].Hidden = true;
  413. this.ultraGrid1.DisplayLayout.Bands[0].Columns["STD_STYLE_DESC_S_NK"].Hidden = true;
  414. }
  415. }
  416. /// <summary>
  417. /// 查询条件
  418. /// </summary>
  419. /// <returns></returns>
  420. private ArrayList QueryCondition()
  421. {
  422. ArrayList conditionList = new ArrayList();
  423. //标准名称
  424. string stdName = "";
  425. if (ultraCheckStd.Checked)
  426. stdName = ultraTextStd.Text.Trim();
  427. conditionList.Add(stdName);
  428. //产品规范描述
  429. string pscDesc = "";
  430. if (CustomInfo == "1")
  431. {
  432. if (ultraCheckMSC.Checked)
  433. pscDesc = ultraTextMSC.Text.Trim();
  434. }
  435. conditionList.Add(pscDesc);
  436. //包含无效
  437. string valid = "1";
  438. if (ultraCheckValid.Checked)
  439. valid = "0";
  440. conditionList.Add(valid);
  441. conditionList.Add(stdCode);
  442. return conditionList;
  443. }
  444. /// <summary>
  445. /// 查询
  446. /// </summary>
  447. private void DoQuery()
  448. {
  449. ArrayList condition = QueryCondition();
  450. //主表查询
  451. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreDetection.getCoreDetection",
  452. new Object[] { condition, CustomInfo, dic, msc, codeJg, produccodeNk,
  453. steelcodeNk, stdCodesNk, stdStylesNk, isNkEdite, processCode, modelCode}, this.ob);
  454. dataTable2.Clear();
  455. GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
  456. //从表查询
  457. //包含无效
  458. string valid = "1";
  459. if (ultraCheckValid.Checked)
  460. valid = "0";
  461. DataTable dt1 = ServerHelper.GetData("com.steering.pss.qcm.CoreDetection.getCoreDetectionC",
  462. new Object[] { CustomInfo, valid, stdCode, msc, codeJg, produccodeNk, steelcodeNk, processCode, modelCode }, this.ob);
  463. dt1 = QcmBaseCommon.FilterTable(dt, dt1, "DIC");
  464. GridHelper.CopyDataToDatatable(ref dt1, ref this.dataTable2, true);
  465. UltraGridColumn[] col = new UltraGridColumn[] { this.ultraGrid1.DisplayLayout.Bands[0].Columns["MEMO"], this.ultraGrid1.DisplayLayout.Bands[0].Columns["MSC"],
  466. this.ultraGrid1.DisplayLayout.Bands[0].Columns["PSC_DESC"],this.ultraGrid1.DisplayLayout.Bands[0].Columns["STD_CODE_NK"],
  467. this.ultraGrid1.DisplayLayout.Bands[0].Columns["MODEL_DESC"]};
  468. //GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid1, col);
  469. QcmBaseCommon.SetGridColor(ultraGrid1, "VALIDFLAG", "无效");
  470. QcmBaseCommon.SetUltraGridNoEdit(ultraGrid1);
  471. //isSelect = 0;
  472. //展开或者定位
  473. UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "DIC" }, new string[] { _dic });
  474. if (rows1.Length > 0)
  475. {
  476. rows1[0].Activate();
  477. if (_isEx)
  478. rows1[0].ExpandAll();
  479. }
  480. _isEx = false;
  481. _dic = "";
  482. foreach (UltraGridRow ugr in ultraGrid1.Rows)
  483. {
  484. ugr.Cells["CHKNK"].Value = "选择";
  485. }
  486. dataTable1.AcceptChanges();
  487. dataTable2.AcceptChanges();
  488. //清空复制数据
  489. //_copyedRows.Clear();
  490. }
  491. public void QueryPurchaseAgreement(string stdCodeNk)
  492. {
  493. dataTable2.Clear();
  494. dataTable1.Clear();
  495. DataTable dtP = ServerHelper.GetData("com.steering.pss.qcm.CoreDetection.getPurchaseAgreementDic",
  496. new object[] { stdCodeNk }, ob);
  497. GridHelper.CopyDataToDatatable(ref dtP, ref this.dataTable1, true);
  498. DataTable dtC = ServerHelper.GetData("com.steering.pss.qcm.CoreDetection.getPurchaseAgreementDetec",
  499. new object[] { stdCodeNk }, ob);
  500. GridHelper.CopyDataToDatatable(ref dtC, ref this.dataTable2, true);
  501. QcmBaseCommon.SetGridColor(ultraGrid1, "VALIDFLAG", "无效");
  502. QcmBaseCommon.SetUltraGridNoEdit(ultraGrid1);
  503. }
  504. private int GetGridSelectCount()
  505. {
  506. foreach (UltraGridRow row in ultraGrid1.Rows)
  507. {
  508. if (row.Cells["CHC"].Value.ToString() == "True")
  509. {
  510. return 1;
  511. }
  512. UltraGridRow[] rows = GridHelper.GetRowsWithKey(row.ChildBands[0],
  513. new string[] { "CHC" }, new string[] { "True" });
  514. if (rows.Length > 0)
  515. {
  516. return 1;
  517. }
  518. }
  519. return 0;
  520. }
  521. private DataRow GetComBaseStdRowByPk(string stdCode)
  522. {
  523. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComStandard.getComBaseStdByPk",
  524. new object[] { stdCode }, ob);
  525. return dt.Rows[0];
  526. }
  527. /// <summary>
  528. /// 保存
  529. /// </summary>
  530. private void DoSave()
  531. {
  532. ultraGrid1.UpdateData();
  533. DataRow comBaseStdRow = null;
  534. string style = "G";
  535. if (CustomInfo == "2") //内控的编码特殊处理
  536. {
  537. comBaseStdRow = GetComBaseStdRowByPk(stdCode);
  538. if (comBaseStdRow["ACCEPT_BID"].ToString() == "1")
  539. {
  540. style = "N";
  541. }
  542. else
  543. {
  544. style = "L";
  545. }
  546. }
  547. if (CustomInfo == "3")
  548. style = "K";
  549. if (CustomInfo == "4")
  550. style = "S";
  551. if (GetGridSelectCount() == 0)
  552. {
  553. MessageBox.Show("请选择记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  554. return;
  555. }
  556. if (CustomInfo == "2")
  557. {
  558. if (comBaseStdRow["ACCEPT_BID"].ToString() == "1" && comBaseStdRow["UNIT_CODE"].ToString() != UserInfo.GetDeptid()
  559. && UserInfo.GetUserID() != "admin" && UserInfo.GetUserID() != "longjinhua")
  560. {
  561. MessageUtil.ShowWarning("该记录只有[" + comBaseStdRow["UNIT_DESC"].ToString() + "]的成员才能操作!");
  562. return;
  563. }
  564. }
  565. ArrayList baseList = new ArrayList();
  566. ArrayList childList = new ArrayList();
  567. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  568. {
  569. UltraGridRow ugr = ultraGrid1.Rows[i];
  570. DataRow rowDic = null;
  571. //主表行
  572. if (Convert.ToBoolean(ugr.Cells["CHC"].Value))
  573. {
  574. if (ugr.GetValue("VALIDFLAG") != "")
  575. {
  576. rowDic = GetMscDicByDic(ugr.GetValue("DIC"));
  577. }
  578. if (comBaseStdRow != null && comBaseStdRow["ACCEPT_BID"].ToString() == "0" && rowDic != null)
  579. {
  580. string[] units = ClsBaseInfo.GetUnitByUserName(rowDic["CREATE_NAME"].ToString(), ob, "002001007", "002001001", "002023005");
  581. if (units[0] != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin")
  582. {
  583. MessageUtil.ShowWarning("该记录只有[" + units[1] + "]才能操作!");
  584. ugr.Activate();
  585. return;
  586. }
  587. }
  588. DectionObject comM = GetBaseData(ugr, rowDic);
  589. if (comM == null)
  590. {
  591. MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  592. return;
  593. }
  594. baseList.Add(JSONFormat.Format(comM));
  595. _dic = comM.Dic;
  596. }
  597. //从表行
  598. if (ugr.HasChild())
  599. {
  600. if (ugr.Cells["VALIDFLAG"].Value.ToString().Equals("") && !Convert.ToBoolean(ugr.Cells["CHC"].Value))
  601. {
  602. MessageBox.Show("请选择主记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  603. return;
  604. }
  605. for (int j = 0; j < ugr.ChildBands[0].Rows.Count; j++)
  606. {
  607. UltraGridRow ugrChild = ugr.ChildBands[0].Rows[j];
  608. if (Convert.ToBoolean(ugrChild.Cells["CHC"].Value))
  609. {
  610. if (ugr.GetValue("VALIDFLAG") != "")
  611. {
  612. rowDic = GetMscDicByDic(ugr.GetValue("DIC"));
  613. }
  614. if (comBaseStdRow != null && comBaseStdRow["ACCEPT_BID"].ToString() == "0" && rowDic != null)
  615. {
  616. string[] units = ClsBaseInfo.GetUnitByUserName(rowDic["CREATE_NAME"].ToString(), ob, "002001007", "002001001", "002023005");
  617. if (units[0] != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin")
  618. {
  619. MessageUtil.ShowWarning("该记录只有[" + units[1] + "]才能操作!");
  620. ugrChild.Activate();
  621. return;
  622. }
  623. }
  624. DectionCObject comMC = GetChildData(ugrChild, rowDic);
  625. if (comMC == null)
  626. {
  627. MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  628. return;
  629. }
  630. childList.Add(JSONFormat.Format(comMC));
  631. _dic = comMC.Dic;
  632. _isEx = true;
  633. }
  634. }
  635. }
  636. }
  637. if (MessageBox.Show("是否保存选择记录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  638. {
  639. return;
  640. }
  641. if (baseList.Count > 0 || childList.Count > 0)
  642. {
  643. int count = ServerHelper.SetData("com.steering.pss.qcm.CoreDetection.saveCoreDetection",
  644. new Object[] { baseList, childList, style }, this.ob);
  645. if (count > 0)
  646. {
  647. MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  648. DoQuery();
  649. }
  650. }
  651. }
  652. private DataTable GetMscTabByMsc(string msc)
  653. {
  654. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreFrmProPSCMSC2.getComMscByMsc",
  655. new object[] { msc }, ob);
  656. return dt;
  657. }
  658. private string GetMscByDic(string dic)
  659. {
  660. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreDetection.getComDicByDic",
  661. new object[] { dic }, ob);
  662. if (dt.Rows.Count > 0)
  663. {
  664. return dt.Rows[0]["MSC"].ToString();
  665. }
  666. return "";
  667. }
  668. /// <summary>
  669. /// 通过主键查询探伤主表
  670. /// </summary>
  671. /// <returns></returns>
  672. private DataRow GetMscDicByDic(string dic)
  673. {
  674. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreDetection.getComDicByDic",
  675. new object[] { dic }, ob);
  676. if (dt.Rows.Count == 0)
  677. {
  678. return null;
  679. }
  680. else
  681. {
  682. return dt.Rows[0];
  683. }
  684. }
  685. private bool CheckAuthority(UltraGridRow row)
  686. {
  687. if (CustomInfo == "1")
  688. {
  689. string mscOld;
  690. if (row.GetValue("VALIDFLAG") != "")
  691. {
  692. mscOld = GetMscByDic(row.GetValue("DIC"));
  693. }
  694. else
  695. {
  696. mscOld = row.HasParent() ? row.ParentRow.GetValue("MSC") : row.GetValue("MSC");
  697. }
  698. DataTable dtMsc = GetMscTabByMsc(mscOld);
  699. //if (dtMsc.Rows[0]["UNIT_CODE"].ToString() != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin")
  700. //{
  701. // errMessage = "该条记录对应的冶金规范是[" + dtMsc.Rows[0]["UNIT_DESC"].ToString() + "]科室维护的,您没有权限!";
  702. // row.Activate();
  703. // return false;
  704. //}
  705. }
  706. return true;
  707. }
  708. /// <summary>
  709. /// 主表操作项
  710. /// </summary>
  711. /// <returns></returns>
  712. private DectionObject GetBaseData(UltraGridRow ugr, DataRow rowDic)
  713. {
  714. DectionObject comM = new DectionObject();
  715. string dic = ugr.Cells["DIC"].Value.ToString().Trim();
  716. string psc = ugr.Cells["PSC"].Value.ToString().Trim();
  717. string msc = ugr.Cells["MSC"].Value.ToString().Trim();
  718. if (psc.Equals("") && CustomInfo == "1")
  719. {
  720. errMessage = "请选择冶金规范码";
  721. return null;
  722. }
  723. if (CheckAuthority(ugr) == false) return null;
  724. string stdStyle = ugr.Cells["STDSTYLE"].Value.ToString().Trim();
  725. if (stdStyle.Equals("内控"))
  726. stdStyle = "N";
  727. else if (stdStyle.Equals("订货标准"))
  728. stdStyle = "G";
  729. else if (stdStyle.Equals("协议标准"))
  730. stdStyle = "X";
  731. else if (stdStyle.Equals("Alpha"))
  732. stdStyle = "K";
  733. else if (stdStyle.Equals("试验标准"))
  734. stdStyle = "S";
  735. else if (stdStyle.Equals("成分偏差标准"))
  736. stdStyle = "P";
  737. else
  738. stdStyle = "";
  739. string process_code = ugr.Cells["PROCESS_CODE"].Value.ToString().Trim();
  740. string process_desc = ugr.Cells["PROCESS_DESC"].Value.ToString().Trim();
  741. string std_code_nk = ugr.Cells["STD_CODE_NK"].Value.ToString().Trim();
  742. string std_name_nk = ugr.Cells["STD_NAME_NK"].Value.ToString().Trim();
  743. if (CustomInfo != "1" && std_name_nk.Equals(""))
  744. {
  745. errMessage = "请选择内控标准";
  746. return null;
  747. }
  748. string model_code = ugr.Cells["MODEL_CODE"].Value.ToString().Trim();
  749. string model_desc = ugr.Cells["MODEL_DESC"].Value.ToString().Trim();
  750. string create_name = UserInfo.GetUserName();
  751. string create_time = ugr.Cells["CREATE_TIME"].Value.ToString().Trim();
  752. string update_name = UserInfo.GetUserName();
  753. string update_time = ugr.Cells["UPDATE_TIME"].Value.ToString().Trim();
  754. string delete_name = UserInfo.GetUserName();
  755. string delete_time = ugr.Cells["DELETE_TIME"].Value.ToString().Trim();
  756. string validflag = ugr.Cells["VALIDFLAG"].Value.ToString().Trim();
  757. if (rowDic != null && (rowDic["VALIDFLAG"].ToString() == "2" || rowDic["VALIDFLAG"].ToString() == "3"))
  758. {
  759. errMessage = "提交审核或已审核记录不能保存";
  760. return null;
  761. }
  762. //if (CustomInfo == "2" && ugr.GetValue("PRODUCCODE_NK") == "")
  763. //{
  764. // errMessage = "请选择品名!";
  765. // return null;
  766. //}
  767. string memo = ugr.Cells["MEMO"].Value.ToString().Trim();
  768. comM.Dic = dic;
  769. comM.Psc = psc;
  770. comM.Msc = msc;
  771. comM.StdStyle = stdStyle;
  772. comM.ProcessCode = process_code;
  773. comM.ProcessDesc = process_desc;
  774. comM.StdCodeNk = std_code_nk;
  775. comM.StdNameNk = std_name_nk;
  776. comM.ModelCode = model_code;
  777. comM.ModelDesc = model_desc;
  778. comM.CreateName = create_name;
  779. comM.CreateTime = create_time;
  780. comM.UpdateName = update_name;
  781. comM.UpdateTime = update_time;
  782. comM.DeleteName = delete_name;
  783. comM.DeleteTime = delete_time;
  784. comM.Memo = memo;
  785. comM.ProducHead = ugr.GetValue("PRODUC_HEAD");
  786. comM.CodeJg = codeJg == "DefaultValue" ? "" : codeJg;
  787. comM.Validflag = validflag;
  788. comM.SteelcodeNk = ugr.GetValue("STEELCODE_NK");
  789. comM.SteelnameNk = ugr.GetValue("STEELNAME_NK");
  790. comM.ModelCodeNk = ugr.GetValue("MODEL_CODE_NK");
  791. comM.ModelDescNk = ugr.GetValue("MODEL_DESC_NK");
  792. comM.ProduccodeNk = ugr.GetValue("PRODUCCODE_NK");
  793. comM.ProducnameNk = ugr.GetValue("PRODUCNAME_NK");
  794. comM.StdCodeSNk = ugr.GetValue("STD_CODE_S_NK");
  795. comM.StdNameSNk = ugr.GetValue("STD_NAME_S_NK");
  796. comM.StdStyleSNk = ugr.GetValue("STD_STYLE_S_NK");
  797. comM.StdStyleDescSNk = ugr.GetValue("STD_STYLE_DESC_S_NK");
  798. return comM;
  799. }
  800. /// <summary>
  801. /// 从表操作项
  802. /// </summary>
  803. /// <param name="ugr"></param>
  804. /// <returns></returns>
  805. private DectionCObject GetChildData(UltraGridRow ugr, DataRow rowDic)
  806. {
  807. if (CheckAuthority(ugr) == false) return null;
  808. if (rowDic != null && (rowDic["VALIDFLAG"].ToString() == "2" || rowDic["VALIDFLAG"].ToString() == "2"))
  809. {
  810. errMessage = "主记录为提交审核或已审核状态时,无法修改";
  811. return null;
  812. }
  813. string dic = ugr.Cells["DIC"].Value.ToString().Trim();
  814. string xh = ugr.Cells["XH"].Value.ToString().Trim();
  815. string phy_code = ugr.Cells["PHY_CODE"].Value.ToString().Trim();
  816. string phy_name = ugr.Cells["PHY_CODE"].Text;
  817. string rate = ugr.Cells["RATE"].Value.ToString().Trim();
  818. string rate_desc = ugr.Cells["DESC_RATE"].Text.Trim();
  819. string rateval = ugr.Cells["DESC_VAL"].Value.ToString().Trim();
  820. string position_code = ugr.Cells["POSITION_CODE"].Value.ToString().Trim();
  821. string position_desc = ugr.Cells["POSITION_CODE"].Text;
  822. string std_desc = ugr.Cells["STD_CODE"].Value.ToString().Trim();
  823. string lv_code = ugr.Cells["LV_CODE"].Value.ToString().Trim();
  824. string lv_desc = ugr.Cells["LV_DESC"].Value.ToString().Trim();
  825. string coverage = ugr.Cells["COVERAGE"].Value.ToString();
  826. string groove_pos = ugr.Cells["GROOVE_POS"].Value.ToString().Trim();
  827. string groove_dir = ugr.Cells["GROOVE_DIR"].Value.ToString().Trim();
  828. string create_name = UserInfo.GetUserName();
  829. string create_time = ugr.Cells["CREATE_TIME"].Value.ToString().Trim();
  830. string update_name = UserInfo.GetUserName();
  831. string update_time = ugr.Cells["UPDATE_TIME"].Value.ToString().Trim();
  832. string delete_name = UserInfo.GetUserName();
  833. string delete_time = ugr.Cells["DELETE_TIME"].Value.ToString().Trim();
  834. string validflag = ugr.Cells["VALIDFLAG"].Value.ToString().Trim();
  835. string minD = ugr.GetValue("MIN_D").Trim();
  836. string maxD = ugr.GetValue("MAX_D").Trim();
  837. string minH = ugr.GetValue("MIN_H").Trim();
  838. string maxH = ugr.GetValue("MAX_H").Trim();
  839. string memo = ugr.Cells["MEMO"].Text.Trim();
  840. if (phy_name.Equals(""))
  841. {
  842. errMessage = "请选择材质检验项";
  843. return null;
  844. }
  845. if (rate_desc == "")
  846. {
  847. errMessage = "请选择检验频次!";
  848. return null;
  849. }
  850. else
  851. {
  852. if (rate_desc == "按比例")
  853. {
  854. if (rateval == "")
  855. {
  856. errMessage = "请输入频率值!";
  857. return null;
  858. }
  859. if (!StringUtil.IsNumber(rateval))
  860. {
  861. errMessage = "频率值:请输入数字!";
  862. return null;
  863. }
  864. if (Convert.ToDouble(rateval) <= 0 || Convert.ToDouble(rateval) > 100)
  865. {
  866. errMessage = "频率值:请输入大于0小于等于100的数字";
  867. return null;
  868. }
  869. }
  870. }
  871. if (position_desc.Equals(""))
  872. {
  873. errMessage = "请选择探伤位置";
  874. return null;
  875. }
  876. if (std_desc.Equals(""))
  877. {
  878. errMessage = "请选择探伤参考标准";
  879. return null;
  880. }
  881. if (lv_desc.Equals(""))
  882. {
  883. errMessage = "请选择探伤级别";
  884. return null;
  885. }
  886. if (coverage != "" && (!StringUtil.IsNumber(coverage) || Convert.ToDouble(coverage) > 150 || Convert.ToDouble(coverage) < 0))
  887. {
  888. errMessage = "请输入探伤覆盖率:0~150";
  889. return null;
  890. }
  891. if (!coverage.Equals("") && coverage.StartsWith("."))
  892. coverage = "0" + coverage;
  893. if (groove_pos.Equals(""))
  894. {
  895. errMessage = "请选择刻槽位置";
  896. return null;
  897. }
  898. if (minD != "" || maxD != "")
  899. {
  900. if (minD == "")
  901. {
  902. errMessage = "请输入适用规格-外径下限!";
  903. ugr.SetCellActive("MIN_D");
  904. return null;
  905. }
  906. else if (minD.TryParseDouble() == false)
  907. {
  908. errMessage = "适用规格-外径下限:请输入数字";
  909. ugr.SetCellActive("MIN_D");
  910. return null;
  911. }
  912. if (maxD == "")
  913. {
  914. errMessage = "请输入适用规格-外径上限!";
  915. ugr.SetCellActive("MAX_D");
  916. return null;
  917. }
  918. else if (maxD.TryParseDouble() == false)
  919. {
  920. errMessage = "适用规格-外径上限:请输入数字";
  921. ugr.SetCellActive("MAX_D");
  922. return null;
  923. }
  924. }
  925. if (minH != "" || maxH != "")
  926. {
  927. if (minH == "")
  928. {
  929. errMessage = "请输入适用规格-壁厚下限!";
  930. ugr.SetCellActive("MIN_H");
  931. return null;
  932. }
  933. else if (minH.TryParseDouble() == false)
  934. {
  935. errMessage = "适用规格-壁厚下限:请输入数字";
  936. ugr.SetCellActive("MIN_H");
  937. return null;
  938. }
  939. if (maxH == "")
  940. {
  941. errMessage = "请输入适用规格-壁厚上限!";
  942. ugr.SetCellActive("MAX_H");
  943. return null;
  944. }
  945. else if (maxH.TryParseDouble() == false)
  946. {
  947. errMessage = "适用规格-壁厚上限:请输入数字";
  948. ugr.SetCellActive("MAX_H");
  949. return null;
  950. }
  951. }
  952. DectionCObject comMC = new DectionCObject();
  953. comMC.Dic = dic;
  954. comMC.Xh = xh;
  955. comMC.PhyCode = phy_code;
  956. comMC.PhyName = phy_name;
  957. comMC.PositionCode = position_code;
  958. comMC.PositionDesc = position_desc;
  959. comMC.StdDesc = std_desc;
  960. comMC.LvCode = lv_code;
  961. comMC.LvDesc = lv_desc;
  962. comMC.Coverage = coverage;
  963. comMC.GroovePos = groove_pos;
  964. comMC.GrooveDir = groove_dir;
  965. comMC.CreateName = create_name;
  966. comMC.CreateTime = create_time;
  967. comMC.UpdateName = update_name;
  968. comMC.DeleteName = delete_name;
  969. comMC.UpdateTime = update_time;
  970. comMC.DeleteTime = delete_time;
  971. comMC.Validflag = validflag;
  972. comMC.Memo = memo;
  973. comMC.Rate = rate;
  974. comMC.Ratedesc = rate_desc;
  975. comMC.Rateval = rateval;
  976. comMC.MinD = minD;
  977. comMC.MaxD = maxD;
  978. comMC.MinH = minH;
  979. comMC.MaxH = maxH;
  980. comMC.GroupSeq = ugr.GetValue("GROUP_SEQ");
  981. return comMC;
  982. }
  983. /// <summary>
  984. /// 删除或者恢复
  985. /// </summary>
  986. private void DoUpdateOrResume(Boolean flag)
  987. {
  988. ultraGrid1.UpdateData();
  989. if (GetGridSelectCount() == 0)
  990. {
  991. MessageBox.Show("请选择记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  992. return;
  993. }
  994. DataRow comBaseStdRow = null;
  995. if (CustomInfo == "2")
  996. {
  997. comBaseStdRow = GetComBaseStdRowByPk(stdCode);
  998. if (comBaseStdRow["ACCEPT_BID"].ToString() == "1" && comBaseStdRow["UNIT_CODE"].ToString() != UserInfo.GetDeptid()
  999. && UserInfo.GetUserID() != "admin")
  1000. {
  1001. MessageUtil.ShowWarning("该记录只有[" + comBaseStdRow["UNIT_DESC"].ToString() + "]的成员才能" + (flag ? "作废" : "恢复") + "!");
  1002. return;
  1003. }
  1004. }
  1005. ultraGrid1.UpdateData();
  1006. ArrayList baseList = new ArrayList();
  1007. ArrayList childList = new ArrayList();
  1008. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  1009. {
  1010. UltraGridRow ugr = ultraGrid1.Rows[i];
  1011. if (Convert.ToBoolean(ugr.Cells["CHC"].Value))
  1012. {
  1013. DataRow rowDic = null;
  1014. if (ugr.GetValue("VALIDFLAG") != "")
  1015. {
  1016. rowDic = GetMscDicByDic(ugr.GetValue("DIC"));
  1017. }
  1018. if (comBaseStdRow != null && comBaseStdRow["ACCEPT_BID"].ToString() == "0" && rowDic != null)
  1019. {
  1020. string[] units = ClsBaseInfo.GetUnitByUserName(rowDic["CREATE_NAME"].ToString(), ob, "002001007", "002001001", "002023005");
  1021. if (units[0] != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin")
  1022. {
  1023. MessageUtil.ShowWarning("该记录只有[" + units[1] + "]才能操作!");
  1024. ugr.Activate();
  1025. return;
  1026. }
  1027. }
  1028. if (CheckAuthority(ugr) == false)
  1029. {
  1030. MessageUtil.ShowWarning(errMessage);
  1031. return;
  1032. }
  1033. DectionObject comM = new DectionObject();
  1034. comM.DeleteName = UserInfo.GetUserName();
  1035. comM.Dic = ugr.Cells["DIC"].Value.ToString();
  1036. if (ugr.Cells["VALIDFLAG"].Value.Equals("无效") && flag)
  1037. {
  1038. MessageBox.Show("无效记录不能作废", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1039. return;
  1040. }
  1041. if (flag && (ugr.Cells["VALIDFLAG"].Value.Equals("提交审核") || ugr.Cells["VALIDFLAG"].Value.Equals("已审核")))
  1042. {
  1043. MessageBox.Show("提交审核或已审核记录不能作废", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1044. return;
  1045. }
  1046. if (ugr.Cells["VALIDFLAG"].Value.Equals("有效") && (!flag))
  1047. {
  1048. MessageBox.Show("有效记录不能恢复", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1049. return;
  1050. }
  1051. if (ugr.HasChild())
  1052. {
  1053. if (MessageBox.Show("对应子记录将全部作废!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  1054. {
  1055. return;
  1056. }
  1057. foreach (UltraGridRow ugrc in ugr.ChildBands[0].Rows)
  1058. {
  1059. //子记录全部删除
  1060. DectionCObject comMC = new DectionCObject();
  1061. comMC.DeleteName = UserInfo.GetUserName();
  1062. comMC.Dic = ugrc.Cells["DIC"].Value.ToString();
  1063. comMC.Xh = ugrc.Cells["XH"].Value.ToString();
  1064. childList.Add(JSONFormat.Format(comMC));
  1065. }
  1066. }
  1067. baseList.Add(JSONFormat.Format(comM));
  1068. }
  1069. if (ugr.HasChild())
  1070. {
  1071. for (int j = 0; j < ugr.ChildBands[0].Rows.Count; j++)
  1072. {
  1073. UltraGridRow ugrc = ugr.ChildBands[0].Rows[j];
  1074. if (Convert.ToBoolean(ugrc.Cells["CHC"].Value))
  1075. {
  1076. DataRow rowDic = null;
  1077. if (ugr.GetValue("VALIDFLAG") != "")
  1078. {
  1079. rowDic = GetMscDicByDic(ugr.GetValue("DIC"));
  1080. }
  1081. if (comBaseStdRow != null && comBaseStdRow["ACCEPT_BID"].ToString() == "0" && rowDic != null)
  1082. {
  1083. string[] units = ClsBaseInfo.GetUnitByUserName(rowDic["CREATE_NAME"].ToString(), ob, "002001007", "002001001", "002023005");
  1084. if (units[0] != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin")
  1085. {
  1086. MessageUtil.ShowWarning("该记录只有[" + units[1] + "]才能操作!");
  1087. ugrc.Activate();
  1088. return;
  1089. }
  1090. }
  1091. if (CheckAuthority(ugrc) == false)
  1092. {
  1093. MessageUtil.ShowWarning(errMessage);
  1094. return;
  1095. }
  1096. if (!flag && ugrc.ParentRow.Cells["VALIDFLAG"].Value.Equals("无效") && !Convert.ToBoolean(ugrc.ParentRow.Cells["CHC"].Value))
  1097. {
  1098. MessageBox.Show("请选择主记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1099. return;
  1100. }
  1101. if (ugrc.ParentRow.Cells["VALIDFLAG"].Value.ToString() != "录入状态"
  1102. && ugrc.ParentRow.Cells["VALIDFLAG"].Value.ToString() != "无效"
  1103. && ugr.Cells["VALIDFLAG"].Value.ToString() != "")
  1104. {
  1105. MessageUtil.ShowWarning("主记录为提交审核或已审核状态时,无法修改");
  1106. return;
  1107. }
  1108. DectionCObject comMC = new DectionCObject();
  1109. comMC.DeleteName = UserInfo.GetUserName();
  1110. comMC.Dic = ugrc.Cells["DIC"].Value.ToString();
  1111. comMC.Xh = ugrc.Cells["XH"].Value.ToString();
  1112. if (ugrc.Cells["VALIDFLAG"].Value.Equals("无效") && flag)
  1113. {
  1114. MessageBox.Show("无效记录不能作废", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1115. return;
  1116. }
  1117. if (ugrc.Cells["VALIDFLAG"].Value.Equals("有效") && !flag)
  1118. {
  1119. MessageBox.Show("有效记录不能恢复", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1120. return;
  1121. }
  1122. childList.Add(JSONFormat.Format(comMC));
  1123. }
  1124. }
  1125. }
  1126. }
  1127. if (flag)
  1128. {
  1129. if (MessageBox.Show("作废选中记录,您是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  1130. {
  1131. return;
  1132. }
  1133. }
  1134. else
  1135. {
  1136. if (MessageBox.Show("恢复选中记录,您是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  1137. {
  1138. return;
  1139. }
  1140. }
  1141. if (baseList.Count > 0 || childList.Count > 0)
  1142. {
  1143. int count = ServerHelper.SetData("com.steering.pss.qcm.CoreDetection.deleteOrResume", new Object[] { baseList, childList, flag }, this.ob);
  1144. if (count > 0)
  1145. {
  1146. DoQuery();
  1147. if (flag)
  1148. MessageBox.Show("作废成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1149. else
  1150. MessageBox.Show("恢复成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1151. }
  1152. }
  1153. }
  1154. private void FrmComMSCStdDetection_Load(object sender, EventArgs e)
  1155. {
  1156. HideColumn();
  1157. InitDownList();
  1158. ultraTextStd.Enabled = false;
  1159. ultraTextMSC.Enabled = false;
  1160. }
  1161. /// <summary>
  1162. /// 新增一行
  1163. /// </summary>
  1164. /// <param name="sender"></param>
  1165. /// <param name="e"></param>
  1166. private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e)
  1167. {
  1168. UltraGridRow ugr = ultraGrid1.DisplayLayout.ActiveRow;
  1169. string style = "G";
  1170. if (CustomInfo == "2")
  1171. style = "N";
  1172. if (CustomInfo == "3")
  1173. style = "K";
  1174. if (CustomInfo == "4")
  1175. style = "S";
  1176. if (!ugr.HasParent()) //主表自动填充主键(成分索引号)
  1177. {
  1178. string dic = "";
  1179. int temp = 0;
  1180. for (int i = 0; i < ultraGrid1.Rows.Count - 1; i++)
  1181. {
  1182. string str = ultraGrid1.Rows[i].Cells["DIC"].Value.ToString().Substring(4, 6);
  1183. if (Convert.ToInt32(str) > temp)
  1184. temp = Convert.ToInt32(str);
  1185. }
  1186. dic = "DIC" + style + string.Format("{0:000000}", temp + 1);
  1187. ugr.Cells["DIC"].Value = dic;
  1188. }
  1189. //从表自动填充序号
  1190. if (ugr.HasParent())
  1191. {
  1192. int index = 0;
  1193. string cic = ugr.Cells["DIC"].Value.ToString();
  1194. foreach (UltraGridRow ug in ultraGrid1.Rows)
  1195. {
  1196. if (ug.Cells["DIC"].Value.ToString().Equals(cic))
  1197. {
  1198. for (int i = 0; i < ug.ChildBands[0].Rows.Count - 1; i++)
  1199. {
  1200. int indexSeq = Convert.ToInt32(ug.ChildBands[0].Rows[i].Cells["XH"].Value.ToString());
  1201. if (indexSeq > index)
  1202. index = indexSeq;
  1203. }
  1204. }
  1205. }
  1206. ugr.Cells["XH"].Value = index + 1;
  1207. ugr.Cells["DESC_VAL"].Activation = Activation.NoEdit;
  1208. }
  1209. //增加行如果没有勾选则不可编辑
  1210. if (!Convert.ToBoolean(ugr.Cells["CHC"].Value))
  1211. {
  1212. for (int i = 0; i < ugr.Cells.Count; i++)
  1213. {
  1214. if (!ugr.Cells[i].Column.Key.Equals("CHC"))
  1215. ugr.Cells[i].Activation = Activation.ActivateOnly;
  1216. if (ugr.Cells[i].Column.Key.Equals("CHKNK"))
  1217. ugr.Cells["CHKNK"].Value = "选择";
  1218. }
  1219. }
  1220. e.Row.Update();
  1221. }
  1222. FrmComMSCStdDetection _frmComMSCStdDetection = null;
  1223. /// <summary>
  1224. /// 扣型选择
  1225. /// </summary>
  1226. /// <param name="sender"></param>
  1227. /// <param name="e"></param>
  1228. private void ultraGrid1_ClickCellButton(object sender, CellEventArgs e)
  1229. {
  1230. if (e.Cell.Column.Key.Equals("MODEL_DESC") && Convert.ToBoolean(ultraGrid1.DisplayLayout.ActiveRow.Cells["CHC"].Value))
  1231. {
  1232. UltraGridRow row = this.ultraGrid1.DisplayLayout.ActiveRow;
  1233. FrmModel frms = new FrmModel();
  1234. frms.FrmOb = this.ob;
  1235. frms.Desc = row.Cells["MODEL_DESC"].Value.ToString();
  1236. frms.ShowDialog();
  1237. row.Cells["MODEL_CODE"].Value = frms.Code;
  1238. row.Cells["MODEL_DESC"].Value = frms.Desc;
  1239. }
  1240. if (e.Cell.Column.Key.Equals("CHKNK"))
  1241. {
  1242. UltraGridRow ugr = ultraGrid1.ActiveRow;
  1243. _frmComMSCStdDetection = new FrmComMSCStdDetection();
  1244. _frmComMSCStdDetection.PopupLoad("3", ob);
  1245. //_frmComMSCStdDetection.UltraPanel1.Visible = false;
  1246. _frmComMSCStdDetection.ultraToolbarsManager1.Visible = true;
  1247. _frmComMSCStdDetection.Msc = msc;
  1248. _frmComMSCStdDetection.CodeJg = "";
  1249. _frmComMSCStdDetection.DoQuery1();
  1250. if (_frmComMSCStdDetection.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  1251. {
  1252. DataRow CurRow, NewRow;
  1253. for (int i = 0; i < _frmComMSCStdDetection.dataTable2.Rows.Count; i++)
  1254. {
  1255. CurRow = _frmComMSCStdDetection.dataTable2.Rows[i];
  1256. NewRow = dataTable2.NewRow();
  1257. if (!_frmComMSCStdDetection.Ids.Contains(CurRow["DIC"].ToString2()))
  1258. {
  1259. continue;
  1260. }
  1261. for (int j = 0; j < _frmComMSCStdDetection.dataTable2.Columns.Count; j++)
  1262. {
  1263. try
  1264. {
  1265. if (dataTable2.Columns.Contains(_frmComMSCStdDetection.dataTable2.Columns[j].ColumnName))
  1266. {
  1267. if (_frmComMSCStdDetection.dataTable2.Columns[j].ColumnName == "DIC")
  1268. {
  1269. NewRow[_frmComMSCStdDetection.dataTable2.Columns[j].ColumnName] = ultraGrid1.ActiveRow.GetValue("DIC");
  1270. }
  1271. else
  1272. {
  1273. NewRow[_frmComMSCStdDetection.dataTable2.Columns[j].ColumnName] = CurRow[j];
  1274. }
  1275. }
  1276. }
  1277. catch { }
  1278. }
  1279. dataTable2.Rows.Add(NewRow);
  1280. }
  1281. ultraGrid1.UpdateData();
  1282. ultraGrid1.ActiveRow.ExpandAll();
  1283. }
  1284. }
  1285. }
  1286. /// <summary>
  1287. /// 单元格值变化事件
  1288. /// </summary>
  1289. /// <param name="sender"></param>
  1290. /// <param name="e"></param>
  1291. public void ultraGrid1_CellChange(object sender, CellEventArgs e)
  1292. {
  1293. ultraGrid1.UpdateData();
  1294. UltraGridRow ugr = ultraGrid1.DisplayLayout.ActiveRow;
  1295. if (e.Cell.Column.Key.Equals("MSC"))//
  1296. {
  1297. string msc = ugr.Cells["MSC"].Value.ToString();
  1298. DataRow[] dr = ((DataTable)ultras[0].DataSource).Select("MSC='" + msc + "'");
  1299. if (dr.Length > 0)
  1300. {
  1301. ugr.Cells["PSC"].Value = dr[0][2];
  1302. ugr.Cells["PSC_DESC"].Value = dr[0][3];
  1303. ugr.Cells["PRODUCNAME"].Value = dr[0][4];
  1304. ugr.Cells["STD_NAME"].Value = dr[0][5];
  1305. ugr.Cells["STEELNAME"].Value = dr[0][6];
  1306. ugr.Cells["STD_STYLE_DESC"].Value = dr[0][7];
  1307. ugr.Cells["STDSTYLE"].Value = dr[0][8];
  1308. }
  1309. }
  1310. //工序
  1311. if (e.Cell.Column.Key.Equals("PROCESS_CODE"))
  1312. {
  1313. ugr.Cells["PROCESS_DESC"].Value = ugr.Cells["PROCESS_CODE"].Text.ToString();
  1314. }
  1315. //标准内控
  1316. if (e.Cell.Column.Key.Equals("STD_CODE_NK"))
  1317. {
  1318. string stdCode = ugr.Cells["STD_CODE_NK"].Value.ToString();
  1319. ugr.Cells["STD_NAME_NK"].Value = ugr.Cells["STD_CODE_NK"].Text.Trim();
  1320. DataRow[] dr = ((DataTable)ultras[1].DataSource).Select("STD_CODE='" + stdCode + "'");
  1321. if (dr.Length > 0)
  1322. {
  1323. ugr.Cells["STDSTYLE"].Value = dr[0][2];
  1324. }
  1325. }
  1326. //检验项
  1327. if (e.Cell.Column.Key.Equals("PHY_CODE"))
  1328. {
  1329. ugr.Cells["PHY_NAME"].Value = ugr.Cells["PHY_CODE"].Text.ToString();
  1330. ugr.Cells["STD_DESC"].Value = "";
  1331. ugr.Cells["STD_CODE"].Value = "";
  1332. ugr.Cells["LV_DESC"].Value = "";
  1333. ugr.Cells["LV_CODE"].Value = "";
  1334. }
  1335. //探伤位置
  1336. if (e.Cell.Column.Key.Equals("POSITION_CODE"))
  1337. {
  1338. ugr.Cells["POSITION_DESC"].Value = ugr.Cells["POSITION_CODE"].Text.ToString();
  1339. }
  1340. //检验频次
  1341. if (e.Cell.Column.Key.Equals("DESC_RATE"))
  1342. {
  1343. ugr.Cells["RATE"].Value = ugr.Cells["DESC_RATE"].Value.ToString();
  1344. if (ugr.Cells["DESC_RATE"].Text.Trim() != "按比例")
  1345. {
  1346. ugr.Cells["DESC_VAL"].Activation = Activation.NoEdit;
  1347. }
  1348. else
  1349. {
  1350. ugr.Cells["DESC_VAL"].Activation = Activation.AllowEdit;
  1351. }
  1352. }
  1353. //选择
  1354. if (e.Cell.Column.Key.Equals("CHC"))
  1355. {
  1356. Activation activation = Activation.ActivateOnly;
  1357. if (Convert.ToBoolean(e.Cell.Value))
  1358. {
  1359. activation = Activation.AllowEdit;
  1360. //isSelect += 1;
  1361. if (e.Cell.Row.HasParent())
  1362. {
  1363. if (e.Cell.Row.Cells["DESC_RATE"].Value.ToString() == "按比例")
  1364. e.Cell.Row.Cells["DESC_VAL"].Activation = Activation.AllowEdit;
  1365. else
  1366. e.Cell.Row.Cells["DESC_VAL"].Activation = Activation.NoEdit;
  1367. }
  1368. }
  1369. else
  1370. {
  1371. if (e.Cell.Row.HasParent())
  1372. e.Cell.Row.Cells["DESC_VAL"].Activation = Activation.NoEdit;
  1373. }
  1374. //else
  1375. // isSelect -= 1;
  1376. CellsCollection cells = e.Cell.Row.Cells;
  1377. for (int i = 0; i < cells.Count; i++)
  1378. {
  1379. if (!cells[i].Column.Key.Equals("CHC"))
  1380. {
  1381. if (!cells[i].Column.Key.Equals("DESC_VAL"))
  1382. e.Cell.Row.Cells[i].Activation = activation;
  1383. }
  1384. }
  1385. }
  1386. }
  1387. /// <summary>
  1388. /// 标准名称
  1389. /// </summary>
  1390. /// <param name="sender"></param>
  1391. /// <param name="e"></param>
  1392. private void ultraCheckStd_CheckedChanged(object sender, EventArgs e)
  1393. {
  1394. if (ultraCheckStd.Checked)
  1395. ultraTextStd.Enabled = true;
  1396. else
  1397. ultraTextStd.Enabled = false;
  1398. }
  1399. private void ultraCheckMSC_CheckedChanged(object sender, EventArgs e)
  1400. {
  1401. if (ultraCheckMSC.Checked)
  1402. ultraTextMSC.Enabled = true;
  1403. else
  1404. ultraTextMSC.Enabled = false;
  1405. }
  1406. private void DoGroup()
  1407. {
  1408. ArrayList list = new ArrayList();
  1409. int ischeck = 0; //是否勾选
  1410. int isselect = 0; //勾选项是否已写入数据库
  1411. int isvalid = 0; //是否有效
  1412. //是否有数据修改
  1413. foreach (DataRow dr in dataTable2.Rows)
  1414. {
  1415. IQueryable<UltraGridRow> rows = ultraGrid1.Rows.AsQueryable().Where(a => ((DataRowView)a.ListObject).Row == dr
  1416. && a.GetValue("CHK") == "True");
  1417. if ((dr.RowState == DataRowState.Added || dr.RowState == DataRowState.Modified)
  1418. && rows.Count() > 0)
  1419. {
  1420. MessageUtil.ShowWarning("理化标准有数据修改,请保存后再进行分组操作!");
  1421. return;
  1422. }
  1423. }
  1424. foreach (UltraGridRow row in ultraGrid1.Rows)
  1425. {
  1426. if (row.HasChild() && row.Cells["CHC"].Value.ToString().ToUpper() == "TRUE")
  1427. {
  1428. MessageBox.Show("主表不能进行分组操作", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1429. return;
  1430. }
  1431. ArrayList plist = new ArrayList(); //分为几组。
  1432. Dictionary<int, DataTable> dicStation = new Dictionary<int, DataTable>();
  1433. int i = 0;
  1434. foreach (UltraGridRow crow in row.ChildBands[0].Rows)
  1435. {
  1436. ArrayList clist = new ArrayList(); //哪些分为一组。
  1437. if (crow.Cells["CHC"].Value.ToString().ToUpper() == "TRUE")
  1438. {
  1439. if (crow.Cells["VALIDFLAG"].Value.ToString().Equals(""))
  1440. {
  1441. isselect += 1;
  1442. }
  1443. if (crow.Cells["VALIDFLAG"].Value.ToString().Equals("无效"))
  1444. {
  1445. isvalid += 1;
  1446. }
  1447. ischeck += 1;
  1448. clist.Add(crow.Cells["DIC"].Value.ToString());
  1449. clist.Add(crow.Cells["XH"].Value.ToString());
  1450. plist.Add(clist);
  1451. _dic = crow.Cells["DIC"].Value.ToString();
  1452. _isEx = true;
  1453. //验证是否同一工序点
  1454. DataTable dtStation = GetStationByPhyCode(crow.GetValue("PHY_CODE"));
  1455. dicStation.Add(i, dtStation);
  1456. if (i != 0)
  1457. {
  1458. bool isSame = false;
  1459. foreach (DataRow dr in dicStation[i].Rows)
  1460. {
  1461. for (int j = i - 1; j >= 0; j--)
  1462. {
  1463. if (dicStation[j].Rows.Count == 0 || dicStation[i].Rows.Count == 0)
  1464. {
  1465. isSame = true;
  1466. }
  1467. int cnt = dicStation[j].Select("PROCESS_CODE = '" + dr["PROCESS_CODE"] + "'").Length;
  1468. if (cnt > 0)
  1469. {
  1470. isSame = true;
  1471. }
  1472. else
  1473. {
  1474. isSame = false;
  1475. break;
  1476. }
  1477. }
  1478. if (isSame)
  1479. {
  1480. break;
  1481. }
  1482. }
  1483. if (isSame == false)
  1484. {
  1485. MessageUtil.ShowWarning("不能将工序不一样的检验项分组到一组中!");
  1486. return;
  1487. }
  1488. }
  1489. i++;
  1490. }
  1491. }
  1492. list.Add(plist);
  1493. }
  1494. if (ischeck == 0)
  1495. {
  1496. MessageBox.Show("请选择你要分组的记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1497. return;
  1498. }
  1499. if (isselect > 0)
  1500. {
  1501. MessageBox.Show("您选择的分组记录中存在未保存的项,请先保存后再分组", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1502. return;
  1503. }
  1504. if (isvalid > 0)
  1505. {
  1506. MessageBox.Show("您选择的分组记录中存在无效数据,无法分组", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1507. return;
  1508. }
  1509. if (MessageBox.Show("是否确认对所选项进行分组?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  1510. {
  1511. return;
  1512. }
  1513. CoreClientParam ccp = new CoreClientParam(); //CoreClientParam是平台用来向服务端传递存放所有相关参数信息的。
  1514. ccp.ServerName = "com.steering.pss.qcm.CoreDetection"; //服务名指的是服务端的包名+类名
  1515. ccp.MethodName = "doGroup"; //方法名指的是服务名指定类里的方法
  1516. ccp.ServerParams = new object[] { list };//服务端方法的参数
  1517. //ExecuteNonQuery主要用来执行添加、修改、删除、存储过程的操作。
  1518. ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  1519. if (ccp.ReturnCode == -1)
  1520. return;
  1521. MessageBox.Show("分组成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1522. DoQuery();
  1523. }
  1524. private DataTable GetStationByPhyCode(string phyCode)
  1525. {
  1526. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreDetection.getStationByPhyCode",
  1527. new object[] { phyCode }, ob);
  1528. return dt;
  1529. }
  1530. private void CancelGroup()
  1531. {
  1532. int ischeck = 0; //是否勾选
  1533. int isselect = 0; //勾选项是否已写入数据库
  1534. int isvalid = 0; //是否有效
  1535. int hasindex = 0;
  1536. ArrayList plist = new ArrayList();
  1537. foreach (UltraGridRow row in ultraGrid1.Rows)
  1538. {
  1539. if (row.HasChild() && row.Cells["CHC"].Value.ToString().ToUpper() == "TRUE")
  1540. {
  1541. MessageBox.Show("主表不能进行取消分组操作", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1542. return;
  1543. }
  1544. foreach (UltraGridRow crow in row.ChildBands[0].Rows)
  1545. {
  1546. ArrayList clist = new ArrayList(); //需要取消的GIC和XH
  1547. if (crow.Cells["CHC"].Value.ToString().ToUpper() == "TRUE")
  1548. {
  1549. if (crow.Cells["VALIDFLAG"].Value.ToString().Equals(""))
  1550. {
  1551. isselect += 1;
  1552. }
  1553. if (crow.Cells["VALIDFLAG"].Value.ToString().Equals("无效"))
  1554. {
  1555. isvalid += 1;
  1556. }
  1557. if (crow.Cells["GROUP_SEQ"].Value.ToString().Equals(""))
  1558. {
  1559. hasindex += 1;
  1560. }
  1561. ischeck += 1;
  1562. clist.Add(crow.Cells["DIC"].Value.ToString());
  1563. clist.Add(crow.Cells["XH"].Value.ToString());
  1564. plist.Add(clist);
  1565. _dic = crow.Cells["DIC"].Value.ToString();
  1566. _isEx = true;
  1567. }
  1568. }
  1569. }
  1570. if (ischeck == 0)
  1571. {
  1572. MessageBox.Show("请选择你要取消分组的记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1573. return;
  1574. }
  1575. if (isselect > 0)
  1576. {
  1577. MessageBox.Show("您选择的记录中存在未保存的项,不能对其进行取消分组操作", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1578. return;
  1579. }
  1580. if (isvalid > 0)
  1581. {
  1582. MessageBox.Show("您选择的记录中存在无效数据,无法取消分组", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1583. return;
  1584. }
  1585. if (hasindex > 0)
  1586. {
  1587. MessageBox.Show("您选择的记录中存在未分组的数据,无法取消分组", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1588. return;
  1589. }
  1590. if (MessageBox.Show("是否确认对所选项进行取消分组?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  1591. {
  1592. return;
  1593. }
  1594. int count = ServerHelper.SetData("com.steering.pss.qcm.CoreDetection.cancleGroup", new Object[] { plist }, this.ob);
  1595. if (count > 0)
  1596. {
  1597. MessageBox.Show("取消分组成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  1598. DoQuery();
  1599. }
  1600. }
  1601. private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
  1602. {
  1603. if (isPasting)
  1604. {
  1605. e.Row.SetValue("CHC", "True");
  1606. }
  1607. }
  1608. /// <summary>
  1609. /// 2015-07-15 PDY
  1610. /// </summary>
  1611. private void InnerChange()
  1612. {
  1613. ultraGrid1.DisplayLayout.Bands[0].Columns["PROCESS_CODE"].CellActivation = Activation.ActivateOnly;
  1614. ultraGrid1.DisplayLayout.Bands[0].Columns["STD_CODE_NK"].CellActivation = Activation.ActivateOnly;
  1615. ultraGrid1.DisplayLayout.Bands[0].Columns["MODEL_DESC"].Hidden = true;
  1616. }
  1617. private void ultraTextEditor3_EditorButtonClick(object sender, EditorButtonEventArgs e)
  1618. {
  1619. if (ultraGrid1.ActiveCell.Column.Key == "PROCESS_DESC")
  1620. {
  1621. string processCodes = ultraGrid1.ActiveRow.GetValue("PROCESS_CODE");
  1622. ChoiceProcessPopup choiceProcessPopup = new ChoiceProcessPopup(processCodes, this.ob);
  1623. if (choiceProcessPopup.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  1624. {
  1625. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComStandard.getProcessByStdCode",
  1626. new object[] { this.stdCode }, ob);
  1627. string stdProcessCodes = dt.Rows[0]["PROCESS_CODE"].ToString();
  1628. string[] processCodesAry = choiceProcessPopup.ProcessCodes.Split(',');
  1629. for (int i = 0; i < processCodesAry.Length; i++)
  1630. {
  1631. if (!stdProcessCodes.Contains(processCodesAry[i].Trim()))
  1632. {
  1633. DataTable dtBaseProcess = ServerHelper.GetData("com.steering.pss.qcm.ComStandard.getProcessDescByCode",
  1634. new object[] { processCodesAry[i].Trim() }, ob);
  1635. string processDesc = dtBaseProcess.Rows[0]["PROCESS_DESC"].ToString();
  1636. MessageUtil.ShowWarning("该标准下不包含工序" + processDesc + ", 不能选择!");
  1637. return;
  1638. }
  1639. }
  1640. ultraGrid1.ActiveRow.SetValue("PROCESS_CODE", choiceProcessPopup.ProcessCodes);
  1641. ultraGrid1.ActiveRow.SetValue("PROCESS_DESC", choiceProcessPopup.ProcessDescs);
  1642. }
  1643. }
  1644. else if (ultraGrid1.ActiveCell.Column.Key == "STEELNAME_NK")
  1645. {
  1646. FrmRepSteel frmSteel = new FrmRepSteel();
  1647. frmSteel.Ob1 = this.ob;
  1648. frmSteel.Code = ultraGrid1.ActiveRow.GetValue("STEELCODE_NK");
  1649. if (frmSteel.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  1650. {
  1651. ultraGrid1.ActiveRow.SetValue("STEELCODE_NK", frmSteel.Code);
  1652. ultraGrid1.ActiveRow.SetValue("STEELNAME_NK", frmSteel.Desc);
  1653. }
  1654. }
  1655. else if (ultraGrid1.ActiveCell.Column.Key == "MODEL_DESC_NK")
  1656. {
  1657. FrmModel frmModel = new FrmModel();
  1658. frmModel.FrmOb = this.ob;
  1659. frmModel.Code = ultraGrid1.ActiveRow.GetValue("MODEL_CODE_NK");
  1660. frmModel.Desc = ultraGrid1.ActiveCell.Value.ToString();
  1661. if (frmModel.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  1662. {
  1663. ultraGrid1.ActiveRow.SetValue("MODEL_CODE_NK", frmModel.Code);
  1664. ultraGrid1.ActiveRow.SetValue("MODEL_DESC_NK", frmModel.Desc);
  1665. }
  1666. }
  1667. else if (ultraGrid1.ActiveCell.Column.Key == "PRODUCNAME_NK")
  1668. {
  1669. PopupProductName popupProductName = new PopupProductName(
  1670. ultraGrid1.ActiveRow.GetValue("PRODUCCODE_NK"), ob);
  1671. if (popupProductName.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  1672. {
  1673. ultraGrid1.ActiveRow.SetValue("PRODUCCODE_NK", popupProductName.ProductCodes);
  1674. ultraGrid1.ActiveRow.SetValue("PRODUCNAME_NK", popupProductName.ProductNames);
  1675. }
  1676. }
  1677. else if (ultraGrid1.ActiveCell.Column.Key == "STD_NAME_S_NK")
  1678. {
  1679. string stdCodes = ultraGrid1.ActiveRow.GetValue("STD_CODE_S_NK");
  1680. FrmStandardChoice standardChoice = new FrmStandardChoice(stdCodes, ob);
  1681. if (standardChoice.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  1682. {
  1683. ultraGrid1.ActiveRow.SetValue("STD_CODE_S_NK", standardChoice.StdCodes);
  1684. ultraGrid1.ActiveRow.SetValue("STD_NAME_S_NK", standardChoice.StdNames);
  1685. }
  1686. }
  1687. else if (ultraGrid1.ActiveCell.Column.Key == "STD_STYLE_DESC_S_NK")
  1688. {
  1689. string stdStyles = ultraGrid1.ActiveRow.GetValue("STD_STYLE_S_NK");
  1690. FrmStandardStyleChoice standardStyleChoice = new FrmStandardStyleChoice(stdStyles, ob);
  1691. if (standardStyleChoice.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  1692. {
  1693. ultraGrid1.ActiveRow.SetValue("STD_STYLE_S_NK", standardStyleChoice.StdStyles);
  1694. ultraGrid1.ActiveRow.SetValue("STD_STYLE_DESC_S_NK", standardStyleChoice.StdStyleDescs);
  1695. }
  1696. }
  1697. else if (ultraGrid1.ActiveCell.Column.Key == "STD_DESC")
  1698. {
  1699. var row = ultraGrid1.ActiveRow;
  1700. if (row.GetValue("PHY_CODE") == "")
  1701. {
  1702. MessageUtil.ShowWarning("请选择探伤项!");
  1703. row.Cells["PHY_CODE"].Activate();
  1704. return;
  1705. }
  1706. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.DAL.ComBaseDetectionRltDAL.QueryStdBaseInfo", new object[] { row.GetValue("PHY_CODE") }, ob);
  1707. dt.Columns["STD_DESC"].Caption = "参考标准";
  1708. BaseInfoPopup baseInfoPopup = new BaseInfoPopup(dt, "STD_DESC", "PHY_CODE", "PHY_NAME", "STD_CODE", "LV_CODE", "LV_DESC", "ID");
  1709. baseInfoPopup.Text = "参考标准";
  1710. baseInfoPopup.LabelTextBox1.Caption = "参考标准";
  1711. baseInfoPopup.Shown += new EventHandler((c, d) =>
  1712. {
  1713. IQueryable<UltraGridRow> rows = baseInfoPopup.UltraGrid1.Rows.AsQueryable().Where(
  1714. a => a.GetValue("STD_CODE") == ultraGrid1.ActiveRow.GetValue("STD_CODE"));
  1715. if (rows.Count() > 0)
  1716. {
  1717. rows.First().Activate();
  1718. }
  1719. });
  1720. if (baseInfoPopup.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  1721. {
  1722. ultraGrid1.ActiveRow.SetValue("STD_DESC", baseInfoPopup.ChoicedRow.GetValue("STD_DESC"));
  1723. ultraGrid1.ActiveRow.SetValue("STD_CODE", baseInfoPopup.ChoicedRow.GetValue("STD_CODE"));
  1724. ultraGrid1.ActiveRow.Cells["LV_DESC"].Value = "";
  1725. ultraGrid1.ActiveRow.Cells["LV_CODE"].Value = "";
  1726. }
  1727. }
  1728. else if (ultraGrid1.ActiveCell.Column.Key == "LV_DESC")
  1729. {
  1730. var row = ultraGrid1.ActiveRow;
  1731. if (row.GetValue("STD_CODE") == "")
  1732. {
  1733. MessageUtil.ShowWarning("请选择参考标准!");
  1734. row.Cells["STD_CODE"].Activate();
  1735. return;
  1736. }
  1737. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.DAL.ComBaseDetectionRltDAL.QueryLvBaseInfo", new object[] { row.GetValue("STD_CODE") }, ob);
  1738. dt.Columns["LV_DESC"].Caption = "探伤级别";
  1739. BaseInfoPopup baseInfoPopup = new BaseInfoPopup(dt, "LV_DESC", "PHY_CODE", "PHY_NAME", "STD_DESC", "STD_CODE", "LV_CODE", "ID");
  1740. baseInfoPopup.Text = "探伤级别";
  1741. baseInfoPopup.LabelTextBox1.Caption = "探伤级别";
  1742. baseInfoPopup.Shown += new EventHandler((c, d) =>
  1743. {
  1744. IQueryable<UltraGridRow> rows = baseInfoPopup.UltraGrid1.Rows.AsQueryable().Where(
  1745. a => a.GetValue("LV_CODE") == ultraGrid1.ActiveRow.GetValue("LV_CODE"));
  1746. if (rows.Count() > 0)
  1747. {
  1748. rows.First().Activate();
  1749. }
  1750. });
  1751. if (baseInfoPopup.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  1752. {
  1753. ultraGrid1.ActiveRow.SetValue("LV_DESC", baseInfoPopup.ChoicedRow.GetValue("LV_DESC"));
  1754. ultraGrid1.ActiveRow.SetValue("LV_CODE", baseInfoPopup.ChoicedRow.GetValue("LV_CODE"));
  1755. }
  1756. }
  1757. ultraGrid1.UpdateData();
  1758. }
  1759. private void ultraGrid1_AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
  1760. {
  1761. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in this.ultraGrid1.Selected.Rows)
  1762. {
  1763. ugr.Cells["CHC"].Value = true;
  1764. Activation activation = Activation.ActivateOnly;
  1765. if (Convert.ToBoolean(ugr.Cells["CHC"].Value))
  1766. {
  1767. activation = Activation.AllowEdit;
  1768. //isSelect += 1;
  1769. }
  1770. //else
  1771. //isSelect -= 1;
  1772. CellsCollection cells = ugr.Cells;
  1773. for (int i = 0; i < cells.Count; i++)
  1774. {
  1775. if (!cells[i].Column.Key.Equals("CHC"))
  1776. {
  1777. ugr.Cells[i].Activation = activation;
  1778. }
  1779. }
  1780. }
  1781. }
  1782. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  1783. {
  1784. switch (e.Tool.Key)
  1785. {
  1786. case "查询":
  1787. DoQuery1();
  1788. break;
  1789. case "确认选择":
  1790. Choice();
  1791. break;
  1792. }
  1793. }
  1794. private DataRow[] rows;
  1795. public DataRow[] Rows
  1796. {
  1797. get { return rows; }
  1798. set { rows = value; }
  1799. }
  1800. List<string> ids;
  1801. public List<string> Ids
  1802. {
  1803. get { return ids; }
  1804. set { ids = value; }
  1805. }
  1806. private void DoQuery1()
  1807. {
  1808. //主表查询
  1809. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreDetection.getComDetectionNK",
  1810. new Object[] { msc }, this.ob);
  1811. dataTable2.Clear();
  1812. GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
  1813. //从表查询
  1814. DataTable dt1 = ServerHelper.GetData("com.steering.pss.qcm.CoreDetection.getComDetectionNKC",
  1815. new Object[] { msc }, this.ob);
  1816. dt1 = QcmBaseCommon.FilterTable(dt, dt1, "DIC");
  1817. GridHelper.CopyDataToDatatable(ref dt1, ref this.dataTable2, true);
  1818. UltraGridColumn[] col = new UltraGridColumn[] { this.ultraGrid1.DisplayLayout.Bands[0].Columns["MEMO"], this.ultraGrid1.DisplayLayout.Bands[0].Columns["MSC"],
  1819. this.ultraGrid1.DisplayLayout.Bands[0].Columns["PSC_DESC"],this.ultraGrid1.DisplayLayout.Bands[0].Columns["STD_CODE_NK"],
  1820. this.ultraGrid1.DisplayLayout.Bands[0].Columns["MODEL_DESC"]};
  1821. //GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid1, col);
  1822. QcmBaseCommon.SetGridColor(ultraGrid1, "VALIDFLAG", "无效");
  1823. QcmBaseCommon.SetUltraGridNoEdit(ultraGrid1);
  1824. //isSelect = 0;
  1825. //展开或者定位
  1826. UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "DIC" }, new string[] { _dic });
  1827. if (rows1.Length > 0)
  1828. {
  1829. rows1[0].Activate();
  1830. if (_isEx)
  1831. rows1[0].ExpandAll();
  1832. }
  1833. _isEx = false;
  1834. _dic = "";
  1835. dataTable1.AcceptChanges();
  1836. dataTable2.AcceptChanges();
  1837. //清空复制数据
  1838. //_copyedRows.Clear();
  1839. }
  1840. private void Choice()
  1841. {
  1842. ultraGrid1.UpdateData();
  1843. int count = ultraGrid1.Rows.Where(a => Convert.ToBoolean(a.GetValue("CHC"))).Count();
  1844. if (count > 1)
  1845. {
  1846. MessageUtil.ShowTips("请选择一条数据!");
  1847. return;
  1848. }
  1849. foreach (UltraGridRow ugr in ultraGrid1.Rows.Where(a => Convert.ToBoolean(a.GetValue("CHC"))))
  1850. {
  1851. //从表操作
  1852. if (ugr.HasChild())
  1853. {
  1854. Ids = ugr.ChildBands[0].Rows.Select(p => p.GetValue("DIC")).ToList();
  1855. Rows = dataTable2.Select("DIC IN ('" + string.Join("','", Ids) + "')");
  1856. }
  1857. }
  1858. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  1859. }
  1860. }
  1861. }