Ejemplo n.º 1
0
        private void  除机器ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < dataGridView1.SelectedRows.Count; i++)
            {
                int     id       = (int)dataGridView1.SelectedRows[i].Cells["id"].Value;
                Machine _machine = (from machine in MachineList
                                    where machine.id == id
                                    select machine).Single <Machine>();
                MachineList.Remove(_machine);
            }

            //List转换成Datatable
            DataTable dt = TableHelper.ToDataTable <Machine>(MachineList);

            dataGridView1.DataSource = dt;
        }
Ejemplo n.º 2
0
 private void button5_Click(object sender, EventArgs e)
 {
     if (dataGridView1.SelectedRows.Count >= 1)
     {
         for (int i = 0; i < dataGridView1.SelectedRows.Count; i++)
         {
             int     id       = (int)dataGridView1.SelectedRows[i].Cells["id"].Value;
             Machine _machine = (from machine in MachineList
                                 where machine.id == id
                                 select machine).Single <Machine>();
             _machine.ProductionCycle = (int)numericUpDown3.Value;
         }
         //List转换成Datatable
         DataTable dt = TableHelper.ToDataTable <Machine>(MachineList);
         dataGridView1.DataSource = dt;
     }
     else
     {
         MessageBox.Show("请选中要修改的机器");
     }
 }
Ejemplo n.º 3
0
        //新建机器
        private void button1_Click(object sender, EventArgs e)
        {
            Machine _machine = new Machine();

            _machine.IpAddress       = GetIP();
            _machine.ProductionCycle = (int)numericUpDown1.Value;
            _machine.isRun           = false;

            _machine.ParameterNames.Add("Parameter1");

            _machine.ParameterNames.Add("Parameter2");


            _machine.id   = machineID++;
            _machine.Name = textBox2.Text + _machine.id;
            MachineList.Add(_machine);

            //List转换成Datatable
            DataTable dt = TableHelper.ToDataTable <Machine>(MachineList);

            dataGridView1.DataSource                = dt;
            dataGridView1.Columns["id"].ReadOnly    = true;
            dataGridView1.Columns["isRun"].ReadOnly = true;
        }
Ejemplo n.º 4
0
        private void 载入机器列表ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.InitialDirectory = AppDomain.CurrentDomain.BaseDirectory + @"MachineConfig\";
            openFileDialog.Filter           = "xml配置文件|*.xml";
            openFileDialog.RestoreDirectory = true;
            openFileDialog.FilterIndex      = 1;
            if (openFileDialog.ShowDialog() == DialogResult.OK)
            {
                string     fName          = openFileDialog.FileName;
                List <int> GlobalVariable = new List <int>();
                XMLHelper.LoadMachineList(fName, out this.MachineList, out GlobalVariable);

                machineID  = GlobalVariable[0];
                firstByte  = GlobalVariable[1];
                secondByte = GlobalVariable[2];
                thirdByte  = GlobalVariable[3];
                fourByte   = GlobalVariable[4];

                DataTable dt = TableHelper.ToDataTable <Machine>(MachineList);
                dataGridView1.DataSource = dt;
            }
        }