WorkpieceMaintenance .cs 84 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729
  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. this.groupBox3.Enabled = true;
  782. dataGridView1.Rows.Clear();
  783. this.operation = 1;
  784. this.groupBox3.Show();
  785. this.textBox1.Text = this.dataGridView2.SelectedRows[0].Cells[0].Value.ToString();
  786. int rowNum = 0;
  787. if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeA))
  788. {
  789. this.radioButton1.Checked = true;
  790. rowNum = 3;
  791. }
  792. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeB))
  793. {
  794. this.radioButton2.Checked = true;
  795. rowNum = 6;
  796. }
  797. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeC))
  798. {
  799. this.radioButton3.Checked = true;
  800. rowNum = 9;
  801. }
  802. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeD))
  803. {
  804. this.radioButton4.Checked = true;
  805. rowNum = 12;
  806. }
  807. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeE))
  808. {
  809. this.radioButton5.Checked = true;
  810. rowNum = 6;
  811. }
  812. for (int i = 2; i < rowNum + 2; i += 3)
  813. {
  814. DataGridViewRow row = new DataGridViewRow();
  815. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  816. textboxcell.Value = this.dataGridView2.SelectedRows[0].Cells[i].Value;
  817. row.Cells.Add(textboxcell);
  818. textboxcell = new DataGridViewTextBoxCell();
  819. textboxcell.Value = this.dataGridView2.SelectedRows[0].Cells[i + 1].Value;
  820. row.Cells.Add(textboxcell);
  821. textboxcell = new DataGridViewTextBoxCell();
  822. textboxcell.Value = this.dataGridView2.SelectedRows[0].Cells[i + 2].Value;
  823. row.Cells.Add(textboxcell);
  824. dataGridView1.Rows.Add(row);
  825. }
  826. this.DataTable = new DataTable();
  827. foreach (DataGridViewColumn c in this.dataGridView1.Columns)
  828. {
  829. this.DataTable.Columns.Add(c.HeaderText);
  830. }
  831. for (int r = 0; r < this.dataGridView1.Rows.Count; r++)
  832. {
  833. DataRow dataRow = this.DataTable.NewRow();
  834. for (int c = 0; c < this.dataGridView1.Rows[r].Cells.Count; c++)
  835. {
  836. dataRow[this.dataGridView1.Columns[c].HeaderText] = this.dataGridView1.Rows[r].Cells[c].Value;
  837. }
  838. this.DataTable.Rows.Add(dataRow);
  839. }
  840. }
  841. else
  842. {
  843. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaworkpiece.text")+"!");
  844. }
  845. }
  846. }
  847. /// <summary>
  848. /// 关闭按钮
  849. /// </summary>
  850. /// <param name="sender"></param>
  851. /// <param name=constTypeE></param>
  852. private void button1_Click(object sender, EventArgs e)
  853. {
  854. this.Close();
  855. }
  856. /// <summary>
  857. /// 保存按钮
  858. /// </summary>
  859. /// <param name="sender"></param>
  860. /// <param name=constTypeE></param>
  861. private void button2_Click(object sender, EventArgs e)
  862. {
  863. if (this.operation == 0)
  864. {
  865. if (string.IsNullOrEmpty(this.textBox1.Text))
  866. MessageBox.Show(PdnResources.GetString("Menu.Pleaseenterthworkpiece.text")+"!");
  867. else
  868. {
  869. DataGridViewRow row = new DataGridViewRow();
  870. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  871. textboxcell.Value = this.textBox1.Text;
  872. row.Cells.Add(textboxcell);
  873. if (this.radioButton1.Checked)
  874. {
  875. textboxcell = new DataGridViewTextBoxCell();
  876. textboxcell.Value = constTypeA;
  877. row.Cells.Add(textboxcell);
  878. }
  879. else if (this.radioButton2.Checked)
  880. {
  881. textboxcell = new DataGridViewTextBoxCell();
  882. textboxcell.Value = constTypeB;
  883. row.Cells.Add(textboxcell);
  884. }
  885. else if (this.radioButton3.Checked)
  886. {
  887. textboxcell = new DataGridViewTextBoxCell();
  888. textboxcell.Value = constTypeC;
  889. row.Cells.Add(textboxcell);
  890. }
  891. else if (this.radioButton4.Checked)
  892. {
  893. textboxcell = new DataGridViewTextBoxCell();
  894. textboxcell.Value = constTypeD;
  895. row.Cells.Add(textboxcell);
  896. }
  897. else if (this.radioButton5.Checked)
  898. {
  899. textboxcell = new DataGridViewTextBoxCell();
  900. textboxcell.Value = constTypeE;
  901. row.Cells.Add(textboxcell);
  902. }
  903. for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
  904. {
  905. for (int j = 0; j < this.dataGridView1.Rows[i].Cells.Count; j++)
  906. {
  907. textboxcell = new DataGridViewTextBoxCell();
  908. textboxcell.Value = this.dataGridView1.Rows[i].Cells[j].Value;
  909. row.Cells.Add(textboxcell);
  910. }
  911. }
  912. for (int i = 0; i < dataGridView2.Rows.Count; i++)
  913. {
  914. if (this.textBox1.Text.Equals(dataGridView2.Rows[i].Cells[0].Value))
  915. {
  916. MessageBox.Show(PdnResources.GetString("Menu.Namealreadyexists.text")+"!");
  917. return;
  918. }
  919. }
  920. for (int i = 0; i < dataGridView1.Rows.Count; i++)
  921. {
  922. for (int j = 0; j < dataGridView1.Rows[i].Cells.Count; j++)
  923. {
  924. if (dataGridView1.Rows[i].Cells[j].Value == null)
  925. {
  926. if (j == 1)
  927. {
  928. MessageBox.Show(PdnResources.GetString("Menu.Targetvaluecannotbeempty.text")+"!");
  929. dataGridView1.Rows[i].Cells[j].Style.BackColor = Color.Red;
  930. return;
  931. }
  932. else if (j == 2)
  933. {
  934. MessageBox.Show(PdnResources.GetString("Menu.Errorcannotbeempty.text")+"!");
  935. dataGridView1.Rows[i].Cells[j].Style.BackColor = Color.Red;
  936. return;
  937. }
  938. }
  939. }
  940. }
  941. dataGridView2.Rows.Add(row);
  942. dataGridView2.ClearSelection();
  943. SaveToConfigurationFile();
  944. RecombinationRateDialog recombinationRateDialog = (RecombinationRateDialog)this.Owner;
  945. recombinationRateDialog.selectItemValue = this.textBox1.Text;
  946. recombinationRateDialog.RefreshCombobox();
  947. dataGridView2.Rows[dataGridView2.Rows.Count - 1].Selected = true;
  948. MessageBox.Show(PdnResources.GetString("Menu.Successfullysaved.text")+"!", PdnResources.GetString("Menu.Addto.text"));
  949. }
  950. }
  951. else if (this.operation == 1)
  952. {
  953. for (int i = 0; i < dataGridView2.Rows.Count; i++)
  954. {
  955. if (this.dataGridView2.SelectedRows[0].Index != i)
  956. {
  957. if (this.textBox1.Text.Equals(dataGridView2.Rows[i].Cells[0].Value))
  958. {
  959. MessageBox.Show(PdnResources.GetString("Menu.Namealreadyexists.text")+"!");
  960. return;
  961. }
  962. }
  963. }
  964. for (int i = 0; i < dataGridView1.Rows.Count; i++)
  965. {
  966. for (int j = 0; j < dataGridView1.Rows[i].Cells.Count; j++)
  967. {
  968. if (dataGridView1.Rows[i].Cells[j].Value == null)
  969. {
  970. if (j == 1)
  971. {
  972. MessageBox.Show(PdnResources.GetString("Menu.Targetvaluecannotbeempty.text")+"!");
  973. dataGridView1.Rows[i].Cells[j].Style.BackColor = Color.Red;
  974. return;
  975. }
  976. else if (j == 2)
  977. {
  978. MessageBox.Show(PdnResources.GetString("Menu.Errorcannotbeempty.text")+"!");
  979. dataGridView1.Rows[i].Cells[j].Style.BackColor = Color.Red;
  980. return;
  981. }
  982. }
  983. }
  984. }
  985. this.dataGridView2.SelectedRows[0].Cells[0].Value = this.textBox1.Text;
  986. if (this.radioButton1.Checked)
  987. {
  988. this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeA;
  989. }
  990. else if (this.radioButton2.Checked)
  991. {
  992. this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeB;
  993. }
  994. else if (this.radioButton3.Checked)
  995. {
  996. this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeC;
  997. }
  998. else if (this.radioButton4.Checked)
  999. {
  1000. this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeD;
  1001. }
  1002. else if (this.radioButton5.Checked)
  1003. {
  1004. this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeE;
  1005. }
  1006. int col = 2;
  1007. for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
  1008. {
  1009. for (int j = 0; j < this.dataGridView1.Rows[i].Cells.Count; j++)
  1010. {
  1011. this.dataGridView2.SelectedRows[0].Cells[col].Value = this.dataGridView1.Rows[i].Cells[j].Value;
  1012. col++;
  1013. }
  1014. }
  1015. int se = this.dataGridView2.SelectedRows[0].Index;
  1016. dataGridView2.ClearSelection();
  1017. SaveToConfigurationFile();
  1018. RecombinationRateDialog recombinationRateDialog = (RecombinationRateDialog)this.Owner;
  1019. recombinationRateDialog.selectItemValue = this.textBox1.Text;
  1020. recombinationRateDialog.RefreshCombobox();
  1021. this.dataGridView2.Rows[se].Selected = true;
  1022. MessageBox.Show(PdnResources.GetString("Menu.Successfullysaved.text")+"!", PdnResources.GetString("Menu.Edit.Text"));
  1023. }
  1024. this.operation = -1;
  1025. }
  1026. #region 工件类型选择
  1027. private void radioButton1_CheckedChanged(object sender, EventArgs e)
  1028. {
  1029. if(this.radioButton1.Checked && this.groupBox3.Enabled)
  1030. {
  1031. if(this.operation == 0)
  1032. {
  1033. dataGridView1.Rows.Clear();
  1034. DataGridViewRow row = new DataGridViewRow();
  1035. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1036. textboxcell.Value = constTypeA;
  1037. row.Cells.Add(textboxcell);
  1038. dataGridView1.Rows.Add(row);
  1039. }
  1040. else if(this.operation == 1)
  1041. {
  1042. if(this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeA))
  1043. {
  1044. GetDataTable();
  1045. }
  1046. else
  1047. {
  1048. dataGridView1.Rows.Clear();
  1049. DataGridViewRow row = new DataGridViewRow();
  1050. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1051. textboxcell.Value = constTypeA;
  1052. row.Cells.Add(textboxcell);
  1053. dataGridView1.Rows.Add(row);
  1054. }
  1055. }
  1056. }
  1057. }
  1058. private void radioButton2_CheckedChanged(object sender, EventArgs e)
  1059. {
  1060. if (this.radioButton2.Checked && this.groupBox3.Enabled)
  1061. {
  1062. if (this.operation == 0)
  1063. {
  1064. dataGridView1.Rows.Clear();
  1065. DataGridViewRow row = new DataGridViewRow();
  1066. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1067. textboxcell.Value = constTypeA;
  1068. row.Cells.Add(textboxcell);
  1069. dataGridView1.Rows.Add(row);
  1070. row = new DataGridViewRow();
  1071. textboxcell = new DataGridViewTextBoxCell();
  1072. textboxcell.Value = constTypeB;
  1073. row.Cells.Add(textboxcell);
  1074. dataGridView1.Rows.Add(row);
  1075. }
  1076. else if (this.operation == 1)
  1077. {
  1078. if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeB))
  1079. {
  1080. GetDataTable();
  1081. }
  1082. else
  1083. {
  1084. dataGridView1.Rows.Clear();
  1085. DataGridViewRow row = new DataGridViewRow();
  1086. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1087. textboxcell.Value = constTypeA;
  1088. row.Cells.Add(textboxcell);
  1089. dataGridView1.Rows.Add(row);
  1090. row = new DataGridViewRow();
  1091. textboxcell = new DataGridViewTextBoxCell();
  1092. textboxcell.Value = constTypeB;
  1093. row.Cells.Add(textboxcell);
  1094. dataGridView1.Rows.Add(row);
  1095. }
  1096. }
  1097. }
  1098. }
  1099. private void radioButton3_CheckedChanged(object sender, EventArgs e)
  1100. {
  1101. if (this.radioButton3.Checked && this.groupBox3.Enabled)
  1102. {
  1103. if (this.operation == 0)
  1104. {
  1105. dataGridView1.Rows.Clear();
  1106. DataGridViewRow row = new DataGridViewRow();
  1107. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1108. textboxcell.Value = constTypeA;
  1109. row.Cells.Add(textboxcell);
  1110. dataGridView1.Rows.Add(row);
  1111. row = new DataGridViewRow();
  1112. textboxcell = new DataGridViewTextBoxCell();
  1113. textboxcell.Value = constTypeB;
  1114. row.Cells.Add(textboxcell);
  1115. dataGridView1.Rows.Add(row);
  1116. row = new DataGridViewRow();
  1117. textboxcell = new DataGridViewTextBoxCell();
  1118. textboxcell.Value = constTypeC;
  1119. row.Cells.Add(textboxcell);
  1120. dataGridView1.Rows.Add(row);
  1121. }
  1122. else if (this.operation == 1)
  1123. {
  1124. if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeC))
  1125. {
  1126. GetDataTable();
  1127. }
  1128. else
  1129. {
  1130. dataGridView1.Rows.Clear();
  1131. DataGridViewRow row = new DataGridViewRow();
  1132. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1133. textboxcell.Value = constTypeA;
  1134. row.Cells.Add(textboxcell);
  1135. dataGridView1.Rows.Add(row);
  1136. row = new DataGridViewRow();
  1137. textboxcell = new DataGridViewTextBoxCell();
  1138. textboxcell.Value = constTypeB;
  1139. row.Cells.Add(textboxcell);
  1140. dataGridView1.Rows.Add(row);
  1141. row = new DataGridViewRow();
  1142. textboxcell = new DataGridViewTextBoxCell();
  1143. textboxcell.Value = constTypeC;
  1144. row.Cells.Add(textboxcell);
  1145. dataGridView1.Rows.Add(row);
  1146. }
  1147. }
  1148. }
  1149. }
  1150. private void radioButton4_CheckedChanged(object sender, EventArgs e)
  1151. {
  1152. if (this.radioButton4.Checked && this.groupBox3.Enabled)
  1153. {
  1154. if (this.operation == 0)
  1155. {
  1156. dataGridView1.Rows.Clear();
  1157. DataGridViewRow row = new DataGridViewRow();
  1158. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1159. textboxcell.Value = constTypeA;
  1160. row.Cells.Add(textboxcell);
  1161. dataGridView1.Rows.Add(row);
  1162. row = new DataGridViewRow();
  1163. textboxcell = new DataGridViewTextBoxCell();
  1164. textboxcell.Value = constTypeB;
  1165. row.Cells.Add(textboxcell);
  1166. dataGridView1.Rows.Add(row);
  1167. row = new DataGridViewRow();
  1168. textboxcell = new DataGridViewTextBoxCell();
  1169. textboxcell.Value = constTypeC;
  1170. row.Cells.Add(textboxcell);
  1171. dataGridView1.Rows.Add(row);
  1172. row = new DataGridViewRow();
  1173. textboxcell = new DataGridViewTextBoxCell();
  1174. textboxcell.Value = constTypeD;
  1175. row.Cells.Add(textboxcell);
  1176. dataGridView1.Rows.Add(row);
  1177. }
  1178. else if (this.operation == 1)
  1179. {
  1180. if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeD))
  1181. {
  1182. GetDataTable();
  1183. }
  1184. else
  1185. {
  1186. dataGridView1.Rows.Clear();
  1187. DataGridViewRow row = new DataGridViewRow();
  1188. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1189. textboxcell.Value = constTypeA;
  1190. row.Cells.Add(textboxcell);
  1191. dataGridView1.Rows.Add(row);
  1192. row = new DataGridViewRow();
  1193. textboxcell = new DataGridViewTextBoxCell();
  1194. textboxcell.Value = constTypeB;
  1195. row.Cells.Add(textboxcell);
  1196. dataGridView1.Rows.Add(row);
  1197. row = new DataGridViewRow();
  1198. textboxcell = new DataGridViewTextBoxCell();
  1199. textboxcell.Value = constTypeC;
  1200. row.Cells.Add(textboxcell);
  1201. dataGridView1.Rows.Add(row);
  1202. row = new DataGridViewRow();
  1203. textboxcell = new DataGridViewTextBoxCell();
  1204. textboxcell.Value = constTypeD;
  1205. row.Cells.Add(textboxcell);
  1206. dataGridView1.Rows.Add(row);
  1207. }
  1208. }
  1209. }
  1210. }
  1211. private void radioButton5_CheckedChanged(object sender, EventArgs e)
  1212. {
  1213. if (this.radioButton5.Checked && this.groupBox3.Enabled)
  1214. {
  1215. if (this.operation == 0)
  1216. {
  1217. dataGridView1.Rows.Clear();
  1218. DataGridViewRow row = new DataGridViewRow();
  1219. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1220. textboxcell.Value = constTypeA;
  1221. row.Cells.Add(textboxcell);
  1222. dataGridView1.Rows.Add(row);
  1223. row = new DataGridViewRow();
  1224. textboxcell = new DataGridViewTextBoxCell();
  1225. textboxcell.Value = constTypeB;
  1226. row.Cells.Add(textboxcell);
  1227. dataGridView1.Rows.Add(row);
  1228. }
  1229. else if (this.operation == 1)
  1230. {
  1231. if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeE))
  1232. {
  1233. GetDataTable();
  1234. }
  1235. else
  1236. {
  1237. dataGridView1.Rows.Clear();
  1238. DataGridViewRow row = new DataGridViewRow();
  1239. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1240. textboxcell.Value = constTypeA;
  1241. row.Cells.Add(textboxcell);
  1242. dataGridView1.Rows.Add(row);
  1243. row = new DataGridViewRow();
  1244. textboxcell = new DataGridViewTextBoxCell();
  1245. textboxcell.Value = constTypeB;
  1246. row.Cells.Add(textboxcell);
  1247. dataGridView1.Rows.Add(row);
  1248. }
  1249. }
  1250. }
  1251. }
  1252. /// <summary>
  1253. /// 编辑的工件内容
  1254. /// </summary>
  1255. private void GetDataTable()
  1256. {
  1257. this.dataGridView1.Rows.Clear();
  1258. for (int r = 0; r < this.DataTable.Rows.Count; r++)
  1259. {
  1260. DataGridViewRow dgvr = new DataGridViewRow();
  1261. foreach (DataGridViewColumn Column in this.dataGridView1.Columns)
  1262. {
  1263. dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
  1264. }
  1265. for (int c = 0; c < DataTable.Columns.Count; c++)
  1266. {
  1267. dgvr.Cells[c].Value = this.DataTable.Rows[r][c].ToString();
  1268. }
  1269. this.dataGridView1.Rows.Add(dgvr);
  1270. }
  1271. }
  1272. #endregion
  1273. /// <summary>
  1274. /// 选中工件
  1275. /// </summary>
  1276. /// <param name="sender"></param>
  1277. /// <param name=e></param>
  1278. private void dataGridView2_SelectionChanged(object sender, EventArgs e)
  1279. {
  1280. if (this.dataGridView2.SelectedRows.Count > 0)
  1281. {
  1282. this.groupBox3.Enabled = false;
  1283. dataGridView1.Rows.Clear();
  1284. this.groupBox3.Show();
  1285. this.textBox1.Text = this.dataGridView2.SelectedRows[0].Cells[0].Value.ToString();
  1286. int rowNum = 0;
  1287. if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeA))
  1288. {
  1289. this.radioButton1.Checked = true;
  1290. rowNum = 3;
  1291. }
  1292. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeB))
  1293. {
  1294. this.radioButton2.Checked = true;
  1295. rowNum = 6;
  1296. }
  1297. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeC))
  1298. {
  1299. this.radioButton3.Checked = true;
  1300. rowNum = 9;
  1301. }
  1302. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeD))
  1303. {
  1304. this.radioButton4.Checked = true;
  1305. rowNum = 12;
  1306. }
  1307. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeE))
  1308. {
  1309. this.radioButton5.Checked = true;
  1310. rowNum = 6;
  1311. }
  1312. for (int i = 2; i < rowNum + 2; i += 3)
  1313. {
  1314. DataGridViewRow row = new DataGridViewRow();
  1315. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1316. textboxcell.Value = this.dataGridView2.SelectedRows[0].Cells[i].Value;
  1317. row.Cells.Add(textboxcell);
  1318. textboxcell = new DataGridViewTextBoxCell();
  1319. textboxcell.Value = this.dataGridView2.SelectedRows[0].Cells[i + 1].Value;
  1320. row.Cells.Add(textboxcell);
  1321. textboxcell = new DataGridViewTextBoxCell();
  1322. textboxcell.Value = this.dataGridView2.SelectedRows[0].Cells[i + 2].Value;
  1323. row.Cells.Add(textboxcell);
  1324. dataGridView1.Rows.Add(row);
  1325. }
  1326. }
  1327. }
  1328. /// <summary>
  1329. /// 工件删除
  1330. /// </summary>
  1331. /// <param name="sender"></param>
  1332. /// <param name=constTypeE></param>
  1333. private void button6_Click(object sender, EventArgs e)
  1334. {
  1335. this.operation = -1;
  1336. if(this.dataGridView2.Rows.Count == 0)
  1337. {
  1338. MessageBox.Show(PdnResources.GetString("Menu.Noartifacts.text")+"!");
  1339. }
  1340. else
  1341. {
  1342. if (this.dataGridView2.SelectedRows.Count > 0)
  1343. {
  1344. DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousureartifact?.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
  1345. if (dr == DialogResult.OK)
  1346. {
  1347. this.dataGridView2.Rows.Remove(this.dataGridView2.SelectedRows[0]);
  1348. SaveToConfigurationFile();
  1349. RecombinationRateDialog recombinationRateDialog = (RecombinationRateDialog)this.Owner;
  1350. if(this.dataGridView2.Rows.Count > 0 && this.dataGridView2.SelectedRows.Count > 0)
  1351. recombinationRateDialog.selectItemValue = this.dataGridView2.SelectedRows[0].Cells[0].Value.ToString();
  1352. recombinationRateDialog.RefreshCombobox();
  1353. InitGroupBox3();
  1354. if(this.dataGridView2.Rows.Count > 0)
  1355. {
  1356. if (this.dataGridView2.SelectedRows.Count > 0)
  1357. {
  1358. this.groupBox3.Enabled = false;
  1359. dataGridView1.Rows.Clear();
  1360. this.groupBox3.Show();
  1361. this.textBox1.Text = this.dataGridView2.SelectedRows[0].Cells[0].Value.ToString();
  1362. int rowNum = 0;
  1363. if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeA))
  1364. {
  1365. this.radioButton1.Checked = true;
  1366. rowNum = 3;
  1367. }
  1368. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeB))
  1369. {
  1370. this.radioButton2.Checked = true;
  1371. rowNum = 6;
  1372. }
  1373. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeC))
  1374. {
  1375. this.radioButton3.Checked = true;
  1376. rowNum = 9;
  1377. }
  1378. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeD))
  1379. {
  1380. this.radioButton4.Checked = true;
  1381. rowNum = 12;
  1382. }
  1383. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeE))
  1384. {
  1385. this.radioButton5.Checked = true;
  1386. rowNum = 6;
  1387. }
  1388. for (int i = 2; i < rowNum + 2; i += 3)
  1389. {
  1390. DataGridViewRow row = new DataGridViewRow();
  1391. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1392. textboxcell.Value = this.dataGridView2.SelectedRows[0].Cells[i].Value;
  1393. row.Cells.Add(textboxcell);
  1394. textboxcell = new DataGridViewTextBoxCell();
  1395. textboxcell.Value = this.dataGridView2.SelectedRows[0].Cells[i + 1].Value;
  1396. row.Cells.Add(textboxcell);
  1397. textboxcell = new DataGridViewTextBoxCell();
  1398. textboxcell.Value = this.dataGridView2.SelectedRows[0].Cells[i + 2].Value;
  1399. row.Cells.Add(textboxcell);
  1400. dataGridView1.Rows.Add(row);
  1401. }
  1402. }
  1403. else
  1404. {
  1405. this.groupBox3.Enabled = false;
  1406. dataGridView1.Rows.Clear();
  1407. this.groupBox3.Show();
  1408. this.textBox1.Text = this.dataGridView2.Rows[0].Cells[0].Value.ToString();
  1409. int rowNum = 0;
  1410. if (this.dataGridView2.Rows[0].Cells[1].Value.Equals(constTypeA))
  1411. {
  1412. this.radioButton1.Checked = true;
  1413. rowNum = 3;
  1414. }
  1415. else if (this.dataGridView2.Rows[0].Cells[1].Value.Equals(constTypeB))
  1416. {
  1417. this.radioButton2.Checked = true;
  1418. rowNum = 6;
  1419. }
  1420. else if (this.dataGridView2.Rows[0].Cells[1].Value.Equals(constTypeC))
  1421. {
  1422. this.radioButton3.Checked = true;
  1423. rowNum = 9;
  1424. }
  1425. else if (this.dataGridView2.Rows[0].Cells[1].Value.Equals(constTypeD))
  1426. {
  1427. this.radioButton4.Checked = true;
  1428. rowNum = 12;
  1429. }
  1430. else if (this.dataGridView2.Rows[0].Cells[1].Value.Equals(constTypeE))
  1431. {
  1432. this.radioButton5.Checked = true;
  1433. rowNum = 6;
  1434. }
  1435. for (int i = 2; i < rowNum + 2; i += 3)
  1436. {
  1437. DataGridViewRow row = new DataGridViewRow();
  1438. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1439. textboxcell.Value = this.dataGridView2.Rows[0].Cells[i].Value;
  1440. row.Cells.Add(textboxcell);
  1441. textboxcell = new DataGridViewTextBoxCell();
  1442. textboxcell.Value = this.dataGridView2.Rows[0].Cells[i + 1].Value;
  1443. row.Cells.Add(textboxcell);
  1444. textboxcell = new DataGridViewTextBoxCell();
  1445. textboxcell.Value = this.dataGridView2.Rows[0].Cells[i + 2].Value;
  1446. row.Cells.Add(textboxcell);
  1447. dataGridView1.Rows.Add(row);
  1448. }
  1449. }
  1450. }
  1451. else
  1452. {
  1453. this.dataGridView1.Rows.Clear();
  1454. }
  1455. }
  1456. }
  1457. else
  1458. {
  1459. MessageBox.Show(PdnResources.GetString("Menu.Pleaseselecttdelete.text")+"!");
  1460. }
  1461. }
  1462. }
  1463. /// <summary>
  1464. /// 使用按钮
  1465. /// </summary>
  1466. /// <param name="sender"></param>
  1467. /// <param name=constTypeE></param>
  1468. private void button3_Click(object sender, EventArgs e)
  1469. {
  1470. bool success = false;
  1471. if (this.operation == 0)
  1472. {
  1473. if (string.IsNullOrEmpty(this.textBox1.Text))
  1474. MessageBox.Show(PdnResources.GetString("Menu.Pleaseenterthworkpiece.text")+"!");
  1475. else
  1476. {
  1477. DataGridViewRow row = new DataGridViewRow();
  1478. DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
  1479. textboxcell.Value = this.textBox1.Text;
  1480. row.Cells.Add(textboxcell);
  1481. if (this.radioButton1.Checked)
  1482. {
  1483. textboxcell = new DataGridViewTextBoxCell();
  1484. textboxcell.Value = constTypeA;
  1485. row.Cells.Add(textboxcell);
  1486. }
  1487. else if (this.radioButton2.Checked)
  1488. {
  1489. textboxcell = new DataGridViewTextBoxCell();
  1490. textboxcell.Value = constTypeB;
  1491. row.Cells.Add(textboxcell);
  1492. }
  1493. else if (this.radioButton3.Checked)
  1494. {
  1495. textboxcell = new DataGridViewTextBoxCell();
  1496. textboxcell.Value = constTypeC;
  1497. row.Cells.Add(textboxcell);
  1498. }
  1499. else if (this.radioButton4.Checked)
  1500. {
  1501. textboxcell = new DataGridViewTextBoxCell();
  1502. textboxcell.Value = constTypeD;
  1503. row.Cells.Add(textboxcell);
  1504. }
  1505. else if (this.radioButton5.Checked)
  1506. {
  1507. textboxcell = new DataGridViewTextBoxCell();
  1508. textboxcell.Value = constTypeE;
  1509. row.Cells.Add(textboxcell);
  1510. }
  1511. for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
  1512. {
  1513. for (int j = 0; j < this.dataGridView1.Rows[i].Cells.Count; j++)
  1514. {
  1515. textboxcell = new DataGridViewTextBoxCell();
  1516. textboxcell.Value = this.dataGridView1.Rows[i].Cells[j].Value;
  1517. row.Cells.Add(textboxcell);
  1518. }
  1519. }
  1520. bool canAdd = true;
  1521. for (int i = 0; i < dataGridView2.Rows.Count; i++)
  1522. {
  1523. if (this.textBox1.Text.Equals(dataGridView2.Rows[i].Cells[0].Value))
  1524. {
  1525. MessageBox.Show(PdnResources.GetString("Menu.Namealreadyexists.text")+"!");
  1526. canAdd = false;
  1527. }
  1528. }
  1529. for (int i = 0; i < dataGridView1.Rows.Count; i++)
  1530. {
  1531. for (int j = 0; j < dataGridView1.Rows[i].Cells.Count; j++)
  1532. {
  1533. if (dataGridView1.Rows[i].Cells[j].Value == null)
  1534. {
  1535. if (j == 1)
  1536. {
  1537. canAdd = false;
  1538. MessageBox.Show(PdnResources.GetString("Menu.Targetvaluecannotbeempty.text")+"!");
  1539. dataGridView1.Rows[i].Cells[j].Style.BackColor = Color.Red;
  1540. break;
  1541. }
  1542. else if (j == 2)
  1543. {
  1544. canAdd = false;
  1545. MessageBox.Show(PdnResources.GetString("Menu.Errorcannotbeempty.text")+"!");
  1546. dataGridView1.Rows[i].Cells[j].Style.BackColor = Color.Red;
  1547. break;
  1548. }
  1549. }
  1550. }
  1551. }
  1552. if (canAdd)
  1553. {
  1554. success = true;
  1555. dataGridView2.Rows.Add(row);
  1556. dataGridView2.Rows[dataGridView2.Rows.Count - 1].Selected = true;
  1557. SaveToConfigurationFile();
  1558. }
  1559. }
  1560. }
  1561. else if (this.operation == 1)
  1562. {
  1563. bool canAdd = true;
  1564. for (int i = 0; i < dataGridView2.Rows.Count; i++)
  1565. {
  1566. if (this.dataGridView2.SelectedRows[0].Index != i)
  1567. {
  1568. if (this.textBox1.Text.Equals(dataGridView2.Rows[i].Cells[0].Value))
  1569. {
  1570. MessageBox.Show(PdnResources.GetString("Menu.Namealreadyexists.text")+"!");
  1571. canAdd = false;
  1572. }
  1573. }
  1574. }
  1575. for (int i = 0; i < dataGridView1.Rows.Count; i++)
  1576. {
  1577. for (int j = 0; j < dataGridView1.Rows[i].Cells.Count; j++)
  1578. {
  1579. if (dataGridView1.Rows[i].Cells[j].Value == null)
  1580. {
  1581. if (j == 1)
  1582. {
  1583. canAdd = false;
  1584. MessageBox.Show(PdnResources.GetString("Menu.Targetvaluecannotbeempty.text")+"!");
  1585. dataGridView1.Rows[i].Cells[j].Style.BackColor = Color.Red;
  1586. break;
  1587. }
  1588. else if (j == 2)
  1589. {
  1590. canAdd = false;
  1591. MessageBox.Show(PdnResources.GetString("Menu.Errorcannotbeempty.text")+"!");
  1592. dataGridView1.Rows[i].Cells[j].Style.BackColor = Color.Red;
  1593. break;
  1594. }
  1595. }
  1596. }
  1597. }
  1598. if (canAdd)
  1599. {
  1600. success = true;
  1601. this.dataGridView2.SelectedRows[0].Cells[0].Value = this.textBox1.Text;
  1602. if (this.radioButton1.Checked)
  1603. {
  1604. this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeA;
  1605. }
  1606. else if (this.radioButton2.Checked)
  1607. {
  1608. this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeB;
  1609. }
  1610. else if (this.radioButton3.Checked)
  1611. {
  1612. this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeC;
  1613. }
  1614. else if (this.radioButton4.Checked)
  1615. {
  1616. this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeD;
  1617. }
  1618. else if (this.radioButton5.Checked)
  1619. {
  1620. this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeE;
  1621. }
  1622. int col = 2;
  1623. for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
  1624. {
  1625. for (int j = 0; j < this.dataGridView1.Rows[i].Cells.Count; j++)
  1626. {
  1627. this.dataGridView2.SelectedRows[0].Cells[col].Value = this.dataGridView1.Rows[i].Cells[j].Value;
  1628. col++;
  1629. }
  1630. }
  1631. SaveToConfigurationFile();
  1632. }
  1633. }
  1634. else
  1635. {
  1636. if (this.dataGridView2.SelectedRows.Count < 1)
  1637. MessageBox.Show(PdnResources.GetString("Menu.heartifacttous.Text")+"!");
  1638. else
  1639. success = true;
  1640. }
  1641. if (success)
  1642. {
  1643. SaveToConfigurationFile();
  1644. RecombinationRateDialog recombinationRateDialog = (RecombinationRateDialog)this.Owner;
  1645. recombinationRateDialog.selectItemValue = this.dataGridView2.SelectedRows[0].Cells[0].Value.ToString();
  1646. recombinationRateDialog.RefreshCombobox();
  1647. this.Close();
  1648. }
  1649. }
  1650. /// <summary>
  1651. /// 编辑工件
  1652. /// </summary>
  1653. /// <param name="sender"></param>
  1654. /// <param name="e"></param>
  1655. private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  1656. {
  1657. if (this.operation == 1)
  1658. {
  1659. if (this.dataGridView2.Rows.Count > 0)
  1660. {
  1661. if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeA) && this.radioButton1.Checked)
  1662. {
  1663. SaveDataTable();
  1664. }
  1665. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeB) && this.radioButton2.Checked)
  1666. {
  1667. SaveDataTable();
  1668. }
  1669. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeC) && this.radioButton3.Checked)
  1670. {
  1671. SaveDataTable();
  1672. }
  1673. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeD) && this.radioButton4.Checked)
  1674. {
  1675. SaveDataTable();
  1676. }
  1677. else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeE) && this.radioButton5.Checked)
  1678. {
  1679. SaveDataTable();
  1680. }
  1681. }
  1682. }
  1683. }
  1684. /// <summary>
  1685. /// 保持到table
  1686. /// </summary>
  1687. private void SaveDataTable()
  1688. {
  1689. this.DataTable = new DataTable();
  1690. foreach (DataGridViewColumn c in this.dataGridView1.Columns)
  1691. {
  1692. this.DataTable.Columns.Add(c.HeaderText);
  1693. }
  1694. for (int r = 0; r < this.dataGridView1.Rows.Count; r++)
  1695. {
  1696. DataRow dataRow = this.DataTable.NewRow();
  1697. for (int c = 0; c < this.dataGridView1.Rows[r].Cells.Count; c++)
  1698. {
  1699. dataRow[this.dataGridView1.Columns[c].HeaderText] = this.dataGridView1.Rows[r].Cells[c].Value;
  1700. }
  1701. this.DataTable.Rows.Add(dataRow);
  1702. }
  1703. }
  1704. }
  1705. }