1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729 |
- using PaintDotNet.Base.SettingModel;
- using PaintDotNet.Base.CommTool;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace PaintDotNet.DedicatedAnalysis
- {
- public partial class WorkpieceMaintenance : PdnBaseForm
- {
- /// <summary>
- /// 操作区分(0 :添加 1 :编辑)
- /// </summary>
- private int operation = -1;
- /// <summary>
- /// 配置文件
- /// </summary>
- private WorkpieceMaintenanceModel workpieceMaintenanceModel;
- /// <summary>
- /// 工件类型
- /// </summary>
- private const string constTypeA = "a";
- private const string constTypeB = "b";
- private const string constTypeC = "c";
- private const string constTypeD = "d";
- private const string constTypeE = "e";
- /// <summary>
- /// 编辑时的数据
- /// </summary>
- private DataTable DataTable;
- #region 控件
- private GroupBox groupBox2;
- private GroupBox groupBox3;
- private Button button3;
- private Button button2;
- private Button button1;
- private Button button6;
- private Button button5;
- private Button button4;
- private PictureBox pictureBox5;
- private PictureBox pictureBox4;
- private PictureBox pictureBox3;
- private PictureBox pictureBox2;
- private PictureBox pictureBox1;
- private RadioButton radioButton5;
- private RadioButton radioButton4;
- private RadioButton radioButton3;
- private RadioButton radioButton2;
- private RadioButton radioButton1;
- private TextBox textBox1;
- private Label label3;
- private Label label2;
- private Label label1;
- private DataGridView dataGridView1;
- private DataGridView dataGridView2;
- private DataGridViewTextBoxColumn name;
- private DataGridViewTextBoxColumn type;
- private DataGridViewTextBoxColumn Name1;
- private DataGridViewTextBoxColumn Standardvalue1;
- private DataGridViewTextBoxColumn Error1;
- private DataGridViewTextBoxColumn Name2;
- private DataGridViewTextBoxColumn Standardvalue2;
- private DataGridViewTextBoxColumn Error2;
- private DataGridViewTextBoxColumn Name3;
- private DataGridViewTextBoxColumn Standardvalue3;
- private DataGridViewTextBoxColumn Error3;
- private DataGridViewTextBoxColumn Name4;
- private DataGridViewTextBoxColumn Standardvalue4;
- private DataGridViewTextBoxColumn Error4;
- private DataGridViewTextBoxColumn DetailName;
- private DataGridViewTextBoxColumn DetailStandardvalue;
- private DataGridViewTextBoxColumn DetailError;
- private ToolTip toolTip1;
- private IContainer components;
- private GroupBox groupBox1;
- #endregion
- public WorkpieceMaintenance()
- {
- InitializeComponent();
- InitializeLanguageText();
- InitializeButtonBackgroudImage();
- InitializeToolTip();
- this.groupBox3.Hide();
- this.radioButton1.Checked = true;
- this.pictureBox1.Image = PdnResources.GetImageResource("Workpiece.WorkpieceA.png").Reference;
- this.pictureBox2.Image = PdnResources.GetImageResource("Workpiece.WorkpieceB.png").Reference;
- this.pictureBox3.Image = PdnResources.GetImageResource("Workpiece.WorkpieceC.png").Reference;
- this.pictureBox4.Image = PdnResources.GetImageResource("Workpiece.WorkpieceD.png").Reference;
- this.pictureBox5.Image = PdnResources.GetImageResource("Workpiece.WorkpieceE.png").Reference;
- GetFromConfigurationFile();
- }
- private void InitializeToolTip()
- {
- this.toolTip1 = new ToolTip();
- this.toolTip1.SetToolTip(this.button4, PdnResources.GetString("Menu.Addto.text"));
- this.toolTip1.SetToolTip(this.button5, PdnResources.GetString("Menu.Edit.Text"));
- this.toolTip1.SetToolTip(this.button6, PdnResources.GetString("Menu.Edit.Delete.Text"));
- this.toolTip1.ShowAlways = true;
- }
- private void InitializeButtonBackgroudImage()
- {
- this.button4.FlatStyle = FlatStyle.Flat;
- this.button4.FlatAppearance.BorderSize = 0;
- this.button4.BackgroundImageLayout = ImageLayout.Center;
- this.button4.BackgroundImage = PdnResources.GetImageResource("Icons.MenuRulesListAddIcon.png").Reference;
- this.button5.FlatStyle = FlatStyle.Flat;
- this.button5.FlatAppearance.BorderSize = 0;
- this.button5.BackgroundImageLayout = ImageLayout.Center;
- this.button5.BackgroundImage = PdnResources.GetImageResource("Icons.MenuRulesListEditIcon.png").Reference;
- this.button6.FlatStyle = FlatStyle.Flat;
- this.button6.FlatAppearance.BorderSize = 0;
- this.button6.BackgroundImageLayout = ImageLayout.Center;
- this.button6.BackgroundImage = PdnResources.GetImageResource("Icons.MenuRulesListDeleteIcon.png").Reference;
- }
- private void InitializeLanguageText()
- {
- this.groupBox1.Text = PdnResources.GetString("Menu.Dedicatedanalysis.Non-ferrousmetals.artifactmaintenance.text");
- this.button3.Text = PdnResources.GetString("Menu.use.text");
- this.button2.Text = PdnResources.GetString("CommonAction.Save");
- this.button1.Text = PdnResources.GetString("Menu.File.Close.Text");
- this.groupBox2.Text = PdnResources.GetString("Menu.Dedicatedanalysis.Non-ferrousmetals.artifactrecord.text");
- this.name.HeaderText = PdnResources.GetString("Menu.name.text");
- this.type.HeaderText = PdnResources.GetString("Menu.Dedicatedanalysis.Non-ferrousmetals.artifacttype.text");
- this.groupBox3.Text = PdnResources.GetString("Menu.Dedicatedanalysis.Non-ferrousmetals.detailinformation.text");
- this.label1.Text = PdnResources.GetString("Menu.Dedicatedanalysis.Non-ferrousmetals.artifact name.text") + ":";
- this.DetailName.HeaderText = PdnResources.GetString("Menu.name.text");
- this.DetailStandardvalue.HeaderText = PdnResources.GetString("Menu.Dedicatedanalysis.Nmetals.standardvalue.text") + "(%)";
- this.DetailError.HeaderText = PdnResources.GetString("Menu.error.text");
- this.label3.Text = PdnResources.GetString("Menu.detailed.text") + ":";
- this.label2.Text = PdnResources.GetString("Menu.Dedicatedanalysis.Non-ferrousmetals.artifacttype.text") + ":";
- this.Text = PdnResources.GetString("Menu.Dedicatedanalysis.Non-ferrousmetals.artifactmaintenance.text");
- }
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle28 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle29 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle30 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle31 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle35 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle36 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle32 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle33 = new System.Windows.Forms.DataGridViewCellStyle();
- System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle34 = new System.Windows.Forms.DataGridViewCellStyle();
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.button3 = new System.Windows.Forms.Button();
- this.button2 = new System.Windows.Forms.Button();
- this.button1 = new System.Windows.Forms.Button();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.dataGridView2 = new System.Windows.Forms.DataGridView();
- this.name = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.type = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Name1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Standardvalue1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Error1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Name2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Standardvalue2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Error2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Name3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Standardvalue3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Error3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Name4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Standardvalue4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.Error4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.button6 = new System.Windows.Forms.Button();
- this.button5 = new System.Windows.Forms.Button();
- this.button4 = new System.Windows.Forms.Button();
- this.groupBox3 = new System.Windows.Forms.GroupBox();
- this.dataGridView1 = new System.Windows.Forms.DataGridView();
- this.DetailName = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.DetailStandardvalue = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.DetailError = new System.Windows.Forms.DataGridViewTextBoxColumn();
- this.pictureBox5 = new System.Windows.Forms.PictureBox();
- this.pictureBox4 = new System.Windows.Forms.PictureBox();
- this.pictureBox3 = new System.Windows.Forms.PictureBox();
- this.pictureBox2 = new System.Windows.Forms.PictureBox();
- this.pictureBox1 = new System.Windows.Forms.PictureBox();
- this.radioButton5 = new System.Windows.Forms.RadioButton();
- this.radioButton4 = new System.Windows.Forms.RadioButton();
- this.radioButton3 = new System.Windows.Forms.RadioButton();
- this.radioButton2 = new System.Windows.Forms.RadioButton();
- this.radioButton1 = new System.Windows.Forms.RadioButton();
- this.textBox1 = new System.Windows.Forms.TextBox();
- this.label3 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.label1 = new System.Windows.Forms.Label();
- this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
- this.groupBox1.SuspendLayout();
- this.groupBox2.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).BeginInit();
- this.groupBox3.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
- this.SuspendLayout();
- //
- // groupBox1
- //
- this.groupBox1.Controls.Add(this.button3);
- this.groupBox1.Controls.Add(this.button2);
- this.groupBox1.Controls.Add(this.button1);
- this.groupBox1.Location = new System.Drawing.Point(12, 12);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(840, 52);
- this.groupBox1.TabIndex = 0;
- this.groupBox1.TabStop = false;
-
- //
- // button3
- //
- this.button3.Location = new System.Drawing.Point(729, 13);
- this.button3.Name = "button3";
- this.button3.Size = new System.Drawing.Size(103, 31);
- this.button3.TabIndex = 2;
- this.button3.UseVisualStyleBackColor = true;
- this.button3.Click += new System.EventHandler(this.button3_Click);
- //
- // button2
- //
- this.button2.Location = new System.Drawing.Point(610, 13);
- this.button2.Name = "button2";
- this.button2.Size = new System.Drawing.Size(103, 31);
- this.button2.TabIndex = 1;
- this.button2.UseVisualStyleBackColor = true;
- this.button2.Click += new System.EventHandler(this.button2_Click);
- //
- // button1
- //
- this.button1.Location = new System.Drawing.Point(491, 13);
- this.button1.Name = "button1";
- this.button1.Size = new System.Drawing.Size(103, 31);
- this.button1.TabIndex = 0;
- this.button1.UseVisualStyleBackColor = true;
- this.button1.Click += new System.EventHandler(this.button1_Click);
- //
- // groupBox2
- //
- this.groupBox2.Controls.Add(this.dataGridView2);
- this.groupBox2.Controls.Add(this.button6);
- this.groupBox2.Controls.Add(this.button5);
- this.groupBox2.Controls.Add(this.button4);
- this.groupBox2.Location = new System.Drawing.Point(12, 70);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(220, 326);
- this.groupBox2.TabIndex = 1;
- this.groupBox2.TabStop = false;
- //
- // dataGridView2
- //
- this.dataGridView2.AllowUserToAddRows = false;
- this.dataGridView2.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
- this.dataGridView2.BackgroundColor = System.Drawing.SystemColors.Control;
- dataGridViewCellStyle28.Alignment = System.Windows.Forms.DataGridViewContentAlignment.TopCenter;
- dataGridViewCellStyle28.BackColor = System.Drawing.SystemColors.Control;
- dataGridViewCellStyle28.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- dataGridViewCellStyle28.ForeColor = System.Drawing.SystemColors.WindowText;
- dataGridViewCellStyle28.SelectionBackColor = System.Drawing.SystemColors.Highlight;
- dataGridViewCellStyle28.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
- dataGridViewCellStyle28.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
- this.dataGridView2.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle28;
- this.dataGridView2.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView2.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
- this.name,
- this.type,
- this.Name1,
- this.Standardvalue1,
- this.Error1,
- this.Name2,
- this.Standardvalue2,
- this.Error2,
- this.Name3,
- this.Standardvalue3,
- this.Error3,
- this.Name4,
- this.Standardvalue4,
- this.Error4});
- this.dataGridView2.Location = new System.Drawing.Point(6, 46);
- this.dataGridView2.MultiSelect = false;
- this.dataGridView2.Name = "dataGridView2";
- this.dataGridView2.RowHeadersVisible = false;
- this.dataGridView2.RowTemplate.Height = 23;
- this.dataGridView2.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
- this.dataGridView2.Size = new System.Drawing.Size(206, 274);
- this.dataGridView2.TabIndex = 14;
- this.dataGridView2.SelectionChanged += new System.EventHandler(this.dataGridView2_SelectionChanged);
- //
- // name
- //
- dataGridViewCellStyle29.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
- this.name.DefaultCellStyle = dataGridViewCellStyle29;
- this.name.Name = "name";
- this.name.ReadOnly = true;
- //
- // type
- //
- this.type.Name = "type";
- this.type.Visible = false;
- //
- // Name1
- //
- this.Name1.HeaderText = "Name1";
- this.Name1.Name = "Name1";
- this.Name1.Visible = false;
- //
- // Standardvalue1
- //
- this.Standardvalue1.HeaderText = "Standardvalue1";
- this.Standardvalue1.Name = "Standardvalue1";
- this.Standardvalue1.Visible = false;
- //
- // Error1
- //
- this.Error1.HeaderText = "Error1";
- this.Error1.Name = "Error1";
- this.Error1.Visible = false;
- //
- // Name2
- //
- this.Name2.HeaderText = "Name2";
- this.Name2.Name = "Name2";
- this.Name2.Visible = false;
- //
- // Standardvalue2
- //
- this.Standardvalue2.HeaderText = "Standardvalue2";
- this.Standardvalue2.Name = "Standardvalue2";
- this.Standardvalue2.Visible = false;
- //
- // Error2
- //
- this.Error2.HeaderText = "Error2";
- this.Error2.Name = "Error2";
- this.Error2.Visible = false;
- //
- // Name3
- //
- this.Name3.HeaderText = "Name3";
- this.Name3.Name = "Name3";
- this.Name3.Visible = false;
- //
- // Standardvalue3
- //
- this.Standardvalue3.HeaderText = "Standardvalue3";
- this.Standardvalue3.Name = "Standardvalue3";
- this.Standardvalue3.Visible = false;
- //
- // Error3
- //
- this.Error3.HeaderText = "Error3";
- this.Error3.Name = "Error3";
- this.Error3.Visible = false;
- //
- // Name4
- //
- this.Name4.HeaderText = "Name4";
- this.Name4.Name = "Name4";
- this.Name4.Visible = false;
- //
- // Standardvalue4
- //
- this.Standardvalue4.HeaderText = "Standardvalue4";
- this.Standardvalue4.Name = "Standardvalue4";
- this.Standardvalue4.Visible = false;
- //
- // Error4
- //
- this.Error4.HeaderText = "Error4";
- this.Error4.Name = "Error4";
- this.Error4.Visible = false;
- //
- // button6
- //
- this.button6.Location = new System.Drawing.Point(185, 15);
- this.button6.Name = "button6";
- this.button6.Size = new System.Drawing.Size(27, 25);
- this.button6.TabIndex = 7;
- this.button6.UseVisualStyleBackColor = true;
- this.button6.Click += new System.EventHandler(this.button6_Click);
- //
- // button5
- //
- this.button5.Location = new System.Drawing.Point(152, 15);
- this.button5.Name = "button5";
- this.button5.Size = new System.Drawing.Size(27, 25);
- this.button5.TabIndex = 6;
- this.button5.UseVisualStyleBackColor = true;
- this.button5.Click += new System.EventHandler(this.button5_Click);
- //
- // button4
- //
- this.button4.Location = new System.Drawing.Point(119, 15);
- this.button4.Name = "button4";
- this.button4.Size = new System.Drawing.Size(27, 25);
- this.button4.TabIndex = 5;
- this.button4.UseVisualStyleBackColor = true;
- this.button4.Click += new System.EventHandler(this.button4_Click);
- //
- // groupBox3
- //
- this.groupBox3.Controls.Add(this.dataGridView1);
- this.groupBox3.Controls.Add(this.pictureBox5);
- this.groupBox3.Controls.Add(this.pictureBox4);
- this.groupBox3.Controls.Add(this.pictureBox3);
- this.groupBox3.Controls.Add(this.pictureBox2);
- this.groupBox3.Controls.Add(this.pictureBox1);
- this.groupBox3.Controls.Add(this.radioButton5);
- this.groupBox3.Controls.Add(this.radioButton4);
- this.groupBox3.Controls.Add(this.radioButton3);
- this.groupBox3.Controls.Add(this.radioButton2);
- this.groupBox3.Controls.Add(this.radioButton1);
- this.groupBox3.Controls.Add(this.textBox1);
- this.groupBox3.Controls.Add(this.label3);
- this.groupBox3.Controls.Add(this.label2);
- this.groupBox3.Controls.Add(this.label1);
- this.groupBox3.Location = new System.Drawing.Point(238, 70);
- this.groupBox3.Name = "groupBox3";
- this.groupBox3.Size = new System.Drawing.Size(614, 326);
- this.groupBox3.TabIndex = 2;
- this.groupBox3.TabStop = false;
-
- //
- // dataGridView1
- //
- this.dataGridView1.AllowUserToAddRows = false;
- dataGridViewCellStyle30.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
- this.dataGridView1.AlternatingRowsDefaultCellStyle = dataGridViewCellStyle30;
- this.dataGridView1.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
- this.dataGridView1.BackgroundColor = System.Drawing.SystemColors.Control;
- dataGridViewCellStyle31.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
- dataGridViewCellStyle31.BackColor = System.Drawing.SystemColors.Control;
- dataGridViewCellStyle31.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- dataGridViewCellStyle31.ForeColor = System.Drawing.SystemColors.WindowText;
- dataGridViewCellStyle31.SelectionBackColor = System.Drawing.SystemColors.Highlight;
- dataGridViewCellStyle31.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
- dataGridViewCellStyle31.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
- this.dataGridView1.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle31;
- this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView1.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
- this.DetailName,
- this.DetailStandardvalue,
- this.DetailError});
- this.dataGridView1.Location = new System.Drawing.Point(72, 153);
- this.dataGridView1.Name = "dataGridView1";
- dataGridViewCellStyle35.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
- dataGridViewCellStyle35.BackColor = System.Drawing.SystemColors.Control;
- dataGridViewCellStyle35.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
- dataGridViewCellStyle35.ForeColor = System.Drawing.SystemColors.WindowText;
- dataGridViewCellStyle35.SelectionBackColor = System.Drawing.SystemColors.Highlight;
- dataGridViewCellStyle35.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
- dataGridViewCellStyle35.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
- this.dataGridView1.RowHeadersDefaultCellStyle = dataGridViewCellStyle35;
- this.dataGridView1.RowHeadersVisible = false;
- dataGridViewCellStyle36.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
- this.dataGridView1.RowsDefaultCellStyle = dataGridViewCellStyle36;
- this.dataGridView1.RowTemplate.Height = 23;
- this.dataGridView1.Size = new System.Drawing.Size(528, 159);
- this.dataGridView1.TabIndex = 13;
- this.dataGridView1.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellValueChanged);
- //
- // DetailName
- //
- dataGridViewCellStyle32.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
- this.DetailName.DefaultCellStyle = dataGridViewCellStyle32;
- this.DetailName.Name = "DetailName";
- this.DetailName.ReadOnly = true;
- //
- // DetailStandardvalue
- //
- dataGridViewCellStyle33.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
- this.DetailStandardvalue.DefaultCellStyle = dataGridViewCellStyle33;
- this.DetailStandardvalue.Name = "DetailStandardvalue";
- //
- // DetailError
- //
- dataGridViewCellStyle34.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
- this.DetailError.DefaultCellStyle = dataGridViewCellStyle34;
- this.DetailError.Name = "DetailError";
- //
- // pictureBox5
- //
- this.pictureBox5.Location = new System.Drawing.Point(500, 73);
- this.pictureBox5.Name = "pictureBox5";
- this.pictureBox5.Size = new System.Drawing.Size(68, 57);
- this.pictureBox5.TabIndex = 12;
- this.pictureBox5.TabStop = false;
- //
- // pictureBox4
- //
- this.pictureBox4.Location = new System.Drawing.Point(403, 73);
- this.pictureBox4.Name = "pictureBox4";
- this.pictureBox4.Size = new System.Drawing.Size(68, 57);
- this.pictureBox4.TabIndex = 11;
- this.pictureBox4.TabStop = false;
- //
- // pictureBox3
- //
- this.pictureBox3.Location = new System.Drawing.Point(306, 73);
- this.pictureBox3.Name = "pictureBox3";
- this.pictureBox3.Size = new System.Drawing.Size(68, 57);
- this.pictureBox3.TabIndex = 10;
- this.pictureBox3.TabStop = false;
- //
- // pictureBox2
- //
- this.pictureBox2.Location = new System.Drawing.Point(209, 73);
- this.pictureBox2.Name = "pictureBox2";
- this.pictureBox2.Size = new System.Drawing.Size(68, 57);
- this.pictureBox2.TabIndex = 9;
- this.pictureBox2.TabStop = false;
- //
- // pictureBox1
- //
- this.pictureBox1.Location = new System.Drawing.Point(112, 73);
- this.pictureBox1.Name = "pictureBox1";
- this.pictureBox1.Size = new System.Drawing.Size(68, 57);
- this.pictureBox1.TabIndex = 8;
- this.pictureBox1.TabStop = false;
- //
- // radioButton5
- //
- this.radioButton5.AutoSize = true;
- this.radioButton5.Location = new System.Drawing.Point(481, 93);
- this.radioButton5.Name = "radioButton5";
- this.radioButton5.Size = new System.Drawing.Size(14, 13);
- this.radioButton5.TabIndex = 7;
- this.radioButton5.UseVisualStyleBackColor = true;
- this.radioButton5.CheckedChanged += new System.EventHandler(this.radioButton5_CheckedChanged);
- //
- // radioButton4
- //
- this.radioButton4.AutoSize = true;
- this.radioButton4.Location = new System.Drawing.Point(384, 93);
- this.radioButton4.Name = "radioButton4";
- this.radioButton4.Size = new System.Drawing.Size(14, 13);
- this.radioButton4.TabIndex = 7;
- this.radioButton4.UseVisualStyleBackColor = true;
- this.radioButton4.CheckedChanged += new System.EventHandler(this.radioButton4_CheckedChanged);
- //
- // radioButton3
- //
- this.radioButton3.AutoSize = true;
- this.radioButton3.Location = new System.Drawing.Point(287, 93);
- this.radioButton3.Name = "radioButton3";
- this.radioButton3.Size = new System.Drawing.Size(14, 13);
- this.radioButton3.TabIndex = 6;
- this.radioButton3.UseVisualStyleBackColor = true;
- this.radioButton3.CheckedChanged += new System.EventHandler(this.radioButton3_CheckedChanged);
- //
- // radioButton2
- //
- this.radioButton2.AutoSize = true;
- this.radioButton2.Location = new System.Drawing.Point(190, 93);
- this.radioButton2.Name = "radioButton2";
- this.radioButton2.Size = new System.Drawing.Size(14, 13);
- this.radioButton2.TabIndex = 5;
- this.radioButton2.UseVisualStyleBackColor = true;
- this.radioButton2.CheckedChanged += new System.EventHandler(this.radioButton2_CheckedChanged);
- //
- // radioButton1
- //
- this.radioButton1.AutoSize = true;
- this.radioButton1.Location = new System.Drawing.Point(93, 93);
- this.radioButton1.Name = "radioButton1";
- this.radioButton1.Size = new System.Drawing.Size(14, 13);
- this.radioButton1.TabIndex = 4;
- this.radioButton1.UseVisualStyleBackColor = true;
- this.radioButton1.CheckedChanged += new System.EventHandler(this.radioButton1_CheckedChanged);
- //
- // textBox1
- //
- this.textBox1.Location = new System.Drawing.Point(96, 31);
- this.textBox1.Name = "textBox1";
- this.textBox1.Size = new System.Drawing.Size(493, 21);
- this.textBox1.TabIndex = 3;
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(25, 153);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(41, 12);
- this.label3.TabIndex = 2;
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(25, 93);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(65, 12);
- this.label2.TabIndex = 1;
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(25, 35);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(65, 12);
- this.label1.TabIndex = 0;
- //
- // WorkpieceMaintenance
- //
- this.ClientSize = new System.Drawing.Size(864, 408);
- this.Controls.Add(this.groupBox3);
- this.Controls.Add(this.groupBox2);
- this.Controls.Add(this.groupBox1);
- this.MaximizeBox = false;
- this.MaximumSize = new System.Drawing.Size(880, 447);
- this.MinimizeBox = false;
- this.MinimumSize = new System.Drawing.Size(880, 447);
- this.Name = "WorkpieceMaintenance";
- this.ShowInTaskbar = false;
- this.groupBox1.ResumeLayout(false);
- this.groupBox2.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView2)).EndInit();
- this.groupBox3.ResumeLayout(false);
- this.groupBox3.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
- this.ResumeLayout(false);
- }
- /// <summary>
- /// 初始化右侧编辑模块
- /// </summary>
- private void InitGroupBox3()
- {
- this.groupBox3.Enabled = true;
- this.textBox1.Text = string.Empty;
- dataGridView1.Rows.Clear();
- DataGridViewRow row = new DataGridViewRow();
- DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeA;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- this.radioButton1.Checked = true;
- }
- /// <summary>
- /// 保存工件到配置文件
- /// </summary>
- private void SaveToConfigurationFile()
- {
- WorkpieceMaintenanceModel workpieceMaintenanceModel = new WorkpieceMaintenanceModel();
- workpieceMaintenanceModel.Workpieces = new List<WorkpieceMaintenanceModel.Workpiece>();
- for (int i = 0; i < this.dataGridView2.Rows.Count; i++)
- {
- WorkpieceMaintenanceModel.Workpiece workpiece = new WorkpieceMaintenanceModel.Workpiece();
- if(this.dataGridView2.Rows[i].Cells[0].Value != null)
- workpiece.Name = this.dataGridView2.Rows[i].Cells[0].Value.ToString();
- if (this.dataGridView2.Rows[i].Cells[1].Value != null)
- workpiece.Type = this.dataGridView2.Rows[i].Cells[1].Value.ToString();
- if (this.dataGridView2.Rows[i].Cells[2].Value != null)
- workpiece.NameA = this.dataGridView2.Rows[i].Cells[2].Value.ToString();
- if (this.dataGridView2.Rows[i].Cells[3].Value != null)
- workpiece.StandardValueA = this.dataGridView2.Rows[i].Cells[3].Value.ToString();
- if (this.dataGridView2.Rows[i].Cells[4].Value != null)
- workpiece.ErrorA = this.dataGridView2.Rows[i].Cells[4].Value.ToString();
- if (this.dataGridView2.Rows[i].Cells[5].Value != null)
- workpiece.NameB = this.dataGridView2.Rows[i].Cells[5].Value.ToString();
- if (this.dataGridView2.Rows[i].Cells[6].Value != null)
- workpiece.StandardValueB = this.dataGridView2.Rows[i].Cells[6].Value.ToString();
- if (this.dataGridView2.Rows[i].Cells[7].Value != null)
- workpiece.ErrorB = this.dataGridView2.Rows[i].Cells[7].Value.ToString();
- if (this.dataGridView2.Rows[i].Cells[8].Value != null)
- workpiece.NameC = this.dataGridView2.Rows[i].Cells[8].Value.ToString();
- if (this.dataGridView2.Rows[i].Cells[9].Value != null)
- workpiece.StandardValueC = this.dataGridView2.Rows[i].Cells[9].Value.ToString();
- if (this.dataGridView2.Rows[i].Cells[10].Value != null)
- workpiece.ErrorC = this.dataGridView2.Rows[i].Cells[10].Value.ToString();
- if (this.dataGridView2.Rows[i].Cells[11].Value != null)
- workpiece.NameD = this.dataGridView2.Rows[i].Cells[11].Value.ToString();
- if (this.dataGridView2.Rows[i].Cells[12].Value != null)
- workpiece.StandardValueD = this.dataGridView2.Rows[i].Cells[12].Value.ToString();
- if (this.dataGridView2.Rows[i].Cells[13].Value != null)
- workpiece.ErrorD = this.dataGridView2.Rows[i].Cells[13].Value.ToString();
- workpieceMaintenanceModel.Workpieces.Add(workpiece);
- }
- string configXml = XmlSerializeHelper.XmlSerialize<WorkpieceMaintenanceModel>(workpieceMaintenanceModel);
- string filePath = Application.StartupPath + "\\Config\\" + Startup.instance.SettingPrefix + "\\WorkpieceMaintenanceModel.xml";
- if (FileOperationHelper.WriteStringToFile(configXml, filePath, FileMode.Create))
- {
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.xmlsavefailed.text"));
- }
- }
- /// <summary>
- /// 从配置文件中读取工件信息
- /// </summary>
- private void GetFromConfigurationFile()
- {
- workpieceMaintenanceModel = XmlSerializeHelper.DESerializer<WorkpieceMaintenanceModel>(FileOperationHelper.ReadStringFromFile(Application.StartupPath + "\\Config\\" +Startup.instance.SettingPrefix + "\\WorkpieceMaintenanceModel.xml", FileMode.Open));
- if (workpieceMaintenanceModel.Workpieces != null)
- {
- this.dataGridView2.Rows.Clear();
- for (int i = 0; i < workpieceMaintenanceModel.Workpieces.Count; i++)
- {
- DataGridViewRow row = new DataGridViewRow();
- DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = workpieceMaintenanceModel.Workpieces[i].Name;
- row.Cells.Add(textboxcell);
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = workpieceMaintenanceModel.Workpieces[i].Type;
- row.Cells.Add(textboxcell);
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = workpieceMaintenanceModel.Workpieces[i].NameA;
- row.Cells.Add(textboxcell);
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = workpieceMaintenanceModel.Workpieces[i].StandardValueA;
- row.Cells.Add(textboxcell);
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = workpieceMaintenanceModel.Workpieces[i].ErrorA;
- row.Cells.Add(textboxcell);
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = workpieceMaintenanceModel.Workpieces[i].NameB;
- row.Cells.Add(textboxcell);
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = workpieceMaintenanceModel.Workpieces[i].StandardValueB;
- row.Cells.Add(textboxcell);
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = workpieceMaintenanceModel.Workpieces[i].ErrorB;
- row.Cells.Add(textboxcell);
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = workpieceMaintenanceModel.Workpieces[i].NameC;
- row.Cells.Add(textboxcell);
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = workpieceMaintenanceModel.Workpieces[i].StandardValueC;
- row.Cells.Add(textboxcell);
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = workpieceMaintenanceModel.Workpieces[i].ErrorC;
- row.Cells.Add(textboxcell);
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = workpieceMaintenanceModel.Workpieces[i].NameD;
- row.Cells.Add(textboxcell);
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = workpieceMaintenanceModel.Workpieces[i].StandardValueD;
- row.Cells.Add(textboxcell);
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = workpieceMaintenanceModel.Workpieces[i].ErrorD;
- row.Cells.Add(textboxcell);
- dataGridView2.Rows.Add(row);
- }
- }
- }
- /// <summary>
- /// 工件添加按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name=constTypeE></param>
- private void button4_Click(object sender, EventArgs e)
- {
- this.operation = 0;
- InitGroupBox3();
- this.groupBox3.Show();
- }
- /// <summary>
- /// 工件编辑按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name=constTypeE></param>
- private void button5_Click(object sender, EventArgs e)
- {
- if (this.dataGridView2.Rows.Count == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Noartifacts.text")+"!");
- }
- else
- {
- if (this.dataGridView2.SelectedRows.Count > 0)
- {
- this.groupBox3.Enabled = true;
- dataGridView1.Rows.Clear();
- this.operation = 1;
- this.groupBox3.Show();
- this.textBox1.Text = this.dataGridView2.SelectedRows[0].Cells[0].Value.ToString();
- int rowNum = 0;
- if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeA))
- {
- this.radioButton1.Checked = true;
- rowNum = 3;
- }
- else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeB))
- {
- this.radioButton2.Checked = true;
- rowNum = 6;
- }
- else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeC))
- {
- this.radioButton3.Checked = true;
- rowNum = 9;
- }
- else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeD))
- {
- this.radioButton4.Checked = true;
- rowNum = 12;
- }
- else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeE))
- {
- this.radioButton5.Checked = true;
- rowNum = 6;
- }
- for (int i = 2; i < rowNum + 2; i += 3)
- {
- DataGridViewRow row = new DataGridViewRow();
- DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = this.dataGridView2.SelectedRows[0].Cells[i].Value;
- row.Cells.Add(textboxcell);
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = this.dataGridView2.SelectedRows[0].Cells[i + 1].Value;
- row.Cells.Add(textboxcell);
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = this.dataGridView2.SelectedRows[0].Cells[i + 2].Value;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- }
- this.DataTable = new DataTable();
- foreach (DataGridViewColumn c in this.dataGridView1.Columns)
- {
- this.DataTable.Columns.Add(c.HeaderText);
- }
- for (int r = 0; r < this.dataGridView1.Rows.Count; r++)
- {
- DataRow dataRow = this.DataTable.NewRow();
- for (int c = 0; c < this.dataGridView1.Rows[r].Cells.Count; c++)
- {
- dataRow[this.dataGridView1.Columns[c].HeaderText] = this.dataGridView1.Rows[r].Cells[c].Value;
- }
- this.DataTable.Rows.Add(dataRow);
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselectaworkpiece.text")+"!");
- }
- }
- }
- /// <summary>
- /// 关闭按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name=constTypeE></param>
- private void button1_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- /// <summary>
- /// 保存按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name=constTypeE></param>
- private void button2_Click(object sender, EventArgs e)
- {
- if (this.operation == 0)
- {
- if (string.IsNullOrEmpty(this.textBox1.Text))
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseenterthworkpiece.text")+"!");
- else
- {
- DataGridViewRow row = new DataGridViewRow();
- DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = this.textBox1.Text;
- row.Cells.Add(textboxcell);
- if (this.radioButton1.Checked)
- {
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeA;
- row.Cells.Add(textboxcell);
- }
- else if (this.radioButton2.Checked)
- {
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeB;
- row.Cells.Add(textboxcell);
- }
- else if (this.radioButton3.Checked)
- {
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeC;
- row.Cells.Add(textboxcell);
- }
- else if (this.radioButton4.Checked)
- {
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeD;
- row.Cells.Add(textboxcell);
- }
- else if (this.radioButton5.Checked)
- {
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeE;
- row.Cells.Add(textboxcell);
- }
- for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
- {
- for (int j = 0; j < this.dataGridView1.Rows[i].Cells.Count; j++)
- {
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = this.dataGridView1.Rows[i].Cells[j].Value;
- row.Cells.Add(textboxcell);
- }
- }
- for (int i = 0; i < dataGridView2.Rows.Count; i++)
- {
- if (this.textBox1.Text.Equals(dataGridView2.Rows[i].Cells[0].Value))
- {
- MessageBox.Show(PdnResources.GetString("Menu.Namealreadyexists.text")+"!");
- return;
- }
- }
- for (int i = 0; i < dataGridView1.Rows.Count; i++)
- {
- for (int j = 0; j < dataGridView1.Rows[i].Cells.Count; j++)
- {
- if (dataGridView1.Rows[i].Cells[j].Value == null)
- {
- if (j == 1)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Targetvaluecannotbeempty.text")+"!");
- dataGridView1.Rows[i].Cells[j].Style.BackColor = Color.Red;
- return;
- }
- else if (j == 2)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Errorcannotbeempty.text")+"!");
- dataGridView1.Rows[i].Cells[j].Style.BackColor = Color.Red;
- return;
- }
- }
- }
- }
- dataGridView2.Rows.Add(row);
- dataGridView2.ClearSelection();
- SaveToConfigurationFile();
- RecombinationRateDialog recombinationRateDialog = (RecombinationRateDialog)this.Owner;
- recombinationRateDialog.selectItemValue = this.textBox1.Text;
- recombinationRateDialog.RefreshCombobox();
- dataGridView2.Rows[dataGridView2.Rows.Count - 1].Selected = true;
- MessageBox.Show(PdnResources.GetString("Menu.Successfullysaved.text")+"!", PdnResources.GetString("Menu.Addto.text"));
- }
- }
- else if (this.operation == 1)
- {
- for (int i = 0; i < dataGridView2.Rows.Count; i++)
- {
- if (this.dataGridView2.SelectedRows[0].Index != i)
- {
- if (this.textBox1.Text.Equals(dataGridView2.Rows[i].Cells[0].Value))
- {
- MessageBox.Show(PdnResources.GetString("Menu.Namealreadyexists.text")+"!");
- return;
- }
- }
- }
- for (int i = 0; i < dataGridView1.Rows.Count; i++)
- {
- for (int j = 0; j < dataGridView1.Rows[i].Cells.Count; j++)
- {
- if (dataGridView1.Rows[i].Cells[j].Value == null)
- {
- if (j == 1)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Targetvaluecannotbeempty.text")+"!");
- dataGridView1.Rows[i].Cells[j].Style.BackColor = Color.Red;
- return;
- }
- else if (j == 2)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Errorcannotbeempty.text")+"!");
- dataGridView1.Rows[i].Cells[j].Style.BackColor = Color.Red;
- return;
- }
- }
- }
- }
- this.dataGridView2.SelectedRows[0].Cells[0].Value = this.textBox1.Text;
- if (this.radioButton1.Checked)
- {
- this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeA;
- }
- else if (this.radioButton2.Checked)
- {
- this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeB;
- }
- else if (this.radioButton3.Checked)
- {
- this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeC;
- }
- else if (this.radioButton4.Checked)
- {
- this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeD;
- }
- else if (this.radioButton5.Checked)
- {
- this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeE;
- }
- int col = 2;
- for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
- {
- for (int j = 0; j < this.dataGridView1.Rows[i].Cells.Count; j++)
- {
- this.dataGridView2.SelectedRows[0].Cells[col].Value = this.dataGridView1.Rows[i].Cells[j].Value;
- col++;
- }
- }
- int se = this.dataGridView2.SelectedRows[0].Index;
- dataGridView2.ClearSelection();
- SaveToConfigurationFile();
- RecombinationRateDialog recombinationRateDialog = (RecombinationRateDialog)this.Owner;
- recombinationRateDialog.selectItemValue = this.textBox1.Text;
- recombinationRateDialog.RefreshCombobox();
- this.dataGridView2.Rows[se].Selected = true;
- MessageBox.Show(PdnResources.GetString("Menu.Successfullysaved.text")+"!", PdnResources.GetString("Menu.Edit.Text"));
- }
- this.operation = -1;
- }
- #region 工件类型选择
- private void radioButton1_CheckedChanged(object sender, EventArgs e)
- {
- if(this.radioButton1.Checked && this.groupBox3.Enabled)
- {
- if(this.operation == 0)
- {
- dataGridView1.Rows.Clear();
- DataGridViewRow row = new DataGridViewRow();
- DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeA;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- }
- else if(this.operation == 1)
- {
- if(this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeA))
- {
- GetDataTable();
- }
- else
- {
- dataGridView1.Rows.Clear();
- DataGridViewRow row = new DataGridViewRow();
- DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeA;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- }
- }
- }
- }
- private void radioButton2_CheckedChanged(object sender, EventArgs e)
- {
- if (this.radioButton2.Checked && this.groupBox3.Enabled)
- {
- if (this.operation == 0)
- {
- dataGridView1.Rows.Clear();
- DataGridViewRow row = new DataGridViewRow();
- DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeA;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- row = new DataGridViewRow();
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeB;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- }
- else if (this.operation == 1)
- {
- if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeB))
- {
- GetDataTable();
- }
- else
- {
- dataGridView1.Rows.Clear();
- DataGridViewRow row = new DataGridViewRow();
- DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeA;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- row = new DataGridViewRow();
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeB;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- }
- }
- }
- }
- private void radioButton3_CheckedChanged(object sender, EventArgs e)
- {
- if (this.radioButton3.Checked && this.groupBox3.Enabled)
- {
- if (this.operation == 0)
- {
- dataGridView1.Rows.Clear();
- DataGridViewRow row = new DataGridViewRow();
- DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeA;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- row = new DataGridViewRow();
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeB;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- row = new DataGridViewRow();
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeC;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- }
- else if (this.operation == 1)
- {
- if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeC))
- {
- GetDataTable();
- }
- else
- {
- dataGridView1.Rows.Clear();
- DataGridViewRow row = new DataGridViewRow();
- DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeA;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- row = new DataGridViewRow();
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeB;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- row = new DataGridViewRow();
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeC;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- }
- }
- }
- }
- private void radioButton4_CheckedChanged(object sender, EventArgs e)
- {
- if (this.radioButton4.Checked && this.groupBox3.Enabled)
- {
- if (this.operation == 0)
- {
- dataGridView1.Rows.Clear();
- DataGridViewRow row = new DataGridViewRow();
- DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeA;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- row = new DataGridViewRow();
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeB;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- row = new DataGridViewRow();
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeC;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- row = new DataGridViewRow();
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeD;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- }
- else if (this.operation == 1)
- {
- if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeD))
- {
- GetDataTable();
- }
- else
- {
- dataGridView1.Rows.Clear();
- DataGridViewRow row = new DataGridViewRow();
- DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeA;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- row = new DataGridViewRow();
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeB;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- row = new DataGridViewRow();
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeC;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- row = new DataGridViewRow();
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeD;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- }
- }
- }
- }
- private void radioButton5_CheckedChanged(object sender, EventArgs e)
- {
- if (this.radioButton5.Checked && this.groupBox3.Enabled)
- {
- if (this.operation == 0)
- {
- dataGridView1.Rows.Clear();
- DataGridViewRow row = new DataGridViewRow();
- DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeA;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- row = new DataGridViewRow();
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeB;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- }
- else if (this.operation == 1)
- {
- if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeE))
- {
- GetDataTable();
- }
- else
- {
- dataGridView1.Rows.Clear();
- DataGridViewRow row = new DataGridViewRow();
- DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeA;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- row = new DataGridViewRow();
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeB;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- }
- }
- }
- }
- /// <summary>
- /// 编辑的工件内容
- /// </summary>
- private void GetDataTable()
- {
- this.dataGridView1.Rows.Clear();
- for (int r = 0; r < this.DataTable.Rows.Count; r++)
- {
- DataGridViewRow dgvr = new DataGridViewRow();
- foreach (DataGridViewColumn Column in this.dataGridView1.Columns)
- {
- dgvr.Cells.Add(Column.CellTemplate.Clone() as DataGridViewCell);
- }
- for (int c = 0; c < DataTable.Columns.Count; c++)
- {
- dgvr.Cells[c].Value = this.DataTable.Rows[r][c].ToString();
- }
- this.dataGridView1.Rows.Add(dgvr);
- }
- }
- #endregion
- /// <summary>
- /// 选中工件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name=e></param>
- private void dataGridView2_SelectionChanged(object sender, EventArgs e)
- {
- if (this.dataGridView2.SelectedRows.Count > 0)
- {
- this.groupBox3.Enabled = false;
- dataGridView1.Rows.Clear();
- this.groupBox3.Show();
- this.textBox1.Text = this.dataGridView2.SelectedRows[0].Cells[0].Value.ToString();
- int rowNum = 0;
- if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeA))
- {
- this.radioButton1.Checked = true;
- rowNum = 3;
- }
- else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeB))
- {
- this.radioButton2.Checked = true;
- rowNum = 6;
- }
- else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeC))
- {
- this.radioButton3.Checked = true;
- rowNum = 9;
- }
- else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeD))
- {
- this.radioButton4.Checked = true;
- rowNum = 12;
- }
- else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeE))
- {
- this.radioButton5.Checked = true;
- rowNum = 6;
- }
- for (int i = 2; i < rowNum + 2; i += 3)
- {
- DataGridViewRow row = new DataGridViewRow();
- DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = this.dataGridView2.SelectedRows[0].Cells[i].Value;
- row.Cells.Add(textboxcell);
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = this.dataGridView2.SelectedRows[0].Cells[i + 1].Value;
- row.Cells.Add(textboxcell);
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = this.dataGridView2.SelectedRows[0].Cells[i + 2].Value;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- }
- }
- }
- /// <summary>
- /// 工件删除
- /// </summary>
- /// <param name="sender"></param>
- /// <param name=constTypeE></param>
- private void button6_Click(object sender, EventArgs e)
- {
- this.operation = -1;
- if(this.dataGridView2.Rows.Count == 0)
- {
- MessageBox.Show(PdnResources.GetString("Menu.Noartifacts.text")+"!");
- }
- else
- {
- if (this.dataGridView2.SelectedRows.Count > 0)
- {
- DialogResult dr = MessageBox.Show(PdnResources.GetString("Menu.Areyousureartifact?.text")+"?", PdnResources.GetString("Menu.hint.text"), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
- if (dr == DialogResult.OK)
- {
- this.dataGridView2.Rows.Remove(this.dataGridView2.SelectedRows[0]);
- SaveToConfigurationFile();
- RecombinationRateDialog recombinationRateDialog = (RecombinationRateDialog)this.Owner;
- if(this.dataGridView2.Rows.Count > 0 && this.dataGridView2.SelectedRows.Count > 0)
- recombinationRateDialog.selectItemValue = this.dataGridView2.SelectedRows[0].Cells[0].Value.ToString();
- recombinationRateDialog.RefreshCombobox();
- InitGroupBox3();
- if(this.dataGridView2.Rows.Count > 0)
- {
- if (this.dataGridView2.SelectedRows.Count > 0)
- {
- this.groupBox3.Enabled = false;
- dataGridView1.Rows.Clear();
- this.groupBox3.Show();
- this.textBox1.Text = this.dataGridView2.SelectedRows[0].Cells[0].Value.ToString();
- int rowNum = 0;
- if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeA))
- {
- this.radioButton1.Checked = true;
- rowNum = 3;
- }
- else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeB))
- {
- this.radioButton2.Checked = true;
- rowNum = 6;
- }
- else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeC))
- {
- this.radioButton3.Checked = true;
- rowNum = 9;
- }
- else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeD))
- {
- this.radioButton4.Checked = true;
- rowNum = 12;
- }
- else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeE))
- {
- this.radioButton5.Checked = true;
- rowNum = 6;
- }
- for (int i = 2; i < rowNum + 2; i += 3)
- {
- DataGridViewRow row = new DataGridViewRow();
- DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = this.dataGridView2.SelectedRows[0].Cells[i].Value;
- row.Cells.Add(textboxcell);
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = this.dataGridView2.SelectedRows[0].Cells[i + 1].Value;
- row.Cells.Add(textboxcell);
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = this.dataGridView2.SelectedRows[0].Cells[i + 2].Value;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- }
- }
- else
- {
- this.groupBox3.Enabled = false;
- dataGridView1.Rows.Clear();
- this.groupBox3.Show();
- this.textBox1.Text = this.dataGridView2.Rows[0].Cells[0].Value.ToString();
- int rowNum = 0;
- if (this.dataGridView2.Rows[0].Cells[1].Value.Equals(constTypeA))
- {
- this.radioButton1.Checked = true;
- rowNum = 3;
- }
- else if (this.dataGridView2.Rows[0].Cells[1].Value.Equals(constTypeB))
- {
- this.radioButton2.Checked = true;
- rowNum = 6;
- }
- else if (this.dataGridView2.Rows[0].Cells[1].Value.Equals(constTypeC))
- {
- this.radioButton3.Checked = true;
- rowNum = 9;
- }
- else if (this.dataGridView2.Rows[0].Cells[1].Value.Equals(constTypeD))
- {
- this.radioButton4.Checked = true;
- rowNum = 12;
- }
- else if (this.dataGridView2.Rows[0].Cells[1].Value.Equals(constTypeE))
- {
- this.radioButton5.Checked = true;
- rowNum = 6;
- }
- for (int i = 2; i < rowNum + 2; i += 3)
- {
- DataGridViewRow row = new DataGridViewRow();
- DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = this.dataGridView2.Rows[0].Cells[i].Value;
- row.Cells.Add(textboxcell);
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = this.dataGridView2.Rows[0].Cells[i + 1].Value;
- row.Cells.Add(textboxcell);
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = this.dataGridView2.Rows[0].Cells[i + 2].Value;
- row.Cells.Add(textboxcell);
- dataGridView1.Rows.Add(row);
- }
- }
- }
- else
- {
- this.dataGridView1.Rows.Clear();
- }
- }
- }
- else
- {
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseselecttdelete.text")+"!");
- }
- }
- }
- /// <summary>
- /// 使用按钮
- /// </summary>
- /// <param name="sender"></param>
- /// <param name=constTypeE></param>
- private void button3_Click(object sender, EventArgs e)
- {
- bool success = false;
- if (this.operation == 0)
- {
- if (string.IsNullOrEmpty(this.textBox1.Text))
- MessageBox.Show(PdnResources.GetString("Menu.Pleaseenterthworkpiece.text")+"!");
- else
- {
- DataGridViewRow row = new DataGridViewRow();
- DataGridViewTextBoxCell textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = this.textBox1.Text;
- row.Cells.Add(textboxcell);
- if (this.radioButton1.Checked)
- {
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeA;
- row.Cells.Add(textboxcell);
- }
- else if (this.radioButton2.Checked)
- {
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeB;
- row.Cells.Add(textboxcell);
- }
- else if (this.radioButton3.Checked)
- {
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeC;
- row.Cells.Add(textboxcell);
- }
- else if (this.radioButton4.Checked)
- {
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeD;
- row.Cells.Add(textboxcell);
- }
- else if (this.radioButton5.Checked)
- {
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = constTypeE;
- row.Cells.Add(textboxcell);
- }
- for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
- {
- for (int j = 0; j < this.dataGridView1.Rows[i].Cells.Count; j++)
- {
- textboxcell = new DataGridViewTextBoxCell();
- textboxcell.Value = this.dataGridView1.Rows[i].Cells[j].Value;
- row.Cells.Add(textboxcell);
- }
- }
- bool canAdd = true;
- for (int i = 0; i < dataGridView2.Rows.Count; i++)
- {
- if (this.textBox1.Text.Equals(dataGridView2.Rows[i].Cells[0].Value))
- {
- MessageBox.Show(PdnResources.GetString("Menu.Namealreadyexists.text")+"!");
- canAdd = false;
- }
- }
- for (int i = 0; i < dataGridView1.Rows.Count; i++)
- {
- for (int j = 0; j < dataGridView1.Rows[i].Cells.Count; j++)
- {
- if (dataGridView1.Rows[i].Cells[j].Value == null)
- {
- if (j == 1)
- {
- canAdd = false;
- MessageBox.Show(PdnResources.GetString("Menu.Targetvaluecannotbeempty.text")+"!");
- dataGridView1.Rows[i].Cells[j].Style.BackColor = Color.Red;
- break;
- }
- else if (j == 2)
- {
- canAdd = false;
- MessageBox.Show(PdnResources.GetString("Menu.Errorcannotbeempty.text")+"!");
- dataGridView1.Rows[i].Cells[j].Style.BackColor = Color.Red;
- break;
- }
- }
- }
- }
- if (canAdd)
- {
- success = true;
- dataGridView2.Rows.Add(row);
- dataGridView2.Rows[dataGridView2.Rows.Count - 1].Selected = true;
- SaveToConfigurationFile();
- }
- }
- }
- else if (this.operation == 1)
- {
- bool canAdd = true;
- for (int i = 0; i < dataGridView2.Rows.Count; i++)
- {
- if (this.dataGridView2.SelectedRows[0].Index != i)
- {
- if (this.textBox1.Text.Equals(dataGridView2.Rows[i].Cells[0].Value))
- {
- MessageBox.Show(PdnResources.GetString("Menu.Namealreadyexists.text")+"!");
- canAdd = false;
- }
- }
- }
- for (int i = 0; i < dataGridView1.Rows.Count; i++)
- {
- for (int j = 0; j < dataGridView1.Rows[i].Cells.Count; j++)
- {
- if (dataGridView1.Rows[i].Cells[j].Value == null)
- {
- if (j == 1)
- {
- canAdd = false;
- MessageBox.Show(PdnResources.GetString("Menu.Targetvaluecannotbeempty.text")+"!");
- dataGridView1.Rows[i].Cells[j].Style.BackColor = Color.Red;
- break;
- }
- else if (j == 2)
- {
- canAdd = false;
- MessageBox.Show(PdnResources.GetString("Menu.Errorcannotbeempty.text")+"!");
- dataGridView1.Rows[i].Cells[j].Style.BackColor = Color.Red;
- break;
- }
- }
- }
- }
- if (canAdd)
- {
- success = true;
- this.dataGridView2.SelectedRows[0].Cells[0].Value = this.textBox1.Text;
- if (this.radioButton1.Checked)
- {
- this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeA;
- }
- else if (this.radioButton2.Checked)
- {
- this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeB;
- }
- else if (this.radioButton3.Checked)
- {
- this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeC;
- }
- else if (this.radioButton4.Checked)
- {
- this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeD;
- }
- else if (this.radioButton5.Checked)
- {
- this.dataGridView2.SelectedRows[0].Cells[1].Value = constTypeE;
- }
- int col = 2;
- for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
- {
- for (int j = 0; j < this.dataGridView1.Rows[i].Cells.Count; j++)
- {
- this.dataGridView2.SelectedRows[0].Cells[col].Value = this.dataGridView1.Rows[i].Cells[j].Value;
- col++;
- }
- }
- SaveToConfigurationFile();
- }
- }
- else
- {
- if (this.dataGridView2.SelectedRows.Count < 1)
- MessageBox.Show(PdnResources.GetString("Menu.heartifacttous.Text")+"!");
- else
- success = true;
- }
- if (success)
- {
- SaveToConfigurationFile();
- RecombinationRateDialog recombinationRateDialog = (RecombinationRateDialog)this.Owner;
- recombinationRateDialog.selectItemValue = this.dataGridView2.SelectedRows[0].Cells[0].Value.ToString();
- recombinationRateDialog.RefreshCombobox();
- this.Close();
- }
- }
- /// <summary>
- /// 编辑工件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e)
- {
- if (this.operation == 1)
- {
- if (this.dataGridView2.Rows.Count > 0)
- {
- if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeA) && this.radioButton1.Checked)
- {
- SaveDataTable();
- }
- else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeB) && this.radioButton2.Checked)
- {
- SaveDataTable();
- }
- else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeC) && this.radioButton3.Checked)
- {
- SaveDataTable();
- }
- else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeD) && this.radioButton4.Checked)
- {
- SaveDataTable();
- }
- else if (this.dataGridView2.SelectedRows[0].Cells[1].Value.Equals(constTypeE) && this.radioButton5.Checked)
- {
- SaveDataTable();
- }
- }
- }
- }
- /// <summary>
- /// 保持到table
- /// </summary>
- private void SaveDataTable()
- {
- this.DataTable = new DataTable();
- foreach (DataGridViewColumn c in this.dataGridView1.Columns)
- {
- this.DataTable.Columns.Add(c.HeaderText);
- }
- for (int r = 0; r < this.dataGridView1.Rows.Count; r++)
- {
- DataRow dataRow = this.DataTable.NewRow();
- for (int c = 0; c < this.dataGridView1.Rows[r].Cells.Count; c++)
- {
- dataRow[this.dataGridView1.Columns[c].HeaderText] = this.dataGridView1.Rows[r].Cells[c].Value;
- }
- this.DataTable.Rows.Add(dataRow);
- }
- }
- }
- }
|