123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734 |
- 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)
- {
- dataGridView2_SelectionChanged(null, null);
- 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();
- if (this.DataTable == null)
- {
- return;
- }
- 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);
- }
- }
- }
- }
|