FrmTolerancesStandard.cs 91 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180
  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 FrmTolerancesStandard : FrmBase
  21. {
  22. private bool isPasting = false;
  23. /// <summary>
  24. /// 公差索引号
  25. /// </summary>
  26. private string sic = "";
  27. public string Sic
  28. {
  29. get { return sic; }
  30. set { sic = value; }
  31. }
  32. private string msc = "";
  33. public string Msc
  34. {
  35. get { return msc; }
  36. set { msc = value; }
  37. }
  38. private string codeJg = "DefaultValue";
  39. public string CodeJg
  40. {
  41. get { return codeJg; }
  42. set { codeJg = value; }
  43. }
  44. private string stdCode = "";
  45. public string StdCode
  46. {
  47. get { return stdCode; }
  48. set { stdCode = value; }
  49. }
  50. private ArrayList steelCodes = new ArrayList();
  51. public ArrayList SteelCodes
  52. {
  53. get { return steelCodes; }
  54. set { steelCodes = value; }
  55. }
  56. private string producCodeNk = "";
  57. public string ProducCodeNk
  58. {
  59. get { return producCodeNk; }
  60. set { producCodeNk = value; }
  61. }
  62. private string steelcodeNk = "";
  63. public string SteelcodeNk
  64. {
  65. get { return steelcodeNk; }
  66. set { steelcodeNk = value; }
  67. }
  68. private string processCode = "";
  69. public string ProcessCode
  70. {
  71. get { return processCode; }
  72. set { processCode = value; }
  73. }
  74. private string modelCode = "";
  75. public string ModelCode
  76. {
  77. get { return modelCode; }
  78. set { modelCode = value; }
  79. }
  80. private string acceptBid = "";
  81. public string AcceptBid
  82. {
  83. get { return acceptBid; }
  84. set { acceptBid = value; }
  85. }
  86. //提示
  87. private string errMessage = "";
  88. //用于展开项和定位到操作项
  89. private string _sic = "";
  90. private bool _isEx = false;
  91. //用于判断是否勾选
  92. //public int isSelect = 0;
  93. //初始下拉框
  94. private UltraComboEditor[] ultras = new UltraComboEditor[9];
  95. public FrmTolerancesStandard()
  96. {
  97. IsLoadUserView = true;
  98. InitializeComponent();
  99. ExceptionHelper.RegistException();
  100. }
  101. public void PopupLoad(string customInfo, OpeBase ob)
  102. {
  103. this.CustomInfo = customInfo;
  104. this.ob = ob;
  105. FrmTolerancesStandard_Load(null, null);
  106. }
  107. /// <summary>
  108. /// 登入初始化
  109. /// </summary>
  110. /// <param name="sender"></param>
  111. /// <param name="e"></param>
  112. private void FrmTolerancesStandard_Load(object sender, EventArgs e)
  113. {
  114. HideColumn();
  115. InitDrop();
  116. }
  117. public void PopupRefresh()
  118. {
  119. UltraGridBand ugb = ultraGrid1.DisplayLayout.Bands[0];
  120. if (CustomInfo == "1")
  121. { //冶金规范码
  122. QcmBaseQuery.NitializeMSC(ultras[0], false, this.ob, msc);
  123. QcmBaseQuery.BindColumn(ultras[0], "MSC", ugb);
  124. }
  125. }
  126. /// <summary>
  127. /// 初始化下拉框
  128. /// </summary>
  129. private void InitDrop()
  130. {
  131. for (int i = 0; i < ultras.Length; i++)
  132. {
  133. ultras[i] = new UltraComboEditor();
  134. Controls.Add(ultras[i]);
  135. ultras[i].Visible = false;
  136. ultras[i].DropDownListWidth = -1;
  137. }
  138. //主表
  139. UltraGridBand ugb = ultraGrid1.DisplayLayout.Bands[0];
  140. //从表
  141. UltraGridBand ugbC = ultraGrid1.DisplayLayout.Bands[1];
  142. if (CustomInfo == "1")
  143. { //冶金规范码
  144. QcmBaseQuery.NitializeMSC(ultras[0], false, this.ob, msc);
  145. QcmBaseQuery.BindColumn(ultras[0], "MSC", ugb);
  146. }
  147. //下限符号
  148. QcmBaseQuery.NitializeSignMin(ultras[1]);
  149. //公差约束项一下限符号
  150. QcmBaseQuery.BindColumn(ultras[1], "ZMIN_SIGN", ugbC);
  151. //公差约束项二下限符号
  152. QcmBaseQuery.BindColumn(ultras[1], "CMIN_SIGN", ugbC);
  153. //公差约束项三下限符号
  154. QcmBaseQuery.BindColumn(ultras[1], "SMIN_SIGN", ugbC);
  155. //上限符号
  156. QcmBaseQuery.NitializeSignMax(ultras[2]);
  157. //公差约束项一上限符号
  158. QcmBaseQuery.BindColumn(ultras[2], "ZMAX_SIGN", ugbC);
  159. //公差约束项二上限符号
  160. QcmBaseQuery.BindColumn(ultras[2], "CMAX_SIGN", ugbC);
  161. //公差约束项三上限符号
  162. QcmBaseQuery.BindColumn(ultras[2], "SMAX_SIGN", ugbC);
  163. //公差项
  164. QcmBaseQuery.NitializeTolerance(ultras[3], false, this.ob);
  165. QcmBaseQuery.BindColumn(ultras[3], "BIAS_CODE", ugbC);
  166. //精度等级
  167. QcmBaseQuery.NitializePrecision(ultras[4], true, this.ob);
  168. QcmBaseQuery.BindColumn(ultras[4], "LV", ugbC);
  169. if (CustomInfo != "1")
  170. { //标准名称
  171. //标准名称
  172. if (CustomInfo == "2")
  173. QcmBaseQuery.NitializeInnerStandard(ultras[5], false, this.ob);
  174. else if (CustomInfo == "3")
  175. QcmBaseQuery.NitializeAlphaStandard(ultras[5], false, this.ob);
  176. else
  177. QcmBaseQuery.NitializeOtherStandard(ultras[5], false, this.ob);
  178. QcmBaseQuery.BindColumn(ultras[5], "STD_CODE", ugb);
  179. //工序
  180. QcmBaseQuery.NitializeProcess(ultras[6], true, this.ob);
  181. QcmBaseQuery.BindColumn(ultras[6], "PROCESS_CODE", ugb);
  182. }
  183. //公差约束项
  184. QcmBaseQuery.NitializeToleranceRestrain(ultras[7], true, this.ob);
  185. QcmBaseQuery.BindColumn(ultras[7], "BIAS_CODE_Z", ugbC);
  186. QcmBaseQuery.BindColumn(ultras[7], "BIAS_CODE_C", ugbC);
  187. QcmBaseQuery.BindColumn(ultras[7], "BIAS_CODE_S", ugbC);
  188. QcmBaseQuery.NitializeProductBigType(ultras[8], false, ob);
  189. QcmBaseQuery.BindColumn(ultras[8], "PRODUC_HEAD", ugb);
  190. ClsBaseInfo.SetComboItemHeight(ultras[8]);
  191. }
  192. public override void ToolBar_Click(object sender, string ToolbarKey)
  193. {
  194. switch (ToolbarKey)
  195. {
  196. case "Query":
  197. this.DoQuery();
  198. break;
  199. case "Save":
  200. this.DoSave();
  201. break;
  202. case "Delete":
  203. DoDeleteOrResume(true);
  204. break;
  205. case "Resume":
  206. DoDeleteOrResume(false);
  207. break;
  208. case "Copy":
  209. Copy();
  210. break;
  211. case "Paste":
  212. isPasting = true;
  213. try
  214. {
  215. Paste();
  216. }
  217. finally
  218. {
  219. isPasting = false;
  220. }
  221. break;
  222. case "Refresh":
  223. InitDrop();
  224. break;
  225. case "Group":
  226. Group(true);
  227. break;
  228. case "Cancel":
  229. Group(false);
  230. break;
  231. case "Close":
  232. this.Close();
  233. break;
  234. }
  235. }
  236. /// <summary>
  237. /// 复制
  238. /// </summary>
  239. private void Copy()
  240. {
  241. if (ultraGrid1.ActiveRow == null)
  242. {
  243. MessageUtil.ShowWarning("请选择记录后,再进行操作!");
  244. return;
  245. }
  246. ultraGrid1.UpdateData();
  247. DataTable copyTab = dataTable2.Copy();
  248. DataTable copyTab2 = dataTable1.Copy();
  249. copyTab.Clear();
  250. copyTab2.Clear();
  251. if (ultraGrid1.ActiveRow.HasParent())
  252. {
  253. foreach (UltraGridRow row in ultraGrid1.ActiveRow.ParentRow.ChildBands[0].Rows)
  254. {
  255. if (row.GetValue("CHC") != "True") continue;
  256. DataRow dr = copyTab.NewRow();
  257. CopyRowToRow(((DataRowView)row.ListObject).Row, dr);
  258. copyTab.Rows.Add(dr);
  259. }
  260. }
  261. else
  262. {
  263. foreach (UltraGridRow row in ultraGrid1.ActiveRow.ChildBands[0].Rows)
  264. {
  265. DataRow dr = copyTab.NewRow();
  266. CopyRowToRow(((DataRowView)row.ListObject).Row, dr);
  267. copyTab.Rows.Add(dr);
  268. }
  269. DataRow dr2 = copyTab2.NewRow();
  270. CopyRowToRow(((DataRowView)ultraGrid1.ActiveRow.ListObject).Row, dr2);
  271. copyTab2.Rows.Add(dr2);
  272. }
  273. DataTable[] copyTabs = new DataTable[] { copyTab, copyTab2 };
  274. Clipboard.SetData("Sic", copyTabs);
  275. }
  276. private void CopyRowToRow(DataRow srcRow, DataRow desRow)
  277. {
  278. for (int i = 0; i < srcRow.Table.Columns.Count; i++)
  279. {
  280. string columnName = srcRow.Table.Columns[i].ColumnName;
  281. desRow[columnName] = srcRow[columnName];
  282. }
  283. }
  284. /// <summary>
  285. /// 粘贴
  286. /// </summary>
  287. private void Paste()
  288. {
  289. DataTable[] copyTabs = (DataTable[])Clipboard.GetData("Sic");
  290. if (copyTabs == null)
  291. {
  292. MessageUtil.ShowWarning("没有数据,请复制后再进行操作!");
  293. return;
  294. }
  295. DataTable copyTab = copyTabs[0];
  296. DataTable copyTab2 = copyTabs[1];
  297. if (copyTab == null || copyTab.Rows.Count == 0)
  298. {
  299. MessageUtil.ShowWarning("没有数据,请复制后再进行操作!");
  300. return;
  301. }
  302. dataTable2.BeginInit();
  303. string sic = "";
  304. UltraGridRow rowParent;
  305. if (ultraGrid1.ActiveRow.HasParent())
  306. {
  307. //if (ultraGrid1.ActiveRow.ParentRow.ChildBands[0].Rows.Count > 0)
  308. //{
  309. // MessageUtil.ShowWarning("该记录下存在子记录,不能进行粘贴操作!");
  310. // return;
  311. //}
  312. sic = ultraGrid1.ActiveRow.ParentRow.GetValue("SIC");
  313. rowParent = ultraGrid1.ActiveRow.ParentRow;
  314. }
  315. else
  316. {
  317. //if (ultraGrid1.ActiveRow.ChildBands[0].Rows.Count > 0)
  318. //{
  319. // MessageUtil.ShowWarning("该记录下存在子记录,不能进行粘贴操作!");
  320. // return;
  321. //}
  322. sic = ultraGrid1.GetActiveRowValue("SIC");
  323. rowParent = ultraGrid1.ActiveRow;
  324. }
  325. List<string> notCopyColumns = new List<string>();
  326. notCopyColumns.AddRange("CHC", "CREATE_TIME", "CREATE_NAME", "UPDATE_TIME", "UPDATE_NAME",
  327. "DELETE_TIME", "DELETE_NAME", "VALIDFLAG", "SIC", "MSC", "PSC_DESC", "PSC", "STD_CODE", "STD_NAME", "STDSTYLE",
  328. "STEELNAME", "PRODUCNAME", "PROCESS_CODE", "STD_STYLE_DESC", "PRODUCCODE_NK", "PRODUCNAME_NK",
  329. "PROCESS_CODE", "PROCESS_DESC", "STEELCODE_NK", "STEELNAME_NK");
  330. if (copyTab2.Rows.Count > 0)
  331. {
  332. DataRow drParent = ((DataRowView)rowParent.ListObject).Row;
  333. foreach (DataColumn column in dataTable1.Columns)
  334. {
  335. string columnName = column.ColumnName;
  336. if (notCopyColumns.Contains(columnName) == true) continue;
  337. drParent[columnName] = copyTab2.Rows[0][columnName];
  338. }
  339. }
  340. foreach (DataRow row in copyTab.Rows)
  341. {
  342. DataRow tempRow = dataTable2.NewRow();
  343. foreach (DataColumn column in dataTable2.Columns)
  344. {
  345. string columnName = column.ColumnName;
  346. if (notCopyColumns.Contains(columnName) == true) continue;
  347. tempRow[columnName] = row[columnName];
  348. }
  349. tempRow["SIC"] = sic;
  350. dataTable2.Rows.Add(tempRow);
  351. }
  352. dataTable2.EndInit();
  353. if (copyTab.Rows.Count > 0 && ultraGrid1.ActiveRow != null)
  354. {
  355. ultraGrid1.ActiveRow.ExpandAll();
  356. }
  357. ultraGrid1.UpdateData();
  358. }
  359. /// <summary>
  360. /// 根据内控、交付标准分别隐藏不同列
  361. /// </summary>
  362. private void HideColumn()
  363. {
  364. if (CustomInfo == "1")
  365. {
  366. this.ultraGrid1.DisplayLayout.Bands[0].Columns["SPECIAL_PATH"].Hidden = true;
  367. this.ultraGrid1.DisplayLayout.Bands[0].Columns["PROCESS_DESC"].Hidden = true;
  368. this.ultraGrid1.DisplayLayout.Bands[0].Columns["STD_CODE"].Hidden = true;
  369. this.ultraGrid1.DisplayLayout.Bands[0].Columns["STEELNAME_NK"].Hidden = true;
  370. this.ultraGrid1.DisplayLayout.Bands[0].Columns["MODEL_DESC_NK"].Hidden = true;
  371. this.ultraGrid1.DisplayLayout.Bands[0].Columns["PRODUCCODE_NK"].Hidden = true;
  372. this.ultraGrid1.DisplayLayout.Bands[0].Columns["PRODUCNAME_NK"].Hidden = true;
  373. }
  374. if (CustomInfo == "2" || CustomInfo == "4")
  375. {
  376. this.ultraGrid1.DisplayLayout.Bands[0].Columns["STD_NAME"].Hidden = true;
  377. this.ultraGrid1.DisplayLayout.Bands[0].Columns["MSC"].Hidden = true;
  378. this.ultraGrid1.DisplayLayout.Bands[0].Columns["PSC_DESC"].Hidden = true;
  379. this.ultraGrid1.DisplayLayout.Bands[0].Columns["PRODUCNAME"].Hidden = true;
  380. this.ultraGrid1.DisplayLayout.Bands[0].Columns["STEELNAME"].Hidden = true;
  381. this.ultraGrid1.DisplayLayout.Bands[0].Columns["STD_STYLE_DESC"].Hidden = true;
  382. if (CustomInfo == "2")
  383. {
  384. this.ultraGrid1.DisplayLayout.Bands[0].Columns["STD_CODE"].Header.Caption = "内控管理编号";
  385. }
  386. this.ultraCheckMSC.Visible = false;
  387. this.TextMSC.Visible = false;
  388. InnerChange();
  389. }
  390. if (CustomInfo == "3")
  391. {
  392. this.ultraGrid1.DisplayLayout.Bands[0].Columns["SPECIAL_PATH"].Hidden = true;
  393. this.ultraGrid1.DisplayLayout.Bands[0].Columns["STD_NAME"].Hidden = true;
  394. this.ultraGrid1.DisplayLayout.Bands[0].Columns["MSC"].Hidden = true;
  395. this.ultraGrid1.DisplayLayout.Bands[0].Columns["PSC_DESC"].Hidden = true;
  396. this.ultraGrid1.DisplayLayout.Bands[0].Columns["PRODUCNAME"].Hidden = true;
  397. this.ultraGrid1.DisplayLayout.Bands[0].Columns["STEELNAME"].Hidden = true;
  398. this.ultraGrid1.DisplayLayout.Bands[0].Columns["STD_STYLE_DESC"].Hidden = true;
  399. this.ultraCheckMSC.Visible = false;
  400. this.TextMSC.Visible = false;
  401. ultraGrid1.DisplayLayout.Bands[0].Columns["PROCESS_DESC"].Hidden = true;
  402. this.ultraGrid1.DisplayLayout.Bands[0].Columns["STEELNAME_NK"].Hidden = true;
  403. this.ultraGrid1.DisplayLayout.Bands[0].Columns["MODEL_DESC_NK"].Hidden = true;
  404. this.ultraGrid1.DisplayLayout.Bands[0].Columns["PRODUCCODE_NK"].Hidden = true;
  405. this.ultraGrid1.DisplayLayout.Bands[0].Columns["PRODUCNAME_NK"].Hidden = true;
  406. }
  407. }
  408. /// <summary>
  409. /// 查询条件
  410. /// </summary>
  411. /// <returns></returns>
  412. private ArrayList QueryCodition()
  413. {
  414. ArrayList list = new ArrayList();
  415. //标准名称
  416. string stand = "";
  417. if (this.ultraCheckStand.Checked)
  418. stand = TextStd.Text.Trim();
  419. list.Add(stand);
  420. //冶金规范码
  421. string msc = "";
  422. if (CustomInfo == "1")
  423. {
  424. if (ultraCheckMSC.Checked)
  425. msc = TextMSC.Text.Trim();
  426. }
  427. list.Add(msc);
  428. //是否包含无效
  429. string valid = "1";
  430. if (chkValid.Checked)
  431. valid = "0";
  432. list.Add(valid);
  433. list.Add(stdCode);
  434. return list;
  435. }
  436. /// <summary>
  437. /// 查询
  438. /// </summary>
  439. private void DoQuery()
  440. {
  441. ArrayList list = QueryCodition();
  442. //主表查询
  443. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreTolerances.getCoreTolerances",
  444. new Object[] { list, CustomInfo, sic, msc, codeJg, producCodeNk, steelcodeNk, processCode, modelCode }, this.ob);
  445. dataTable2.Clear();
  446. GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
  447. //从表查询
  448. string valid = "1";
  449. if (chkValid.Checked)
  450. valid = "0";
  451. DataTable dt1 = ServerHelper.GetData("com.steering.pss.qcm.CoreTolerances.getCoreTolerancesC",
  452. new Object[] { CustomInfo, valid, stdCode, msc, codeJg, producCodeNk, steelcodeNk, processCode, modelCode }, this.ob);
  453. dt1 = QcmBaseCommon.FilterTable(dt, dt1, "SIC");
  454. GridHelper.CopyDataToDatatable(ref dt1, ref this.dataTable2, true);
  455. //不同颜色区分是否有效数据
  456. QcmBaseCommon.SetGridColor(ultraGrid1, "VALIDFLAG", "无效");
  457. //isSelect = 0;
  458. QcmBaseCommon.SetUltraGridNoEdit(ultraGrid1);
  459. UltraGridColumn[] col = new UltraGridColumn[] {
  460. this.ultraGrid1.DisplayLayout.Bands[0].Columns["STDMEMO"],
  461. this.ultraGrid1.DisplayLayout.Bands[0].Columns["MSC"],
  462. this.ultraGrid1.DisplayLayout.Bands[0].Columns["STD_CODE"],
  463. this.ultraGrid1.DisplayLayout.Bands[0].Columns["STEELNAME_NK"],
  464. this.ultraGrid1.DisplayLayout.Bands[1].Columns["BIAS_CODE"]};
  465. GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid1, col);
  466. //展开或者定位
  467. UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "SIC" }, new string[] { _sic });
  468. if (rows1.Length > 0)
  469. {
  470. rows1[0].Activate();
  471. if (_isEx)
  472. rows1[0].ExpandAll();
  473. }
  474. _isEx = false;
  475. _sic = "";
  476. foreach (UltraGridRow ugr in ultraGrid1.Rows)
  477. {
  478. ugr.Cells["CHKNK"].Value = "选择";
  479. }
  480. dataTable1.AcceptChanges();
  481. dataTable2.AcceptChanges();
  482. //清空复制数据
  483. //_copyedRows.Clear();
  484. }
  485. private void DoQuery1()
  486. {
  487. ArrayList list = QueryCodition();
  488. //主表查询
  489. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreTolerances.getComSpecNK",
  490. new Object[] { msc }, this.ob);
  491. dataTable2.Clear();
  492. GridHelper.CopyDataToDatatable(ref dt, ref this.dataTable1, true);
  493. //从表查询
  494. string valid = "1";
  495. if (chkValid.Checked)
  496. valid = "0";
  497. DataTable dt1 = ServerHelper.GetData("com.steering.pss.qcm.CoreTolerances.getComSpecNKC",
  498. new Object[] { msc }, this.ob);
  499. dt1 = QcmBaseCommon.FilterTable(dt, dt1, "SIC");
  500. GridHelper.CopyDataToDatatable(ref dt1, ref this.dataTable2, true);
  501. //不同颜色区分是否有效数据
  502. QcmBaseCommon.SetGridColor(ultraGrid1, "VALIDFLAG", "无效");
  503. //isSelect = 0;
  504. QcmBaseCommon.SetUltraGridNoEdit(ultraGrid1);
  505. UltraGridColumn[] col = new UltraGridColumn[] {
  506. this.ultraGrid1.DisplayLayout.Bands[0].Columns["STDMEMO"],
  507. this.ultraGrid1.DisplayLayout.Bands[0].Columns["MSC"],
  508. this.ultraGrid1.DisplayLayout.Bands[0].Columns["STD_CODE"],
  509. this.ultraGrid1.DisplayLayout.Bands[0].Columns["STEELNAME_NK"],
  510. this.ultraGrid1.DisplayLayout.Bands[1].Columns["BIAS_CODE"]};
  511. GridHelper.RefreshAndAutoSizeExceptRows(ultraGrid1, col);
  512. //展开或者定位
  513. UltraGridRow[] rows1 = GridHelper.GetRowsWithKey(ultraGrid1, new string[] { "SIC" }, new string[] { _sic });
  514. if (rows1.Length > 0)
  515. {
  516. rows1[0].Activate();
  517. if (_isEx)
  518. rows1[0].ExpandAll();
  519. }
  520. _isEx = false;
  521. _sic = "";
  522. dataTable1.AcceptChanges();
  523. dataTable2.AcceptChanges();
  524. //清空复制数据
  525. //_copyedRows.Clear();
  526. }
  527. public void QueryPurchaseAgreement(string stdCodeNk)
  528. {
  529. dataTable2.Clear();
  530. dataTable1.Clear();
  531. DataTable dtP = ServerHelper.GetData("com.steering.pss.qcm.CoreTolerances.getPurchaseAgreementSic",
  532. new object[] { stdCodeNk }, ob);
  533. GridHelper.CopyDataToDatatable(ref dtP, ref this.dataTable1, true);
  534. DataTable dtC = ServerHelper.GetData("com.steering.pss.qcm.CoreTolerances.getPurchaseAgreementSpec",
  535. new object[] { stdCodeNk }, ob);
  536. GridHelper.CopyDataToDatatable(ref dtC, ref this.dataTable2, true);
  537. QcmBaseCommon.SetGridColor(ultraGrid1, "VALIDFLAG", "无效");
  538. QcmBaseCommon.SetUltraGridNoEdit(ultraGrid1);
  539. }
  540. private int GetGridSelectCount()
  541. {
  542. foreach (UltraGridRow row in ultraGrid1.Rows)
  543. {
  544. if (row.Cells["CHC"].Value.ToString() == "True")
  545. {
  546. return 1;
  547. }
  548. UltraGridRow[] rows = GridHelper.GetRowsWithKey(row.ChildBands[0],
  549. new string[] { "CHC" }, new string[] { "True" });
  550. if (rows.Length > 0)
  551. {
  552. return 1;
  553. }
  554. }
  555. return 0;
  556. }
  557. private DataRow GetComBaseStdRowByPk(string stdCode)
  558. {
  559. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComStandard.getComBaseStdByPk",
  560. new object[] { stdCode }, ob);
  561. return dt.Rows[0];
  562. }
  563. /// <summary>
  564. /// 保存
  565. /// </summary>
  566. private void DoSave()
  567. {
  568. ultraGrid1.UpdateData();
  569. if (GetGridSelectCount() == 0)
  570. {
  571. MessageBox.Show("请选择记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  572. return;
  573. }
  574. DataRow comBaseStdRow = null;
  575. if (CustomInfo == "2")
  576. {
  577. comBaseStdRow = GetComBaseStdRowByPk(stdCode);
  578. if (comBaseStdRow["ACCEPT_BID"].ToString() == "1" && comBaseStdRow["UNIT_CODE"].ToString() != UserInfo.GetDeptid()
  579. && UserInfo.GetUserID() != "admin" && UserInfo.GetUserID() != "longjinhua" && !"002023005003".Equals(UserInfo.GetDeptid()))
  580. {
  581. MessageUtil.ShowWarning("该记录只有[" + comBaseStdRow["UNIT_DESC"].ToString() + "]的成员才能操作!");
  582. return;
  583. }
  584. }
  585. string style = "G";
  586. if (CustomInfo == "2")
  587. {
  588. if (comBaseStdRow["ACCEPT_BID"].ToString() == "1")
  589. {
  590. style = "N";
  591. }
  592. else
  593. {
  594. style = "L";
  595. }
  596. }
  597. if (CustomInfo == "3")
  598. style = "K";
  599. if (CustomInfo == "4")
  600. style = "S";
  601. ArrayList baseList = new ArrayList();
  602. ArrayList childList = new ArrayList();
  603. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  604. {
  605. UltraGridRow ugr = ultraGrid1.Rows[i];//主项
  606. DataRow rowSic = null;
  607. if (Convert.ToBoolean(ugr.Cells["CHC"].Value))//是否选择
  608. {
  609. if (ugr.GetValue("VALIDFLAG") != "")
  610. {
  611. rowSic = GetMscSicBySic(ugr.GetValue("SIC"));
  612. }
  613. if (comBaseStdRow != null && comBaseStdRow["ACCEPT_BID"].ToString() == "0" && rowSic != null)
  614. {
  615. string[] units = ClsBaseInfo.GetUnitByUserName(rowSic["CREATE_NAME"].ToString(), ob, "002001007", "002001001", "002023005");
  616. if (units[0] != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin" && !"002023005003".Equals(UserInfo.GetDeptid()))
  617. {
  618. MessageUtil.ShowWarning("该记录只有[" + units[1] + "]才能操作!");
  619. ugr.Activate();
  620. return;
  621. }
  622. }
  623. SpecObject com = GetMasterData(ugr, rowSic);
  624. if (com == null)
  625. {
  626. MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  627. return;
  628. }
  629. baseList.Add(JSONFormat.Format(com));
  630. _sic = com.Sic;
  631. }
  632. if (ugr.HasChild()) //子项
  633. {
  634. if (ugr.Cells["VALIDFLAG"].Value.ToString().Equals("") && !Convert.ToBoolean(ugr.Cells["CHC"].Value))
  635. {
  636. MessageBox.Show("请选择主记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  637. return;
  638. }
  639. for (int j = 0; j < ugr.ChildBands[0].Rows.Count; j++)
  640. {
  641. UltraGridRow ugrChild = ugr.ChildBands[0].Rows[j];
  642. if (Convert.ToBoolean(ugrChild.Cells["CHC"].Value))
  643. {
  644. if (ugr.GetValue("VALIDFLAG") != "")
  645. {
  646. rowSic = GetMscSicBySic(ugr.GetValue("SIC"));
  647. }
  648. if (comBaseStdRow != null && comBaseStdRow["ACCEPT_BID"].ToString() == "0" && rowSic != null)
  649. {
  650. string[] units = ClsBaseInfo.GetUnitByUserName(rowSic["CREATE_NAME"].ToString(), ob, "002001007", "002001001", "002023005");
  651. if (units[0] != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin" && !"002023005003".Equals(UserInfo.GetDeptid()))
  652. {
  653. MessageUtil.ShowWarning("该记录只有[" + units[1] + "]才能操作!");
  654. ugrChild.Activate();
  655. return;
  656. }
  657. }
  658. SpecCObject comC = GetFromData(ugrChild, rowSic);
  659. if (comC == null)
  660. {
  661. MessageBox.Show(errMessage, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  662. return;
  663. }
  664. childList.Add(JSONFormat.Format(comC));
  665. _sic = comC.Sic;
  666. _isEx = true;
  667. }
  668. }
  669. }
  670. }
  671. if (MessageBox.Show("是否保存选择记录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  672. {
  673. return;
  674. }
  675. if (baseList.Count > 0 || childList.Count > 0)
  676. {
  677. int count = ServerHelper.SetData("com.steering.pss.qcm.CoreTolerances.saveCoreTolerances",
  678. new Object[] { baseList, childList, style }, this.ob);
  679. if (count > 0)
  680. {
  681. MessageBox.Show("保存成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  682. DoQuery();
  683. }
  684. }
  685. }
  686. /// <summary>
  687. /// 删除或者恢复
  688. /// </summary>
  689. /// <param name="flag">true 删除 false 恢复</param>
  690. private void DoDeleteOrResume(Boolean flag)
  691. {
  692. ultraGrid1.UpdateData();
  693. if (GetGridSelectCount() == 0)
  694. {
  695. MessageBox.Show("请选择记录!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  696. return;
  697. }
  698. DataRow comBaseStdRow = null;
  699. if (CustomInfo == "2")
  700. {
  701. comBaseStdRow = GetComBaseStdRowByPk(stdCode);
  702. if (comBaseStdRow["ACCEPT_BID"].ToString() == "1" && comBaseStdRow["UNIT_CODE"].ToString() != UserInfo.GetDeptid()
  703. && UserInfo.GetUserID() != "admin")
  704. {
  705. MessageUtil.ShowWarning("该记录只有[" + comBaseStdRow["UNIT_DESC"].ToString() + "]的成员才能" + (flag ? "作废" : "恢复") + "!");
  706. return;
  707. }
  708. }
  709. ArrayList baseList = new ArrayList();
  710. ArrayList childList = new ArrayList();
  711. for (int i = 0; i < ultraGrid1.Rows.Count; i++)
  712. {
  713. UltraGridRow ugr = ultraGrid1.Rows[i];
  714. if (Convert.ToBoolean(ugr.Cells["CHC"].Value))
  715. {
  716. DataRow rowSic = null;
  717. if (ugr.GetValue("VALIDFLAG") != "")
  718. {
  719. rowSic = GetMscSicBySic(ugr.GetValue("SIC"));
  720. }
  721. if (comBaseStdRow != null && comBaseStdRow["ACCEPT_BID"].ToString() == "0" && rowSic != null)
  722. {
  723. string[] units = ClsBaseInfo.GetUnitByUserName(rowSic["CREATE_NAME"].ToString(), ob, "002001007", "002001001", "002023005");
  724. if (units[0] != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin" && !"002023005003".Equals(UserInfo.GetDeptid()))
  725. {
  726. MessageUtil.ShowWarning("该记录只有[" + units[1] + "]才能操作!");
  727. ugr.Activate();
  728. return;
  729. }
  730. }
  731. if (CheckAuthority(ugr) == false)
  732. {
  733. MessageUtil.ShowWarning(errMessage);
  734. return;
  735. }
  736. if (ugr.Cells["VALIDFLAG"].Value.Equals("无效") && flag)
  737. {
  738. MessageBox.Show("无效记录不能作废!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  739. return;
  740. }
  741. if (flag && (ugr.Cells["VALIDFLAG"].Value.Equals("提交审核") || ugr.Cells["VALIDFLAG"].Value.Equals("已审核")))
  742. {
  743. MessageBox.Show("提交审核或已审核记录不能作废!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  744. return;
  745. }
  746. if (ugr.Cells["VALIDFLAG"].Value.Equals("有效") && !flag)
  747. {
  748. MessageBox.Show("有效记录不能恢复!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  749. return;
  750. }
  751. if (ugr.HasChild() && flag)
  752. {
  753. if (MessageBox.Show("对应子记录将全部作废!", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  754. {
  755. return;
  756. }
  757. foreach (UltraGridRow ugrc in ugr.ChildBands[0].Rows)
  758. {
  759. SpecCObject comc = new SpecCObject();
  760. comc.Sic = ugrc.Cells["SIC"].Value.ToString();
  761. comc.DeleteName = UserInfo.GetUserName();
  762. comc.IndexSeq = ugrc.Cells["INDEX_SEQ"].Value.ToString();
  763. childList.Add(JSONFormat.Format(comc));
  764. }
  765. }
  766. SpecObject com = new SpecObject();
  767. com.Sic = ugr.Cells["SIC"].Value.ToString();
  768. com.DeleteName = UserInfo.GetUserName();
  769. baseList.Add(JSONFormat.Format(com));
  770. _sic = com.Sic;
  771. }
  772. if (ugr.HasChild())
  773. {
  774. for (int j = 0; j < ugr.ChildBands[0].Rows.Count; j++)
  775. {
  776. UltraGridRow ugrc = ugr.ChildBands[0].Rows[j];
  777. if (Convert.ToBoolean(ugrc.Cells["CHC"].Value))
  778. {
  779. DataRow rowSic = null;
  780. if (ugr.GetValue("VALIDFLAG") != "")
  781. {
  782. rowSic = GetMscSicBySic(ugr.GetValue("SIC"));
  783. }
  784. if (comBaseStdRow != null && comBaseStdRow["ACCEPT_BID"].ToString() == "0" && rowSic != null)
  785. {
  786. string[] units = ClsBaseInfo.GetUnitByUserName(rowSic["CREATE_NAME"].ToString(), ob, "002001007", "002001001", "002023005");
  787. if (units[0] != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin" && !"002023005003".Equals(UserInfo.GetDeptid()))
  788. {
  789. MessageUtil.ShowWarning("该记录只有[" + units[1] + "]才能操作!");
  790. ugrc.Activate();
  791. return;
  792. }
  793. }
  794. if (CheckAuthority(ugrc) == false)
  795. {
  796. MessageUtil.ShowWarning(errMessage);
  797. return;
  798. }
  799. if (!flag && ugrc.ParentRow.Cells["VALIDFLAG"].Value.Equals("无效") && !Convert.ToBoolean(ugrc.ParentRow.Cells["CHC"].Value))
  800. {
  801. MessageBox.Show("请选择主记录", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  802. return;
  803. }
  804. if (ugrc.Cells["VALIDFLAG"].Value.Equals("无效") && flag)
  805. {
  806. MessageBox.Show("无效记录不能作废!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  807. return;
  808. }
  809. if (ugrc.Cells["VALIDFLAG"].Value.Equals("有效") && !flag)
  810. {
  811. MessageBox.Show("有效记录不能恢复!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  812. return;
  813. }
  814. if (flag)
  815. {
  816. if (ugrc.ParentRow.Cells["VALIDFLAG"].Value.ToString() != "录入状态"
  817. && ugrc.ParentRow.Cells["VALIDFLAG"].Value.ToString() != "无效"
  818. && ugr.Cells["VALIDFLAG"].Value.ToString() != "")
  819. {
  820. MessageUtil.ShowWarning("主记录为提交审核或已审核状态时,无法作废");
  821. return;
  822. }
  823. }
  824. SpecCObject comc = new SpecCObject();
  825. comc.Sic = ugrc.Cells["SIC"].Value.ToString();
  826. comc.DeleteName = UserInfo.GetUserName();
  827. comc.IndexSeq = ugrc.Cells["INDEX_SEQ"].Value.ToString();
  828. childList.Add(JSONFormat.Format(comc));
  829. _sic = comc.Sic;
  830. _isEx = true;
  831. }
  832. }
  833. }
  834. }
  835. if (MessageBox.Show("是否" + (flag ? "作废" : "恢复") + "选择记录?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
  836. {
  837. return;
  838. }
  839. if (baseList.Count > 0 || childList.Count > 0)
  840. {
  841. int count = ServerHelper.SetData("com.steering.pss.qcm.CoreTolerances.deleteOrResume", new Object[] { baseList, childList, flag }, this.ob);
  842. if (count > 0)
  843. {
  844. DoQuery();
  845. MessageBox.Show((flag ? "作废" : "恢复") + "成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  846. }
  847. }
  848. }
  849. /// <summary>
  850. /// 分组
  851. /// </summary>
  852. private void Group(bool isGroup)
  853. {
  854. string str = isGroup ? "分组" : "取消分组";
  855. ArrayList list = new ArrayList();
  856. int cnt = 0;
  857. foreach (UltraGridRow row in ultraGrid1.Rows)
  858. {
  859. if (row.GetValue("CHC") == "True")
  860. {
  861. MessageUtil.ShowWarning("不能对主记录进行" + str + "!");
  862. return;
  863. }
  864. ArrayList listSub = new ArrayList();
  865. listSub.Add(row.GetValue("SIC"));
  866. string strIndexs = "''";
  867. foreach (UltraGridRow row2 in row.ChildBands[0].Rows)
  868. {
  869. if (row2.GetValue("CHC") != "True") continue;
  870. if (row2.GetValue("CREATE_TIME") == "")
  871. {
  872. MessageUtil.ShowWarning("您选择的分组记录中存在未保存的项,请先保存后再" + str + "!");
  873. return;
  874. }
  875. if (row2.GetValue("VALIDFLAG") == "无效")
  876. {
  877. MessageUtil.ShowWarning("您选择的分组记录中存在无效数据,无法" + str + "!");
  878. return;
  879. }
  880. strIndexs += ", '" + row2.GetValue("INDEX_SEQ") + "'";
  881. cnt++;
  882. }
  883. strIndexs = strIndexs.Substring(1);
  884. strIndexs = strIndexs.Substring(0, strIndexs.Length - 1);
  885. listSub.Add(strIndexs);
  886. if (strIndexs != "")
  887. {
  888. _sic = row.GetValue("SIC");
  889. _isEx = true;
  890. list.Add(listSub);
  891. }
  892. }
  893. if (cnt == 0)
  894. {
  895. MessageUtil.ShowWarning("请选择您要" + str + "的记录!");
  896. return;
  897. }
  898. if (MessageUtil.ShowYesNoAndQuestion("是否确认" + str + "!") == DialogResult.No)
  899. {
  900. return;
  901. }
  902. ServerHelper.SetData("com.steering.pss.qcm.CoreTolerances.group",
  903. new object[] { list, isGroup }, this.ob);
  904. MessageUtil.ShowTips(str + "成功!");
  905. DoQuery();
  906. }
  907. /// <summary>
  908. /// 增加一行事件
  909. /// </summary>
  910. /// <param name="sender"></param>
  911. /// <param name="e"></param>
  912. private void ultraGrid1_AfterRowInsert(object sender, RowEventArgs e)
  913. {
  914. UltraGridRow ugr = ultraGrid1.DisplayLayout.ActiveRow;
  915. string style = "G";
  916. if (CustomInfo == "2")
  917. style = "N";
  918. if (CustomInfo == "3")
  919. style = "K";
  920. if (CustomInfo == "4")
  921. style = "S";
  922. if (!ugr.HasParent()) //主表自动填充主键(成分索引号)
  923. {
  924. string sic = "";
  925. int temp = 0;
  926. for (int i = 0; i < ultraGrid1.Rows.Count - 1; i++)
  927. {
  928. string str = ultraGrid1.Rows[i].Cells["SIC"].Value.ToString().Substring(4, 6);
  929. if (Convert.ToInt32(str) > temp)
  930. temp = Convert.ToInt32(str);
  931. }
  932. sic = "SIC" + style + string.Format("{0:000000}", temp + 1);
  933. ugr.Cells["SIC"].Value = sic;
  934. }
  935. //从表自动填充序号
  936. if (ugr.HasParent())
  937. {
  938. int index = 0;
  939. string cic = ugr.Cells["SIC"].Value.ToString();
  940. foreach (UltraGridRow ug in ultraGrid1.Rows)
  941. {
  942. if (ug.Cells["SIC"].Value.ToString().Equals(cic))
  943. {
  944. for (int i = 0; i < ug.ChildBands[0].Rows.Count - 1; i++)
  945. {
  946. int indexSeq = Convert.ToInt32(ug.ChildBands[0].Rows[i].Cells["INDEX_SEQ"].Value.ToString());
  947. if (indexSeq > index)
  948. index = indexSeq;
  949. }
  950. }
  951. }
  952. ugr.Cells["INDEX_SEQ"].Value = index + 1;
  953. ugr.Cells["ISCHECK"].Value = true;
  954. ugr.Cells["STD_MIN_FORMULA_V"].Value = true;
  955. ugr.Cells["STD_MAX_FORMULA_V"].Value = false;
  956. }
  957. //增加行如果没有勾选则不可编辑
  958. if (!Convert.ToBoolean(ugr.Cells["CHC"].Value))
  959. {
  960. for (int i = 0; i < ugr.Cells.Count; i++)
  961. {
  962. if (!ugr.Cells[i].Column.Key.Equals("CHC"))
  963. ugr.Cells[i].Activation = Activation.ActivateOnly;
  964. if (ugr.Cells[i].Column.Key.Equals("CHKNK"))
  965. ugr.Cells["CHKNK"].Value = "选择";
  966. }
  967. }
  968. e.Row.Update();
  969. }
  970. /// <summary>
  971. /// 下拉事件
  972. /// </summary>
  973. /// <param name="sender"></param>
  974. /// <param name="e"></param>
  975. public void ultraGrid1_CellChange(object sender, CellEventArgs e)
  976. {
  977. ultraGrid1.UpdateData();
  978. UltraGridRow ugr = ultraGrid1.DisplayLayout.ActiveRow;
  979. if (ugr == null)
  980. return;
  981. if (e.Cell.Column.Key.Equals("MSC"))//冶金规范码
  982. {
  983. string msc = ugr.Cells["MSC"].Value.ToString();
  984. DataRow[] dr = ((DataTable)ultras[0].DataSource).Select("MSC='" + msc + "'");
  985. if (dr.Length > 0)
  986. {
  987. ugr.Cells["PSC"].Value = dr[0][2];
  988. ugr.Cells["PSC_DESC"].Value = dr[0][3];
  989. ugr.Cells["PRODUCNAME"].Value = dr[0][4];
  990. ugr.Cells["STD_NAME"].Value = dr[0][5];
  991. ugr.Cells["STEELNAME"].Value = dr[0][6];
  992. ugr.Cells["STD_STYLE_DESC"].Value = dr[0][7];
  993. ugr.Cells["STDSTYLE"].Value = dr[0][8];
  994. }
  995. return;
  996. }
  997. if (e.Cell.Column.Key.Equals("STD_CODE")) //标准类型
  998. {
  999. string stdCode = ugr.Cells["STD_CODE"].Value.ToString();
  1000. DataRow[] dr = ((DataTable)ultras[5].DataSource).Select("STD_CODE='" + stdCode + "'");
  1001. if (dr.Length > 0)
  1002. {
  1003. ugr.Cells["STD_NAME"].Value = dr[0][1];
  1004. ugr.Cells["STDSTYLE"].Value = dr[0][2];
  1005. }
  1006. }
  1007. if (e.Cell.Column.Key.Equals("BIAS_CODE")) //公差主项
  1008. {
  1009. ugr.Cells["BIAS_NAME"].Value = ugr.Cells["BIAS_CODE"].Text;
  1010. }
  1011. if (e.Cell.Column.Key.Equals("BIAS_CODE_Z"))//公差约束项一
  1012. {
  1013. ugr.Cells["BIAS_NAME_Z"].Value = ugr.Cells["BIAS_CODE_Z"].Text;
  1014. string biasnamez = ugr.Cells["BIAS_NAME_Z"].Value.ToString();
  1015. string biasnames = ugr.Cells["BIAS_NAME_S"].Value.ToString();
  1016. string biasnamec = ugr.Cells["BIAS_NAME_C"].Value.ToString();
  1017. if (!biasnamez.Equals(""))
  1018. {
  1019. if (biasnamez.Equals(biasnames) || biasnamez.Equals(biasnamec))
  1020. {
  1021. ugr.Cells["BIAS_NAME_Z"].Value = "";
  1022. ugr.Cells["BIAS_CODE_Z"].Value = "";
  1023. MessageBox.Show("公差约束项不能相同", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1024. return;
  1025. }
  1026. }
  1027. if (ugr.Cells["BIAS_CODE_Z"].Value.ToString() == "")
  1028. {
  1029. ugr.Cells["ZMIN_SIGN"].Value = "";
  1030. ugr.Cells["ZMIN"].Value = "";
  1031. ugr.Cells["ZMAX_SIGN"].Value = "";
  1032. ugr.Cells["ZMAX"].Value = "";
  1033. }
  1034. }
  1035. if (e.Cell.Column.Key.Equals("BIAS_CODE_C"))//公差约束项二
  1036. {
  1037. ugr.Cells["BIAS_NAME_C"].Value = ugr.Cells["BIAS_CODE_C"].Text;
  1038. string biasnamez = ugr.Cells["BIAS_NAME_Z"].Value.ToString();
  1039. string biasnames = ugr.Cells["BIAS_NAME_S"].Value.ToString();
  1040. string biasnamec = ugr.Cells["BIAS_NAME_C"].Value.ToString();
  1041. if (!biasnamec.Equals(""))
  1042. {
  1043. if (biasnamec.Equals(biasnames) || biasnamec.Equals(biasnamez))
  1044. {
  1045. ugr.Cells["BIAS_NAME_C"].Value = "";
  1046. ugr.Cells["BIAS_CODE_C"].Value = "";
  1047. MessageBox.Show("公差约束项不能相同", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1048. return;
  1049. }
  1050. }
  1051. if (ugr.Cells["BIAS_CODE_C"].Value.ToString() == "")
  1052. {
  1053. ugr.Cells["CMIN_SIGN"].Value = "";
  1054. ugr.Cells["CMIN"].Value = "";
  1055. ugr.Cells["CMAX_SIGN"].Value = "";
  1056. ugr.Cells["CMAX"].Value = "";
  1057. }
  1058. }
  1059. if (e.Cell.Column.Key.Equals("BIAS_CODE_S"))//公差约束项三
  1060. {
  1061. ugr.Cells["BIAS_NAME_S"].Value = ugr.Cells["BIAS_CODE_S"].Text;
  1062. string biasnamez = ugr.Cells["BIAS_NAME_Z"].Value.ToString();
  1063. string biasnames = ugr.Cells["BIAS_NAME_S"].Value.ToString();
  1064. string biasnamec = ugr.Cells["BIAS_NAME_C"].Value.ToString();
  1065. if (!biasnames.Equals(""))
  1066. {
  1067. if (biasnames.Equals(biasnamec) || biasnames.Equals(biasnamez))
  1068. {
  1069. ugr.Cells["BIAS_NAME_S"].Value = "";
  1070. ugr.Cells["BIAS_CODE_S"].Value = "";
  1071. MessageBox.Show("公差约束项不能相同", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1072. return;
  1073. }
  1074. }
  1075. if (ugr.Cells["BIAS_CODE_S"].Value.ToString() == "")
  1076. {
  1077. ugr.Cells["SMIN_SIGN"].Value = "";
  1078. ugr.Cells["SMIN"].Value = "";
  1079. ugr.Cells["SMAX_SIGN"].Value = "";
  1080. ugr.Cells["SMAX"].Value = "";
  1081. }
  1082. }
  1083. if (e.Cell.Column.Key.Equals("PROCESS_CODE")) //工序
  1084. {
  1085. ugr.Cells["PROCESS_DESC"].Value = ugr.Cells["PROCESS_CODE"].Text;
  1086. }
  1087. if (e.Cell.Column.Key.Equals("STD_MIN_FORMULA_V"))
  1088. {
  1089. if (Convert.ToBoolean(e.Cell.Value.ToString()) == true)
  1090. {
  1091. ugr.Cells["STD_MAX_FORMULA_V"].Value = false;
  1092. }
  1093. }
  1094. if (e.Cell.Column.Key.Equals("STD_MAX_FORMULA_V"))
  1095. {
  1096. if (Convert.ToBoolean(e.Cell.Value.ToString()) == true)
  1097. {
  1098. ugr.Cells["STD_MIN_FORMULA_V"].Value = false;
  1099. }
  1100. }
  1101. if (e.Cell.Column.Key.Equals("CHC"))//选择
  1102. {
  1103. Activation activation = Activation.ActivateOnly;
  1104. if (Convert.ToBoolean(e.Cell.Value))
  1105. {
  1106. activation = Activation.AllowEdit;
  1107. //isSelect += 1;
  1108. }
  1109. //else
  1110. // isSelect -= 1;
  1111. CellsCollection cells = e.Cell.Row.Cells;
  1112. for (int i = 0; i < cells.Count; i++)
  1113. {
  1114. if (!cells[i].Column.Key.Equals("CHC"))
  1115. {
  1116. if (cells[i].Column.Key == "GROUP_SEQ") continue;
  1117. e.Cell.Row.Cells[i].Activation = activation;
  1118. }
  1119. }
  1120. }
  1121. }
  1122. private DataTable GetMscTabByMsc(string msc)
  1123. {
  1124. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreFrmProPSCMSC2.getComMscByMsc",
  1125. new object[] { msc }, ob);
  1126. return dt;
  1127. }
  1128. private string GetMscBySic(string sic)
  1129. {
  1130. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreTolerances.getComSicBySic",
  1131. new object[] { sic }, ob);
  1132. if (dt.Rows.Count > 0)
  1133. {
  1134. return dt.Rows[0]["MSC"].ToString();
  1135. }
  1136. return "";
  1137. }
  1138. /// <summary>
  1139. /// 通过主键查询公差主表
  1140. /// </summary>
  1141. /// <param name="sic"></param>
  1142. /// <returns></returns>
  1143. private DataRow GetMscSicBySic(string sic)
  1144. {
  1145. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.CoreTolerances.getComSicBySic",
  1146. new object[] { sic }, ob);
  1147. if (dt.Rows.Count == 0)
  1148. {
  1149. return null;
  1150. }
  1151. else
  1152. {
  1153. return dt.Rows[0];
  1154. }
  1155. }
  1156. private bool CheckAuthority(UltraGridRow row)
  1157. {
  1158. if (CustomInfo == "1")
  1159. {
  1160. string mscOld;
  1161. if (row.GetValue("VALIDFLAG") != "")
  1162. {
  1163. mscOld = GetMscBySic(row.GetValue("SIC"));
  1164. }
  1165. else
  1166. {
  1167. mscOld = row.HasParent() ? row.ParentRow.GetValue("MSC") : row.GetValue("MSC");
  1168. }
  1169. DataTable dtMsc = GetMscTabByMsc(mscOld);
  1170. //if (dtMsc.Rows[0]["UNIT_CODE"].ToString() != UserInfo.GetDeptid() && UserInfo.GetUserID() != "admin")
  1171. //{
  1172. // errMessage = "该条记录对应的冶金规范是[" + dtMsc.Rows[0]["UNIT_DESC"].ToString() + "]科室维护的,您没有权限!";
  1173. // row.Activate();
  1174. // return false;
  1175. //}
  1176. }
  1177. return true;
  1178. }
  1179. /// <summary>
  1180. /// 新增或者修改项 主表
  1181. /// </summary>
  1182. /// <param name="i">行</param>
  1183. /// <returns></returns>
  1184. private SpecObject GetMasterData(UltraGridRow ugr, DataRow rowSic)
  1185. {
  1186. string sic = ugr.Cells["SIC"].Text.ToString();
  1187. string psc = ugr.Cells["PSC"].Text.ToString();
  1188. string msc = ugr.Cells["MSC"].Value.ToString();
  1189. if (CustomInfo == "1" && msc.Equals(""))
  1190. if (msc.Equals(""))
  1191. {
  1192. errMessage = "请选择冶金规范码";
  1193. return null;
  1194. }
  1195. if (CheckAuthority(ugr) == false) return null;
  1196. string stdStyle = ugr.Cells["STDSTYLE"].Text.ToString();
  1197. string stdCode = ugr.Cells["STD_CODE"].Value.ToString();
  1198. string stdName = ugr.Cells["STD_NAME"].Text.ToString();
  1199. if (CustomInfo != "1" && stdName.Equals(""))
  1200. {
  1201. errMessage = "请选择标准名称";
  1202. return null;
  1203. }
  1204. if (stdStyle.Equals("内控"))
  1205. stdStyle = "N";
  1206. else if (stdStyle.Equals("订货标准"))
  1207. stdStyle = "G";
  1208. else if (stdStyle.Equals("协议标准"))
  1209. stdStyle = "X";
  1210. else if (stdStyle.Equals("Alpha"))
  1211. stdStyle = "K";
  1212. else if (stdStyle.Equals("试验标准"))
  1213. stdStyle = "S";
  1214. else if (stdStyle.Equals("成分偏差标准"))
  1215. stdStyle = "P";
  1216. else
  1217. stdStyle = "";
  1218. string processCode = ugr.Cells["PROCESS_CODE"].Value.ToString();
  1219. string processDesc = ugr.Cells["PROCESS_DESC"].Text.ToString();
  1220. string modelCode = ugr.Cells["MODEL_CODE"].Value.ToString();
  1221. string modelDesc = ugr.Cells["MODEL_DESC"].Text.ToString();
  1222. string stdmemo = ugr.Cells["STDMEMO"].Text.ToString();
  1223. string userName = UserInfo.GetUserName();
  1224. string createTime = ugr.Cells["CREATE_TIME"].Value.ToString();
  1225. string userTime = System.DateTime.Now.ToString();
  1226. string validflag = ugr.Cells["VALIDFLAG"].Value.ToString();
  1227. string steelcodeNk = ugr.GetValue("STEELCODE_NK");
  1228. string steelnameNk = ugr.GetValue("STEELNAME_NK");
  1229. string modelCodeNk = ugr.GetValue("MODEL_CODE_NK");
  1230. string modelDescNk = ugr.GetValue("MODEL_DESC_NK");
  1231. string produccodeNk = ugr.GetValue("PRODUCCODE_NK");
  1232. string producnameNk = ugr.GetValue("PRODUCNAME_NK");
  1233. if (rowSic != null && (rowSic["VALIDFLAG"].ToString() == "2" || rowSic["VALIDFLAG"].ToString() == "3"))
  1234. {
  1235. errMessage = "提交审核或已审核记录不能保存!";
  1236. return null;
  1237. }
  1238. String specialPath = ugr.Cells["SPECIAL_PATH"].Value.ToString();
  1239. if (specialPath.Equals(""))
  1240. {
  1241. specialPath = "0";
  1242. }
  1243. else
  1244. {
  1245. if (Boolean.Parse(specialPath))
  1246. {
  1247. specialPath = "1";
  1248. }
  1249. else
  1250. {
  1251. specialPath = "0";
  1252. }
  1253. }
  1254. //if(CustomInfo == "2" && produccodeNk == "")
  1255. //{
  1256. // errMessage = "请选择品名!";
  1257. // return null;
  1258. //}
  1259. SpecObject com = new SpecObject();
  1260. com.Sic = sic;
  1261. com.Psc = psc;
  1262. com.Msc = msc;
  1263. com.StdCode = stdCode;
  1264. com.StdStyle = stdStyle;
  1265. com.StdName = stdName;
  1266. com.ProcessCode = processCode;
  1267. com.ProcessDesc = processDesc;
  1268. com.ModelCode = modelCode;
  1269. com.ModelDesc = modelDesc;
  1270. com.StdMemo = stdmemo;
  1271. com.ProducHead = ugr.GetValue("PRODUC_HEAD");
  1272. com.CodeJg = codeJg == "DefaultValue" ? "" : codeJg;
  1273. com.CreateName = userName;
  1274. com.CreateTime = createTime;
  1275. com.UpdateName = userName;
  1276. com.DeleteName = userName;
  1277. com.Validflag = validflag;
  1278. com.SpecialPath = specialPath;
  1279. com.SteelcodeNk = steelcodeNk;
  1280. com.SteelnameNk = steelnameNk;
  1281. com.ModelCodeNk = modelCodeNk;
  1282. com.ModelDescNk = modelDescNk;
  1283. com.ProduccodeNk = produccodeNk;
  1284. com.ProducnameNk = producnameNk;
  1285. return com;
  1286. }
  1287. /// <summary>
  1288. /// 新增或者修改项 从表
  1289. /// </summary>
  1290. /// <param name="i">行</param>
  1291. /// <returns></returns>
  1292. private SpecCObject GetFromData(UltraGridRow rows, DataRow rowSic)
  1293. {
  1294. if (CheckAuthority(rows) == false) return null;
  1295. if (rowSic != null && (rowSic["VALIDFLAG"].ToString() == "2" || rowSic["VALIDFLAG"].ToString() == "3"))
  1296. {
  1297. errMessage = "主记录为提交审核或已审核状态时,无法修改";
  1298. return null;
  1299. }
  1300. SpecCObject com = new SpecCObject();
  1301. com.Sic = rows.Cells["SIC"].Value.ToString().Trim();
  1302. com.IndexSeq = rows.Cells["INDEX_SEQ"].Value.ToString().Trim();
  1303. com.BiasCode = rows.Cells["BIAS_CODE"].Value.ToString().Trim();
  1304. com.BiasName = rows.Cells["BIAS_CODE"].Text.Trim();
  1305. if (com.BiasCode.Equals(""))
  1306. {
  1307. errMessage = "请选择公差项";
  1308. return null;
  1309. }
  1310. com.Lv = rows.Cells["LV"].Value.ToString().Trim();
  1311. com.BiasCodeZ = rows.Cells["BIAS_CODE_Z"].Value.ToString().Trim();
  1312. com.BiasNameZ = rows.Cells["BIAS_CODE_Z"].Text;
  1313. com.ZminSign = rows.Cells["ZMIN_SIGN"].Value.ToString().Trim();
  1314. com.Zmin = rows.Cells["ZMIN"].Value.ToString().Trim();
  1315. com.ZmaxSign = rows.Cells["ZMAX_SIGN"].Value.ToString().Trim();
  1316. com.Zmax = rows.Cells["ZMAX"].Value.ToString().Trim();
  1317. if (!com.BiasCodeZ.Equals(""))
  1318. {
  1319. if (com.ZminSign.Equals("=") && !com.ZmaxSign.Equals(""))
  1320. {
  1321. errMessage = "公差约束项<一>:下限符号为‘=’,不能选择上限符号";
  1322. return null;
  1323. }
  1324. if (com.ZminSign.Equals("") && com.ZmaxSign.Equals(""))
  1325. {
  1326. errMessage = "请选择公差约束项<一>:下限符号或者上限符号";
  1327. return null;
  1328. }
  1329. //上限符号与上限值
  1330. if (!com.Zmax.Equals(""))
  1331. {
  1332. if (com.ZmaxSign.Equals(""))
  1333. {
  1334. errMessage = "请选择公差约束项<一>:上限符号";
  1335. return null;
  1336. }
  1337. if (StringUtil.IsNumber(com.Zmax) && com.Zmax.Length > 10)
  1338. {
  1339. errMessage = "公差约束项<一>:上限值(10位以内数字)";
  1340. return null;
  1341. }
  1342. string zMax = com.Zmax.Replace("t", "1.0").Replace("D", "1.0").Replace("L", "1.0");
  1343. if (!StringUtil.IsNumber(com.Zmax) && zMax.CompileFormula() == null)
  1344. {
  1345. errMessage = "公差约束项<一>:上限值(请输入合法公式!)";
  1346. return null;
  1347. }
  1348. }
  1349. else
  1350. {
  1351. if (!com.ZmaxSign.Equals(""))
  1352. {
  1353. errMessage = "请输入公差约束项<一>:上限值";
  1354. return null;
  1355. }
  1356. }
  1357. //下限符号与下限值
  1358. if (!com.Zmin.Equals(""))
  1359. {
  1360. if (com.ZminSign.Equals(""))
  1361. {
  1362. errMessage = "请选择公差约束项<一>:下限符号";
  1363. return null;
  1364. }
  1365. if (StringUtil.IsNumber(com.Zmin) && com.Zmin.Length > 10)
  1366. {
  1367. errMessage = "请输入公差约束项<一>:下限值(10位以内数字)";
  1368. return null;
  1369. }
  1370. string zMin = com.Zmin.Replace("t", "1.0").Replace("D", "1.0").Replace("L", "1.0");
  1371. if (!StringUtil.IsNumber(com.Zmin) && zMin.CompileFormula() == null)
  1372. {
  1373. errMessage = "公差约束项<一>:下限值(请输入合法公式!)";
  1374. return null;
  1375. }
  1376. }
  1377. else
  1378. {
  1379. if (!com.ZminSign.Equals(""))
  1380. {
  1381. errMessage = "请输入公差约束项<一>:下限值";
  1382. return null;
  1383. }
  1384. }
  1385. if (!com.Zmax.Equals("") && !com.Zmin.Equals("")) //&&Convert.ToDouble(com.Zmin)>Convert.ToDouble(com.Zmax)
  1386. {
  1387. int retrunValue = QcmBaseInfo.CheckStdData(com.ZminSign, com.ZmaxSign, com.Zmin, com.Zmax);
  1388. if (retrunValue == 0)
  1389. {
  1390. errMessage = "输入的数据不完整";
  1391. return null;
  1392. }
  1393. if (retrunValue == 1)
  1394. {
  1395. errMessage = "公差约束项<一>下限值与上限值相等,上下限符号请选择<=和>=";
  1396. return null;
  1397. }
  1398. if (retrunValue == 2)
  1399. {
  1400. errMessage = "公差约束项<一>下限值不能大于上限值";
  1401. return null;
  1402. }
  1403. }
  1404. }
  1405. else
  1406. {
  1407. if (!com.ZminSign.Equals("") || !com.Zmin.Equals("") || !com.ZmaxSign.Equals("") || !com.Zmax.Equals(""))
  1408. {
  1409. errMessage = "请选择公差约束项<一>:公差约束项";
  1410. return null;
  1411. }
  1412. }
  1413. //公差约束项二
  1414. com.BiasCodeC = rows.Cells["BIAS_CODE_C"].Value.ToString().Trim();
  1415. com.BiasNameC = rows.Cells["BIAS_CODE_C"].Text;
  1416. com.CminSign = rows.Cells["CMIN_SIGN"].Value.ToString().Trim();
  1417. com.Cmin = rows.Cells["CMIN"].Value.ToString().Trim();
  1418. com.CmaxSign = rows.Cells["CMAX_SIGN"].Value.ToString().Trim();
  1419. com.Cmax = rows.Cells["CMAX"].Value.ToString().Trim();
  1420. if (!com.BiasCodeC.Equals(""))
  1421. {
  1422. if (com.CminSign.Equals("=") && !com.CmaxSign.Equals(""))
  1423. {
  1424. errMessage = "公差约束项<二>:下限符号为‘=’,不能选择上限符号";
  1425. return null;
  1426. }
  1427. if (com.CminSign.Equals("") && com.CmaxSign.Equals(""))
  1428. {
  1429. errMessage = "请选择公差约束项<二>:下限符号或者上限符号";
  1430. return null;
  1431. }
  1432. //上限符号与上限值
  1433. if (!com.Cmax.Equals(""))
  1434. {
  1435. if (com.CmaxSign.Equals(""))
  1436. {
  1437. errMessage = "请选择公差约束项<二>:上限符号";
  1438. return null;
  1439. }
  1440. if (StringUtil.IsNumber(com.Cmax) && com.Cmax.Length > 10)
  1441. {
  1442. errMessage = "请输入公差约束项<二>:上限值(10位以内数字)";
  1443. return null;
  1444. }
  1445. string Cmax = com.Cmax.Replace("t", "1.0").Replace("D", "1.0").Replace("L", "1.0");
  1446. if (!StringUtil.IsNumber(com.Cmax) && Cmax.CompileFormula() == null)
  1447. {
  1448. errMessage = "公差约束项<二>:上限值(请输入合法公式!)";
  1449. return null;
  1450. }
  1451. }
  1452. else
  1453. {
  1454. if (!com.CmaxSign.Equals(""))
  1455. {
  1456. errMessage = "请输入公差约束项<二>:上限值";
  1457. return null;
  1458. }
  1459. }
  1460. //下限符号与下限值
  1461. if (!com.Cmin.Equals(""))
  1462. {
  1463. if (com.CminSign.Equals(""))
  1464. {
  1465. errMessage = "请选择公差约束项<二>:下限符号";
  1466. return null;
  1467. }
  1468. if (StringUtil.IsNumber(com.Cmin) && com.Cmin.Length > 10)
  1469. {
  1470. errMessage = "请输入公差约束项<二>:下限值(10位以内数字)";
  1471. return null;
  1472. }
  1473. string Cmin = com.Cmin.Replace("t", "1.0").Replace("D", "1.0").Replace("L", "1.0");
  1474. if (!StringUtil.IsNumber(com.Cmin) && Cmin.CompileFormula() == null)
  1475. {
  1476. errMessage = "公差约束项<二>:下限值(请输入合法公式!)";
  1477. return null;
  1478. }
  1479. }
  1480. else
  1481. {
  1482. if (!com.CminSign.Equals(""))
  1483. {
  1484. errMessage = "请输入公差约束项<二>:下限值";
  1485. return null;
  1486. }
  1487. }
  1488. if (!com.Cmax.Equals("") && !com.Cmin.Equals("")) // && Convert.ToDouble(com.Cmin) > Convert.ToDouble(com.Cmax)
  1489. {
  1490. int retrunValue = QcmBaseInfo.CheckStdData(com.CminSign, com.CmaxSign, com.Cmin, com.Cmax);
  1491. if (retrunValue == 0)
  1492. {
  1493. errMessage = "输入的数据不完整";
  1494. return null;
  1495. }
  1496. if (retrunValue == 1)
  1497. {
  1498. errMessage = "公差约束项<二>下限值与上限值相等,上下限符号请选择<=和>=";
  1499. return null;
  1500. }
  1501. if (retrunValue == 2)
  1502. {
  1503. errMessage = "公差约束项<二>下限值不能大于上限值";
  1504. return null;
  1505. }
  1506. }
  1507. }
  1508. else
  1509. {
  1510. if (!com.CminSign.Equals("") || !com.Cmin.Equals("") || !com.CmaxSign.Equals("") || !com.Cmax.Equals(""))
  1511. {
  1512. errMessage = "请选择公差约束项<二>:公差约束项";
  1513. return null;
  1514. }
  1515. }
  1516. //公差约束项三
  1517. com.BiasCodeS = rows.Cells["BIAS_CODE_S"].Value.ToString().Trim();
  1518. com.BiasNameS = rows.Cells["BIAS_CODE_S"].Text;
  1519. com.SminSign = rows.Cells["SMIN_SIGN"].Value.ToString().Trim();
  1520. com.Smin = rows.Cells["SMIN"].Value.ToString().Trim();
  1521. com.SmaxSign = rows.Cells["SMAX_SIGN"].Value.ToString().Trim();
  1522. com.Smax = rows.Cells["SMAX"].Value.ToString().Trim();
  1523. if (!com.BiasCodeS.Equals(""))
  1524. {
  1525. if (com.SminSign.Equals("=") && !com.SmaxSign.Equals(""))
  1526. {
  1527. errMessage = "公差约束项<三>:下限符号为‘=’,不能选择上限符号";
  1528. return null;
  1529. }
  1530. if (com.SminSign.Equals("") && com.SmaxSign.Equals(""))
  1531. {
  1532. errMessage = "请选择公差约束项<三>:下限符号或者上限符号";
  1533. return null;
  1534. }
  1535. //上限符号与上限值
  1536. if (!com.Smax.Equals(""))
  1537. {
  1538. if (com.SmaxSign.Equals(""))
  1539. {
  1540. errMessage = "请选择公差约束项<三>:上限符号";
  1541. return null;
  1542. }
  1543. if (StringUtil.IsNumber(com.Smax) && com.Smax.Length > 10)
  1544. {
  1545. errMessage = "请输入公差约束项<三>:上限值(10位以内数字)";
  1546. return null;
  1547. }
  1548. string Smax = com.Smax.Replace("t", "1.0").Replace("D", "1.0").Replace("L", "1.0");
  1549. if (!StringUtil.IsNumber(com.Smax) && Smax.CompileFormula() == null)
  1550. {
  1551. errMessage = "公差约束项<三>:上限值(请输入合法公式!)";
  1552. return null;
  1553. }
  1554. }
  1555. else
  1556. {
  1557. if (!com.SmaxSign.Equals(""))
  1558. {
  1559. errMessage = "请输入公差约束项<三>:上限值";
  1560. return null;
  1561. }
  1562. }
  1563. //下限符号与下限值
  1564. if (!com.Smin.Equals(""))
  1565. {
  1566. if (com.SminSign.Equals(""))
  1567. {
  1568. errMessage = "请选择公差约束项<三>:下限符号";
  1569. return null;
  1570. }
  1571. if (StringUtil.IsNumber(com.Smin) && com.Smin.Length > 10)
  1572. {
  1573. errMessage = "请输入公差约束项<三>:下限值(10位以内数字)";
  1574. return null;
  1575. }
  1576. string Smin = com.Smin.Replace("t", "1.0").Replace("D", "1.0").Replace("L", "1.0");
  1577. if (!StringUtil.IsNumber(com.Smin) && Smin.CompileFormula() == null)
  1578. {
  1579. errMessage = "公差约束项<三>:下限值(请输入合法公式!)";
  1580. return null;
  1581. }
  1582. }
  1583. else
  1584. {
  1585. if (!com.SminSign.Equals(""))
  1586. {
  1587. errMessage = "请输入公差约束项<三>:下限值";
  1588. return null;
  1589. }
  1590. }
  1591. if (!com.Smax.Equals("") && !com.Smin.Equals("")) //&& Convert.ToDouble(com.Smin) > Convert.ToDouble(com.Smax)
  1592. {
  1593. int retrunValue = QcmBaseInfo.CheckStdData(com.SminSign, com.SmaxSign, com.Smin, com.Smax);
  1594. if (retrunValue == 0)
  1595. {
  1596. errMessage = "输入的数据不完整";
  1597. return null;
  1598. }
  1599. if (retrunValue == 1)
  1600. {
  1601. errMessage = "公差约束项<三>下限值与上限值相等,上下限符号请选择<=和>=";
  1602. return null;
  1603. }
  1604. if (retrunValue == 2)
  1605. {
  1606. errMessage = "公差约束项<三>下限值不能大于上限值";
  1607. return null;
  1608. }
  1609. }
  1610. }
  1611. else
  1612. {
  1613. if (!com.SminSign.Equals("") || !com.Smin.Equals("") || !com.SmaxSign.Equals("") || !com.Smax.Equals(""))
  1614. {
  1615. errMessage = "请选择公差约束项<三>:公差约束项";
  1616. return null;
  1617. }
  1618. }
  1619. if (!com.BiasCodeS.Equals(""))
  1620. {
  1621. if (com.BiasCodeC.Equals(""))
  1622. {
  1623. errMessage = "请依次填写公差约束项";
  1624. return null;
  1625. }
  1626. else
  1627. {
  1628. if (com.BiasCodeZ.Equals(""))
  1629. {
  1630. errMessage = "请依次填写公差约束项";
  1631. return null;
  1632. }
  1633. }
  1634. }
  1635. else
  1636. {
  1637. if (!com.BiasCodeC.Equals(""))
  1638. {
  1639. if (com.BiasCodeZ.Equals(""))
  1640. {
  1641. errMessage = "请依次填写公差约束项";
  1642. return null;
  1643. }
  1644. }
  1645. }
  1646. com.IsCheck = rows.Cells["ISCHECK"].Value.ToString().Trim();
  1647. if (Convert.ToBoolean(com.IsCheck))
  1648. com.IsCheck = "1";
  1649. else
  1650. com.IsCheck = "0";
  1651. com.StdMinVal = rows.Cells["STD_MIN_VAL"].Value.ToString().Trim();
  1652. int i = 0;
  1653. if (!com.StdMinVal.Equals(""))
  1654. {
  1655. i += 1;
  1656. if (!StringUtil.IsNumber(com.StdMinVal) || com.StdMinVal.Length > 10)
  1657. {
  1658. errMessage = "下偏差值(mm)请输入10位以内数字";
  1659. return null;
  1660. }
  1661. if ((com.BiasCode == "404019" || com.BiasCode == "404020") && decimal.Parse(com.StdMinVal) > 0)
  1662. {
  1663. errMessage = "(管体/管端壁厚)下偏差值(mm)不能为正数";
  1664. return null;
  1665. }
  1666. }
  1667. com.StdMaxVal = rows.Cells["STD_MAX_VAL"].Value.ToString().Trim();
  1668. if (!com.StdMaxVal.Equals(""))
  1669. {
  1670. if (!StringUtil.IsNumber(com.StdMaxVal) || com.StdMaxVal.Length > 10)
  1671. {
  1672. errMessage = "上偏差值(mm)请输入10位以内数字";
  1673. return null;
  1674. }
  1675. }
  1676. com.StdMinIn = rows.Cells["STD_MIN_IN"].Value.ToString().Trim();
  1677. if (!com.StdMinIn.Equals(""))
  1678. {
  1679. if (!StringUtil.IsNumber(com.StdMinIn) || com.StdMinIn.Length > 10)
  1680. {
  1681. errMessage = "标准负值(in)请输入10位以内数字";
  1682. return null;
  1683. }
  1684. }
  1685. com.StdMaxIn = rows.Cells["STD_MAX_IN"].Value.ToString().Trim();
  1686. if (!com.StdMaxIn.Equals(""))
  1687. {
  1688. if (!StringUtil.IsNumber(com.StdMaxIn) || com.StdMaxIn.Length > 10)
  1689. {
  1690. errMessage = "标准正值(in)请输入10位以内数字";
  1691. return null;
  1692. }
  1693. }
  1694. com.StdMinPercent = rows.Cells["STD_MIN_PERCENT"].Value.ToString().Trim();
  1695. if (!com.StdMinPercent.Equals(""))
  1696. {
  1697. i += 1;
  1698. if (!StringUtil.IsNumber(com.StdMinPercent) || com.StdMinPercent.Length > 10)
  1699. {
  1700. errMessage = "下偏差值(%)请输入10位以内数字";
  1701. return null;
  1702. }
  1703. if ((com.BiasCode == "404019" || com.BiasCode == "404020") && decimal.Parse(com.StdMinPercent) > 0)
  1704. {
  1705. errMessage = "(管体/管端壁厚)下偏差值(%)不能为正数";
  1706. return null;
  1707. }
  1708. }
  1709. com.StdMaxPercent = rows.Cells["STD_MAX_PERCENT"].Value.ToString().Trim();
  1710. if (!com.StdMaxPercent.Equals(""))
  1711. {
  1712. if (!StringUtil.IsNumber(com.StdMaxPercent) || com.StdMaxPercent.Length > 10)
  1713. {
  1714. errMessage = "上偏差值(%)请输入10位以内数字";
  1715. return null;
  1716. }
  1717. }
  1718. com.StdMinFormula = rows.Cells["STD_MIN_FORMULA"].Value.ToString().Trim();
  1719. if (!com.StdMinFormula.Equals(""))
  1720. {
  1721. i += 1;
  1722. if (com.StdMinFormula.Length > 100)
  1723. {
  1724. errMessage = "请输入标准公式下偏差值(mm)";
  1725. return null;
  1726. }
  1727. if ((com.BiasCode == "404019" || com.BiasCode == "404020") && (!com.StdMinFormula.StartsWith("-") && com.StdMinFormula != "0"))
  1728. {
  1729. errMessage = "(管体/管端壁厚)标准公式下偏差值(mm)不能为正数";
  1730. return null;
  1731. }
  1732. }
  1733. com.StdMaxFormula = rows.Cells["STD_MAX_FORMULA"].Value.ToString().Trim();
  1734. if (!com.StdMaxFormula.Equals(""))
  1735. {
  1736. if (com.StdMaxFormula.Length > 100)
  1737. {
  1738. errMessage = "请输入标准公式上偏差值(mm)";
  1739. return null;
  1740. }
  1741. }
  1742. if (com.StdMinVal.Equals("") && com.StdMinFormula.Equals("") && com.StdMinPercent.Equals(""))
  1743. {
  1744. errMessage = "请输入一组标准值";
  1745. return null;
  1746. }
  1747. if (com.StdMinVal.Equals(""))
  1748. {
  1749. if (!com.StdMaxVal.Equals(""))
  1750. {
  1751. errMessage = "下偏差值(mm)请输入10位以内数字";
  1752. return null;
  1753. }
  1754. }
  1755. else
  1756. {
  1757. if (com.StdMaxVal.Equals(""))
  1758. {
  1759. errMessage = "上偏差值(mm)请输入10位以内数字";
  1760. return null;
  1761. }
  1762. }
  1763. if (com.StdMinPercent.Equals(""))
  1764. {
  1765. if (!com.StdMaxPercent.Equals(""))
  1766. {
  1767. errMessage = "下偏差值(%)请输入10位以内数字";
  1768. return null;
  1769. }
  1770. }
  1771. else
  1772. {
  1773. if (com.StdMaxPercent.Equals(""))
  1774. {
  1775. errMessage = "上偏差值(%)请输入10位以内数字";
  1776. return null;
  1777. }
  1778. }
  1779. if (com.StdMinFormula.Equals(""))
  1780. {
  1781. if (!com.StdMaxFormula.Equals(""))
  1782. {
  1783. errMessage = "请输入标准公式下偏差值(mm)";
  1784. return null;
  1785. }
  1786. }
  1787. else
  1788. {
  1789. if (com.StdMaxFormula.Equals(""))
  1790. {
  1791. errMessage = "请输入标准公式上偏差值(mm)";
  1792. return null;
  1793. }
  1794. }
  1795. if (!com.StdMinFormula.Equals("") && !StringUtil.IsNumber(com.StdMinFormula))
  1796. {
  1797. if (!QcmBaseCommon.CheckToleranceFormula(com.StdMinFormula))
  1798. {
  1799. errMessage = "您输入的标准值-公式下偏差值(mm):[" + com.StdMinFormula + "]不合法,请重新输入!";
  1800. return null;
  1801. }
  1802. }
  1803. if (!com.StdMaxFormula.Equals("") && !StringUtil.IsNumber(com.StdMaxFormula))
  1804. {
  1805. if (!QcmBaseCommon.CheckToleranceFormula(com.StdMaxFormula))
  1806. {
  1807. errMessage = "您输入的标准值-公式上偏差值(mm):[" + com.StdMaxFormula + "]不合法,请重新输入!";
  1808. return null;
  1809. }
  1810. }
  1811. com.StdMinFormulaV = rows.Cells["STD_MIN_FORMULA_V"].Value.ToString().Trim();
  1812. com.StdMaxFormulaV = rows.Cells["STD_MAX_FORMULA_V"].Value.ToString().Trim();
  1813. if (Convert.ToBoolean(com.StdMinFormulaV))
  1814. com.StdMinFormulaV = "1";
  1815. else
  1816. com.StdMinFormulaV = "0";
  1817. if (Convert.ToBoolean(com.StdMaxFormulaV))
  1818. com.StdMaxFormulaV = "1";
  1819. else
  1820. com.StdMaxFormulaV = "0";
  1821. if (com.StdMaxFormulaV.Equals("1") && com.StdMinFormulaV.Equals("1"))
  1822. {
  1823. errMessage = "不能同时选择标准取小值和取大值";
  1824. return null;
  1825. }
  1826. if (i > 1 && com.StdMinFormulaV.Equals("0") && com.StdMaxFormulaV.Equals("0"))
  1827. {
  1828. errMessage = "请选择标准取小值或者取大值";
  1829. return null;
  1830. }
  1831. com.StdMemo = rows.Cells["STDMEMO"].Value.ToString().Trim();
  1832. com.CreateName = UserInfo.GetUserName();
  1833. com.UpdateName = UserInfo.GetUserName();
  1834. com.Validflag = rows.Cells["VALIDFLAG"].Value.ToString();
  1835. com.CreateTime = rows.Cells["CREATE_TIME"].Value.ToString().Trim();
  1836. com.GroupSeq = rows.Cells["GROUP_SEQ"].Value.ToString();
  1837. if (!com.BiasCodeC.Equals(""))
  1838. {
  1839. if (com.BiasCodeC.Equals(com.BiasCodeS) || com.BiasCodeC.Equals(com.BiasCodeZ))
  1840. {
  1841. errMessage = "公差约束项不能相同,请重新选择";
  1842. return null;
  1843. }
  1844. }
  1845. if (!com.BiasCodeS.Equals(""))
  1846. {
  1847. if (com.BiasCodeS.Equals(com.BiasCodeC) || com.BiasCodeS.Equals(com.BiasCodeZ))
  1848. {
  1849. errMessage = "公差约束项不能相同,请重新选择";
  1850. return null;
  1851. }
  1852. }
  1853. if (!com.BiasCodeZ.Equals(""))
  1854. {
  1855. if (com.BiasCodeZ.Equals(com.BiasCodeC) || com.BiasCodeZ.Equals(com.BiasCodeS))
  1856. {
  1857. errMessage = "公差约束项不能相同,请重新选择";
  1858. return null;
  1859. }
  1860. }
  1861. return com;
  1862. }
  1863. FrmTolerancesStandard _frmTolerancesStandard = null;
  1864. /// <summary>
  1865. /// 扣型选择
  1866. /// </summary>
  1867. /// <param name="sender"></param>
  1868. /// <param name="e"></param>
  1869. private void ultraGrid1_ClickCellButton(object sender, CellEventArgs e)
  1870. {
  1871. if (e.Cell.Column.Key.Equals("MODEL_DESC") && Convert.ToBoolean(ultraGrid1.DisplayLayout.ActiveRow.Cells["CHC"].Value))
  1872. {
  1873. UltraGridRow row = this.ultraGrid1.DisplayLayout.ActiveRow;
  1874. FrmModel frms = new FrmModel();
  1875. frms.Code = row.Cells["MODEL_CODE"].Value.ToString();
  1876. frms.Desc = row.Cells["MODEL_DESC"].Value.ToString();
  1877. frms.FrmOb = this.ob;
  1878. frms.ShowDialog();
  1879. row.Cells["MODEL_CODE"].Value = frms.Code;
  1880. row.Cells["MODEL_DESC"].Value = frms.Desc;
  1881. }
  1882. if (e.Cell.Column.Key.Equals("CHKNK"))
  1883. {
  1884. UltraGridRow ugr = ultraGrid1.ActiveRow;
  1885. _frmTolerancesStandard = new FrmTolerancesStandard();
  1886. _frmTolerancesStandard.PopupLoad("3", ob);
  1887. _frmTolerancesStandard.UltraPanel1.Visible = false;
  1888. _frmTolerancesStandard.ultraToolbarsManager1.Visible = true;
  1889. _frmTolerancesStandard.Msc = msc;
  1890. _frmTolerancesStandard.CodeJg = "";
  1891. _frmTolerancesStandard.DoQuery1();
  1892. if (_frmTolerancesStandard.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  1893. {
  1894. DataRow CurRow, NewRow;
  1895. for (int i = 0; i < _frmTolerancesStandard.dataTable2.Rows.Count; i++)
  1896. {
  1897. CurRow = _frmTolerancesStandard.dataTable2.Rows[i];
  1898. NewRow = dataTable2.NewRow();
  1899. if (!_frmTolerancesStandard.Ids.Contains(CurRow["SIC"].ToString2()))
  1900. {
  1901. continue;
  1902. }
  1903. for (int j = 0; j < _frmTolerancesStandard.dataTable2.Columns.Count; j++)
  1904. {
  1905. try
  1906. {
  1907. if (dataTable2.Columns.Contains(_frmTolerancesStandard.dataTable2.Columns[j].ColumnName))
  1908. {
  1909. if (_frmTolerancesStandard.dataTable2.Columns[j].ColumnName == "SIC")
  1910. {
  1911. NewRow[_frmTolerancesStandard.dataTable2.Columns[j].ColumnName] = ultraGrid1.ActiveRow.GetValue("SIC");
  1912. }
  1913. else
  1914. {
  1915. NewRow[_frmTolerancesStandard.dataTable2.Columns[j].ColumnName] = CurRow[j];
  1916. }
  1917. }
  1918. }
  1919. catch { }
  1920. }
  1921. dataTable2.Rows.Add(NewRow);
  1922. }
  1923. ultraGrid1.UpdateData();
  1924. ultraGrid1.ActiveRow.ExpandAll();
  1925. }
  1926. }
  1927. }
  1928. private void ultraCheckMSC_CheckedChanged(object sender, EventArgs e)
  1929. {
  1930. if (ultraCheckMSC.Checked)
  1931. TextMSC.Enabled = true;
  1932. else
  1933. TextMSC.Enabled = false;
  1934. }
  1935. private void ultraCheckStand_CheckedChanged(object sender, EventArgs e)
  1936. {
  1937. if (ultraCheckStand.Checked)
  1938. TextStd.Enabled = true;
  1939. else
  1940. TextStd.Enabled = false;
  1941. }
  1942. private void ultraGrid1_InitializeRow(object sender, InitializeRowEventArgs e)
  1943. {
  1944. if (isPasting)
  1945. {
  1946. e.Row.SetValue("CHC", "True");
  1947. }
  1948. }
  1949. /// <summary>
  1950. /// 2015-07-15 PDY
  1951. /// </summary>
  1952. private void InnerChange()
  1953. {
  1954. ultraGrid1.DisplayLayout.Bands[0].Columns["PROCESS_CODE"].CellActivation = Activation.ActivateOnly;
  1955. ultraGrid1.DisplayLayout.Bands[0].Columns["STD_CODE"].CellActivation = Activation.ActivateOnly;
  1956. ultraGrid1.DisplayLayout.Bands[0].Columns["MODEL_DESC"].Hidden = true;
  1957. }
  1958. private void ultraTextEditor3_EditorButtonClick(object sender, EditorButtonEventArgs e)
  1959. {
  1960. if (ultraGrid1.ActiveCell.Column.Key == "PROCESS_DESC")
  1961. {
  1962. string processCodes = ultraGrid1.ActiveRow.GetValue("PROCESS_CODE");
  1963. ChoiceProcessPopup choiceProcessPopup = new ChoiceProcessPopup(processCodes, this.ob);
  1964. if (choiceProcessPopup.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  1965. {
  1966. DataTable dt = ServerHelper.GetData("com.steering.pss.qcm.ComStandard.getProcessByStdCode",
  1967. new object[] { this.stdCode }, ob);
  1968. string stdProcessCodes = dt.Rows[0]["PROCESS_CODE"].ToString();
  1969. string[] processCodesAry = choiceProcessPopup.ProcessCodes.Split(',');
  1970. for (int i = 0; i < processCodesAry.Length; i++)
  1971. {
  1972. if (!stdProcessCodes.Contains(processCodesAry[i].Trim()))
  1973. {
  1974. DataTable dtBaseProcess = ServerHelper.GetData("com.steering.pss.qcm.ComStandard.getProcessDescByCode",
  1975. new object[] { processCodesAry[i].Trim() }, ob);
  1976. string processDesc = dtBaseProcess.Rows[0]["PROCESS_DESC"].ToString();
  1977. MessageUtil.ShowWarning("该标准下不包含工序" + processDesc + ", 不能选择!");
  1978. return;
  1979. }
  1980. }
  1981. ultraGrid1.ActiveRow.SetValue("PROCESS_CODE", choiceProcessPopup.ProcessCodes);
  1982. ultraGrid1.ActiveRow.SetValue("PROCESS_DESC", choiceProcessPopup.ProcessDescs);
  1983. }
  1984. }
  1985. else if (ultraGrid1.ActiveCell.Column.Key == "STEELNAME_NK")
  1986. {
  1987. FrmRepSteel frmSteel = new FrmRepSteel();
  1988. frmSteel.Ob1 = this.ob;
  1989. frmSteel.Code = ultraGrid1.ActiveRow.GetValue("STEELCODE_NK");
  1990. if (frmSteel.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  1991. {
  1992. ultraGrid1.ActiveRow.SetValue("STEELCODE_NK", frmSteel.Code);
  1993. ultraGrid1.ActiveRow.SetValue("STEELNAME_NK", frmSteel.Desc);
  1994. }
  1995. }
  1996. else if (ultraGrid1.ActiveCell.Column.Key == "MODEL_DESC_NK")
  1997. {
  1998. FrmModel frmModel = new FrmModel();
  1999. frmModel.FrmOb = this.ob;
  2000. frmModel.Code = ultraGrid1.ActiveRow.GetValue("MODEL_CODE_NK");
  2001. frmModel.Desc = ultraGrid1.ActiveCell.Value.ToString();
  2002. if (frmModel.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  2003. {
  2004. ultraGrid1.ActiveRow.SetValue("MODEL_CODE_NK", frmModel.Code);
  2005. ultraGrid1.ActiveRow.SetValue("MODEL_DESC_NK", frmModel.Desc);
  2006. }
  2007. }
  2008. else if (ultraGrid1.ActiveCell.Column.Key == "PRODUCNAME_NK")
  2009. {
  2010. PopupProductName popupProductName = new PopupProductName(
  2011. ultraGrid1.ActiveRow.GetValue("PRODUCCODE_NK"), ob);
  2012. if (popupProductName.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  2013. {
  2014. ultraGrid1.ActiveRow.SetValue("PRODUCCODE_NK", popupProductName.ProductCodes);
  2015. ultraGrid1.ActiveRow.SetValue("PRODUCNAME_NK", popupProductName.ProductNames);
  2016. }
  2017. }
  2018. }
  2019. private void ultraGrid1_AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
  2020. {
  2021. foreach (Infragistics.Win.UltraWinGrid.UltraGridRow ugr in this.ultraGrid1.Selected.Rows)
  2022. {
  2023. ugr.Cells["CHC"].Value = true;
  2024. Activation activation = Activation.ActivateOnly;
  2025. if (Convert.ToBoolean(ugr.Cells["CHC"].Value))
  2026. {
  2027. activation = Activation.AllowEdit;
  2028. //isSelect += 1;
  2029. }
  2030. //else
  2031. //isSelect -= 1;
  2032. CellsCollection cells = ugr.Cells;
  2033. for (int i = 0; i < cells.Count; i++)
  2034. {
  2035. if (!cells[i].Column.Key.Equals("CHC"))
  2036. {
  2037. ugr.Cells[i].Activation = activation;
  2038. }
  2039. }
  2040. }
  2041. }
  2042. private void ultraToolbarsManager1_ToolClick(object sender, Infragistics.Win.UltraWinToolbars.ToolClickEventArgs e)
  2043. {
  2044. switch (e.Tool.Key)
  2045. {
  2046. case "查询":
  2047. DoQuery1();
  2048. break;
  2049. case "确认选择":
  2050. Choice();
  2051. break;
  2052. }
  2053. }
  2054. private DataRow[] rows;
  2055. public DataRow[] Rows
  2056. {
  2057. get { return rows; }
  2058. set { rows = value; }
  2059. }
  2060. List<string> ids;
  2061. public List<string> Ids
  2062. {
  2063. get { return ids; }
  2064. set { ids = value; }
  2065. }
  2066. private void Choice()
  2067. {
  2068. ultraGrid1.UpdateData();
  2069. int count = ultraGrid1.Rows.Where(a => Convert.ToBoolean(a.GetValue("CHC"))).Count();
  2070. if (count > 1)
  2071. {
  2072. MessageUtil.ShowTips("请选择一条数据!");
  2073. return;
  2074. }
  2075. foreach (UltraGridRow ugr in ultraGrid1.Rows.Where(a => Convert.ToBoolean(a.GetValue("CHC"))))
  2076. {
  2077. //从表操作
  2078. if (ugr.HasChild())
  2079. {
  2080. Ids = ugr.ChildBands[0].Rows.Select(p => p.GetValue("SIC")).ToList();
  2081. Rows = dataTable2.Select("SIC IN ('" + string.Join("','", Ids) + "')");
  2082. }
  2083. }
  2084. this.DialogResult = System.Windows.Forms.DialogResult.OK;
  2085. }
  2086. }
  2087. }