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
{
///
/// 操作区分(0 :添加 1 :编辑)
///
private int operation = -1;
///
/// 配置文件
///
private WorkpieceMaintenanceModel workpieceMaintenanceModel;
///
/// 工件类型
///
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";
///
/// 编辑时的数据
///
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);
}
///
/// 初始化右侧编辑模块
///
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;
}
///
/// 保存工件到配置文件
///
private void SaveToConfigurationFile()
{
WorkpieceMaintenanceModel workpieceMaintenanceModel = new WorkpieceMaintenanceModel();
workpieceMaintenanceModel.Workpieces = new List();
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);
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"));
}
}
///
/// 从配置文件中读取工件信息
///
private void GetFromConfigurationFile()
{
workpieceMaintenanceModel = XmlSerializeHelper.DESerializer(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);
}
}
}
///
/// 工件添加按钮
///
///
///
private void button4_Click(object sender, EventArgs e)
{
this.operation = 0;
InitGroupBox3();
this.groupBox3.Show();
}
///
/// 工件编辑按钮
///
///
///
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")+"!");
}
}
}
///
/// 关闭按钮
///
///
///
private void button1_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 保存按钮
///
///
///
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);
}
}
}
}
///
/// 编辑的工件内容
///
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
///
/// 选中工件
///
///
///
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);
}
}
}
///
/// 工件删除
///
///
///
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")+"!");
}
}
}
///
/// 使用按钮
///
///
///
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();
}
}
///
/// 编辑工件
///
///
///
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();
}
}
}
}
///
/// 保持到table
///
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);
}
}
}
}