FrmChoiceCraftFileLv2New.cs 100 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Tool;
  3. using Core.StlMes.Client.Qcm;
  4. using Core.StlMes.Client.SaleOrder.BLL;
  5. using Core.StlMes.Client.SaleOrder.Control;
  6. using Core.StlMes.Client.SaleOrder.Dialog;
  7. using CoreFS.CA06;
  8. using Infragistics.Win.UltraWinGrid;
  9. using System;
  10. using System.Collections.Generic;
  11. using System.ComponentModel;
  12. using System.Data;
  13. using System.Drawing;
  14. using System.Linq;
  15. using System.Text;
  16. using System.Windows.Forms;
  17. using Core.Mes.Client.Comm.Format;
  18. using Core.Mes.Client.Comm.Server;
  19. using Infragistics.Win;
  20. using Infragistics.Win.UltraWinEditors;
  21. using ButtonDisplayStyle = Infragistics.Win.UltraWinGrid.ButtonDisplayStyle;
  22. namespace Core.StlMes.Client.SaleOrder.ReviewForm
  23. {
  24. public partial class FrmChoiceCraftFileLv2New : FrmBase
  25. {
  26. private CraftOrdDesignBLL _craftOrdDesignBLL;
  27. private CraftOrdDesignStdCicCtrl _cicCtrl;
  28. private CraftOrdDesignStdPicCtrl _picCtrl;
  29. private CraftOrdDesignStdSicCtrl _sicCtrl;
  30. private CraftOrdDesignStdDicCtrl _dicCtrl;
  31. private CraftOrdDesignStdWicCtrl _wicCtrl;
  32. private CraftOrdDesignStdGicCtrl _gicCtrl;
  33. private CraftOrdDesignStdCicBLL _cicBLL;
  34. private CraftOrdDesignStdPicBLL _picBLL;
  35. private CraftOrdDesignStdSicBLL _sicBLL;
  36. private CraftOrdDesignStdDicBLL _dicBLL;
  37. private CraftOrdDesignStdWicBLL _wicBLL;
  38. private CraftOrdDesignStdGicBLL _gicBLL;
  39. UltraComboEditor uceA = new UltraComboEditor();
  40. private int maxBatch = 0;
  41. private List<string> AllPline = new DataSourceList<string>();
  42. private Dictionary<string,List<string>> CanNotMergePhyCode = new Dictionary<string, List<string>>();
  43. public FrmChoiceCraftFileLv2New()
  44. {
  45. InitializeComponent();
  46. EntityHelper.ShowGridCaption<ChoiceCraftFileLv2Entity>(ultraGrid1.DisplayLayout.Bands[0]);
  47. EntityHelper.ShowGridCaption<CraftOrdDesignStdPicSmpDetailEntity>(ultraGrid10.DisplayLayout.Bands[0]);
  48. EntityHelper.ShowGridCaption<CraftOrdDesignStdPicSmpTotalEntity>(ultraGrid9.DisplayLayout.Bands[0]);
  49. EntityHelper.ShowGridCaption<CraftOrdDesignStdPicEntity>(ultraGrid11.DisplayLayout.Bands[0]);
  50. foreach (UltraGridColumn ugc in ultraGrid9.DisplayLayout.Bands[0].Columns)
  51. {
  52. ugc.SortIndicator = SortIndicator.Disabled;
  53. }
  54. ultraGrid9.DisplayLayout.Bands[0].Columns["DescPosition"].MergedCellEvaluator = new CustomMergedCellEvaluator(new string[] { "BatchNum", "StoveNum" });
  55. ultraGrid9.DisplayLayout.Bands[0].Columns["BatchNoStr"].MergedCellEvaluator = new CustomMergedCellEvaluator(new string[] { "BatchNum", "StoveNum" });
  56. ValueList vlist = new ValueList();
  57. vlist.ValueListItems.Add("1", "首检增项");
  58. vlist.ValueListItems.Add("0", "正常");
  59. ultraGrid10.DisplayLayout.Bands[0].Columns["Type"].ValueList = vlist;
  60. ultraGrid10.DisplayLayout.Bands[0].Columns["Type"].Style = Infragistics.Win.UltraWinGrid.ColumnStyle.DropDownList;
  61. ValueList vlist1 = new ValueList();
  62. vlist1.ValueListItems.Add("1", "生产批");
  63. vlist1.ValueListItems.Add("0", "非生产批");
  64. ultraGrid9.DisplayLayout.Bands[0].Columns["StoveNum"].ValueList = vlist1;
  65. // 写死限制压扁和扩口不在同一个管头上
  66. CanNotMergePhyCode.Add("C0009", new List<string>() { "C0026" });
  67. CanNotMergePhyCode.Add("C0026", new List<string>() { "C0009" });
  68. /* ultraGrid9.DisplayLayout.Bands[0].Columns["Remark"].CellActivation = Activation.AllowEdit;*/
  69. this.IsLoadUserView = true;
  70. }
  71. private void FrmChoiceCraftFileLv2_Load(object sender, EventArgs e)
  72. {
  73. _craftOrdDesignBLL = new CraftOrdDesignBLL(ob);
  74. lblCmbPlanStatus.ComboBox.SelectedIndex = 0;
  75. //ultraGrid1.DisplayLayout.Bands[0].Columns["CraftFileLv2" + CustomInfo + "Desc"].Hidden = false;
  76. string process = CustomInfo.Substring(0, 1);
  77. if (process != "D")
  78. {
  79. GridHelper.HidenColumns(ultraGrid1.DisplayLayout.Bands[0], "PlanTimeBZg", "CraftFileLv2DDesc", "CraftFileLv2FDown");
  80. }
  81. if (process != "E")
  82. {
  83. GridHelper.HidenColumns(ultraGrid1.DisplayLayout.Bands[0], "PlanTimeBDbk", "CraftFileLv2EDesc");
  84. }
  85. if (process != "F")
  86. {
  87. GridHelper.HidenColumns(ultraGrid1.DisplayLayout.Bands[0], "PlanTimeBRcl", "CraftFileLv2FDesc");
  88. }
  89. if (process != "G")
  90. {
  91. GridHelper.HidenColumns(ultraGrid1.DisplayLayout.Bands[0], "PlanTimeBJgx", "CraftFileLv2GDesc");
  92. }
  93. if (process != "H")
  94. {
  95. GridHelper.HidenColumns(ultraGrid1.DisplayLayout.Bands[0], "PlanTimeBProp", "CraftFileLv2HDesc");
  96. }
  97. if (!CustomInfo.Contains("PLAN"))
  98. {
  99. splitContainer1.Panel2Collapsed = true;
  100. }
  101. if (CustomInfo != "D_PLAN")
  102. {
  103. GridHelper.HidenColumns(ultraGrid1.DisplayLayout.Bands[0], "FlagDStr");
  104. }
  105. if (CustomInfo != "E_PLAN")
  106. {
  107. GridHelper.HidenColumns(ultraGrid1.DisplayLayout.Bands[0], "FlagEStr");
  108. }
  109. if (CustomInfo != "F_PLAN")
  110. {
  111. GridHelper.HidenColumns(ultraGrid1.DisplayLayout.Bands[0], "FlagFStr");
  112. }
  113. if (CustomInfo != "G_PLAN")
  114. {
  115. GridHelper.HidenColumns(ultraGrid1.DisplayLayout.Bands[0], "FlagGStr");
  116. }
  117. if (CustomInfo != "H_PLAN")
  118. {
  119. GridHelper.HidenColumns(ultraGrid1.DisplayLayout.Bands[0], "FlagHStr");
  120. }
  121. AllPline= InitDropPlinePower(process, lcPline.ComboBox, this.ValidDataPurviewIds, ob);
  122. //QcmBaseQuery.NitializePlineByProcess("D", labelComboBox1.ComboBox, true, ob);
  123. //_plnOrderZgSCtrl = new PlnOrderZgSCtrl(splitContainer1.Panel1, ob);
  124. //_plnOrderZgSCtrl.EntityGrid1.AfterRowActivate += plnOrderZgSCtrl_AfterRowActivate;
  125. _cicCtrl = new CraftOrdDesignStdCicCtrl(panel3, ob);
  126. _cicCtrl.EntityGrid1.AfterRowInsert += cicCtrl_AfterRowInsert;
  127. _cicCtrl.EntityGrid1.BeforeRowInsert += cicCtrl_BeforeRowInsert;
  128. _picCtrl = new CraftOrdDesignStdPicCtrl(panel4, ob);
  129. _picCtrl.EntityGrid1.AfterRowInsert += picCtrl_AfterRowInsert;
  130. _picCtrl.EntityGrid1.BeforeRowInsert += picCtrl_BeforeRowInsert;
  131. _picCtrl.EntityGrid1.DisplayLayout.Bands[0].Columns["PhyNameMin"].ButtonDisplayStyle = ButtonDisplayStyle.OnMouseEnter;
  132. _picCtrl.EntityGrid1.DisplayLayout.Bands[0].Columns["PhyNameMax"].ButtonDisplayStyle = ButtonDisplayStyle.OnMouseEnter;
  133. _sicCtrl = new CraftOrdDesignStdSicCtrl(panel5, ob);
  134. _sicCtrl.EntityGrid1.AfterRowInsert += sicCtrl_AfterRowInsert;
  135. _sicCtrl.EntityGrid1.BeforeRowInsert += sicCtrl_BeforeRowInsert;
  136. _dicCtrl = new CraftOrdDesignStdDicCtrl(panel6, ob);
  137. _dicCtrl.EntityGrid1.AfterRowInsert += dicCtrl_AfterRowInsert;
  138. _dicCtrl.EntityGrid1.BeforeRowInsert += dicCtrl_BeforeRowInsert;
  139. _wicCtrl = new CraftOrdDesignStdWicCtrl(panel7, ob);
  140. _wicCtrl.EntityGrid1.AfterRowInsert += wicCtrl_AfterRowInsert;
  141. _wicCtrl.EntityGrid1.BeforeRowInsert += wicCtrl_BeforeRowInsert;
  142. _gicCtrl = new CraftOrdDesignStdGicCtrl(panel8, ob);
  143. _gicCtrl.EntityGrid1.AfterRowInsert += gicCtrl_AfterRowInsert;
  144. _gicCtrl.EntityGrid1.BeforeRowInsert += gicCtrl_BeforeRowInsert;
  145. _cicBLL = new CraftOrdDesignStdCicBLL(ob);
  146. _picBLL = new CraftOrdDesignStdPicBLL(ob);
  147. _sicBLL = new CraftOrdDesignStdSicBLL(ob);
  148. _dicBLL = new CraftOrdDesignStdDicBLL(ob);
  149. _wicBLL = new CraftOrdDesignStdWicBLL(ob);
  150. _gicBLL = new CraftOrdDesignStdGicBLL(ob);
  151. }
  152. void gicCtrl_BeforeRowInsert(object sender, BeforeRowInsertEventArgs e)
  153. {
  154. /* if (ultraGrid7.Rows.Count == 0)*/
  155. if (ultraGrid1.ActiveRow == null)
  156. {
  157. e.Cancel = true;
  158. }
  159. }
  160. void wicCtrl_BeforeRowInsert(object sender, BeforeRowInsertEventArgs e)
  161. {
  162. /* if (ultraGrid6.Rows.Count == 0)*/
  163. if (ultraGrid1.ActiveRow == null)
  164. {
  165. e.Cancel = true;
  166. }
  167. }
  168. void dicCtrl_BeforeRowInsert(object sender, BeforeRowInsertEventArgs e)
  169. {
  170. /* if (ultraGrid5.Rows.Count == 0)*/
  171. if (ultraGrid1.ActiveRow == null)
  172. {
  173. e.Cancel = true;
  174. }
  175. }
  176. void sicCtrl_BeforeRowInsert(object sender, BeforeRowInsertEventArgs e)
  177. {
  178. /* if (ultraGrid4.Rows.Count == 0)*/
  179. if (ultraGrid1.ActiveRow == null)
  180. {
  181. e.Cancel = true;
  182. }
  183. }
  184. void picCtrl_BeforeRowInsert(object sender, BeforeRowInsertEventArgs e)
  185. {
  186. /* if (ultraGrid8.Rows.Count == 0)*/
  187. if (ultraGrid1.ActiveRow == null)
  188. {
  189. e.Cancel = true;
  190. }
  191. }
  192. void cicCtrl_BeforeRowInsert(object sender, BeforeRowInsertEventArgs e)
  193. {
  194. /* if (ultraGrid2.Rows.Count == 0)*/
  195. if (ultraGrid1.ActiveRow==null)
  196. {
  197. e.Cancel = true;
  198. }
  199. }
  200. void gicCtrl_AfterRowInsert(object sender, RowEventArgs e)
  201. {
  202. /* var row = ultraGrid7.ActiveRow;
  203. string mscPline = row.GetValue("MscPline");
  204. string processCode = row.GetValue("ProcessCode");
  205. string gic = row.GetValue("Gic");
  206. e.Row.Cells["MscPline"].Value = mscPline;
  207. e.Row.Cells["ProcessCode"].Value = processCode;
  208. e.Row.Cells["Gic"].Value = gic;*/
  209. var craftOrdDesign = ultraGrid1.ActiveRow.ListObject as ChoiceCraftFileLv2Entity;
  210. e.Row.Cells["Gic"].Value = craftOrdDesign.Gic;
  211. e.Row.Cells["MscPline"].Value = craftOrdDesign.MscPline;
  212. e.Row.Cells["ProcessCode"].Value = CustomInfo.Substring(0, 1);;
  213. }
  214. void wicCtrl_AfterRowInsert(object sender, RowEventArgs e)
  215. {
  216. /* var row = ultraGrid6.ActiveRow;
  217. string mscPline = row.GetValue("MscPline");
  218. string processCode = row.GetValue("ProcessCode");
  219. string wic = row.GetValue("Wic");
  220. e.Row.Cells["MscPline"].Value = mscPline;
  221. e.Row.Cells["ProcessCode"].Value = processCode;
  222. e.Row.Cells["Wic"].Value = wic;*/
  223. var craftOrdDesign = ultraGrid1.ActiveRow.ListObject as ChoiceCraftFileLv2Entity;
  224. e.Row.Cells["Wic"].Value = craftOrdDesign.Wic;
  225. e.Row.Cells["MscPline"].Value = craftOrdDesign.MscPline;
  226. e.Row.Cells["ProcessCode"].Value = CustomInfo.Substring(0, 1); ;
  227. }
  228. void dicCtrl_AfterRowInsert(object sender, RowEventArgs e)
  229. {
  230. /* var row = ultraGrid5.ActiveRow;
  231. string mscPline = row.GetValue("MscPline");
  232. string processCode = row.GetValue("ProcessCode");
  233. string dic = row.GetValue("Dic");
  234. e.Row.Cells["MscPline"].Value = mscPline;
  235. e.Row.Cells["ProcessCode"].Value = processCode;
  236. e.Row.Cells["Dic"].Value = dic;*/
  237. var craftOrdDesign = ultraGrid1.ActiveRow.ListObject as ChoiceCraftFileLv2Entity;
  238. e.Row.Cells["Dic"].Value = craftOrdDesign.Dic;
  239. e.Row.Cells["MscPline"].Value = craftOrdDesign.MscPline;
  240. e.Row.Cells["ProcessCode"].Value = CustomInfo.Substring(0, 1); ;
  241. }
  242. void sicCtrl_AfterRowInsert(object sender, RowEventArgs e)
  243. {
  244. /* var row = ultraGrid4.ActiveRow;
  245. string mscPline = row.GetValue("MscPline");
  246. string processCode = row.GetValue("ProcessCode");
  247. string sic = row.GetValue("Sic");
  248. e.Row.Cells["MscPline"].Value = mscPline;
  249. e.Row.Cells["ProcessCode"].Value = processCode;
  250. e.Row.Cells["Sic"].Value = sic;*/
  251. var craftOrdDesign = ultraGrid1.ActiveRow.ListObject as ChoiceCraftFileLv2Entity;
  252. e.Row.Cells["Sic"].Value = craftOrdDesign.Sic;
  253. e.Row.Cells["MscPline"].Value = craftOrdDesign.MscPline;
  254. e.Row.Cells["ProcessCode"].Value = CustomInfo.Substring(0, 1); ;
  255. }
  256. void picCtrl_AfterRowInsert(object sender, RowEventArgs e)
  257. {
  258. /* var row = ultraGrid3.ActiveRow;
  259. string mscPline = row.GetValue("MscPline");
  260. string processCode = row.GetValue("ProcessCode");
  261. string pic = row.GetValue("Pic");
  262. e.Row.Cells["MscPline"].Value = mscPline;
  263. e.Row.Cells["ProcessCode"].Value = processCode;
  264. e.Row.Cells["Pic"].Value = pic;*/
  265. var craftOrdDesign = ultraGrid1.ActiveRow.ListObject as ChoiceCraftFileLv2Entity;
  266. e.Row.Cells["Pic"].Value = craftOrdDesign.Pic;
  267. e.Row.Cells["MscPline"].Value = craftOrdDesign.MscPline;
  268. e.Row.Cells["ProcessCode"].Value = CustomInfo.Substring(0, 1); ;
  269. }
  270. void cicCtrl_AfterRowInsert(object sender, RowEventArgs e)
  271. {
  272. /* var row = ultraGrid2.ActiveRow;
  273. string mscPline = row.GetValue("MscPline");
  274. string processCode = row.GetValue("ProcessCode");
  275. string cic = row.GetValue("Cic");
  276. e.Row.Cells["MscPline"].Value = mscPline;
  277. e.Row.Cells["ProcessCode"].Value = processCode;
  278. e.Row.Cells["Cic"].Value = cic;*/
  279. var craftOrdDesign = ultraGrid1.ActiveRow.ListObject as ChoiceCraftFileLv2Entity;
  280. e.Row.Cells["Cic"].Value = craftOrdDesign.Cic;
  281. e.Row.Cells["MscPline"].Value = craftOrdDesign.MscPline;
  282. e.Row.Cells["ProcessCode"].Value = CustomInfo.Substring(0, 1); ;
  283. }
  284. public override void ToolBar_Click(object sender, string ToolbarKey)
  285. {
  286. base.ToolBar_Click(sender, ToolbarKey);
  287. switch (ToolbarKey)
  288. {
  289. case "Query":
  290. Query();
  291. break;
  292. case "Save":
  293. Save();
  294. break;
  295. case "Submit":
  296. Submit();
  297. break;
  298. case "Cancel":
  299. Cancel2();
  300. break;
  301. case "Consign":
  302. Consign();
  303. break;
  304. case "CancelConsign":
  305. CancelConsign();
  306. break;
  307. case "Close":
  308. this.Close();
  309. break;
  310. }
  311. }
  312. private void Query()
  313. {
  314. WaitingForm2 wf = new WaitingForm2("正在查询,请稍候....");
  315. try
  316. {
  317. this.Cursor = Cursors.WaitCursor;
  318. string craftNo = labelTextBox1.Checked ? labelTextBox1.Text.Trim() : "";
  319. string orderNo = labelTextBox2.Checked ? labelTextBox2.Text.Trim() : "";
  320. string planStatus = lblCmbPlanStatus.Checked ? lblCmbPlanStatus.SelecteValue.ToString2() : "";
  321. string maintenanceStatus = labelCheckBox1.Checked ? "1" : "";
  322. string[] exeStatus = contorlPlanStatus1.statusArr;
  323. List<string> _allPline = lcPline.Checked && lcPline.ComboBox.SelectedIndex > -1
  324. ? new List<string>() {lcPline.ComboBox.SelectedItem.DataValue.ToString()}
  325. : AllPline;
  326. ultraGrid1.BeginUpdate();
  327. craftOrdDesignEntityBindingSource.DataSource = _craftOrdDesignBLL.QueryCraftLv2New(
  328. craftNo, orderNo, planStatus, maintenanceStatus, CustomInfo.Substring(0, 1), exeStatus, _allPline);
  329. CopyUnfinishTimeZg();
  330. foreach (var row in ultraGrid1.Rows)
  331. {
  332. Color color = row.Cells["CraftNo"].Appearance.BackColor;
  333. if (!row.GetValue("ProcessCodes").Contains("D"))
  334. {
  335. row.Cells["CraftFileLv2DDesc"].Appearance.BackColor = color;
  336. row.Cells["CraftFileLv2DDesc"].Value = "无";
  337. }
  338. if (!row.GetValue("ProcessCodes").Contains("E"))
  339. {
  340. row.Cells["CraftFileLv2EDesc"].Appearance.BackColor = color;
  341. row.Cells["CraftFileLv2EDesc"].Value = "无";
  342. }
  343. if (!row.GetValue("ProcessCodes").Contains("F"))
  344. {
  345. row.Cells["CraftFileLv2FDesc"].Appearance.BackColor = color;
  346. row.Cells["CraftFileLv2FDesc"].Value = "无";
  347. }
  348. if (!row.GetValue("ProcessCodes").Contains("G"))
  349. {
  350. row.Cells["CraftFileLv2GDesc"].Appearance.BackColor = color;
  351. row.Cells["CraftFileLv2GDesc"].Value = "无";
  352. }
  353. if (!row.GetValue("ProcessCodes").Contains("H"))
  354. {
  355. row.Cells["CraftFileLv2HDesc"].Appearance.BackColor = color;
  356. row.Cells["CraftFileLv2HDesc"].Value = "无";
  357. }
  358. }
  359. ultraGrid1.EndUpdate();
  360. ultraGrid1.UpdateData();
  361. ClearCraftDesignDown();
  362. }
  363. finally
  364. {
  365. wf.Close();
  366. this.Cursor = Cursors.Default;
  367. }
  368. }
  369. private void ClearCraftDesignDown()
  370. {
  371. dataTable1.Clear();
  372. craftOrdDesignStdPicSmpDetailEntityBindingSource.Clear();
  373. craftOrdDesignStdPicSmpTotalEntityBindingSource.Clear();
  374. if (_cicCtrl != null)
  375. {
  376. _cicCtrl.Clear();
  377. _picCtrl.Clear();
  378. _sicCtrl.Clear();
  379. _dicCtrl.Clear();
  380. _wicCtrl.Clear();
  381. _gicCtrl.Clear();
  382. }
  383. maxBatch = 0;
  384. }
  385. private void CopyUnfinishTimeZg()
  386. {
  387. //DataTable dtUnfinishTime = _craftOrdDesignBLL.QueryUnfinishTimeZg();
  388. //foreach (var row in ultraGrid1.Rows)
  389. //{
  390. // string pk = row.GetValue("OrdLnDlyPk") + "-" + row.GetValue("PlnDivideId");
  391. // DataRow[] drs = dtUnfinishTime.Select("PK = '"+ pk +"'");
  392. // if (drs.Length > 0)
  393. // {
  394. // row.SetValue("UnfinishTime", drs[0]["UNFINISH_TIME"].ToString());
  395. // }
  396. //}
  397. }
  398. private void Relocat(string ordLnPk, string craftSeq)
  399. {
  400. Query();
  401. var row = ultraGrid1.Rows.Where(a => a.GetValue("OrdLnPk") == ordLnPk
  402. && a.GetValue("CraftSeq") == craftSeq).FirstOrDefault();
  403. if (row != null)
  404. {
  405. row.Activate();
  406. }
  407. }
  408. private void Save()
  409. {
  410. ultraGrid10.UpdateData();
  411. ultraGrid1.UpdateData();
  412. if (CustomInfo.Contains("PLAN"))
  413. {
  414. //保存6个标准
  415. SaveCraftOrdDesignDown();
  416. return;
  417. }
  418. var rows = ultraGrid1.Rows.Where(a=>a.GetValue("Chk") == "True");
  419. if (rows.Count() == 0)
  420. {
  421. MessageUtil.ShowWarning("请选择记录!");
  422. return;
  423. }
  424. List<CraftOrdDesignEntity> craftOrdDesignList = new List<CraftOrdDesignEntity>();
  425. string ordLnPk = "";
  426. string craftSeq = "";
  427. foreach (var row in rows)
  428. {
  429. CraftOrdDesignEntity craftOrdDesign = EntityHelper.CopyEntity<CraftOrdDesignEntity>(row.ListObject);
  430. craftOrdDesign.UpdateName = UserInfo.GetUserName();
  431. craftOrdDesignList.Add(craftOrdDesign);
  432. ordLnPk = craftOrdDesign.OrdLnPk;
  433. craftSeq = craftOrdDesign.CraftSeq.ToString();
  434. }
  435. if (MessageUtil.ShowYesNoAndQuestion("是否确认保存?") == System.Windows.Forms.DialogResult.No)
  436. {
  437. return;
  438. }
  439. _craftOrdDesignBLL.SaveCraftLv2(craftOrdDesignList);
  440. MessageUtil.ShowTips("保存成功!");
  441. Query();
  442. }
  443. private void SaveCraftOrdDesignDown()
  444. {
  445. if (ultraGrid1.ActiveRow == null) return;
  446. var craftOrdDesign = (ChoiceCraftFileLv2Entity)ultraGrid1.ActiveRow.ListObject;
  447. string processCode = CustomInfo.Substring(0, 1);
  448. switch (ultraTabControl1.ActiveTab.Key)
  449. {
  450. case "cic":
  451. _cicCtrl.Save();
  452. break;
  453. case "pic":
  454. _picCtrl.Save();
  455. break;
  456. case "sic":
  457. _sicCtrl.Save();
  458. break;
  459. case "dic":
  460. _dicCtrl.Save();
  461. break;
  462. case "wic":
  463. _wicCtrl.Save();
  464. break;
  465. case "gic":
  466. _gicCtrl.Save();
  467. break;
  468. case "smp":
  469. if (MessageUtil.ShowYesNoAndQuestion("是否确认保存?") == DialogResult.No)
  470. {
  471. return;
  472. }
  473. // _designStdGicBLL.Save(parms);
  474. List<CraftOrdDesignStdPicSmpTotalEntity> CraftOrdDesignStdPicSmpTotalEntitys =
  475. craftOrdDesignStdPicSmpTotalEntityBindingSource.DataSource as List<CraftOrdDesignStdPicSmpTotalEntity>;
  476. List<CraftOrdDesignStdPicSmpDetailEntity> CraftOrdDesignStdPicSmpDetailEntity =
  477. craftOrdDesignStdPicSmpDetailEntityBindingSource.DataSource as List<CraftOrdDesignStdPicSmpDetailEntity>;
  478. if (!CraftOrdDesignStdPicSmpTotalEntitys.Any() || !CraftOrdDesignStdPicSmpDetailEntity.Any())
  479. {
  480. MessageUtil.ShowTips("无试样取样数据!");
  481. return;
  482. }
  483. var checkList =
  484. CraftOrdDesignStdPicSmpDetailEntity.Where(p => p.Rate == "408602" || p.Rate == "401101" || p.Rate == "408608").ToList();
  485. if (checkList.Any() && checkList.Any(p=>!p.BatchCnt.TryParseInt()))
  486. {
  487. MessageBox.Show("分批取样数量必须是数字");
  488. return;
  489. }
  490. ultraGrid9.UpdateData();
  491. _craftOrdDesignBLL.SaveCraftSampling(CraftOrdDesignStdPicSmpTotalEntitys, CraftOrdDesignStdPicSmpDetailEntity);
  492. BindSmpDataGroup(craftOrdDesign.OrdLnPk,craftOrdDesign.CraftSeq.ToString(), craftOrdDesign.CraftNo, craftOrdDesign.DesginKey, craftOrdDesign.MscPline, processCode, craftOrdDesign.Cic,
  493. craftOrdDesign.CutNum == null ? 1 : (int)craftOrdDesign.CutNum);
  494. MessageUtil.ShowTips("保存成功!");
  495. break;
  496. }
  497. }
  498. /// <summary>
  499. /// 计划科委托
  500. /// </summary>
  501. private void Consign()
  502. {
  503. ultraGrid10.UpdateData();
  504. var rows = ultraGrid1.Rows.Where(a => a.GetValue("Chk") == "True");
  505. if (!rows.Any())
  506. {
  507. MessageUtil.ShowWarning("请勾选一条记录!");
  508. return;
  509. }
  510. if (MessageUtil.ShowYesNoAndQuestion("是否确认?") == System.Windows.Forms.DialogResult.No)
  511. {
  512. return;
  513. }
  514. List<object> paras = new List<object>();
  515. foreach (var ultraGridRow in rows)
  516. {
  517. List<object> para = new List<object>();
  518. var craftOrdDesign = (ChoiceCraftFileLv2Entity)ultraGridRow.ListObject;
  519. string Process = CustomInfo.Substring(0, 1);
  520. List<CraftOrdDesignStdPicSmpDetailEntity> list = null;
  521. List<CraftOrdDesignStdPicSmpTotalEntity> listToltal = null;
  522. if (ultraGridRow.Activated)
  523. {
  524. listToltal =
  525. craftOrdDesignStdPicSmpTotalEntityBindingSource.DataSource as
  526. List<CraftOrdDesignStdPicSmpTotalEntity>;
  527. list =
  528. craftOrdDesignStdPicSmpDetailEntityBindingSource.DataSource as
  529. List<CraftOrdDesignStdPicSmpDetailEntity>;
  530. var checkList =
  531. list.Where(p => p.Rate == "408602" || p.Rate == "401101" || p.Rate == "408608").ToList();
  532. if (checkList.Any())
  533. {
  534. var HxCheckList = checkList.Where(p => p.PhyCodeMin == "HX").ToList();
  535. var OtherCheckList = checkList.Where(p => p.PhyCodeMin != "HX").ToList();
  536. if (OtherCheckList.Any() && OtherCheckList.Any(p => !p.BatchCnt.TryParseInt()))
  537. {
  538. MessageBox.Show("分批取样数量必须是数字");
  539. return;
  540. }
  541. if (HxCheckList.Any() && !OtherCheckList.Any())
  542. {
  543. MessageBox.Show("化学频率是检验批,无检验批理化检验项, 无法识别分批数量!");
  544. return;
  545. }
  546. }
  547. }
  548. else
  549. {
  550. list = _craftOrdDesignBLL.GetCraftPicSmpGroup(craftOrdDesign.OrdLnPk,
  551. craftOrdDesign.CraftSeq.ToString(), craftOrdDesign.CraftNo, craftOrdDesign.DesginKey,
  552. craftOrdDesign.MscPline, Process, craftOrdDesign.Cic,
  553. craftOrdDesign.CutNum == null ? 1 : (int)craftOrdDesign.CutNum);
  554. listToltal = GetCraftSamplingTotal(craftOrdDesign.OrdLnPk, craftOrdDesign.CraftSeq.ToString(),
  555. craftOrdDesign.CraftNo, craftOrdDesign.ProcessCodes, list);
  556. var checkList =
  557. list.Where(p => p.Rate == "408602" || p.Rate == "401101" || p.Rate == "408608").ToList();
  558. if (checkList.Any())
  559. {
  560. var HxCheckList = checkList.Where(p => p.PhyCodeMin == "HX").ToList();
  561. var OtherCheckList = checkList.Where(p => p.PhyCodeMin != "HX").ToList();
  562. if (OtherCheckList.Any() && OtherCheckList.Any(p => !p.BatchCnt.TryParseInt()))
  563. {
  564. MessageBox.Show("分批取样数量必须是数字");
  565. return;
  566. }
  567. if (HxCheckList.Any() && !OtherCheckList.Any())
  568. {
  569. MessageBox.Show("化学频率是检验批,无检验批理化检验项, 无法识别分批数量!");
  570. return;
  571. }
  572. }
  573. if (checkList.Any() && checkList.Any(p => !p.BatchCnt.TryParseInt()))
  574. {
  575. MessageBox.Show("分批取样数量必须是数字");
  576. return;
  577. }
  578. }
  579. if (list.Where(p => p.PhyCodeMin != "HX").Select(p => p.Pic).Distinct().Count() > 1)
  580. {
  581. MessageBox.Show("合同(" + craftOrdDesign.OrderManageNo + ") PIC存在多个,请通知工艺人员变更工艺");
  582. return;
  583. }
  584. if (craftOrdDesign.FlagDStr.Equals("是") && Process.Equals("D"))
  585. {
  586. MessageUtil.ShowWarning("已确认的计划不能委托!");
  587. return;
  588. }
  589. para.Add(Process);
  590. para.Add(craftOrdDesign.OrdLnPk);
  591. para.Add(craftOrdDesign.CraftSeq.ToString());
  592. para.Add(listToltal.Select(JSONFormat.Format).ToList());
  593. para.Add(list.Select(JSONFormat.Format).ToList());
  594. paras.Add(para);
  595. }
  596. _craftOrdDesignBLL.SetProcessJhFlag(paras, "1");
  597. MessageUtil.ShowTips("委托成功!");
  598. Query();
  599. }
  600. private void Submit()
  601. {
  602. /* var row = ultraGrid1.Rows.Where(a=>a.GetValue("Chk") == "True").FirstOrDefault();
  603. if (row == null)
  604. {
  605. MessageUtil.ShowWarning("请勾选一条记录!");
  606. return;
  607. }
  608. string process = CustomInfo.Substring(0, 1);
  609. string ordLnPk = row.GetValue("OrdLnPk");
  610. string craftSeq = row.GetValue("CraftSeq");
  611. string craftNo = row.GetValue("CraftNo");
  612. if (MessageUtil.ShowYesNoAndQuestion("是否确认?") == System.Windows.Forms.DialogResult.No)
  613. {
  614. return;
  615. }
  616. List<CraftOrdDesignStdPicSmpTotalEntity> CraftOrdDesignStdPicSmpTotalEntitys =
  617. craftOrdDesignStdPicSmpTotalEntityBindingSource.DataSource as List<CraftOrdDesignStdPicSmpTotalEntity>;
  618. List<CraftOrdDesignStdPicSmpDetailEntity> CraftOrdDesignStdPicSmpDetailEntity =
  619. craftOrdDesignStdPicSmpDetailEntityBindingSource.DataSource as List<CraftOrdDesignStdPicSmpDetailEntity>;
  620. if (CraftOrdDesignStdPicSmpTotalEntitys.Any() && CraftOrdDesignStdPicSmpDetailEntity.Any())
  621. {
  622. ultraGrid9.UpdateData();
  623. _craftOrdDesignBLL.SaveCraftSampling(CraftOrdDesignStdPicSmpTotalEntitys, CraftOrdDesignStdPicSmpDetailEntity);
  624. }
  625. _craftOrdDesignBLL.SetProcessFlag(process, "1", ordLnPk, craftSeq);
  626. MessageUtil.ShowTips("确认成功!");
  627. Relocat(ordLnPk, craftSeq);*/
  628. ultraGrid10.UpdateData();
  629. var rows = ultraGrid1.Rows.Where(a => a.GetValue("Chk") == "True");
  630. if (!rows.Any())
  631. {
  632. MessageUtil.ShowWarning("请勾选一条记录!");
  633. return;
  634. }
  635. if (MessageUtil.ShowYesNoAndQuestion("是否确认?") == System.Windows.Forms.DialogResult.No)
  636. {
  637. return;
  638. }
  639. List<object> paras = new List<object>();
  640. foreach (var ultraGridRow in rows)
  641. {
  642. List<object> para = new List<object>();
  643. var craftOrdDesign = (ChoiceCraftFileLv2Entity)ultraGridRow.ListObject;
  644. string Process = CustomInfo.Substring(0, 1);
  645. List<CraftOrdDesignStdPicSmpDetailEntity> list = null;
  646. List<CraftOrdDesignStdPicSmpTotalEntity> listToltal = null;
  647. if (ultraGridRow.Activated)
  648. {
  649. listToltal =
  650. craftOrdDesignStdPicSmpTotalEntityBindingSource.DataSource as
  651. List<CraftOrdDesignStdPicSmpTotalEntity>;
  652. list =
  653. craftOrdDesignStdPicSmpDetailEntityBindingSource.DataSource as
  654. List<CraftOrdDesignStdPicSmpDetailEntity>;
  655. var checkList =
  656. list.Where(p => p.Rate == "408602" || p.Rate == "401101" || p.Rate == "408608").ToList();
  657. if (checkList.Any())
  658. {
  659. var HxCheckList =checkList.Where(p=>p.PhyCodeMin=="HX").ToList();
  660. var OtherCheckList = checkList.Where(p => p.PhyCodeMin != "HX").ToList();
  661. if (OtherCheckList.Any() && OtherCheckList.Any(p => !p.BatchCnt.TryParseInt()))
  662. {
  663. MessageBox.Show("分批取样数量必须是数字");
  664. return;
  665. }
  666. if (HxCheckList.Any() && !OtherCheckList.Any())
  667. {
  668. MessageBox.Show("化学频率是检验批,无检验批理化检验项, 无法识别分批数量!");
  669. return;
  670. }
  671. }
  672. }
  673. else
  674. {
  675. list = _craftOrdDesignBLL.GetCraftPicSmpGroup(craftOrdDesign.OrdLnPk,
  676. craftOrdDesign.CraftSeq.ToString(), craftOrdDesign.CraftNo, craftOrdDesign.DesginKey,
  677. craftOrdDesign.MscPline, Process, craftOrdDesign.Cic,
  678. craftOrdDesign.CutNum == null ? 1 : (int) craftOrdDesign.CutNum);
  679. listToltal = GetCraftSamplingTotal(craftOrdDesign.OrdLnPk, craftOrdDesign.CraftSeq.ToString(),
  680. craftOrdDesign.CraftNo, craftOrdDesign.ProcessCodes, list);
  681. var checkList =
  682. list.Where(p => p.Rate == "408602" || p.Rate == "401101" || p.Rate == "408608").ToList();
  683. if (checkList.Any())
  684. {
  685. var HxCheckList =checkList.Where(p=>p.PhyCodeMin=="HX").ToList();
  686. var OtherCheckList = checkList.Where(p => p.PhyCodeMin != "HX").ToList();
  687. if (OtherCheckList.Any() && OtherCheckList.Any(p => !p.BatchCnt.TryParseInt()))
  688. {
  689. MessageBox.Show("分批取样数量必须是数字");
  690. return;
  691. }
  692. if (HxCheckList.Any() && !OtherCheckList.Any())
  693. {
  694. MessageBox.Show("化学频率是检验批,无检验批理化检验项, 无法识别分批数量!");
  695. return;
  696. }
  697. }
  698. if (checkList.Any() && checkList.Any(p => !p.BatchCnt.TryParseInt()))
  699. {
  700. MessageBox.Show("分批取样数量必须是数字");
  701. return;
  702. }
  703. }
  704. if (list.Where(p => p.PhyCodeMin != "HX").Select(p => p.Pic).Distinct().Count() > 1)
  705. {
  706. MessageBox.Show("合同(" + craftOrdDesign.OrderManageNo + ") PIC存在多个,请通知工艺人员变更工艺");
  707. return;
  708. }
  709. para.Add(Process);
  710. para.Add(craftOrdDesign.OrdLnPk);
  711. para.Add(craftOrdDesign.CraftSeq.ToString());
  712. para.Add(listToltal.Select(JSONFormat.Format).ToList());
  713. para.Add(list.Select(JSONFormat.Format).ToList());
  714. paras.Add(para);
  715. }
  716. _craftOrdDesignBLL.SetProcessFlag(paras, "1");
  717. MessageUtil.ShowTips("确认成功!");
  718. Query();
  719. }
  720. private void Cancel2()
  721. {
  722. /* var row = ultraGrid1.Rows.Where(a => a.GetValue("Chk") == "True").FirstOrDefault();
  723. if (row == null)
  724. {
  725. MessageUtil.ShowWarning("请勾选一条记录!");
  726. return;
  727. }
  728. string process = CustomInfo.Substring(0, 1);
  729. string ordLnPk = row.GetValue("OrdLnPk");
  730. string craftSeq = row.GetValue("CraftSeq");
  731. string craftNo = row.GetValue("CraftNo");
  732. if (MessageUtil.ShowYesNoAndQuestion("是否取消确认?") == System.Windows.Forms.DialogResult.No)
  733. {
  734. return;
  735. }
  736. List<CraftOrdDesignStdPicSmpTotalEntity> CraftOrdDesignStdPicSmpTotalEntitys =
  737. craftOrdDesignStdPicSmpTotalEntityBindingSource.DataSource as List<CraftOrdDesignStdPicSmpTotalEntity>;
  738. if (CraftOrdDesignStdPicSmpTotalEntitys!=null && CraftOrdDesignStdPicSmpTotalEntitys.Any() )
  739. {
  740. ultraGrid9.UpdateData();
  741. _craftOrdDesignBLL.CancelCraftSampling(CraftOrdDesignStdPicSmpTotalEntitys.FirstOrDefault());
  742. }
  743. _craftOrdDesignBLL.SetProcessFlag(process, "0", ordLnPk, craftSeq);
  744. MessageUtil.ShowTips("取消成功!");
  745. Relocat(ordLnPk, craftSeq);*/
  746. var rows = ultraGrid1.Rows.Where(a => a.GetValue("Chk") == "True");
  747. if (!rows.Any())
  748. {
  749. MessageUtil.ShowWarning("请勾选一条记录!");
  750. return;
  751. }
  752. if (MessageUtil.ShowYesNoAndQuestion("是否取消确认?") == System.Windows.Forms.DialogResult.No)
  753. {
  754. return;
  755. }
  756. List<object> paras = new List<object>();
  757. foreach (var ultraGridRow in rows)
  758. {
  759. List<object> para = new List<object>();
  760. var craftOrdDesign = (ChoiceCraftFileLv2Entity)ultraGridRow.ListObject;
  761. string Process = CustomInfo.Substring(0, 1);
  762. var list = _craftOrdDesignBLL.GetCraftPicSmpGroup(craftOrdDesign.OrdLnPk, craftOrdDesign.CraftSeq.ToString(), craftOrdDesign.CraftNo, craftOrdDesign.DesginKey,
  763. craftOrdDesign.Msc, Process, craftOrdDesign.Cic, craftOrdDesign.CutNum == null ? 1 : (int)craftOrdDesign.CutNum);
  764. var listToltal = GetCraftSamplingTotal(craftOrdDesign.OrdLnPk, craftOrdDesign.CraftSeq.ToString(), craftOrdDesign.CraftNo, craftOrdDesign.ProcessCodes, list);
  765. if (craftOrdDesign.FlagD.Equals("是") && Process.Equals("D"))
  766. {
  767. MessageUtil.ShowWarning("已确认的计划不能取消委托!");
  768. return;
  769. }
  770. para.Add(Process);
  771. para.Add(craftOrdDesign.OrdLnPk);
  772. para.Add(craftOrdDesign.CraftSeq.ToString());
  773. para.Add(JSONFormat.Format(listToltal.Any()? listToltal.FirstOrDefault():new CraftOrdDesignStdPicSmpTotalEntity() ));
  774. paras.Add(para);
  775. }
  776. _craftOrdDesignBLL.SetProcessFlag(paras, "0");
  777. MessageUtil.ShowTips("取消成功!");
  778. Query();
  779. }
  780. /// <summary>
  781. /// 取消计划科委托
  782. /// </summary>
  783. private void CancelConsign()
  784. {
  785. var rows = ultraGrid1.Rows.Where(a => a.GetValue("Chk") == "True");
  786. if (!rows.Any())
  787. {
  788. MessageUtil.ShowWarning("请勾选一条记录!");
  789. return;
  790. }
  791. if (MessageUtil.ShowYesNoAndQuestion("是否取消确认?") == System.Windows.Forms.DialogResult.No)
  792. {
  793. return;
  794. }
  795. List<object> paras = new List<object>();
  796. foreach (var ultraGridRow in rows)
  797. {
  798. List<object> para = new List<object>();
  799. var craftOrdDesign = (ChoiceCraftFileLv2Entity)ultraGridRow.ListObject;
  800. string Process = CustomInfo.Substring(0, 1);
  801. var list = _craftOrdDesignBLL.GetCraftPicSmpGroup(craftOrdDesign.OrdLnPk, craftOrdDesign.CraftSeq.ToString(), craftOrdDesign.CraftNo, craftOrdDesign.DesginKey,
  802. craftOrdDesign.Msc, Process, craftOrdDesign.Cic, craftOrdDesign.CutNum == null ? 1 : (int)craftOrdDesign.CutNum);
  803. var listToltal = GetCraftSamplingTotal(craftOrdDesign.OrdLnPk, craftOrdDesign.CraftSeq.ToString(), craftOrdDesign.CraftNo, craftOrdDesign.ProcessCodes, list);
  804. para.Add(Process);
  805. para.Add(craftOrdDesign.OrdLnPk);
  806. para.Add(craftOrdDesign.CraftSeq.ToString());
  807. para.Add(JSONFormat.Format(listToltal.Any() ? listToltal.FirstOrDefault() : new CraftOrdDesignStdPicSmpTotalEntity()));
  808. paras.Add(para);
  809. }
  810. _craftOrdDesignBLL.SetProcessJhFlag(paras, "0");
  811. MessageUtil.ShowTips("取消成功!");
  812. Query();
  813. }
  814. private void Cancel()
  815. {
  816. }
  817. private void ultraTextEditor1_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  818. {
  819. CraftOrdDesignEntity craftOrdDesign = _craftOrdDesignBLL.QueryByPk(new CraftOrdDesignEntity()
  820. {
  821. OrdLnPk = ultraGrid1.ActiveRow.GetValue("OrdLnPk"),
  822. CraftSeq = decimal.Parse(ultraGrid1.ActiveRow.GetValue("CraftSeq"))
  823. });
  824. //if (craftOrdDesign.Validflag != "1")
  825. //{
  826. // MessageUtil.ShowWarning("只有生效状态才能选择二级工艺文件!");
  827. // return;
  828. //}
  829. string msc = ultraGrid1.ActiveRow.GetValue("Msc");
  830. switch (ultraGrid1.ActiveCell.Column.Key)
  831. {
  832. case "CraftFileLv2DDesc":
  833. ChoiceCraftFileLv2(craftOrdDesign.DesginKey, "D", "轧制", craftOrdDesign.CraftNo, msc);
  834. break;
  835. case "CraftFileLv2EDesc":
  836. ChoiceCraftFileLv2(craftOrdDesign.DesginKey, "E", "镦拔扩", craftOrdDesign.CraftNo, msc);
  837. break;
  838. case "CraftFileLv2FDesc":
  839. ChoiceCraftFileLv2(craftOrdDesign.DesginKey, "F", "热处理", craftOrdDesign.CraftNo, msc);
  840. break;
  841. case "CraftFileLv2GDesc":
  842. ChoiceCraftFileLv2(craftOrdDesign.DesginKey, "G", "加工", craftOrdDesign.CraftNo, msc);
  843. break;
  844. case "CraftFileLv2HDesc":
  845. ChoiceCraftFileLv2(craftOrdDesign.DesginKey, "H", "接箍加工", craftOrdDesign.CraftNo, msc);
  846. break;
  847. }
  848. }
  849. private void ChoiceCraftFileLv2(string designKey, string processCode, string processDesc, string craftNo, string msc)
  850. {
  851. var rows = ultraGrid1.Rows.Where(a => a.GetValue("Chk") == "True");
  852. //if (rows.Count() == 0)
  853. //{
  854. // MessageUtil.ShowWarning("请至少勾选一条记录!");
  855. // return;
  856. //}
  857. int cnt = _craftOrdDesignBLL.GetCntByDesignKeyProcess(designKey, processCode);
  858. if (cnt == 0)
  859. {
  860. MessageUtil.ShowWarning("一级工艺文件不包含" + processDesc + "工序!");
  861. return;
  862. }
  863. string craftFileLv2Pks = ultraGrid1.GetActiveRowValue("CraftFileLv2" + processCode);
  864. bool isAddAsk = ultraGrid1.GetActiveRowValue("DescriptionDiff") == "" ? false : true;
  865. string modelCode = ultraGrid1.GetActiveRowValue("ModelCode");
  866. string modelDesc = ultraGrid1.GetActiveRowValue("ModelDesc");
  867. string dimater = ultraGrid1.GetActiveRowValue("Dimater");
  868. string height = ultraGrid1.GetActiveRowValue("Height");
  869. FrmCraftFileLv2 frmCraftFileLv2 = new FrmCraftFileLv2(designKey, processCode, craftFileLv2Pks,
  870. craftNo, "0", ob, msc, isAddAsk, modelCode, modelDesc, dimater, height);
  871. if (frmCraftFileLv2.ShowDialog() == DialogResult.OK)
  872. {
  873. foreach (var row in rows)
  874. {
  875. row.SetValue("CraftFileLv2" + processCode, frmCraftFileLv2.CraftFileLv2Pks);
  876. row.SetValue("CraftFileLv2" + processCode + "Desc", frmCraftFileLv2.CraftFileLv2Nos);
  877. }
  878. }
  879. }
  880. private PopupTextBox popupTextBox;
  881. private void craftImg_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  882. {
  883. switch (ultraGrid1.ActiveCell.Column.Key)
  884. {
  885. case "CraftPath":
  886. var row = ultraGrid1.ActiveRow;
  887. CraftOrdDesignEntity craftOrdDesign = (CraftOrdDesignEntity)row.ListObject;
  888. string filePathOld = row.GetValue("CraftPathOld");
  889. string filePathNew = "Qcm/Craft/" + craftOrdDesign.OrdLnPk + "/" + craftOrdDesign.CraftSeq + "/";
  890. if (e.Button.Key.ToLower().Equals("select"))
  891. {
  892. dlgOrderAskDown down = new dlgOrderAskDown(this.ob, filePathOld);
  893. down.DeleteButton.Visible = false;
  894. down.ShowDialog();
  895. }
  896. break;
  897. case "OrderSpecialDesc":
  898. case "DescriptionDiff":
  899. case "DescriptionAll":
  900. case "ChgeVal":
  901. case "Memo":
  902. case "CraftChangeMemo":
  903. popupTextBox = new PopupTextBox(ultraGrid1.ActiveCell.Value.ToString());
  904. popupTextBox.TxtInfo.ReadOnly = true;
  905. popupTextBox.UltraPanel1.Visible = false;
  906. popupTextBox.Show();
  907. break;
  908. }
  909. }
  910. private void lblCmbPlanStatus_CheckBox_CheckedChanged(object sender, EventArgs e)
  911. {
  912. }
  913. private void ultraGrid1_MouseUp(object sender, MouseEventArgs e)
  914. {
  915. //foreach (var row in ultraGrid1.Rows)
  916. //{
  917. // if (row.Selected)
  918. // {
  919. // row.Cells["CHK"].Value = true;
  920. // }
  921. //}
  922. ultraGrid1.UpdateData();
  923. }
  924. private void ultraGrid1_CellChange(object sender, Infragistics.Win.UltraWinGrid.CellEventArgs e)
  925. {
  926. /* if (e.Cell.Column.Key == "Chk")
  927. {
  928. UltraGridRow chkRow = e.Cell.Row;
  929. foreach (UltraGridRow row in ultraGrid1.Rows)
  930. {
  931. if (row.Cells["Chk"].Value.ToString() == "True" && row != chkRow)
  932. {
  933. row.Cells["Chk"].Value = false;
  934. row.Update();
  935. }
  936. }
  937. }
  938. ultraGrid1.UpdateData();*/
  939. }
  940. private void QueryCraftOrdDesignDown()
  941. {
  942. if (ultraGrid1.ActiveRow == null) return;
  943. var craftOrdDesign = (ChoiceCraftFileLv2Entity)ultraGrid1.ActiveRow.ListObject;
  944. string processCode = CustomInfo.Substring(0, 1);
  945. DataTable dt;
  946. switch (ultraTabControl1.ActiveTab.Key)
  947. {
  948. case "cic":
  949. /* dt = _cicBLL.getCraftMscPline(craftOrdDesign.DesginKey, processCode);
  950. GridHelper.CopyDataToDatatable(dt, dataTable1, true);*/
  951. _cicCtrl.QueryByDesignKeyCic(new string[] { craftOrdDesign.DesginKey, craftOrdDesign.MscPline, processCode, craftOrdDesign.Cic });
  952. break;
  953. case "pic":
  954. /* dt = _picBLL.getCraftMscPline(craftOrdDesign.DesginKey, processCode);
  955. GridHelper.CopyDataToDatatable(dt, dataTable1, true);*/
  956. dt = _picBLL.getGroupPhyMin(craftOrdDesign.DesginKey, "", craftOrdDesign.MscPline, processCode);
  957. GridHelper.CopyDataToDatatable(dt, dataTable2, true);
  958. break;
  959. case "sic":
  960. /*dt = _sicBLL.getCraftMscPline(craftOrdDesign.DesginKey, processCode);
  961. GridHelper.CopyDataToDatatable(dt, dataTable1, true);*/
  962. _sicCtrl.QueryByDesignKeySic(new string[] { craftOrdDesign.DesginKey, craftOrdDesign.MscPline, processCode, "" });
  963. break;
  964. case "dic":
  965. /* dt = _dicBLL.getCraftMscPline(craftOrdDesign.DesginKey, processCode);
  966. GridHelper.CopyDataToDatatable(dt, dataTable1, true);*/
  967. _dicCtrl.QueryByDesignKeyDic(new string[] { craftOrdDesign.DesginKey, craftOrdDesign.MscPline, processCode, "" });
  968. break;
  969. case "wic":
  970. /* dt = _wicBLL.getCraftMscPline(craftOrdDesign.DesginKey, processCode);
  971. GridHelper.CopyDataToDatatable(dt, dataTable1, true);*/
  972. _wicCtrl.QueryByDesignKeyWic(new string[] { craftOrdDesign.DesginKey, craftOrdDesign.MscPline, processCode, "" });
  973. break;
  974. case "gic":
  975. /* dt = _gicBLL.getCraftMscPline(craftOrdDesign.DesginKey, processCode);
  976. GridHelper.CopyDataToDatatable(dt, dataTable1, true);*/
  977. _gicCtrl.QueryByDesignKeyGic(new string[] { craftOrdDesign.DesginKey, craftOrdDesign.MscPline, processCode, "" });
  978. break;
  979. case "smp":
  980. // BindSmpDataGroup(craftOrdDesign.DesginKey, processCode);
  981. // BindSmpData(craftOrdDesign.DesginKey, processCode);
  982. BindSmpDataGroup(craftOrdDesign.OrdLnPk, craftOrdDesign.CraftSeq.ToString(), craftOrdDesign.CraftNo, craftOrdDesign.DesginKey, craftOrdDesign.MscPline, processCode, craftOrdDesign.Cic,craftOrdDesign.CutNum == null ? 1 : (int)craftOrdDesign.CutNum);
  983. break;
  984. }
  985. }
  986. private void BindSmpDataGroup(string designKey, string processCode)
  987. {
  988. DataTable dt = _craftOrdDesignBLL.GetCraftPicSmpGroup(designKey, processCode);
  989. ultraGrid10.BeginUpdate();
  990. GridHelper.CopyDataToDatatable(dt, dataTable4, true);
  991. GridHelper.RefreshAndAutoSize(ultraGrid10);
  992. ultraGrid10.EndUpdate();
  993. }
  994. private void BindSmpDataGroup(string LnPk,string CraftSeq, string CraftNo, string designKey, string Msc, string processCode,string Cic,int Cut)
  995. {
  996. var list = _craftOrdDesignBLL.GetCraftPicSmpGroup(LnPk, CraftSeq, CraftNo, designKey, Msc, processCode, Cic,Cut);
  997. craftOrdDesignStdPicSmpDetailEntityBindingSource.DataSource = list;
  998. GridHelper.RefreshAndAutoSize(ultraGrid10);
  999. var listToltal = GetCraftSamplingTotal(LnPk, CraftSeq, CraftNo, processCode, list);
  1000. craftOrdDesignStdPicSmpTotalEntityBindingSource.DataSource = listToltal;
  1001. ultraGrid9.DisplayLayout.Bands[0].Columns["TypeStr"].Hidden =
  1002. listToltal.Where(p => p.BatchNum != 0).Select(p => p.BatchNum).Distinct().Count() <=
  1003. 1;
  1004. ultraGrid9.DisplayLayout.Bands[0].Columns["StoveNum"].Hidden =
  1005. listToltal.Select(p => p.StoveNum).Distinct().Count() <=
  1006. 1;
  1007. GridHelper.RefreshAndAutoSize(ultraGrid9);
  1008. var list2 = _craftOrdDesignBLL.getSampleDetail(designKey, processCode);
  1009. craftOrdDesignStdPicEntityBindingSource.DataSource = list2;
  1010. GridHelper.RefreshAndAutoSize(ultraGrid11);
  1011. }
  1012. private List<CraftOrdDesignStdPicSmpTotalEntity> GetCraftSamplingTotal(string LnPk, string CraftSeq, string CraftNo, string processCode, List<CraftOrdDesignStdPicSmpDetailEntity> list)
  1013. {
  1014. var listToltal = _craftOrdDesignBLL.GetCraftSamplingTotal(LnPk, CraftSeq, CraftNo, processCode);
  1015. if (!listToltal.Any())
  1016. {
  1017. list =CutAB(list);
  1018. //找出生产批的检验项
  1019. var ProBatch = list.Where(p => p.Rate == "408601" || p.Rate == "408608").ToList();
  1020. if (ProBatch.Any())
  1021. {
  1022. listToltal.AddRange(GetAllToltalData(list, "1"));
  1023. }
  1024. listToltal.AddRange(GetAllToltalData(list.Where(p => p.Rate != "408601" && p.Rate != "408608").ToList(),
  1025. ProBatch.Any() ? "0" : ""));
  1026. }
  1027. else
  1028. {
  1029. maxBatch = listToltal.Max(p => (int) (p.BatchNum ?? 0));
  1030. }
  1031. return listToltal;
  1032. }
  1033. public List<CraftOrdDesignStdPicSmpDetailEntity> CutAB(List<CraftOrdDesignStdPicSmpDetailEntity> lists)
  1034. {
  1035. lists = lists.Select(p => p.Clone() as CraftOrdDesignStdPicSmpDetailEntity).ToList();
  1036. var listAB = lists.Where(p => p.Position == "401204").ToList();
  1037. return listAB.SelectMany(p =>
  1038. {
  1039. List<CraftOrdDesignStdPicSmpDetailEntity> list = new List<CraftOrdDesignStdPicSmpDetailEntity>();
  1040. if (p.DescCount == "1")
  1041. {
  1042. int Samplen;
  1043. if (!int.TryParse(p.SampleCount, out Samplen))
  1044. {
  1045. Samplen = 2;
  1046. }
  1047. CraftOrdDesignStdPicSmpDetailEntity A = p.Clone() as CraftOrdDesignStdPicSmpDetailEntity;
  1048. A.Position = "401201";
  1049. A.DescPosition = "A端";
  1050. A.SampleCount = (Samplen / 2).ToString();
  1051. list.Add(A);
  1052. CraftOrdDesignStdPicSmpDetailEntity B = p.Clone() as CraftOrdDesignStdPicSmpDetailEntity;
  1053. B.Position = "401202";
  1054. B.DescPosition = "B端";
  1055. B.SampleCount = (Samplen / 2).ToString();
  1056. lists.Add(B);
  1057. }
  1058. else
  1059. {
  1060. int Samplen;
  1061. if (!int.TryParse(p.DescCount, out Samplen))
  1062. {
  1063. Samplen = 2;
  1064. }
  1065. CraftOrdDesignStdPicSmpDetailEntity A = p.Clone() as CraftOrdDesignStdPicSmpDetailEntity;
  1066. A.Position = "401201";
  1067. A.DescPosition = "A端";
  1068. A.DescCount = (Samplen/2).ToString();
  1069. list.Add(A);
  1070. CraftOrdDesignStdPicSmpDetailEntity B = p.Clone() as CraftOrdDesignStdPicSmpDetailEntity;
  1071. B.Position = "401202";
  1072. B.DescPosition = "B端";
  1073. B.DescCount = (Samplen/2).ToString();
  1074. lists.Add(B);
  1075. }
  1076. return list;
  1077. }
  1078. ).ToList().Concat(lists.Where(p => p.Position != "401204")).ToList();
  1079. }
  1080. public List<CraftOrdDesignStdPicSmpTotalEntity> GetOnlyBatchList(List<CraftOrdDesignStdPicSmpDetailEntity> lists, int Type, int BatchNo)
  1081. {
  1082. List<CraftOrdDesignStdPicSmpTotalEntity> listTotalAll = new List<CraftOrdDesignStdPicSmpTotalEntity>();
  1083. /* //先将检验批A端排列好
  1084. GetNewList(listTotalAll,
  1085. lists.Where(p => p.Rate == "408602" && p.Position == "401201").ToList(), "401201", "A端", Type, BatchNo);
  1086. //再将检验批B端排列好
  1087. GetNewList(listTotalAll,
  1088. lists.Where(p => p.Rate == "408602" && p.Position == "401202").ToList(), "401202", "B端", Type, BatchNo);
  1089. //再将检验批A或B端整合进A端或B端 若A或B端管头数大于A端和B端和 先暂时保留A端或B端 给后续插入整炉 留选择. 最后再把A端或B端改成A端
  1090. GetNewList(listTotalAll,
  1091. lists.Where(p => p.Rate == "408602" && p.Position == "401203").ToList(), "401203", "A端或B端", Type, BatchNo);*/
  1092. // A和B端 A端和B端 都取
  1093. foreach (var data in lists.Where(p => p.Rate == "408602" || p.Rate == "401101" || p.Rate == "408608").OrderBy(p => p.Position).GroupBy(p => new { p.Position, p.DescPosition }))
  1094. {
  1095. GetNewList(listTotalAll,
  1096. data.ToList(), data.Key.Position, data.Key.DescPosition, Type, BatchNo);
  1097. }
  1098. if (!listTotalAll.Any() && lists.Any()) listTotalAll.Add(new CraftOrdDesignStdPicSmpTotalEntity()
  1099. {
  1100. OrdLnPk = lists[0].OrdLnPk,
  1101. CraftSeq = lists[0].CraftSeq,
  1102. CraftNo = lists[0].CraftNo,
  1103. ProcessCode = lists[0].ProcessCode,
  1104. Position = "",
  1105. DescPosition = "",
  1106. SampleCount = "0",
  1107. SampleLength = "0",
  1108. BatchNo = BatchNo,
  1109. BatchNum = Type,
  1110. });
  1111. return listTotalAll;
  1112. }
  1113. private List<CraftOrdDesignStdPicSmpDetailEntity> AddStoveToBatchList(List<CraftOrdDesignStdPicSmpTotalEntity> listTotalAll, List<CraftOrdDesignStdPicSmpDetailEntity> lists, int Type, int BatchNo)
  1114. {
  1115. //先将炉批A端 加入检验批中,返回剩下不能加入的炉批
  1116. var list1 = AddStoveToBatch(listTotalAll,
  1117. lists.Where(p => (p.Rate == "408603" || p.Rate == "408601") && p.Position == "401201").ToList(), "401201", "A端", Type, BatchNo);
  1118. //再将检验批B端排列好
  1119. var list2 = AddStoveToBatch(listTotalAll,
  1120. lists.Where(p => (p.Rate == "408603" || p.Rate == "408601") && p.Position == "401202").ToList(), "401202", "B端", Type, BatchNo);
  1121. //再将检验批A或B端整合进A端或B端 若A或B端管头数A端和B端和 先暂时保留A端或B端 给后续插入整炉 留选择. 最后再把A端或B端改成A端
  1122. var list3 = AddStoveToBatch(listTotalAll,
  1123. lists.Where(p => (p.Rate == "408603" || p.Rate == "408601") && p.Position == "401203").ToList(), "401203", "A端或B端", Type, BatchNo);
  1124. /*var list4 = AddStoveToBatch(listTotalAll,
  1125. lists.Where(p => (p.Rate == "408603" || p.Rate == "408601") && p.Position == "401204").ToList(), "401204", "A端和B端", Type, BatchNo);*/
  1126. List<CraftOrdDesignStdPicSmpDetailEntity> returnData = new List<CraftOrdDesignStdPicSmpDetailEntity>();
  1127. if (list1 != null && list1.Count > 0) returnData = returnData.Concat(list1).ToList();
  1128. if (list2 != null && list2.Count > 0) returnData = returnData.Concat(list2).ToList();
  1129. if (list3 != null && list3.Count > 0) returnData = returnData.Concat(list3).ToList();
  1130. foreach (var data in lists.Where(p => (p.Rate == "408603" || p.Rate == "408601") && p.Position != "401201" && p.Position != "401202" && p.Position != "401203").GroupBy(p => new { p.Position, p.DescPosition }))
  1131. {
  1132. var listother = AddStoveToBatch(listTotalAll, data.ToList(), data.Key.DescPosition,
  1133. data.Key.DescPosition, Type, BatchNo);
  1134. if (listother != null && listother.Count > 0) returnData = returnData.Concat(listother).ToList();
  1135. }
  1136. return returnData;
  1137. }
  1138. public void GetNewList(List<CraftOrdDesignStdPicSmpTotalEntity> listTotalAll,
  1139. List<CraftOrdDesignStdPicSmpDetailEntity> listA, string position, string positionName, int Type, int BatchNo)
  1140. {
  1141. if (listTotalAll==null) listTotalAll = new List<CraftOrdDesignStdPicSmpTotalEntity>();
  1142. var data = position == "401203" ?
  1143. listTotalAll.Where(p => p.Position == "401201" || p.Position == "401202" || p.Position == "").ToList()
  1144. : listTotalAll.Where(p => p.Position == position || p.Position == "").ToList();
  1145. foreach (var As in listA)
  1146. {
  1147. var data1 = GetCanNotMergeData(data, As);
  1148. int count = As.DescCount.TryParseInt() ? int.Parse(As.DescCount) : 1;
  1149. for (int i = 0; i < count; i++)
  1150. {
  1151. if (data1.Count <= i)
  1152. {
  1153. CraftOrdDesignStdPicSmpTotalEntity CraftOrdDesignStdPicSmpTotalEntityA =
  1154. new CraftOrdDesignStdPicSmpTotalEntity();
  1155. CraftOrdDesignStdPicSmpTotalEntityA.OrdLnPk = As.OrdLnPk;
  1156. CraftOrdDesignStdPicSmpTotalEntityA.CraftSeq = As.CraftSeq;
  1157. CraftOrdDesignStdPicSmpTotalEntityA.CraftNo = As.CraftNo;
  1158. CraftOrdDesignStdPicSmpTotalEntityA.ProcessCode = As.ProcessCode;
  1159. CraftOrdDesignStdPicSmpTotalEntityA.Position = position;
  1160. CraftOrdDesignStdPicSmpTotalEntityA.DescPosition = positionName;
  1161. CraftOrdDesignStdPicSmpTotalEntityA.SampleCount = "1";
  1162. CraftOrdDesignStdPicSmpTotalEntityA.SampleLength = "0";
  1163. CraftOrdDesignStdPicSmpTotalEntityA.BatchNo = BatchNo;
  1164. CraftOrdDesignStdPicSmpTotalEntityA.BatchNum = Type;
  1165. data1.Add(CraftOrdDesignStdPicSmpTotalEntityA);
  1166. listTotalAll.Add(CraftOrdDesignStdPicSmpTotalEntityA);
  1167. }
  1168. if (!data1[i].PhyCodeGroup.Contains(As.PhyCodeMin))
  1169. {
  1170. data1[i].PhyCodeGroup = string.IsNullOrWhiteSpace(data1[i].PhyCodeGroup)
  1171. ? As.PhyCodeMin
  1172. : (data1[i].PhyCodeGroup + "," + As.PhyCodeMin);
  1173. data1[i].PhyNameGroup = string.IsNullOrWhiteSpace(data1[i].PhyNameGroup)
  1174. ? As.PhyNameMin
  1175. : (data1[i].PhyNameGroup + "," + As.PhyNameMin);
  1176. }
  1177. //环状
  1178. if (As.SampleStyle == "408102")
  1179. {
  1180. data1[i].SampleLength = ((data1[i].SampleLength.TryParseInt()
  1181. ? int.Parse(data1[i].SampleLength)
  1182. : 0) + (
  1183. As.Length.TryParseInt() ? int.Parse(As.Length) : 0)) *
  1184. (As.SampleCount.TryParseInt() ? int.Parse(As.SampleCount) : 1) +
  1185. "";
  1186. }
  1187. else
  1188. {
  1189. Rectangle rectangle = new Rectangle();
  1190. double.TryParse(As.Length, out rectangle.Height);
  1191. double.TryParse(As.Width, out rectangle.Width);
  1192. /* rectangle.Height = double.Parse(As.Length);
  1193. rectangle.Width = double.Parse(As.Width);*/
  1194. var tag = data1[i].Tag as List<Rectangle> ?? new List<Rectangle>();
  1195. tag.Add(rectangle);
  1196. data1[i].Tag = tag;
  1197. }
  1198. }
  1199. }
  1200. }
  1201. private List<CraftOrdDesignStdPicSmpTotalEntity> GetCanNotMergeData(List<CraftOrdDesignStdPicSmpTotalEntity> datas,
  1202. CraftOrdDesignStdPicSmpDetailEntity As)
  1203. {
  1204. try
  1205. {
  1206. if (CanNotMergePhyCode.ContainsKey(As.PhyCodeMin))
  1207. {
  1208. List<string> list = CanNotMergePhyCode[As.PhyCodeMin];
  1209. return datas.Where(p =>
  1210. {
  1211. string[] phyCodeGroups = p.PhyCodeGroup.Split(',');
  1212. for (int i = 0; i < phyCodeGroups.Length; i++)
  1213. {
  1214. if (list.Contains(phyCodeGroups[i])) return false;
  1215. }
  1216. return true;
  1217. }).ToList();
  1218. }
  1219. return datas;
  1220. }
  1221. catch (Exception)
  1222. {
  1223. return datas;
  1224. }
  1225. }
  1226. public List<CraftOrdDesignStdPicSmpTotalEntity> AddRemainStoveToBatch(
  1227. List<CraftOrdDesignStdPicSmpDetailEntity> lists, int Type, int BatchNo)
  1228. {
  1229. List<CraftOrdDesignStdPicSmpTotalEntity> listTotalAll = new List<CraftOrdDesignStdPicSmpTotalEntity>();
  1230. /* //先将检验批A端排列好
  1231. GetNewList(listTotalAll,
  1232. lists.Where(p => p.Position == "401201").ToList(), "401201", "A端", Type, BatchNo);
  1233. //再将检验批B端排列好
  1234. GetNewList(listTotalAll,
  1235. lists.Where(p => p.Position == "401202").ToList(), "401202", "B端", Type, BatchNo);
  1236. //再将检验批A或B端整合进A端或B端 若A或B端管头数大于A端和B端和 先暂时保留A端或B端 给后续插入整炉 留选择. 最后再把A端或B端改成A端
  1237. GetNewList(listTotalAll,
  1238. lists.Where(p => p.Position == "401203").ToList(), "401203", "A端或B端", Type, BatchNo);*/
  1239. foreach (var data in lists.GroupBy(p=>new {p.Position,p.DescPosition}))
  1240. {
  1241. GetNewList(listTotalAll,
  1242. data.ToList(), data.Key.Position, data.Key.DescPosition, Type, BatchNo);
  1243. }
  1244. return listTotalAll;
  1245. }
  1246. public List<CraftOrdDesignStdPicSmpDetailEntity> AddStoveToBatch(List<CraftOrdDesignStdPicSmpTotalEntity> listTotalAll,
  1247. List<CraftOrdDesignStdPicSmpDetailEntity> listA, string position, string positionName, int Type, int BatchNo)
  1248. {
  1249. List<CraftOrdDesignStdPicSmpDetailEntity> remainStove = new List<CraftOrdDesignStdPicSmpDetailEntity>();
  1250. if (listTotalAll == null) listTotalAll = new List<CraftOrdDesignStdPicSmpTotalEntity>();
  1251. var data =
  1252. position == "401203" ?
  1253. listTotalAll.Where(p => p.Position == "401201" || p.Position == "401202" || p.Position == "401203" || p.Position=="").ToList() :
  1254. (position == "401201" || position == "401202") ? listTotalAll.Where(p => p.Position == position || p.Position == "401203" || p.Position == "").ToList()
  1255. : listTotalAll.Where(p => p.Position == position || p.Position == "").ToList();
  1256. bool CanRemain = data.Count <= 0;
  1257. foreach (var As in listA)
  1258. {
  1259. int count = As.DescCount.TryParseInt() ? int.Parse(As.DescCount) : 1;
  1260. for (int i = 0; i < count; i++)
  1261. {
  1262. if (data.Count <= i)
  1263. {
  1264. if (!CanRemain)
  1265. {
  1266. CraftOrdDesignStdPicSmpDetailEntity remain =
  1267. As.Clone() as CraftOrdDesignStdPicSmpDetailEntity;
  1268. if (remain != null)
  1269. {
  1270. remain.DescCount = (count - i) + "";
  1271. remainStove.Add(remain);
  1272. }
  1273. break;
  1274. }
  1275. else
  1276. {
  1277. CraftOrdDesignStdPicSmpTotalEntity CraftOrdDesignStdPicSmpTotalEntityA =
  1278. new CraftOrdDesignStdPicSmpTotalEntity
  1279. {
  1280. OrdLnPk = As.OrdLnPk,
  1281. CraftSeq = As.CraftSeq,
  1282. CraftNo = As.CraftNo,
  1283. ProcessCode = As.ProcessCode,
  1284. Position = position,
  1285. DescPosition = positionName,
  1286. SampleCount = "1",
  1287. SampleLength = "0",
  1288. BatchNo = BatchNo,
  1289. BatchNum = Type
  1290. };
  1291. data.Add(CraftOrdDesignStdPicSmpTotalEntityA);
  1292. listTotalAll.Add(CraftOrdDesignStdPicSmpTotalEntityA);
  1293. }
  1294. }
  1295. if (data[i].Position == "" )
  1296. {
  1297. //data[i] = new CraftOrdDesignStdPicSmpTotalEntity
  1298. //{
  1299. // OrdLnPk = As.OrdLnPk,
  1300. // CraftSeq = As.CraftSeq,
  1301. // CraftNo = As.CraftNo,
  1302. // ProcessCode = As.ProcessCode,
  1303. // Position = position,
  1304. // DescPosition = positionName,
  1305. // SampleCount = "1",
  1306. // SampleLength = "0",
  1307. // BatchNo = BatchNo,
  1308. // BatchNum = Type
  1309. //};
  1310. data[i].OrdLnPk = As.OrdLnPk;
  1311. data[i].CraftSeq = As.CraftSeq;
  1312. data[i].CraftNo = As.CraftNo;
  1313. data[i].ProcessCode = As.ProcessCode;
  1314. data[i].Position = As.Position;
  1315. data[i].DescPosition = As.DescPosition;
  1316. data[i].SampleCount = "1";
  1317. data[i].SampleLength = "0";
  1318. data[i].BatchNo = BatchNo;
  1319. data[i].BatchNum = Type;
  1320. }
  1321. if (!data[i].PhyCodeGroup.Contains(As.PhyCodeMin))
  1322. {
  1323. data[i].PhyCodeGroup = string.IsNullOrWhiteSpace(data[i].PhyCodeGroup)
  1324. ? As.PhyCodeMin
  1325. : (data[i].PhyCodeGroup + "," + As.PhyCodeMin);
  1326. data[i].PhyNameGroup = string.IsNullOrWhiteSpace(data[i].PhyNameGroup)
  1327. ? As.PhyNameMin
  1328. : (data[i].PhyNameGroup + "," + As.PhyNameMin);
  1329. }
  1330. // A或B的检验批的管头 比如加上了A端检验项, 则这个管头标记成A端,后续不能挂B端检验项
  1331. if (data[i].Position == "401203")
  1332. {
  1333. data[i].Position = As.Position;
  1334. data[i].DescPosition = As.DescPosition;
  1335. }
  1336. //环状
  1337. if (As.SampleStyle == "408102")
  1338. {
  1339. data[i].SampleLength = ((data[i].SampleLength.TryParseInt()
  1340. ? int.Parse(data[i].SampleLength)
  1341. : 0) + (
  1342. As.Length.TryParseInt() ? int.Parse(As.Length) : 0)) *
  1343. (As.SampleCount.TryParseInt() ? int.Parse(As.SampleCount) : 1) +
  1344. "";
  1345. }
  1346. else
  1347. {
  1348. Rectangle rectangle = new Rectangle();
  1349. double.TryParse(As.Length, out rectangle.Height);
  1350. double.TryParse(As.Width, out rectangle.Width);
  1351. /* rectangle.Height = double.Parse(As.Length);
  1352. rectangle.Width = double.Parse(As.Width);*/
  1353. var tag = data[i].Tag as List<Rectangle> ?? new List<Rectangle>();
  1354. tag.Add(rectangle);
  1355. data[i].Tag = tag;
  1356. }
  1357. }
  1358. }
  1359. return remainStove;
  1360. }
  1361. public List<CraftOrdDesignStdPicSmpTotalEntity> GetAllToltalData(List<CraftOrdDesignStdPicSmpDetailEntity> lists,string StoveNum)
  1362. {
  1363. List<CraftOrdDesignStdPicSmpTotalEntity> toltalData = new DataSourceList<CraftOrdDesignStdPicSmpTotalEntity>();
  1364. List<CraftOrdDesignStdPicSmpTotalEntity> toltalData1 = new DataSourceList<CraftOrdDesignStdPicSmpTotalEntity>();
  1365. List<List<CraftOrdDesignStdPicSmpDetailEntity>> Remains = new List<List<CraftOrdDesignStdPicSmpDetailEntity>>();
  1366. int i = 0;
  1367. //是否有按炉分配
  1368. if (lists.Any(p => p.Rate == "408603" || p.Rate== "408601"))
  1369. {
  1370. var BatchData = GetOnlyBatchList(lists,1, ++i );
  1371. var RemainStove = AddStoveToBatchList(BatchData, lists, 0, i );
  1372. toltalData1.AddRange(BatchData);
  1373. Remains.Add(RemainStove);
  1374. if (RemainStove != null && RemainStove.Count > 0)
  1375. {
  1376. while (true)
  1377. {
  1378. var BatchData1 = GetOnlyBatchList(lists,0, ++i );
  1379. RemainStove = AddStoveToBatchList(BatchData1, RemainStove, 0, i );
  1380. toltalData1.AddRange(BatchData1);
  1381. Remains.Add(RemainStove);
  1382. if (RemainStove == null || RemainStove.Count <= 0) break;
  1383. }
  1384. }
  1385. }
  1386. toltalData1.AddRange(GetOnlyBatchList(lists,0, ++i ));
  1387. maxBatch = i;
  1388. foreach (var data in toltalData1)
  1389. {
  1390. data.BatchNum = i ;
  1391. }
  1392. for (int j = i-1; j >=1; j--)
  1393. {
  1394. List<CraftOrdDesignStdPicSmpTotalEntity> tempData = toltalData1.Where(p => p.BatchNo < j).
  1395. Select(p =>
  1396. {
  1397. CraftOrdDesignStdPicSmpTotalEntity CraftOrdDesignStdPicSmpTotalEntity =
  1398. p.Clone() as CraftOrdDesignStdPicSmpTotalEntity;
  1399. CraftOrdDesignStdPicSmpTotalEntity.BatchNum = j ;
  1400. return CraftOrdDesignStdPicSmpTotalEntity;
  1401. }).ToList();
  1402. List<CraftOrdDesignStdPicSmpTotalEntity> LastBatch = toltalData1.Where(p => p.BatchNo == j).
  1403. Select(p =>
  1404. {
  1405. CraftOrdDesignStdPicSmpTotalEntity CraftOrdDesignStdPicSmpTotalEntity =
  1406. p.Clone() as CraftOrdDesignStdPicSmpTotalEntity;
  1407. CraftOrdDesignStdPicSmpTotalEntity.BatchNum = j;
  1408. return CraftOrdDesignStdPicSmpTotalEntity;
  1409. }).ToList();
  1410. LastBatch.AddRange(AddRemainStoveToBatch(Remains[j - 1], j, j));
  1411. toltalData.AddRange(tempData);
  1412. toltalData.AddRange(LastBatch);
  1413. }
  1414. toltalData.AddRange(toltalData1);
  1415. toltalData.AddRange(AddRemainStoveToBatch(lists.Where(p => p.Rate != "408602" && p.Rate != "401101" && p.Rate != "408603" && p.Rate != "408601" && p.Rate != "408608").ToList(), 0, -1));
  1416. foreach (var data in toltalData)
  1417. {
  1418. data.SampleLength = (data.SampleLength.TryParseInt()
  1419. ? double.Parse(data.SampleLength)
  1420. : 0) + (CalculateLength(1000, data.Tag as List<Rectangle>)) +
  1421. "";
  1422. // 若最后仍有A或B的检验批的管头 全默认A管头
  1423. if (data.Position == "401203")
  1424. {
  1425. data.Position = "401201";
  1426. data.DescPosition ="A端";
  1427. }
  1428. data.StoveNum = StoveNum;
  1429. }
  1430. toltalData = toltalData.GroupBy(p => new { Type = p.BatchNum, p.BatchNo, p.SampleCount,p.Position, p.PhyCodeGroup }).Select(
  1431. p =>
  1432. {
  1433. CraftOrdDesignStdPicSmpTotalEntity CraftOrdDesignStdPicSmpTotalEntity = p.FirstOrDefault();
  1434. CraftOrdDesignStdPicSmpTotalEntity.SampleCount = p.Sum(q => int.Parse(q.SampleCount)) + "";
  1435. return CraftOrdDesignStdPicSmpTotalEntity;
  1436. }).OrderBy(p => p.BatchNum).ThenBy(p=>p.BatchNo).ThenBy(p=>p.Position).ToList();
  1437. return toltalData;
  1438. }
  1439. private DataTable _dt = null;
  1440. private void BindSmpData(string designKey, string processCode)
  1441. {
  1442. dataTable3.Clear();
  1443. for (int i = dataTable3.Columns.Count - 1; i >= 0; i--)
  1444. {
  1445. if (dataTable3.Columns[i].ColumnName.ToString().StartsWith("C"))
  1446. {
  1447. dataTable3.Columns.Remove(dataTable3.Columns[i]);
  1448. }
  1449. }
  1450. dataTable4.Clear();
  1451. _dt = _craftOrdDesignBLL.GetCraftPicSmp(designKey, processCode);
  1452. var drs = _dt.Rows.Cast<DataRow>();
  1453. if (_dt.Rows.Count == 0)
  1454. {
  1455. return;
  1456. }
  1457. int pipeCnt = drs.Max(a => int.Parse(a["DESC_COUNT"].ToString()));
  1458. //处理主表
  1459. //新增列
  1460. ultraGrid9.BeginUpdate();
  1461. foreach (var dr in drs)
  1462. {
  1463. string phyCodeMin = dr["PHY_CODE_MIN"].ToString();
  1464. string phyNameMin = dr["PHY_NAME_MIN"].ToString();
  1465. if (dataTable3.Columns.Contains(phyCodeMin)) continue;
  1466. dataTable3.Columns.Add(phyCodeMin);
  1467. dataTable3.Columns[phyCodeMin].Caption = phyNameMin;
  1468. }
  1469. for (int i = 0; i < pipeCnt; i++)
  1470. {
  1471. var dt3Dr = dataTable3.NewRow();
  1472. dt3Dr["PIPE_INDEX"] = i + 1;
  1473. dataTable3.Rows.Add(dt3Dr);
  1474. }
  1475. var aryDrs = drs.ToArray();
  1476. for (int i = 0; i < aryDrs.Length; i++)
  1477. {
  1478. var dr = aryDrs[i];
  1479. int descCount = int.Parse(dr["DESC_COUNT"].ToString());
  1480. string phyCodeMin = dr["PHY_CODE_MIN"].ToString();
  1481. string phyNameMin = dr["PHY_NAME_MIN"].ToString();
  1482. string sampleCount = dr["SAMPLE_COUNT"].ToString();
  1483. for (int j = 0; j < descCount; j++)
  1484. {
  1485. int drSmpCnt = sampleCount == "" ? 0 : int.Parse(sampleCount.ToString());
  1486. int dt3SmpCnt = dataTable3.Rows[j][phyCodeMin].ToString() == "" ? 0 : int.Parse(dataTable3.Rows[j][phyCodeMin].ToString());
  1487. dataTable3.Rows[j][phyCodeMin] = drSmpCnt + dt3SmpCnt;
  1488. }
  1489. }
  1490. string strD = ultraGrid1.ActiveRow.GetValue("DIMATER");
  1491. string strH = ultraGrid1.ActiveRow.GetValue("HEIGHT");
  1492. double dimater = strD.TryParseDouble() ? double.Parse(strD) : 0;
  1493. double height = strH.TryParseDouble() ? double.Parse(strH) : 0;
  1494. double perimeter = 2 * Math.PI * (dimater - height); //周长
  1495. //计算长度
  1496. foreach (DataRow pDr in dataTable3.Rows)
  1497. {
  1498. List<Rectangle> noArrayData = new List<Rectangle>();
  1499. double length = 0;
  1500. foreach (DataRow dr in _dt.Rows)
  1501. {
  1502. if (int.Parse(dr["DESC_COUNT"].ToString()) < int.Parse(pDr["PIPE_INDEX"].ToString())) continue;
  1503. if (dr["SAMPLE_STYLE"].ToString() == "408102")
  1504. {
  1505. length += double.Parse(dr["LENGTH"].ToString());
  1506. continue;
  1507. }
  1508. Rectangle rectangle = new Rectangle();
  1509. rectangle.Height = double.Parse(dr["LENGTH"].ToString());
  1510. rectangle.Width = double.Parse(dr["WIDTH"].ToString());
  1511. noArrayData.Add(rectangle);
  1512. }
  1513. length += CalculateLength(perimeter, noArrayData);
  1514. pDr["PIPE_LENGTH"] = length;
  1515. }
  1516. GridHelper.RefreshAndAutoSize(ultraGrid9);
  1517. ultraGrid9.EndUpdate();
  1518. }
  1519. /// <summary>
  1520. /// 计算试样所需的样管高度
  1521. /// </summary>
  1522. /// <param name="perimeter">宽(周长)</param>
  1523. /// <param name="listData">取样集合</param>
  1524. /// <returns></returns>
  1525. private double CalculateLength(double perimeter, List<Rectangle> noArrayData)
  1526. {
  1527. if (noArrayData == null) return 0d;
  1528. double length = 0;
  1529. //已排列好的取样
  1530. List<Rectangle> arrayData = new List<Rectangle>();
  1531. noArrayData = noArrayData.OrderByDescending(a=>a.Height).ToList();
  1532. Test test = new Test(perimeter);
  1533. for (int i = 0; i < noArrayData.Count; i++)
  1534. {
  1535. Rectangle rectangle = noArrayData[i];
  1536. test.Add(rectangle);
  1537. }
  1538. foreach (var area in test.Data)
  1539. {
  1540. length += area.Height;
  1541. }
  1542. return length;
  1543. }
  1544. private class Test
  1545. {
  1546. private List<Area> data = new List<Area>();
  1547. public List<Area> Data
  1548. {
  1549. get { return data; }
  1550. set { data = value; }
  1551. }
  1552. private Area area;
  1553. private double perimeter = 0;
  1554. public Test(double perimeter)
  1555. {
  1556. this.perimeter = perimeter;
  1557. data.Add(new Area());
  1558. }
  1559. public void Add(Rectangle rectangle)
  1560. {
  1561. if (!CheckAdd(rectangle))
  1562. {
  1563. data.Add(new Area());
  1564. }
  1565. Area area = data[data.Count - 1];
  1566. var maxRectangele = area.Rectangles.Where(a => a.Point.X == area.Rectangles.Max(b => b.Point.X)).FirstOrDefault();
  1567. if (maxRectangele.Height != 0)
  1568. {
  1569. rectangle.Point.Y = maxRectangele.Point.Y;
  1570. rectangle.Point.X = maxRectangele.Point.X + rectangle.Width;
  1571. }
  1572. area.Rectangles.Add(rectangle);
  1573. area.Height = area.Rectangles.Max(a => a.Height);
  1574. }
  1575. private bool CheckAdd(Rectangle rectangle)
  1576. {
  1577. Area area = data[data.Count - 1];
  1578. var maxRectangele = area.Rectangles.Where(a => a.Point.X == area.Rectangles.Max(b => b.Point.X)).FirstOrDefault();
  1579. if (maxRectangele.Point.X + rectangle.Width <= perimeter)
  1580. {
  1581. return true;
  1582. }
  1583. else
  1584. {
  1585. return false;
  1586. }
  1587. }
  1588. //public bool IsStartRight()
  1589. //{
  1590. // if (data.Count == 0)
  1591. // {
  1592. // return true;
  1593. // }
  1594. // else
  1595. // {
  1596. // }
  1597. //}
  1598. }
  1599. private class Area
  1600. {
  1601. public List<Rectangle> Rectangles = new List<Rectangle>();
  1602. public double Height;
  1603. }
  1604. [Serializable]
  1605. /// <summary>
  1606. /// 样条属性
  1607. /// </summary>
  1608. private struct Rectangle
  1609. {
  1610. public Point Point;
  1611. public double Width;
  1612. public double Height;
  1613. }
  1614. [Serializable]
  1615. private struct Point
  1616. {
  1617. public double X;
  1618. public double Y;
  1619. public Point(double x, double y)
  1620. {
  1621. X = x;
  1622. Y = y;
  1623. }
  1624. }
  1625. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  1626. {
  1627. if (!CustomInfo.Contains("PLAN")) return;
  1628. try
  1629. {
  1630. this.Cursor = Cursors.WaitCursor;
  1631. ClearCraftDesignDown();
  1632. if (ultraGrid1.ActiveRow == null) return;
  1633. var craftOrdDesign = (CraftOrdDesignEntity)ultraGrid1.ActiveRow.ListObject;
  1634. string processCode = CustomInfo.Substring(0, 1);
  1635. DataTable dt = _craftOrdDesignBLL.GetCraftStationType(craftOrdDesign.DesginKey, processCode);
  1636. bool existCic = false;
  1637. bool existPic = false;
  1638. bool existSic = false;
  1639. bool existDic = false;
  1640. bool existWic = false;
  1641. bool existGic = false;
  1642. foreach (DataRow dr in dt.Rows)
  1643. {
  1644. if (dr["STATION_TYPE"].ToString() == "403201")
  1645. {
  1646. existCic = true;
  1647. }
  1648. else if (dr["STATION_TYPE"].ToString() == "403202")
  1649. {
  1650. existPic = true;
  1651. }
  1652. else if (dr["STATION_TYPE"].ToString() == "403203")
  1653. {
  1654. existSic = true;
  1655. }
  1656. else if (dr["STATION_TYPE"].ToString() == "403204")
  1657. {
  1658. existDic = true;
  1659. }
  1660. else if (dr["STATION_TYPE"].ToString() == "403205")
  1661. {
  1662. existWic = true;
  1663. }
  1664. else if (dr["STATION_TYPE"].ToString() == "403208")
  1665. {
  1666. existGic = true;
  1667. }
  1668. }
  1669. ultraTabControl1.Tabs["cic"].Visible = existCic;
  1670. ultraTabControl1.Tabs["pic"].Visible = existPic;
  1671. ultraTabControl1.Tabs["sic"].Visible = existSic;
  1672. ultraTabControl1.Tabs["dic"].Visible = existDic;
  1673. ultraTabControl1.Tabs["wic"].Visible = existWic;
  1674. ultraTabControl1.Tabs["gic"].Visible = existGic;
  1675. QueryCraftOrdDesignDown();
  1676. }
  1677. finally
  1678. {
  1679. this.Cursor = Cursors.Default;
  1680. }
  1681. }
  1682. private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
  1683. {
  1684. try
  1685. {
  1686. this.Cursor = Cursors.WaitCursor;
  1687. string designKey = ultraGrid2.ActiveRow.GetValue("DesignKey");
  1688. string mscPline = ultraGrid2.ActiveRow.GetValue("MscPline");
  1689. string processCode = ultraGrid2.ActiveRow.GetValue("ProcessCode");
  1690. string cic = ultraGrid2.ActiveRow.GetValue("Cic");
  1691. _cicCtrl.QueryByDesignKeyCic(new string[] { designKey, mscPline, processCode, cic });
  1692. }
  1693. finally
  1694. {
  1695. this.Cursor = Cursors.Default;
  1696. }
  1697. }
  1698. private void ultraGrid3_AfterRowActivate(object sender, EventArgs e)
  1699. {
  1700. try
  1701. {
  1702. this.Cursor = Cursors.WaitCursor;
  1703. string designKey = ultraGrid3.ActiveRow.GetValue("DesignKey");
  1704. string mscPline = ultraGrid3.ActiveRow.GetValue("MscPline");
  1705. string processCode = ultraGrid3.ActiveRow.GetValue("ProcessCode");
  1706. string pic = ultraGrid3.ActiveRow.GetValue("Pic");
  1707. DataTable dt = _picBLL.getGroupPhyMin(designKey, pic, mscPline, processCode);
  1708. GridHelper.CopyDataToDatatable(dt, dataTable2, true);
  1709. }
  1710. finally
  1711. {
  1712. this.Cursor = Cursors.Default;
  1713. }
  1714. }
  1715. private void ultraGrid4_AfterRowActivate(object sender, EventArgs e)
  1716. {
  1717. try
  1718. {
  1719. this.Cursor = Cursors.WaitCursor;
  1720. string designKey = ultraGrid4.ActiveRow.GetValue("DesignKey");
  1721. string mscPline = ultraGrid4.ActiveRow.GetValue("MscPline");
  1722. string processCode = ultraGrid4.ActiveRow.GetValue("ProcessCode");
  1723. string sic = ultraGrid4.ActiveRow.GetValue("Sic");
  1724. _sicCtrl.QueryByDesignKeySic(new string[] { designKey, mscPline, processCode, sic });
  1725. }
  1726. finally
  1727. {
  1728. this.Cursor = Cursors.Default;
  1729. }
  1730. }
  1731. private void ultraGrid5_AfterRowActivate(object sender, EventArgs e)
  1732. {
  1733. try
  1734. {
  1735. this.Cursor = Cursors.WaitCursor;
  1736. string designKey = ultraGrid5.ActiveRow.GetValue("DesignKey");
  1737. string mscPline = ultraGrid5.ActiveRow.GetValue("MscPline");
  1738. string processCode = ultraGrid5.ActiveRow.GetValue("ProcessCode");
  1739. string dic = ultraGrid5.ActiveRow.GetValue("Dic");
  1740. _dicCtrl.QueryByDesignKeyDic(new string[] { designKey, mscPline, processCode, dic });
  1741. }
  1742. finally
  1743. {
  1744. this.Cursor = Cursors.Default;
  1745. }
  1746. }
  1747. private void ultraGrid6_AfterRowActivate(object sender, EventArgs e)
  1748. {
  1749. try
  1750. {
  1751. this.Cursor = Cursors.WaitCursor;
  1752. string designKey = ultraGrid6.ActiveRow.GetValue("DesignKey");
  1753. string mscPline = ultraGrid6.ActiveRow.GetValue("MscPline");
  1754. string processCode = ultraGrid6.ActiveRow.GetValue("ProcessCode");
  1755. string wic = ultraGrid6.ActiveRow.GetValue("Wic");
  1756. _wicCtrl.QueryByDesignKeyWic(new string[] { designKey, mscPline, processCode, wic });
  1757. }
  1758. finally
  1759. {
  1760. this.Cursor = Cursors.Default;
  1761. }
  1762. }
  1763. private void ultraGrid7_AfterRowActivate(object sender, EventArgs e)
  1764. {
  1765. try
  1766. {
  1767. this.Cursor = Cursors.WaitCursor;
  1768. string designKey = ultraGrid7.ActiveRow.GetValue("DesignKey");
  1769. string mscPline = ultraGrid7.ActiveRow.GetValue("MscPline");
  1770. string processCode = ultraGrid7.ActiveRow.GetValue("ProcessCode");
  1771. string gic = ultraGrid7.ActiveRow.GetValue("Gic");
  1772. _gicCtrl.QueryByDesignKeyGic(new string[] { designKey, mscPline, processCode, gic });
  1773. }
  1774. finally
  1775. {
  1776. this.Cursor = Cursors.Default;
  1777. }
  1778. }
  1779. private void ultraTabControl1_SelectedTabChanged(object sender, Infragistics.Win.UltraWinTabControl.SelectedTabChangedEventArgs e)
  1780. {
  1781. try
  1782. {
  1783. this.Cursor = Cursors.WaitCursor;
  1784. ClearCraftDesignDown();
  1785. QueryCraftOrdDesignDown();
  1786. }
  1787. finally
  1788. {
  1789. this.Cursor = Cursors.Default;
  1790. }
  1791. }
  1792. private void ultraGrid8_AfterRowActivate(object sender, EventArgs e)
  1793. {
  1794. try
  1795. {
  1796. this.Cursor = Cursors.WaitCursor;
  1797. /* string designKey = ultraGrid3.ActiveRow.GetValue("DesignKey");
  1798. string mscPline = ultraGrid3.ActiveRow.GetValue("MscPline");
  1799. string processCode = ultraGrid3.ActiveRow.GetValue("ProcessCode");
  1800. string pic = ultraGrid3.ActiveRow.GetValue("Pic");*/
  1801. string phyCodeMin = ultraGrid8.ActiveRow.GetValue("PHY_CODE_MIN");
  1802. if (ultraGrid1.ActiveRow == null) return;
  1803. var craftOrdDesign = (ChoiceCraftFileLv2Entity)ultraGrid1.ActiveRow.ListObject;
  1804. string processCode = CustomInfo.Substring(0, 1);
  1805. _picCtrl.QueryByDesignKeyPic(new string[] { craftOrdDesign.DesginKey, craftOrdDesign.MscPline, processCode, "", phyCodeMin });
  1806. }
  1807. finally
  1808. {
  1809. this.Cursor = Cursors.Default;
  1810. }
  1811. }
  1812. /// <summary>
  1813. /// 通过权限初始化产线
  1814. /// </summary>
  1815. /// <param name="processCode"></param>
  1816. /// <param name="ugc"></param>
  1817. /// <param name="validDataPurviewIds"></param>
  1818. /// <param name="ob"></param>
  1819. public List<String> InitDropPlinePower(string processCode, UltraComboEditor ugc, string[] validDataPurviewIds, OpeBase ob)
  1820. {
  1821. DataTable dt = ServerHelper.GetData("com.steering.pss.plnsaleord.processOrder.base.BaseHelper.initPlinePower", new object[] { processCode, validDataPurviewIds }, ob);
  1822. if (dt != null && dt.Rows.Count > 0)
  1823. {
  1824. ugc.DataSource = dt;
  1825. ugc.ValueMember = "PLINE_CODE";
  1826. ugc.DisplayMember = "PLINE_NAME";
  1827. List<String> plineArr = new List<string>();
  1828. for (int i = 0; i < dt.Rows.Count; i++)
  1829. {
  1830. plineArr.Add(dt.Rows[i]["PLINE_CODE"].ToString());
  1831. }
  1832. return plineArr;
  1833. }
  1834. else
  1835. {
  1836. return null;
  1837. }
  1838. }
  1839. public class CustomMergedCellEvaluator : IMergedCellEvaluator
  1840. {
  1841. private string[] keys;
  1842. public CustomMergedCellEvaluator(string[] GroupKey)
  1843. {
  1844. keys = GroupKey;
  1845. }
  1846. public bool ShouldCellsBeMerged(UltraGridRow row1, UltraGridRow row2, UltraGridColumn column) //控件自带的方法,会自动进行调用,column为初始化中设置的行
  1847. {
  1848. foreach (string key in keys)
  1849. {
  1850. if (row1.Cells[key].Value.ToString() != row2.Cells[key].Value.ToString()) return false;
  1851. }
  1852. return row1.Cells[column].Value.ToString() == row2.Cells[column].Value.ToString();
  1853. }
  1854. }
  1855. private void ultraGrid9_InitializeRow(object sender, InitializeRowEventArgs e)
  1856. {
  1857. if(e.Row.HasParent()) return;
  1858. CraftOrdDesignStdPicSmpTotalEntity CraftOrdDesignStdPicSmpTotalEntity =
  1859. e.Row.ListObject as CraftOrdDesignStdPicSmpTotalEntity;
  1860. e.Row.Cells["TypeStr"].Value =int.Parse(e.Row.Cells["BatchNum"].Value.ToString()) == 0 ? "" : (e.Row.Cells["BatchNum"].Value +
  1861. (int.Parse(e.Row.Cells["BatchNum"].Value.ToString()) == maxBatch ? "-N" : ""));
  1862. e.Row.Cells["BatchNoStr"].Value = (decimal)e.Row.Cells["BatchNo"].Value == 1
  1863. ? "首批"
  1864. : ("第" + e.Row.Cells["BatchNo"].Value +
  1865. ((decimal)e.Row.Cells["BatchNo"].Value == maxBatch ? "-N批" : "批"));
  1866. }
  1867. private void ultraGrid1_AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
  1868. {
  1869. /* foreach (UltraGridRow uRow in ultraGrid1.Selected.Rows.AsParallel())
  1870. {
  1871. if (uRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow))
  1872. {
  1873. uRow.Cells["Chk"].Value = true;
  1874. }
  1875. }*/
  1876. foreach (var ultraGridRow in ultraGrid1.Rows.AsParallel())
  1877. {
  1878. if (ultraGridRow.GetType() != typeof(Infragistics.Win.UltraWinGrid.UltraGridGroupByRow))
  1879. {
  1880. ultraGridRow.Cells["Chk"].Value = ultraGridRow.Selected;
  1881. }
  1882. }
  1883. }
  1884. private void ultraGrid10_InitializeRow(object sender, InitializeRowEventArgs e)
  1885. {
  1886. CraftOrdDesignStdPicSmpDetailEntity row = e.Row.ListObject as CraftOrdDesignStdPicSmpDetailEntity;
  1887. if (row ==null) return;
  1888. if (row.Rate == "408602" || row.Rate == "401101" || row.Rate == "408608")
  1889. {
  1890. ultraGrid10.Rows[e.Row.Index].Cells["BatchCnt"].IgnoreRowColActivation = true;
  1891. ultraGrid10.Rows[e.Row.Index].Cells["BatchCnt"].Activation = Activation.AllowEdit;
  1892. ultraGrid10.Rows[e.Row.Index].Cells["BatchCnt"].Appearance.BackColor = Color.FromArgb(255, 255, 192);
  1893. }
  1894. }
  1895. private void ultraGrid10_CellChange(object sender, CellEventArgs e)
  1896. {
  1897. CraftOrdDesignStdPicSmpDetailEntity row = e.Cell. Row.ListObject as CraftOrdDesignStdPicSmpDetailEntity;
  1898. List<CraftOrdDesignStdPicSmpDetailEntity> lists =
  1899. craftOrdDesignStdPicSmpDetailEntityBindingSource.DataSource as List<CraftOrdDesignStdPicSmpDetailEntity>;
  1900. if (row == null|| lists==null) return;
  1901. if (row.Rate == "408602" || row.Rate == "401101" || row.Rate == "408608")
  1902. {
  1903. lists.Where(p => p.Rate == "408602" || p.Rate == "401101" || p.Rate == "408608" ).ToList().ForEach(p=>p.BatchCnt = e.Cell.Text);
  1904. }
  1905. ultraGrid10.Refresh();
  1906. }
  1907. private void craftView_EditorButtonClick(object sender, EditorButtonEventArgs e)
  1908. {
  1909. var entity = ultraGrid1.ActiveRow.ListObject as ChoiceCraftFileLv2Entity;
  1910. if (entity == null) return;
  1911. /* UltraGridRow row = ultraGrid1.ActiveRow;
  1912. string filePathOld = row.GetValue("CRAFT_PATH_OLD");
  1913. string filePathNew = "";*/
  1914. if (e.Button.Key.ToLower().Equals("select"))
  1915. {
  1916. var strurl = "";
  1917. /*strurl =
  1918. "http://localhost:8075/WebReport/ReportServer?reportlet=HttRotaCrackDetetionPipeHeatReport.cpt&resultNo=" +
  1919. resultNo;*/
  1920. strurl =
  1921. "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepHttCasingProcess.cpt&desginKey={0}&mscPline={1}";
  1922. strurl = String.Format(strurl, entity.DesginKey, entity.MscPline);
  1923. var fre = new FrmRepExcel(ob, strurl);
  1924. fre.AutoSize = true;
  1925. fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width,
  1926. Screen.PrimaryScreen.WorkingArea.Height);
  1927. fre.WindowState = FormWindowState.Maximized;
  1928. fre.Show();
  1929. /* dlgOrderAskDown down = new dlgOrderAskDown(this.ob, filePathOld);
  1930. down.DeleteButton.Visible = false;
  1931. down.ShowDialog();*/
  1932. }
  1933. else if (e.Button.Key.ToLower().Equals("view"))
  1934. {
  1935. string path = "Qcm/CraftLv2/" + entity.OrderManageNo + "/" + entity.CraftFileLv2F;
  1936. dlgOrderAskDown down = new dlgOrderAskDown(this.ob, path);
  1937. down.DeleteButton.Visible = false;
  1938. down.ShowDialog();
  1939. }
  1940. else if (e.Button.Key.ToLower().Equals("insert"))
  1941. {
  1942. /* string guid = Guid.NewGuid().ToString("N").ToUpper();
  1943. dlgOrderAskDown down = new dlgOrderAskDown(this.ob, filePathOld);
  1944. down.CtrlFileDown1.FilePath = filePathOld;
  1945. if (down.CtrlFileDown1.List.Count > 0)
  1946. {
  1947. MessageUtil.ShowWarning("只能上传一份文件!");
  1948. return;*/
  1949. List<FileBean> list = new List<FileBean>();
  1950. FileBean bean = new FileBean();
  1951. OpenFileDialog file = new OpenFileDialog();
  1952. file.Multiselect = false;
  1953. DialogResult drStat;
  1954. drStat = file.ShowDialog();
  1955. if (drStat == DialogResult.OK)
  1956. {
  1957. string fileName = file.FileName;
  1958. string filena = System.IO.Path.GetFileName(fileName);
  1959. string filePathNew = "Qcm/CraftLv2/" + entity.OrderManageNo + "/";
  1960. entity.CraftFileLv2F = filena;
  1961. entity.CraftFileLv2FDesc = filena;
  1962. bean = new FileBean();
  1963. bean.setFileName(filena);
  1964. bean.setPathName(filePathNew);
  1965. bean.setFile(FileHelper.FileToArray(fileName));
  1966. list.Add(bean);
  1967. _craftOrdDesignBLL.SaveCraftLv2(new List<CraftOrdDesignEntity>() {entity});
  1968. bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list);
  1969. if (isSuccess)
  1970. {
  1971. MessageBox.Show("上传成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
  1972. ultraGrid1.Refresh();
  1973. }
  1974. else
  1975. {
  1976. MessageBox.Show("上传失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
  1977. }
  1978. }
  1979. }
  1980. }
  1981. private void ultraTextEditor2_EditorButtonClick(object sender, EditorButtonEventArgs e)
  1982. {
  1983. var strurl = "";
  1984. var entity = ultraGrid1.ActiveRow.ListObject as ChoiceCraftFileLv2Entity;
  1985. strurl =
  1986. "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepHttZhaZhiProcess.cpt&orderManageNo={0}&desginKey={1}&mscPline={2}&sic={3}";
  1987. strurl = String.Format(strurl, entity.OrderManageNo,entity.DesginKey,entity.MscPline,entity.Sic);
  1988. var fre = new FrmRepExcel(ob, strurl);
  1989. fre.AutoSize = true;
  1990. fre.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width,
  1991. Screen.PrimaryScreen.WorkingArea.Height);
  1992. fre.WindowState = FormWindowState.Maximized;
  1993. fre.Show();
  1994. }
  1995. }
  1996. }