WorkpieceMaintenance .cs 85 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734
  1. using PaintDotNet.Base.SettingModel;
  2. using PaintDotNet.Base.CommTool;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.IO;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using System.Windows.Forms;
  13. namespace PaintDotNet.DedicatedAnalysis
  14. {
  15. public partial class WorkpieceMaintenance : PdnBaseForm
  16. {
  17. /// <summary>
  18. /// 操作区分(0 :添加 1 :编辑)
  19. /// </summary>
  20. private int operation = -1;
  21. /// <summary>
  22. /// 配置文件
  23. /// </summary>
  24. private WorkpieceMaintenanceModel workpieceMaintenanceModel;
  25. /// <summary>
  26. /// 工件类型
  27. /// </summary>
  28. private const string constTypeA = "a";
  29. private const string constTypeB = "b";
  30. private const string constTypeC = "c";
  31. private const string constTypeD = "d";
  32. private const string constTypeE = "e";
  33. /// <summary>
  34. /// 编辑时的数据
  35. /// </summary>
  36. private DataTable DataTable;
  37. #region 控件
  38. private GroupBox groupBox2;
  39. private GroupBox groupBox3;
  40. private Button button3;
  41. private Button button2;
  42. private Button button1;
  43. private Button button6;
  44. private Button button5;
  45. private Button button4;
  46. private PictureBox pictureBox5;
  47. private PictureBox pictureBox4;
  48. private PictureBox pictureBox3;
  49. private PictureBox pictureBox2;
  50. private PictureBox pictureBox1;
  51. private RadioButton radioButton5;
  52. private RadioButton radioButton4;
  53. private RadioButton radioButton3;
  54. private RadioButton radioButton2;
  55. private RadioButton radioButton1;
  56. private TextBox textBox1;
  57. private Label label3;
  58. private Label label2;
  59. private Label label1;
  60. private DataGridView dataGridView1;
  61. private DataGridView dataGridView2;
  62. private DataGridViewTextBoxColumn name;
  63. private DataGridViewTextBoxColumn type;
  64. private DataGridViewTextBoxColumn Name1;
  65. private DataGridViewTextBoxColumn Standardvalue1;
  66. private DataGridViewTextBoxColumn Error1;
  67. private DataGridViewTextBoxColumn Name2;
  68. private DataGridViewTextBoxColumn Standardvalue2;
  69. private DataGridViewTextBoxColumn Error2;
  70. private DataGridViewTextBoxColumn Name3;
  71. private DataGridViewTextBoxColumn Standardvalue3;
  72. private DataGridViewTextBoxColumn Error3;
  73. private DataGridViewTextBoxColumn Name4;
  74. private DataGridViewTextBoxColumn Standardvalue4;
  75. private DataGridViewTextBoxColumn Error4;
  76. private DataGridViewTextBoxColumn DetailName;
  77. private DataGridViewTextBoxColumn DetailStandardvalue;
  78. private DataGridViewTextBoxColumn DetailError;
  79. private ToolTip toolTip1;
  80. private IContainer components;
  81. private GroupBox groupBox1;
  82. #endregion
  83. public WorkpieceMaintenance()
  84. {
  85. InitializeComponent();
  86. InitializeLanguageText();
  87. InitializeButtonBackgroudImage();
  88. InitializeToolTip();
  89. this.groupBox3.Hide();
  90. this.radioButton1.Checked = true;
  91. this.pictureBox1.Image = PdnResources.GetImageResource("Workpiece.WorkpieceA.png").Reference;
  92. this.pictureBox2.Image = PdnResources.GetImageResource("Workpiece.WorkpieceB.png").Reference;
  93. this.pictureBox3.Image = PdnResources.GetImageResource("Workpiece.WorkpieceC.png").Reference;
  94. this.pictureBox4.Image = PdnResources.GetImageResource("Workpiece.WorkpieceD.png").Reference;
  95. this.pictureBox5.Image = PdnResources.GetImageResource("Workpiece.WorkpieceE.png").Reference;
  96. GetFromConfigurationFile();
  97. }
  98. private void InitializeToolTip()
  99. {
  100. this.toolTip1 = new ToolTip();
  101. this.toolTip1.SetToolTip(this.button4, PdnResources.GetString("Menu.Addto.text"));
  102. this.toolTip1.SetToolTip(this.button5, PdnResources.GetString("Menu.Edit.Text"));
  103. this.toolTip1.SetToolTip(this.button6, PdnResources.GetString("Menu.Edit.Delete.Text"));
  104. this.toolTip1.ShowAlways = true;
  105. }
  106. private void InitializeButtonBackgroudImage()
  107. {
  108. this.button4.FlatStyle = FlatStyle.Flat;
  109. this.button4.FlatAppearance.BorderSize = 0;
  110. this.button4.BackgroundImageLayout = ImageLayout.Center;
  111. this.button4.BackgroundImage = PdnResources.GetImageResource("Icons.MenuRulesListAddIcon.png").Reference;
  112. this.button5.FlatStyle = FlatStyle.Flat;
  113. this.button5.FlatAppearance.BorderSize = 0;
  114. this.button5.BackgroundImageLayout = ImageLayout.Center;
  115. this.button5.BackgroundImage = PdnResources.GetImageResource("Icons.MenuRulesListEditIcon.png").Reference;
  116. this.button6.FlatStyle = FlatStyle.Flat;
  117. this.button6.FlatAppearance.BorderSize = 0;
  118. this.button6.BackgroundImageLayout = ImageLayout.Center;
  119. this.button6.BackgroundImage = PdnResources.GetImageResource("Icons.MenuRulesListDeleteIcon.png").Reference;
  120. }
  121. private void InitializeLanguageText()
  122. {
  123. this.groupBox1.Text = PdnResources.GetString("Menu.Dedicatedanalysis.Non-ferrousmetals.artifactmaintenance.text");
  124. this.button3.Text = PdnResources.GetString("Menu.use.text");
  125. this.button2.Text = PdnResources.GetString("CommonAction.Save");
  126. this.button1.Text = PdnResources.GetString("Menu.File.Close.Text");
  127. this.groupBox2.Text = PdnResources.GetString("Menu.Dedicatedanalysis.Non-ferrousmetals.artifactrecord.text");
  128. this.name.HeaderText = PdnResources.GetString("Menu.name.text");
  129. this.type.HeaderText = PdnResources.GetString("Menu.Dedicatedanalysis.Non-ferrousmetals.artifacttype.text");
  130. this.groupBox3.Text = PdnResources.GetString("Menu.Dedicatedanalysis.Non-ferrousmetals.detailinformation.text");
  131. this.label1.Text = PdnResources.GetString("Menu.Dedicatedanalysis.Non-ferrousmetals.artifact name.text") + ":";
  132. this.DetailName.HeaderText = PdnResources.GetString("Menu.name.text");
  133. this.DetailStandardvalue.HeaderText = PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.standardvalue.text") + "(%)";
  134. this.DetailError.HeaderText = PdnResources.GetString("Menu.error.text");
  135. this.label3.Text = PdnResources.GetString("Menu.detailed.text") + ":";
  136. this.label2.Text = PdnResources.GetString("Menu.Dedicatedanalysis.Non-ferrousmetals.artifacttype.text") + ":";
  137. this.Text = PdnResources.GetString("Menu.Dedicatedanalysis.Non-ferrousmetals.artifactmaintenance.text");
  138. }
  139. private void InitializeComponent()
  140. {
  141. this.components = new System.ComponentModel.Container();
  142. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle28 = new System.Windows.Forms.DataGridViewCellStyle();
  143. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle29 = new System.Windows.Forms.DataGridViewCellStyle();
  144. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle30 = new System.Windows.Forms.DataGridViewCellStyle();
  145. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle31 = new System.Windows.Forms.DataGridViewCellStyle();
  146. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle35 = new System.Windows.Forms.DataGridViewCellStyle();
  147. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle36 = new System.Windows.Forms.DataGridViewCellStyle();
  148. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle32 = new System.Windows.Forms.DataGridViewCellStyle();
  149. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle33 = new System.Windows.Forms.DataGridViewCellStyle();
  150. System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle34 = new System.Windows.Forms.DataGridViewCellStyle();
  151. this.groupBox1 = new System.Windows.Forms.GroupBox();
  152. this.button3 = new System.Windows.Forms.Button();
  153. this.button2 = new System.Windows.Forms.Button();
  154. this.button1 = new System.Windows.Forms.Button();
  155. this.groupBox2 = new System.Windows.Forms.GroupBox();
  156. this.dataGridView2 = new System.Windows.Forms.DataGridView();
  157. this.name = new System.Windows.Forms.DataGridViewTextBoxColumn();
  158. this.type = new System.Windows.Forms.DataGridViewTextBoxColumn();
  159. this.Name1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  160. this.Standardvalue1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  161. this.Error1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  162. this.Name2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  163. this.Standardvalue2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  164. this.Error2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  165. this.Name3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  166. this.Standardvalue3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  167. this.Error3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  168. this.Name4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  169. this.Standardvalue4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  170. this.Error4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
  171. this.button6 = new System.Windows.Forms.Button();
  172. this.button5 = new System.Windows.Forms.Button();
  173. this.button4 = new System.Windows.Forms.Button();
  174. this.groupBox3 = new System.Windows.Forms.GroupBox();
  175. this.dataGridView1 = new System.Windows.Forms.DataGridView();
  176. this.DetailName = new System.Windows.Forms.DataGridViewTextBoxColumn();
  177. this.DetailStandardvalue = new System.Windows.Forms.DataGridViewTextBoxColumn();
  178. this.DetailError = new System.Windows.Forms.DataGridViewTextBoxColumn();
  179. this.pictureBox5 = new System.Windows.Forms.PictureBox();
  180. this.pictureBox4 = new System.Windows.Forms.PictureBox();
  181. this.pictureBox3 = new System.Windows.Forms.PictureBox();
  182. this.pictureBox2 = new System.Windows.Forms.PictureBox();
  183. this.pictureBox1 = new System.Windows.Forms.PictureBox();
  184. this.radioButton5 = new System.Windows.Forms.RadioButton();
  185. this.radioButton4 = new System.Windows.Forms.RadioButton();
  186. this.radioButton3 = new System.Windows.Forms.RadioButton();
  187. this.radioButton2 = new System.Windows.Forms.RadioButton();
  188. this.radioButton1 = new System.Windows.Forms.RadioButton();
  189. this.textBox1 = new System.Windows.Forms.TextBox();
  190. this.label3 = new System.Windows.Forms.Label();
  191. this.label2 = new System.Windows.Forms.Label();
  192. this.label1 = new System.Windows.Forms.Label();
  193. this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
  194. this.groupBox1.SuspendLayout();
  195. this.groupBox2.SuspendLayout();
  196. ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();
  197. this.groupBox3.SuspendLayout();
  198. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
  199. ((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).BeginInit();
  200. ((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).BeginInit();
  201. ((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit();
  202. ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
  203. ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
  204. this.SuspendLayout();
  205. //
  206. // groupBox1
  207. //
  208. this.groupBox1.Controls.Add(this.button3);
  209. this.groupBox1.Controls.Add(this.button2);
  210. this.groupBox1.Controls.Add(this.button1);
  211. this.groupBox1.Location = new System.Drawing.Point(12, 12);
  212. this.groupBox1.Name = "groupBox1";
  213. this.groupBox1.Size = new System.Drawing.Size(840, 52);
  214. this.groupBox1.TabIndex = 0;
  215. this.groupBox1.TabStop = false;
  216. //
  217. // button3
  218. //
  219. this.button3.Location = new System.Drawing.Point(729, 13);
  220. this.button3.Name = "button3";
  221. this.button3.Size = new System.Drawing.Size(103, 31);
  222. this.button3.TabIndex = 2;
  223. this.button3.UseVisualStyleBackColor = true;
  224. this.button3.Click += new System.EventHandler(this.button3_Click);
  225. //
  226. // button2
  227. //
  228. this.button2.Location = new System.Drawing.Point(610, 13);
  229. this.button2.Name = "button2";
  230. this.button2.Size = new System.Drawing.Size(103, 31);
  231. this.button2.TabIndex = 1;
  232. this.button2.UseVisualStyleBackColor = true;
  233. this.button2.Click += new System.EventHandler(this.button2_Click);
  234. //
  235. // button1
  236. //
  237. this.button1.Location = new System.Drawing.Point(491, 13);
  238. this.button1.Name = "button1";
  239. this.button1.Size = new System.Drawing.Size(103, 31);
  240. this.button1.TabIndex = 0;
  241. this.button1.UseVisualStyleBackColor = true;
  242. this.button1.Click += new System.EventHandler(this.button1_Click);
  243. //
  244. // groupBox2
  245. //
  246. this.groupBox2.Controls.Add(this.dataGridView2);
  247. this.groupBox2.Controls.Add(this.button6);
  248. this.groupBox2.Controls.Add(this.button5);
  249. this.groupBox2.Controls.Add(this.button4);
  250. this.groupBox2.Location = new System.Drawing.Point(12, 70);
  251. this.groupBox2.Name = "groupBox2";
  252. this.groupBox2.Size = new System.Drawing.Size(220, 326);
  253. this.groupBox2.TabIndex = 1;
  254. this.groupBox2.TabStop = false;
  255. //
  256. // dataGridView2
  257. //
  258. this.dataGridView2.AllowUserToAddRows = false;
  259. this.dataGridView2.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  260. this.dataGridView2.BackgroundColor = System.Drawing.SystemColors.Control;
  261. dataGridViewCellStyle28.Alignment = System.Windows.Forms.DataGridViewContentAlignment.TopCenter;
  262. dataGridViewCellStyle28.BackColor = System.Drawing.SystemColors.Control;
  263. dataGridViewCellStyle28.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
  264. dataGridViewCellStyle28.ForeColor = System.Drawing.SystemColors.WindowText;
  265. dataGridViewCellStyle28.SelectionBackColor = System.Drawing.SystemColors.Highlight;
  266. dataGridViewCellStyle28.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
  267. dataGridViewCellStyle28.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
  268. this.dataGridView2.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle28;
  269. this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  270. this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  271. this.name,
  272. this.type,
  273. this.Name1,
  274. this.Standardvalue1,
  275. this.Error1,
  276. this.Name2,
  277. this.Standardvalue2,
  278. this.Error2,
  279. this.Name3,
  280. this.Standardvalue3,
  281. this.Error3,
  282. this.Name4,
  283. this.Standardvalue4,
  284. this.Error4});
  285. this.dataGridView2.Location = new System.Drawing.Point(6, 46);
  286. this.dataGridView2.MultiSelect = false;
  287. this.dataGridView2.Name = "dataGridView2";
  288. this.dataGridView2.RowHeadersVisible = false;
  289. this.dataGridView2.RowTemplate.Height = 23;
  290. this.dataGridView2.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
  291. this.dataGridView2.Size = new System.Drawing.Size(206, 274);
  292. this.dataGridView2.TabIndex = 14;
  293. this.dataGridView2.SelectionChanged += new System.EventHandler(this.dataGridView2_SelectionChanged);
  294. //
  295. // name
  296. //
  297. dataGridViewCellStyle29.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  298. this.name.DefaultCellStyle = dataGridViewCellStyle29;
  299. this.name.Name = "name";
  300. this.name.ReadOnly = true;
  301. //
  302. // type
  303. //
  304. this.type.Name = "type";
  305. this.type.Visible = false;
  306. //
  307. // Name1
  308. //
  309. this.Name1.HeaderText = "Name1";
  310. this.Name1.Name = "Name1";
  311. this.Name1.Visible = false;
  312. //
  313. // Standardvalue1
  314. //
  315. this.Standardvalue1.HeaderText = "Standardvalue1";
  316. this.Standardvalue1.Name = "Standardvalue1";
  317. this.Standardvalue1.Visible = false;
  318. //
  319. // Error1
  320. //
  321. this.Error1.HeaderText = "Error1";
  322. this.Error1.Name = "Error1";
  323. this.Error1.Visible = false;
  324. //
  325. // Name2
  326. //
  327. this.Name2.HeaderText = "Name2";
  328. this.Name2.Name = "Name2";
  329. this.Name2.Visible = false;
  330. //
  331. // Standardvalue2
  332. //
  333. this.Standardvalue2.HeaderText = "Standardvalue2";
  334. this.Standardvalue2.Name = "Standardvalue2";
  335. this.Standardvalue2.Visible = false;
  336. //
  337. // Error2
  338. //
  339. this.Error2.HeaderText = "Error2";
  340. this.Error2.Name = "Error2";
  341. this.Error2.Visible = false;
  342. //
  343. // Name3
  344. //
  345. this.Name3.HeaderText = "Name3";
  346. this.Name3.Name = "Name3";
  347. this.Name3.Visible = false;
  348. //
  349. // Standardvalue3
  350. //
  351. this.Standardvalue3.HeaderText = "Standardvalue3";
  352. this.Standardvalue3.Name = "Standardvalue3";
  353. this.Standardvalue3.Visible = false;
  354. //
  355. // Error3
  356. //
  357. this.Error3.HeaderText = "Error3";
  358. this.Error3.Name = "Error3";
  359. this.Error3.Visible = false;
  360. //
  361. // Name4
  362. //
  363. this.Name4.HeaderText = "Name4";
  364. this.Name4.Name = "Name4";
  365. this.Name4.Visible = false;
  366. //
  367. // Standardvalue4
  368. //
  369. this.Standardvalue4.HeaderText = "Standardvalue4";
  370. this.Standardvalue4.Name = "Standardvalue4";
  371. this.Standardvalue4.Visible = false;
  372. //
  373. // Error4
  374. //
  375. this.Error4.HeaderText = "Error4";
  376. this.Error4.Name = "Error4";
  377. this.Error4.Visible = false;
  378. //
  379. // button6
  380. //
  381. this.button6.Location = new System.Drawing.Point(185, 15);
  382. this.button6.Name = "button6";
  383. this.button6.Size = new System.Drawing.Size(27, 25);
  384. this.button6.TabIndex = 7;
  385. this.button6.UseVisualStyleBackColor = true;
  386. this.button6.Click += new System.EventHandler(this.button6_Click);
  387. //
  388. // button5
  389. //
  390. this.button5.Location = new System.Drawing.Point(152, 15);
  391. this.button5.Name = "button5";
  392. this.button5.Size = new System.Drawing.Size(27, 25);
  393. this.button5.TabIndex = 6;
  394. this.button5.UseVisualStyleBackColor = true;
  395. this.button5.Click += new System.EventHandler(this.button5_Click);
  396. //
  397. // button4
  398. //
  399. this.button4.Location = new System.Drawing.Point(119, 15);
  400. this.button4.Name = "button4";
  401. this.button4.Size = new System.Drawing.Size(27, 25);
  402. this.button4.TabIndex = 5;
  403. this.button4.UseVisualStyleBackColor = true;
  404. this.button4.Click += new System.EventHandler(this.button4_Click);
  405. //
  406. // groupBox3
  407. //
  408. this.groupBox3.Controls.Add(this.dataGridView1);
  409. this.groupBox3.Controls.Add(this.pictureBox5);
  410. this.groupBox3.Controls.Add(this.pictureBox4);
  411. this.groupBox3.Controls.Add(this.pictureBox3);
  412. this.groupBox3.Controls.Add(this.pictureBox2);
  413. this.groupBox3.Controls.Add(this.pictureBox1);
  414. this.groupBox3.Controls.Add(this.radioButton5);
  415. this.groupBox3.Controls.Add(this.radioButton4);
  416. this.groupBox3.Controls.Add(this.radioButton3);
  417. this.groupBox3.Controls.Add(this.radioButton2);
  418. this.groupBox3.Controls.Add(this.radioButton1);
  419. this.groupBox3.Controls.Add(this.textBox1);
  420. this.groupBox3.Controls.Add(this.label3);
  421. this.groupBox3.Controls.Add(this.label2);
  422. this.groupBox3.Controls.Add(this.label1);
  423. this.groupBox3.Location = new System.Drawing.Point(238, 70);
  424. this.groupBox3.Name = "groupBox3";
  425. this.groupBox3.Size = new System.Drawing.Size(614, 326);
  426. this.groupBox3.TabIndex = 2;
  427. this.groupBox3.TabStop = false;
  428. //
  429. // dataGridView1
  430. //
  431. this.dataGridView1.AllowUserToAddRows = false;
  432. dataGridViewCellStyle30.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  433. this.dataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle30;
  434. this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
  435. this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.Control;
  436. dataGridViewCellStyle31.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  437. dataGridViewCellStyle31.BackColor = System.Drawing.SystemColors.Control;
  438. dataGridViewCellStyle31.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
  439. dataGridViewCellStyle31.ForeColor = System.Drawing.SystemColors.WindowText;
  440. dataGridViewCellStyle31.SelectionBackColor = System.Drawing.SystemColors.Highlight;
  441. dataGridViewCellStyle31.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
  442. dataGridViewCellStyle31.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
  443. this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle31;
  444. this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
  445. this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
  446. this.DetailName,
  447. this.DetailStandardvalue,
  448. this.DetailError});
  449. this.dataGridView1.Location = new System.Drawing.Point(72, 153);
  450. this.dataGridView1.Name = "dataGridView1";
  451. dataGridViewCellStyle35.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  452. dataGridViewCellStyle35.BackColor = System.Drawing.SystemColors.Control;
  453. dataGridViewCellStyle35.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
  454. dataGridViewCellStyle35.ForeColor = System.Drawing.SystemColors.WindowText;
  455. dataGridViewCellStyle35.SelectionBackColor = System.Drawing.SystemColors.Highlight;
  456. dataGridViewCellStyle35.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
  457. dataGridViewCellStyle35.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
  458. this.dataGridView1.RowHeadersDefaultCellStyle = dataGridViewCellStyle35;
  459. this.dataGridView1.RowHeadersVisible = false;
  460. dataGridViewCellStyle36.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  461. this.dataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle36;
  462. this.dataGridView1.RowTemplate.Height = 23;
  463. this.dataGridView1.Size = new System.Drawing.Size(528, 159);
  464. this.dataGridView1.TabIndex = 13;
  465. this.dataGridView1.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellValueChanged);
  466. //
  467. // DetailName
  468. //
  469. dataGridViewCellStyle32.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  470. this.DetailName.DefaultCellStyle = dataGridViewCellStyle32;
  471. this.DetailName.Name = "DetailName";
  472. this.DetailName.ReadOnly = true;
  473. //
  474. // DetailStandardvalue
  475. //
  476. dataGridViewCellStyle33.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  477. this.DetailStandardvalue.DefaultCellStyle = dataGridViewCellStyle33;
  478. this.DetailStandardvalue.Name = "DetailStandardvalue";
  479. //
  480. // DetailError
  481. //
  482. dataGridViewCellStyle34.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
  483. this.DetailError.DefaultCellStyle = dataGridViewCellStyle34;
  484. this.DetailError.Name = "DetailError";
  485. //
  486. // pictureBox5
  487. //
  488. this.pictureBox5.Location = new System.Drawing.Point(500, 73);
  489. this.pictureBox5.Name = "pictureBox5";
  490. this.pictureBox5.Size = new System.Drawing.Size(68, 57);
  491. this.pictureBox5.TabIndex = 12;
  492. this.pictureBox5.TabStop = false;
  493. //
  494. // pictureBox4
  495. //
  496. this.pictureBox4.Location = new System.Drawing.Point(403, 73);
  497. this.pictureBox4.Name = "pictureBox4";
  498. this.pictureBox4.Size = new System.Drawing.Size(68, 57);
  499. this.pictureBox4.TabIndex = 11;
  500. this.pictureBox4.TabStop = false;
  501. //
  502. // pictureBox3
  503. //
  504. this.pictureBox3.Location = new System.Drawing.Point(306, 73);
  505. this.pictureBox3.Name = "pictureBox3";
  506. this.pictureBox3.Size = new System.Drawing.Size(68, 57);
  507. this.pictureBox3.TabIndex = 10;
  508. this.pictureBox3.TabStop = false;
  509. //
  510. // pictureBox2
  511. //
  512. this.pictureBox2.Location = new System.Drawing.Point(209, 73);
  513. this.pictureBox2.Name = "pictureBox2";
  514. this.pictureBox2.Size = new System.Drawing.Size(68, 57);
  515. this.pictureBox2.TabIndex = 9;
  516. this.pictureBox2.TabStop = false;
  517. //
  518. // pictureBox1
  519. //
  520. this.pictureBox1.Location = new System.Drawing.Point(112, 73);
  521. this.pictureBox1.Name = "pictureBox1";
  522. this.pictureBox1.Size = new System.Drawing.Size(68, 57);
  523. this.pictureBox1.TabIndex = 8;
  524. this.pictureBox1.TabStop = false;
  525. //
  526. // radioButton5
  527. //
  528. this.radioButton5.AutoSize = true;
  529. this.radioButton5.Location = new System.Drawing.Point(481, 93);
  530. this.radioButton5.Name = "radioButton5";
  531. this.radioButton5.Size = new System.Drawing.Size(14, 13);
  532. this.radioButton5.TabIndex = 7;
  533. this.radioButton5.UseVisualStyleBackColor = true;
  534. this.radioButton5.CheckedChanged += new System.EventHandler(this.radioButton5_CheckedChanged);
  535. //
  536. // radioButton4
  537. //
  538. this.radioButton4.AutoSize = true;
  539. this.radioButton4.Location = new System.Drawing.Point(384, 93);
  540. this.radioButton4.Name = "radioButton4";
  541. this.radioButton4.Size = new System.Drawing.Size(14, 13);
  542. this.radioButton4.TabIndex = 7;
  543. this.radioButton4.UseVisualStyleBackColor = true;
  544. this.radioButton4.CheckedChanged += new System.EventHandler(this.radioButton4_CheckedChanged);
  545. //
  546. // radioButton3
  547. //
  548. this.radioButton3.AutoSize = true;
  549. this.radioButton3.Location = new System.Drawing.Point(287, 93);
  550. this.radioButton3.Name = "radioButton3";
  551. this.radioButton3.Size = new System.Drawing.Size(14, 13);
  552. this.radioButton3.TabIndex = 6;
  553. this.radioButton3.UseVisualStyleBackColor = true;
  554. this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButton3_CheckedChanged);
  555. //
  556. // radioButton2
  557. //
  558. this.radioButton2.AutoSize = true;
  559. this.radioButton2.Location = new System.Drawing.Point(190, 93);
  560. this.radioButton2.Name = "radioButton2";
  561. this.radioButton2.Size = new System.Drawing.Size(14, 13);
  562. this.radioButton2.TabIndex = 5;
  563. this.radioButton2.UseVisualStyleBackColor = true;
  564. this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
  565. //
  566. // radioButton1
  567. //
  568. this.radioButton1.AutoSize = true;
  569. this.radioButton1.Location = new System.Drawing.Point(93, 93);
  570. this.radioButton1.Name = "radioButton1";
  571. this.radioButton1.Size = new System.Drawing.Size(14, 13);
  572. this.radioButton1.TabIndex = 4;
  573. this.radioButton1.UseVisualStyleBackColor = true;
  574. this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
  575. //
  576. // textBox1
  577. //
  578. this.textBox1.Location = new System.Drawing.Point(96, 31);
  579. this.textBox1.Name = "textBox1";
  580. this.textBox1.Size = new System.Drawing.Size(493, 21);
  581. this.textBox1.TabIndex = 3;
  582. //
  583. // label3
  584. //
  585. this.label3.AutoSize = true;
  586. this.label3.Location = new System.Drawing.Point(25, 153);
  587. this.label3.Name = "label3";
  588. this.label3.Size = new System.Drawing.Size(41, 12);
  589. this.label3.TabIndex = 2;
  590. //
  591. // label2
  592. //
  593. this.label2.AutoSize = true;
  594. this.label2.Location = new System.Drawing.Point(25, 93);
  595. this.label2.Name = "label2";
  596. this.label2.Size = new System.Drawing.Size(65, 12);
  597. this.label2.TabIndex = 1;
  598. //
  599. // label1
  600. //
  601. this.label1.AutoSize = true;
  602. this.label1.Location = new System.Drawing.Point(25, 35);
  603. this.label1.Name = "label1";
  604. this.label1.Size = new System.Drawing.Size(65, 12);
  605. this.label1.TabIndex = 0;
  606. //
  607. // WorkpieceMaintenance
  608. //
  609. this.ClientSize = new System.Drawing.Size(864, 408);
  610. this.Controls.Add(this.groupBox3);
  611. this.Controls.Add(this.groupBox2);
  612. this.Controls.Add(this.groupBox1);
  613. this.MaximizeBox = false;
  614. this.MaximumSize = new System.Drawing.Size(880, 447);
  615. this.MinimizeBox = false;
  616. this.MinimumSize = new System.Drawing.Size(880, 447);
  617. this.Name = "WorkpieceMaintenance";
  618. this.ShowInTaskbar = false;
  619. this.groupBox1.ResumeLayout(false);
  620. this.groupBox2.ResumeLayout(false);
  621. ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();
  622. this.groupBox3.ResumeLayout(false);
  623. this.groupBox3.PerformLayout();
  624. ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
  625. ((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).EndInit();
  626. ((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).EndInit();
  627. ((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).EndInit();
  628. ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
  629. ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
  630. this.ResumeLayout(false);
  631. }
  632. /// <summary>
  633. /// 初始化右侧编辑模块
  634. /// </summary>
  635. private void InitGroupBox3()
  636. {
  637. this.groupBox3.Enabled = true;
  638. this.textBox1.Text = string.Empty;
  639. dataGridView1.Rows.Clear();
  640. DataGridViewRow row = new DataGridViewRow();
  641. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  642. textboxcell.Value = constTypeA;
  643. row.Cells.Add(textboxcell);
  644. dataGridView1.Rows.Add(row);
  645. this.radioButton1.Checked = true;
  646. }
  647. /// <summary>
  648. /// 保存工件到配置文件
  649. /// </summary>
  650. private void SaveToConfigurationFile()
  651. {
  652. WorkpieceMaintenanceModel workpieceMaintenanceModel = new WorkpieceMaintenanceModel();
  653. workpieceMaintenanceModel.Workpieces = new List<WorkpieceMaintenanceModel.Workpiece>();
  654. for (int i = 0; i < this.dataGridView2.Rows.Count; i++)
  655. {
  656. WorkpieceMaintenanceModel.Workpiece workpiece = new WorkpieceMaintenanceModel.Workpiece();
  657. if(this.dataGridView2.Rows[i].Cells[0].Value != null)
  658. workpiece.Name = this.dataGridView2.Rows[i].Cells[0].Value.ToString();
  659. if (this.dataGridView2.Rows[i].Cells[1].Value != null)
  660. workpiece.Type = this.dataGridView2.Rows[i].Cells[1].Value.ToString();
  661. if (this.dataGridView2.Rows[i].Cells[2].Value != null)
  662. workpiece.NameA = this.dataGridView2.Rows[i].Cells[2].Value.ToString();
  663. if (this.dataGridView2.Rows[i].Cells[3].Value != null)
  664. workpiece.StandardValueA = this.dataGridView2.Rows[i].Cells[3].Value.ToString();
  665. if (this.dataGridView2.Rows[i].Cells[4].Value != null)
  666. workpiece.ErrorA = this.dataGridView2.Rows[i].Cells[4].Value.ToString();
  667. if (this.dataGridView2.Rows[i].Cells[5].Value != null)
  668. workpiece.NameB = this.dataGridView2.Rows[i].Cells[5].Value.ToString();
  669. if (this.dataGridView2.Rows[i].Cells[6].Value != null)
  670. workpiece.StandardValueB = this.dataGridView2.Rows[i].Cells[6].Value.ToString();
  671. if (this.dataGridView2.Rows[i].Cells[7].Value != null)
  672. workpiece.ErrorB = this.dataGridView2.Rows[i].Cells[7].Value.ToString();
  673. if (this.dataGridView2.Rows[i].Cells[8].Value != null)
  674. workpiece.NameC = this.dataGridView2.Rows[i].Cells[8].Value.ToString();
  675. if (this.dataGridView2.Rows[i].Cells[9].Value != null)
  676. workpiece.StandardValueC = this.dataGridView2.Rows[i].Cells[9].Value.ToString();
  677. if (this.dataGridView2.Rows[i].Cells[10].Value != null)
  678. workpiece.ErrorC = this.dataGridView2.Rows[i].Cells[10].Value.ToString();
  679. if (this.dataGridView2.Rows[i].Cells[11].Value != null)
  680. workpiece.NameD = this.dataGridView2.Rows[i].Cells[11].Value.ToString();
  681. if (this.dataGridView2.Rows[i].Cells[12].Value != null)
  682. workpiece.StandardValueD = this.dataGridView2.Rows[i].Cells[12].Value.ToString();
  683. if (this.dataGridView2.Rows[i].Cells[13].Value != null)
  684. workpiece.ErrorD = this.dataGridView2.Rows[i].Cells[13].Value.ToString();
  685. workpieceMaintenanceModel.Workpieces.Add(workpiece);
  686. }
  687. string configXml = XmlSerializeHelper.XmlSerialize<WorkpieceMaintenanceModel>(workpieceMaintenanceModel);
  688. string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\WorkpieceMaintenanceModel.xml";
  689. if (FileOperationHelper.WriteStringToFile(configXml, filePath, FileMode.Create))
  690. {
  691. }
  692. else
  693. {
  694. MessageBox.Show(PdnResources.GetString("Menu.xmlsavefailed.text"));
  695. }
  696. }
  697. /// <summary>
  698. /// 从配置文件中读取工件信息
  699. /// </summary>
  700. private void GetFromConfigurationFile()
  701. {
  702. workpieceMaintenanceModel = XmlSerializeHelper.DESerializer<WorkpieceMaintenanceModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" +Startup.instance.SettingPrefix + "\\WorkpieceMaintenanceModel.xml", FileMode.Open));
  703. if (workpieceMaintenanceModel.Workpieces != null)
  704. {
  705. this.dataGridView2.Rows.Clear();
  706. for (int i = 0; i < workpieceMaintenanceModel.Workpieces.Count; i++)
  707. {
  708. DataGridViewRow row = new DataGridViewRow();
  709. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  710. textboxcell.Value = workpieceMaintenanceModel.Workpieces[i].Name;
  711. row.Cells.Add(textboxcell);
  712. textboxcell = new DataGridViewTextBoxCell();
  713. textboxcell.Value = workpieceMaintenanceModel.Workpieces[i].Type;
  714. row.Cells.Add(textboxcell);
  715. textboxcell = new DataGridViewTextBoxCell();
  716. textboxcell.Value = workpieceMaintenanceModel.Workpieces[i].NameA;
  717. row.Cells.Add(textboxcell);
  718. textboxcell = new DataGridViewTextBoxCell();
  719. textboxcell.Value = workpieceMaintenanceModel.Workpieces[i].StandardValueA;
  720. row.Cells.Add(textboxcell);
  721. textboxcell = new DataGridViewTextBoxCell();
  722. textboxcell.Value = workpieceMaintenanceModel.Workpieces[i].ErrorA;
  723. row.Cells.Add(textboxcell);
  724. textboxcell = new DataGridViewTextBoxCell();
  725. textboxcell.Value = workpieceMaintenanceModel.Workpieces[i].NameB;
  726. row.Cells.Add(textboxcell);
  727. textboxcell = new DataGridViewTextBoxCell();
  728. textboxcell.Value = workpieceMaintenanceModel.Workpieces[i].StandardValueB;
  729. row.Cells.Add(textboxcell);
  730. textboxcell = new DataGridViewTextBoxCell();
  731. textboxcell.Value = workpieceMaintenanceModel.Workpieces[i].ErrorB;
  732. row.Cells.Add(textboxcell);
  733. textboxcell = new DataGridViewTextBoxCell();
  734. textboxcell.Value = workpieceMaintenanceModel.Workpieces[i].NameC;
  735. row.Cells.Add(textboxcell);
  736. textboxcell = new DataGridViewTextBoxCell();
  737. textboxcell.Value = workpieceMaintenanceModel.Workpieces[i].StandardValueC;
  738. row.Cells.Add(textboxcell);
  739. textboxcell = new DataGridViewTextBoxCell();
  740. textboxcell.Value = workpieceMaintenanceModel.Workpieces[i].ErrorC;
  741. row.Cells.Add(textboxcell);
  742. textboxcell = new DataGridViewTextBoxCell();
  743. textboxcell.Value = workpieceMaintenanceModel.Workpieces[i].NameD;
  744. row.Cells.Add(textboxcell);
  745. textboxcell = new DataGridViewTextBoxCell();
  746. textboxcell.Value = workpieceMaintenanceModel.Workpieces[i].StandardValueD;
  747. row.Cells.Add(textboxcell);
  748. textboxcell = new DataGridViewTextBoxCell();
  749. textboxcell.Value = workpieceMaintenanceModel.Workpieces[i].ErrorD;
  750. row.Cells.Add(textboxcell);
  751. dataGridView2.Rows.Add(row);
  752. }
  753. }
  754. }
  755. /// <summary>
  756. /// 工件添加按钮
  757. /// </summary>
  758. /// <param name="sender"></param>
  759. /// <param name=constTypeE></param>
  760. private void button4_Click(object sender, EventArgs e)
  761. {
  762. this.operation = 0;
  763. InitGroupBox3();
  764. this.groupBox3.Show();
  765. }
  766. /// <summary>
  767. /// 工件编辑按钮
  768. /// </summary>
  769. /// <param name="sender"></param>
  770. /// <param name=constTypeE></param>
  771. private void button5_Click(object sender, EventArgs e)
  772. {
  773. if (this.dataGridView2.Rows.Count == 0)
  774. {
  775. MessageBox.Show(PdnResources.GetString("Menu.Noartifacts.text")+"!");
  776. }
  777. else
  778. {
  779. if (this.dataGridView2.SelectedRows.Count > 0)
  780. {
  781. dataGridView2_SelectionChanged(null, null);
  782. this.groupBox3.Enabled = true;
  783. dataGridView1.Rows.Clear();
  784. this.operation = 1;
  785. this.groupBox3.Show();
  786. this.textBox1.Text = this.dataGridView2.SelectedRows[0].Cells[0].Value.ToString();
  787. int rowNum = 0;
  788. if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeA))
  789. {
  790. this.radioButton1.Checked = true;
  791. rowNum = 3;
  792. }
  793. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeB))
  794. {
  795. this.radioButton2.Checked = true;
  796. rowNum = 6;
  797. }
  798. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeC))
  799. {
  800. this.radioButton3.Checked = true;
  801. rowNum = 9;
  802. }
  803. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeD))
  804. {
  805. this.radioButton4.Checked = true;
  806. rowNum = 12;
  807. }
  808. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeE))
  809. {
  810. this.radioButton5.Checked = true;
  811. rowNum = 6;
  812. }
  813. for (int i = 2; i < rowNum + 2; i += 3)
  814. {
  815. DataGridViewRow row = new DataGridViewRow();
  816. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  817. textboxcell.Value = this.dataGridView2.SelectedRows[0].Cells[i].Value;
  818. row.Cells.Add(textboxcell);
  819. textboxcell = new DataGridViewTextBoxCell();
  820. textboxcell.Value = this.dataGridView2.SelectedRows[0].Cells[i + 1].Value;
  821. row.Cells.Add(textboxcell);
  822. textboxcell = new DataGridViewTextBoxCell();
  823. textboxcell.Value = this.dataGridView2.SelectedRows[0].Cells[i + 2].Value;
  824. row.Cells.Add(textboxcell);
  825. dataGridView1.Rows.Add(row);
  826. }
  827. this.DataTable = new DataTable();
  828. foreach (DataGridViewColumn c in this.dataGridView1.Columns)
  829. {
  830. this.DataTable.Columns.Add(c.HeaderText);
  831. }
  832. for (int r = 0; r < this.dataGridView1.Rows.Count; r++)
  833. {
  834. DataRow dataRow = this.DataTable.NewRow();
  835. for (int c = 0; c < this.dataGridView1.Rows[r].Cells.Count; c++)
  836. {
  837. dataRow[this.dataGridView1.Columns[c].HeaderText] = this.dataGridView1.Rows[r].Cells[c].Value;
  838. }
  839. this.DataTable.Rows.Add(dataRow);
  840. }
  841. }
  842. else
  843. {
  844. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaworkpiece.text")+"!");
  845. }
  846. }
  847. }
  848. /// <summary>
  849. /// 关闭按钮
  850. /// </summary>
  851. /// <param name="sender"></param>
  852. /// <param name=constTypeE></param>
  853. private void button1_Click(object sender, EventArgs e)
  854. {
  855. this.Close();
  856. }
  857. /// <summary>
  858. /// 保存按钮
  859. /// </summary>
  860. /// <param name="sender"></param>
  861. /// <param name=constTypeE></param>
  862. private void button2_Click(object sender, EventArgs e)
  863. {
  864. if (this.operation == 0)
  865. {
  866. if (string.IsNullOrEmpty(this.textBox1.Text))
  867. MessageBox.Show(PdnResources.GetString("Menu.Pleaseenterthworkpiece.text")+"!");
  868. else
  869. {
  870. DataGridViewRow row = new DataGridViewRow();
  871. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  872. textboxcell.Value = this.textBox1.Text;
  873. row.Cells.Add(textboxcell);
  874. if (this.radioButton1.Checked)
  875. {
  876. textboxcell = new DataGridViewTextBoxCell();
  877. textboxcell.Value = constTypeA;
  878. row.Cells.Add(textboxcell);
  879. }
  880. else if (this.radioButton2.Checked)
  881. {
  882. textboxcell = new DataGridViewTextBoxCell();
  883. textboxcell.Value = constTypeB;
  884. row.Cells.Add(textboxcell);
  885. }
  886. else if (this.radioButton3.Checked)
  887. {
  888. textboxcell = new DataGridViewTextBoxCell();
  889. textboxcell.Value = constTypeC;
  890. row.Cells.Add(textboxcell);
  891. }
  892. else if (this.radioButton4.Checked)
  893. {
  894. textboxcell = new DataGridViewTextBoxCell();
  895. textboxcell.Value = constTypeD;
  896. row.Cells.Add(textboxcell);
  897. }
  898. else if (this.radioButton5.Checked)
  899. {
  900. textboxcell = new DataGridViewTextBoxCell();
  901. textboxcell.Value = constTypeE;
  902. row.Cells.Add(textboxcell);
  903. }
  904. for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
  905. {
  906. for (int j = 0; j < this.dataGridView1.Rows[i].Cells.Count; j++)
  907. {
  908. textboxcell = new DataGridViewTextBoxCell();
  909. textboxcell.Value = this.dataGridView1.Rows[i].Cells[j].Value;
  910. row.Cells.Add(textboxcell);
  911. }
  912. }
  913. for (int i = 0; i < dataGridView2.Rows.Count; i++)
  914. {
  915. if (this.textBox1.Text.Equals(dataGridView2.Rows[i].Cells[0].Value))
  916. {
  917. MessageBox.Show(PdnResources.GetString("Menu.Namealreadyexists.text")+"!");
  918. return;
  919. }
  920. }
  921. for (int i = 0; i < dataGridView1.Rows.Count; i++)
  922. {
  923. for (int j = 0; j < dataGridView1.Rows[i].Cells.Count; j++)
  924. {
  925. if (dataGridView1.Rows[i].Cells[j].Value == null)
  926. {
  927. if (j == 1)
  928. {
  929. MessageBox.Show(PdnResources.GetString("Menu.Targetvaluecannotbeempty.text")+"!");
  930. dataGridView1.Rows[i].Cells[j].Style.BackColor = Color.Red;
  931. return;
  932. }
  933. else if (j == 2)
  934. {
  935. MessageBox.Show(PdnResources.GetString("Menu.Errorcannotbeempty.text")+"!");
  936. dataGridView1.Rows[i].Cells[j].Style.BackColor = Color.Red;
  937. return;
  938. }
  939. }
  940. }
  941. }
  942. dataGridView2.Rows.Add(row);
  943. dataGridView2.ClearSelection();
  944. SaveToConfigurationFile();
  945. RecombinationRateDialog recombinationRateDialog = (RecombinationRateDialog)this.Owner;
  946. recombinationRateDialog.selectItemValue = this.textBox1.Text;
  947. recombinationRateDialog.RefreshCombobox();
  948. dataGridView2.Rows[dataGridView2.Rows.Count - 1].Selected = true;
  949. MessageBox.Show(PdnResources.GetString("Menu.Successfullysaved.text")+"!", PdnResources.GetString("Menu.Addto.text"));
  950. }
  951. }
  952. else if (this.operation == 1)
  953. {
  954. for (int i = 0; i < dataGridView2.Rows.Count; i++)
  955. {
  956. if (this.dataGridView2.SelectedRows[0].Index != i)
  957. {
  958. if (this.textBox1.Text.Equals(dataGridView2.Rows[i].Cells[0].Value))
  959. {
  960. MessageBox.Show(PdnResources.GetString("Menu.Namealreadyexists.text")+"!");
  961. return;
  962. }
  963. }
  964. }
  965. for (int i = 0; i < dataGridView1.Rows.Count; i++)
  966. {
  967. for (int j = 0; j < dataGridView1.Rows[i].Cells.Count; j++)
  968. {
  969. if (dataGridView1.Rows[i].Cells[j].Value == null)
  970. {
  971. if (j == 1)
  972. {
  973. MessageBox.Show(PdnResources.GetString("Menu.Targetvaluecannotbeempty.text")+"!");
  974. dataGridView1.Rows[i].Cells[j].Style.BackColor = Color.Red;
  975. return;
  976. }
  977. else if (j == 2)
  978. {
  979. MessageBox.Show(PdnResources.GetString("Menu.Errorcannotbeempty.text")+"!");
  980. dataGridView1.Rows[i].Cells[j].Style.BackColor = Color.Red;
  981. return;
  982. }
  983. }
  984. }
  985. }
  986. this.dataGridView2.SelectedRows[0].Cells[0].Value = this.textBox1.Text;
  987. if (this.radioButton1.Checked)
  988. {
  989. this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeA;
  990. }
  991. else if (this.radioButton2.Checked)
  992. {
  993. this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeB;
  994. }
  995. else if (this.radioButton3.Checked)
  996. {
  997. this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeC;
  998. }
  999. else if (this.radioButton4.Checked)
  1000. {
  1001. this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeD;
  1002. }
  1003. else if (this.radioButton5.Checked)
  1004. {
  1005. this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeE;
  1006. }
  1007. int col = 2;
  1008. for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
  1009. {
  1010. for (int j = 0; j < this.dataGridView1.Rows[i].Cells.Count; j++)
  1011. {
  1012. this.dataGridView2.SelectedRows[0].Cells[col].Value = this.dataGridView1.Rows[i].Cells[j].Value;
  1013. col++;
  1014. }
  1015. }
  1016. int se = this.dataGridView2.SelectedRows[0].Index;
  1017. dataGridView2.ClearSelection();
  1018. SaveToConfigurationFile();
  1019. RecombinationRateDialog recombinationRateDialog = (RecombinationRateDialog)this.Owner;
  1020. recombinationRateDialog.selectItemValue = this.textBox1.Text;
  1021. recombinationRateDialog.RefreshCombobox();
  1022. this.dataGridView2.Rows[se].Selected = true;
  1023. MessageBox.Show(PdnResources.GetString("Menu.Successfullysaved.text")+"!", PdnResources.GetString("Menu.Edit.Text"));
  1024. }
  1025. this.operation = -1;
  1026. }
  1027. #region 工件类型选择
  1028. private void radioButton1_CheckedChanged(object sender, EventArgs e)
  1029. {
  1030. if(this.radioButton1.Checked && this.groupBox3.Enabled)
  1031. {
  1032. if(this.operation == 0)
  1033. {
  1034. dataGridView1.Rows.Clear();
  1035. DataGridViewRow row = new DataGridViewRow();
  1036. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1037. textboxcell.Value = constTypeA;
  1038. row.Cells.Add(textboxcell);
  1039. dataGridView1.Rows.Add(row);
  1040. }
  1041. else if(this.operation == 1)
  1042. {
  1043. if(this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeA))
  1044. {
  1045. GetDataTable();
  1046. }
  1047. else
  1048. {
  1049. dataGridView1.Rows.Clear();
  1050. DataGridViewRow row = new DataGridViewRow();
  1051. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1052. textboxcell.Value = constTypeA;
  1053. row.Cells.Add(textboxcell);
  1054. dataGridView1.Rows.Add(row);
  1055. }
  1056. }
  1057. }
  1058. }
  1059. private void radioButton2_CheckedChanged(object sender, EventArgs e)
  1060. {
  1061. if (this.radioButton2.Checked && this.groupBox3.Enabled)
  1062. {
  1063. if (this.operation == 0)
  1064. {
  1065. dataGridView1.Rows.Clear();
  1066. DataGridViewRow row = new DataGridViewRow();
  1067. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1068. textboxcell.Value = constTypeA;
  1069. row.Cells.Add(textboxcell);
  1070. dataGridView1.Rows.Add(row);
  1071. row = new DataGridViewRow();
  1072. textboxcell = new DataGridViewTextBoxCell();
  1073. textboxcell.Value = constTypeB;
  1074. row.Cells.Add(textboxcell);
  1075. dataGridView1.Rows.Add(row);
  1076. }
  1077. else if (this.operation == 1)
  1078. {
  1079. if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeB))
  1080. {
  1081. GetDataTable();
  1082. }
  1083. else
  1084. {
  1085. dataGridView1.Rows.Clear();
  1086. DataGridViewRow row = new DataGridViewRow();
  1087. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1088. textboxcell.Value = constTypeA;
  1089. row.Cells.Add(textboxcell);
  1090. dataGridView1.Rows.Add(row);
  1091. row = new DataGridViewRow();
  1092. textboxcell = new DataGridViewTextBoxCell();
  1093. textboxcell.Value = constTypeB;
  1094. row.Cells.Add(textboxcell);
  1095. dataGridView1.Rows.Add(row);
  1096. }
  1097. }
  1098. }
  1099. }
  1100. private void radioButton3_CheckedChanged(object sender, EventArgs e)
  1101. {
  1102. if (this.radioButton3.Checked && this.groupBox3.Enabled)
  1103. {
  1104. if (this.operation == 0)
  1105. {
  1106. dataGridView1.Rows.Clear();
  1107. DataGridViewRow row = new DataGridViewRow();
  1108. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1109. textboxcell.Value = constTypeA;
  1110. row.Cells.Add(textboxcell);
  1111. dataGridView1.Rows.Add(row);
  1112. row = new DataGridViewRow();
  1113. textboxcell = new DataGridViewTextBoxCell();
  1114. textboxcell.Value = constTypeB;
  1115. row.Cells.Add(textboxcell);
  1116. dataGridView1.Rows.Add(row);
  1117. row = new DataGridViewRow();
  1118. textboxcell = new DataGridViewTextBoxCell();
  1119. textboxcell.Value = constTypeC;
  1120. row.Cells.Add(textboxcell);
  1121. dataGridView1.Rows.Add(row);
  1122. }
  1123. else if (this.operation == 1)
  1124. {
  1125. if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeC))
  1126. {
  1127. GetDataTable();
  1128. }
  1129. else
  1130. {
  1131. dataGridView1.Rows.Clear();
  1132. DataGridViewRow row = new DataGridViewRow();
  1133. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1134. textboxcell.Value = constTypeA;
  1135. row.Cells.Add(textboxcell);
  1136. dataGridView1.Rows.Add(row);
  1137. row = new DataGridViewRow();
  1138. textboxcell = new DataGridViewTextBoxCell();
  1139. textboxcell.Value = constTypeB;
  1140. row.Cells.Add(textboxcell);
  1141. dataGridView1.Rows.Add(row);
  1142. row = new DataGridViewRow();
  1143. textboxcell = new DataGridViewTextBoxCell();
  1144. textboxcell.Value = constTypeC;
  1145. row.Cells.Add(textboxcell);
  1146. dataGridView1.Rows.Add(row);
  1147. }
  1148. }
  1149. }
  1150. }
  1151. private void radioButton4_CheckedChanged(object sender, EventArgs e)
  1152. {
  1153. if (this.radioButton4.Checked && this.groupBox3.Enabled)
  1154. {
  1155. if (this.operation == 0)
  1156. {
  1157. dataGridView1.Rows.Clear();
  1158. DataGridViewRow row = new DataGridViewRow();
  1159. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1160. textboxcell.Value = constTypeA;
  1161. row.Cells.Add(textboxcell);
  1162. dataGridView1.Rows.Add(row);
  1163. row = new DataGridViewRow();
  1164. textboxcell = new DataGridViewTextBoxCell();
  1165. textboxcell.Value = constTypeB;
  1166. row.Cells.Add(textboxcell);
  1167. dataGridView1.Rows.Add(row);
  1168. row = new DataGridViewRow();
  1169. textboxcell = new DataGridViewTextBoxCell();
  1170. textboxcell.Value = constTypeC;
  1171. row.Cells.Add(textboxcell);
  1172. dataGridView1.Rows.Add(row);
  1173. row = new DataGridViewRow();
  1174. textboxcell = new DataGridViewTextBoxCell();
  1175. textboxcell.Value = constTypeD;
  1176. row.Cells.Add(textboxcell);
  1177. dataGridView1.Rows.Add(row);
  1178. }
  1179. else if (this.operation == 1)
  1180. {
  1181. if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeD))
  1182. {
  1183. GetDataTable();
  1184. }
  1185. else
  1186. {
  1187. dataGridView1.Rows.Clear();
  1188. DataGridViewRow row = new DataGridViewRow();
  1189. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1190. textboxcell.Value = constTypeA;
  1191. row.Cells.Add(textboxcell);
  1192. dataGridView1.Rows.Add(row);
  1193. row = new DataGridViewRow();
  1194. textboxcell = new DataGridViewTextBoxCell();
  1195. textboxcell.Value = constTypeB;
  1196. row.Cells.Add(textboxcell);
  1197. dataGridView1.Rows.Add(row);
  1198. row = new DataGridViewRow();
  1199. textboxcell = new DataGridViewTextBoxCell();
  1200. textboxcell.Value = constTypeC;
  1201. row.Cells.Add(textboxcell);
  1202. dataGridView1.Rows.Add(row);
  1203. row = new DataGridViewRow();
  1204. textboxcell = new DataGridViewTextBoxCell();
  1205. textboxcell.Value = constTypeD;
  1206. row.Cells.Add(textboxcell);
  1207. dataGridView1.Rows.Add(row);
  1208. }
  1209. }
  1210. }
  1211. }
  1212. private void radioButton5_CheckedChanged(object sender, EventArgs e)
  1213. {
  1214. if (this.radioButton5.Checked && this.groupBox3.Enabled)
  1215. {
  1216. if (this.operation == 0)
  1217. {
  1218. dataGridView1.Rows.Clear();
  1219. DataGridViewRow row = new DataGridViewRow();
  1220. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1221. textboxcell.Value = constTypeA;
  1222. row.Cells.Add(textboxcell);
  1223. dataGridView1.Rows.Add(row);
  1224. row = new DataGridViewRow();
  1225. textboxcell = new DataGridViewTextBoxCell();
  1226. textboxcell.Value = constTypeB;
  1227. row.Cells.Add(textboxcell);
  1228. dataGridView1.Rows.Add(row);
  1229. }
  1230. else if (this.operation == 1)
  1231. {
  1232. if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeE))
  1233. {
  1234. GetDataTable();
  1235. }
  1236. else
  1237. {
  1238. dataGridView1.Rows.Clear();
  1239. DataGridViewRow row = new DataGridViewRow();
  1240. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1241. textboxcell.Value = constTypeA;
  1242. row.Cells.Add(textboxcell);
  1243. dataGridView1.Rows.Add(row);
  1244. row = new DataGridViewRow();
  1245. textboxcell = new DataGridViewTextBoxCell();
  1246. textboxcell.Value = constTypeB;
  1247. row.Cells.Add(textboxcell);
  1248. dataGridView1.Rows.Add(row);
  1249. }
  1250. }
  1251. }
  1252. }
  1253. /// <summary>
  1254. /// 编辑的工件内容
  1255. /// </summary>
  1256. private void GetDataTable()
  1257. {
  1258. this.dataGridView1.Rows.Clear();
  1259. if (this.DataTable == null)
  1260. {
  1261. return;
  1262. }
  1263. for (int r = 0; r < this.DataTable.Rows.Count; r++)
  1264. {
  1265. DataGridViewRow dgvr = new DataGridViewRow();
  1266. foreach (DataGridViewColumn Column in this.dataGridView1.Columns)
  1267. {
  1268. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  1269. }
  1270. for (int c = 0; c < DataTable.Columns.Count; c++)
  1271. {
  1272. dgvr.Cells[c].Value = this.DataTable.Rows[r][c].ToString();
  1273. }
  1274. this.dataGridView1.Rows.Add(dgvr);
  1275. }
  1276. }
  1277. #endregion
  1278. /// <summary>
  1279. /// 选中工件
  1280. /// </summary>
  1281. /// <param name="sender"></param>
  1282. /// <param name=e></param>
  1283. private void dataGridView2_SelectionChanged(object sender, EventArgs e)
  1284. {
  1285. if (this.dataGridView2.SelectedRows.Count > 0)
  1286. {
  1287. this.groupBox3.Enabled = false;
  1288. dataGridView1.Rows.Clear();
  1289. this.groupBox3.Show();
  1290. this.textBox1.Text = this.dataGridView2.SelectedRows[0].Cells[0].Value.ToString();
  1291. int rowNum = 0;
  1292. if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeA))
  1293. {
  1294. this.radioButton1.Checked = true;
  1295. rowNum = 3;
  1296. }
  1297. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeB))
  1298. {
  1299. this.radioButton2.Checked = true;
  1300. rowNum = 6;
  1301. }
  1302. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeC))
  1303. {
  1304. this.radioButton3.Checked = true;
  1305. rowNum = 9;
  1306. }
  1307. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeD))
  1308. {
  1309. this.radioButton4.Checked = true;
  1310. rowNum = 12;
  1311. }
  1312. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeE))
  1313. {
  1314. this.radioButton5.Checked = true;
  1315. rowNum = 6;
  1316. }
  1317. for (int i = 2; i < rowNum + 2; i += 3)
  1318. {
  1319. DataGridViewRow row = new DataGridViewRow();
  1320. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1321. textboxcell.Value = this.dataGridView2.SelectedRows[0].Cells[i].Value;
  1322. row.Cells.Add(textboxcell);
  1323. textboxcell = new DataGridViewTextBoxCell();
  1324. textboxcell.Value = this.dataGridView2.SelectedRows[0].Cells[i + 1].Value;
  1325. row.Cells.Add(textboxcell);
  1326. textboxcell = new DataGridViewTextBoxCell();
  1327. textboxcell.Value = this.dataGridView2.SelectedRows[0].Cells[i + 2].Value;
  1328. row.Cells.Add(textboxcell);
  1329. dataGridView1.Rows.Add(row);
  1330. }
  1331. }
  1332. }
  1333. /// <summary>
  1334. /// 工件删除
  1335. /// </summary>
  1336. /// <param name="sender"></param>
  1337. /// <param name=constTypeE></param>
  1338. private void button6_Click(object sender, EventArgs e)
  1339. {
  1340. this.operation = -1;
  1341. if(this.dataGridView2.Rows.Count == 0)
  1342. {
  1343. MessageBox.Show(PdnResources.GetString("Menu.Noartifacts.text")+"!");
  1344. }
  1345. else
  1346. {
  1347. if (this.dataGridView2.SelectedRows.Count > 0)
  1348. {
  1349. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousureartifact?.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1350. if (dr == DialogResult.OK)
  1351. {
  1352. this.dataGridView2.Rows.Remove(this.dataGridView2.SelectedRows[0]);
  1353. SaveToConfigurationFile();
  1354. RecombinationRateDialog recombinationRateDialog = (RecombinationRateDialog)this.Owner;
  1355. if(this.dataGridView2.Rows.Count > 0 && this.dataGridView2.SelectedRows.Count > 0)
  1356. recombinationRateDialog.selectItemValue = this.dataGridView2.SelectedRows[0].Cells[0].Value.ToString();
  1357. recombinationRateDialog.RefreshCombobox();
  1358. InitGroupBox3();
  1359. if(this.dataGridView2.Rows.Count > 0)
  1360. {
  1361. if (this.dataGridView2.SelectedRows.Count > 0)
  1362. {
  1363. this.groupBox3.Enabled = false;
  1364. dataGridView1.Rows.Clear();
  1365. this.groupBox3.Show();
  1366. this.textBox1.Text = this.dataGridView2.SelectedRows[0].Cells[0].Value.ToString();
  1367. int rowNum = 0;
  1368. if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeA))
  1369. {
  1370. this.radioButton1.Checked = true;
  1371. rowNum = 3;
  1372. }
  1373. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeB))
  1374. {
  1375. this.radioButton2.Checked = true;
  1376. rowNum = 6;
  1377. }
  1378. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeC))
  1379. {
  1380. this.radioButton3.Checked = true;
  1381. rowNum = 9;
  1382. }
  1383. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeD))
  1384. {
  1385. this.radioButton4.Checked = true;
  1386. rowNum = 12;
  1387. }
  1388. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeE))
  1389. {
  1390. this.radioButton5.Checked = true;
  1391. rowNum = 6;
  1392. }
  1393. for (int i = 2; i < rowNum + 2; i += 3)
  1394. {
  1395. DataGridViewRow row = new DataGridViewRow();
  1396. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1397. textboxcell.Value = this.dataGridView2.SelectedRows[0].Cells[i].Value;
  1398. row.Cells.Add(textboxcell);
  1399. textboxcell = new DataGridViewTextBoxCell();
  1400. textboxcell.Value = this.dataGridView2.SelectedRows[0].Cells[i + 1].Value;
  1401. row.Cells.Add(textboxcell);
  1402. textboxcell = new DataGridViewTextBoxCell();
  1403. textboxcell.Value = this.dataGridView2.SelectedRows[0].Cells[i + 2].Value;
  1404. row.Cells.Add(textboxcell);
  1405. dataGridView1.Rows.Add(row);
  1406. }
  1407. }
  1408. else
  1409. {
  1410. this.groupBox3.Enabled = false;
  1411. dataGridView1.Rows.Clear();
  1412. this.groupBox3.Show();
  1413. this.textBox1.Text = this.dataGridView2.Rows[0].Cells[0].Value.ToString();
  1414. int rowNum = 0;
  1415. if (this.dataGridView2.Rows[0].Cells[1].Value.Equals(constTypeA))
  1416. {
  1417. this.radioButton1.Checked = true;
  1418. rowNum = 3;
  1419. }
  1420. else if (this.dataGridView2.Rows[0].Cells[1].Value.Equals(constTypeB))
  1421. {
  1422. this.radioButton2.Checked = true;
  1423. rowNum = 6;
  1424. }
  1425. else if (this.dataGridView2.Rows[0].Cells[1].Value.Equals(constTypeC))
  1426. {
  1427. this.radioButton3.Checked = true;
  1428. rowNum = 9;
  1429. }
  1430. else if (this.dataGridView2.Rows[0].Cells[1].Value.Equals(constTypeD))
  1431. {
  1432. this.radioButton4.Checked = true;
  1433. rowNum = 12;
  1434. }
  1435. else if (this.dataGridView2.Rows[0].Cells[1].Value.Equals(constTypeE))
  1436. {
  1437. this.radioButton5.Checked = true;
  1438. rowNum = 6;
  1439. }
  1440. for (int i = 2; i < rowNum + 2; i += 3)
  1441. {
  1442. DataGridViewRow row = new DataGridViewRow();
  1443. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1444. textboxcell.Value = this.dataGridView2.Rows[0].Cells[i].Value;
  1445. row.Cells.Add(textboxcell);
  1446. textboxcell = new DataGridViewTextBoxCell();
  1447. textboxcell.Value = this.dataGridView2.Rows[0].Cells[i + 1].Value;
  1448. row.Cells.Add(textboxcell);
  1449. textboxcell = new DataGridViewTextBoxCell();
  1450. textboxcell.Value = this.dataGridView2.Rows[0].Cells[i + 2].Value;
  1451. row.Cells.Add(textboxcell);
  1452. dataGridView1.Rows.Add(row);
  1453. }
  1454. }
  1455. }
  1456. else
  1457. {
  1458. this.dataGridView1.Rows.Clear();
  1459. }
  1460. }
  1461. }
  1462. else
  1463. {
  1464. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselecttdelete.text")+"!");
  1465. }
  1466. }
  1467. }
  1468. /// <summary>
  1469. /// 使用按钮
  1470. /// </summary>
  1471. /// <param name="sender"></param>
  1472. /// <param name=constTypeE></param>
  1473. private void button3_Click(object sender, EventArgs e)
  1474. {
  1475. bool success = false;
  1476. if (this.operation == 0)
  1477. {
  1478. if (string.IsNullOrEmpty(this.textBox1.Text))
  1479. MessageBox.Show(PdnResources.GetString("Menu.Pleaseenterthworkpiece.text")+"!");
  1480. else
  1481. {
  1482. DataGridViewRow row = new DataGridViewRow();
  1483. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1484. textboxcell.Value = this.textBox1.Text;
  1485. row.Cells.Add(textboxcell);
  1486. if (this.radioButton1.Checked)
  1487. {
  1488. textboxcell = new DataGridViewTextBoxCell();
  1489. textboxcell.Value = constTypeA;
  1490. row.Cells.Add(textboxcell);
  1491. }
  1492. else if (this.radioButton2.Checked)
  1493. {
  1494. textboxcell = new DataGridViewTextBoxCell();
  1495. textboxcell.Value = constTypeB;
  1496. row.Cells.Add(textboxcell);
  1497. }
  1498. else if (this.radioButton3.Checked)
  1499. {
  1500. textboxcell = new DataGridViewTextBoxCell();
  1501. textboxcell.Value = constTypeC;
  1502. row.Cells.Add(textboxcell);
  1503. }
  1504. else if (this.radioButton4.Checked)
  1505. {
  1506. textboxcell = new DataGridViewTextBoxCell();
  1507. textboxcell.Value = constTypeD;
  1508. row.Cells.Add(textboxcell);
  1509. }
  1510. else if (this.radioButton5.Checked)
  1511. {
  1512. textboxcell = new DataGridViewTextBoxCell();
  1513. textboxcell.Value = constTypeE;
  1514. row.Cells.Add(textboxcell);
  1515. }
  1516. for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
  1517. {
  1518. for (int j = 0; j < this.dataGridView1.Rows[i].Cells.Count; j++)
  1519. {
  1520. textboxcell = new DataGridViewTextBoxCell();
  1521. textboxcell.Value = this.dataGridView1.Rows[i].Cells[j].Value;
  1522. row.Cells.Add(textboxcell);
  1523. }
  1524. }
  1525. bool canAdd = true;
  1526. for (int i = 0; i < dataGridView2.Rows.Count; i++)
  1527. {
  1528. if (this.textBox1.Text.Equals(dataGridView2.Rows[i].Cells[0].Value))
  1529. {
  1530. MessageBox.Show(PdnResources.GetString("Menu.Namealreadyexists.text")+"!");
  1531. canAdd = false;
  1532. }
  1533. }
  1534. for (int i = 0; i < dataGridView1.Rows.Count; i++)
  1535. {
  1536. for (int j = 0; j < dataGridView1.Rows[i].Cells.Count; j++)
  1537. {
  1538. if (dataGridView1.Rows[i].Cells[j].Value == null)
  1539. {
  1540. if (j == 1)
  1541. {
  1542. canAdd = false;
  1543. MessageBox.Show(PdnResources.GetString("Menu.Targetvaluecannotbeempty.text")+"!");
  1544. dataGridView1.Rows[i].Cells[j].Style.BackColor = Color.Red;
  1545. break;
  1546. }
  1547. else if (j == 2)
  1548. {
  1549. canAdd = false;
  1550. MessageBox.Show(PdnResources.GetString("Menu.Errorcannotbeempty.text")+"!");
  1551. dataGridView1.Rows[i].Cells[j].Style.BackColor = Color.Red;
  1552. break;
  1553. }
  1554. }
  1555. }
  1556. }
  1557. if (canAdd)
  1558. {
  1559. success = true;
  1560. dataGridView2.Rows.Add(row);
  1561. dataGridView2.Rows[dataGridView2.Rows.Count - 1].Selected = true;
  1562. SaveToConfigurationFile();
  1563. }
  1564. }
  1565. }
  1566. else if (this.operation == 1)
  1567. {
  1568. bool canAdd = true;
  1569. for (int i = 0; i < dataGridView2.Rows.Count; i++)
  1570. {
  1571. if (this.dataGridView2.SelectedRows[0].Index != i)
  1572. {
  1573. if (this.textBox1.Text.Equals(dataGridView2.Rows[i].Cells[0].Value))
  1574. {
  1575. MessageBox.Show(PdnResources.GetString("Menu.Namealreadyexists.text")+"!");
  1576. canAdd = false;
  1577. }
  1578. }
  1579. }
  1580. for (int i = 0; i < dataGridView1.Rows.Count; i++)
  1581. {
  1582. for (int j = 0; j < dataGridView1.Rows[i].Cells.Count; j++)
  1583. {
  1584. if (dataGridView1.Rows[i].Cells[j].Value == null)
  1585. {
  1586. if (j == 1)
  1587. {
  1588. canAdd = false;
  1589. MessageBox.Show(PdnResources.GetString("Menu.Targetvaluecannotbeempty.text")+"!");
  1590. dataGridView1.Rows[i].Cells[j].Style.BackColor = Color.Red;
  1591. break;
  1592. }
  1593. else if (j == 2)
  1594. {
  1595. canAdd = false;
  1596. MessageBox.Show(PdnResources.GetString("Menu.Errorcannotbeempty.text")+"!");
  1597. dataGridView1.Rows[i].Cells[j].Style.BackColor = Color.Red;
  1598. break;
  1599. }
  1600. }
  1601. }
  1602. }
  1603. if (canAdd)
  1604. {
  1605. success = true;
  1606. this.dataGridView2.SelectedRows[0].Cells[0].Value = this.textBox1.Text;
  1607. if (this.radioButton1.Checked)
  1608. {
  1609. this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeA;
  1610. }
  1611. else if (this.radioButton2.Checked)
  1612. {
  1613. this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeB;
  1614. }
  1615. else if (this.radioButton3.Checked)
  1616. {
  1617. this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeC;
  1618. }
  1619. else if (this.radioButton4.Checked)
  1620. {
  1621. this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeD;
  1622. }
  1623. else if (this.radioButton5.Checked)
  1624. {
  1625. this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeE;
  1626. }
  1627. int col = 2;
  1628. for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
  1629. {
  1630. for (int j = 0; j < this.dataGridView1.Rows[i].Cells.Count; j++)
  1631. {
  1632. this.dataGridView2.SelectedRows[0].Cells[col].Value = this.dataGridView1.Rows[i].Cells[j].Value;
  1633. col++;
  1634. }
  1635. }
  1636. SaveToConfigurationFile();
  1637. }
  1638. }
  1639. else
  1640. {
  1641. if (this.dataGridView2.SelectedRows.Count < 1)
  1642. MessageBox.Show(PdnResources.GetString("Menu.heartifacttous.Text")+"!");
  1643. else
  1644. success = true;
  1645. }
  1646. if (success)
  1647. {
  1648. SaveToConfigurationFile();
  1649. RecombinationRateDialog recombinationRateDialog = (RecombinationRateDialog)this.Owner;
  1650. recombinationRateDialog.selectItemValue = this.dataGridView2.SelectedRows[0].Cells[0].Value.ToString();
  1651. recombinationRateDialog.RefreshCombobox();
  1652. this.Close();
  1653. }
  1654. }
  1655. /// <summary>
  1656. /// 编辑工件
  1657. /// </summary>
  1658. /// <param name="sender"></param>
  1659. /// <param name="e"></param>
  1660. private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  1661. {
  1662. if (this.operation == 1)
  1663. {
  1664. if (this.dataGridView2.Rows.Count > 0)
  1665. {
  1666. if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeA) && this.radioButton1.Checked)
  1667. {
  1668. SaveDataTable();
  1669. }
  1670. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeB) && this.radioButton2.Checked)
  1671. {
  1672. SaveDataTable();
  1673. }
  1674. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeC) && this.radioButton3.Checked)
  1675. {
  1676. SaveDataTable();
  1677. }
  1678. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeD) && this.radioButton4.Checked)
  1679. {
  1680. SaveDataTable();
  1681. }
  1682. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeE) && this.radioButton5.Checked)
  1683. {
  1684. SaveDataTable();
  1685. }
  1686. }
  1687. }
  1688. }
  1689. /// <summary>
  1690. /// 保持到table
  1691. /// </summary>
  1692. private void SaveDataTable()
  1693. {
  1694. this.DataTable = new DataTable();
  1695. foreach (DataGridViewColumn c in this.dataGridView1.Columns)
  1696. {
  1697. this.DataTable.Columns.Add(c.HeaderText);
  1698. }
  1699. for (int r = 0; r < this.dataGridView1.Rows.Count; r++)
  1700. {
  1701. DataRow dataRow = this.DataTable.NewRow();
  1702. for (int c = 0; c < this.dataGridView1.Rows[r].Cells.Count; c++)
  1703. {
  1704. dataRow[this.dataGridView1.Columns[c].HeaderText] = this.dataGridView1.Rows[r].Cells[c].Value;
  1705. }
  1706. this.DataTable.Rows.Add(dataRow);
  1707. }
  1708. }
  1709. }
  1710. }