Exemplo n.º 1
0
        //動態測試
        private void dynamic_test(int ChapterNunber)
        {
            string name  = chap_choise.SelectedItem.ToString();
            int    count = 1;

            try
            {
                //開excel
                /*---------------------------------------------------------*/

                OleDbConnection conn = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties='Excel 12.0 Xml;HDR=YES;IMEX=1'");
                DataSet         ds1  = new DataSet();
                DataTable       dt1  = new DataTable();
                conn.Open();
                OleDbDataAdapter da = new OleDbDataAdapter("Select * from [" + name + "$]", conn);
                da.Fill(ds1);
                dt1 = ds1.Tables[0];

                /*---------------------------------------------------------*/

                //判斷標題是否正確
                if (dt1.Rows[0][1].ToString() != "輸入編號" && dt1.Rows[0][2].ToString() != "儀器名稱" && dt1.Rows[0][3].ToString() != "使用函式" && dt1.Rows[0][4].ToString() != "參數" && dt1.Rows[0][5].ToString() != "腳位" && dt1.Rows[0][6].ToString() != "腳位連接的relay" && dt1.Rows[0][7].ToString() != "com1" && dt1.Rows[0][8].ToString() != "com2" && dt1.Rows[0][9].ToString() != "內容")
                {
                    MessageBox.Show("欄位標題錯誤");
                }
                //讀輸入資料
                for (int i = 1, j = -1, k = 0; !string.IsNullOrEmpty(dt1.Rows[i][3].ToString()); i++, k++)
                {
                    if (!string.IsNullOrEmpty(dt1.Rows[i][1].ToString()))
                    {
                        ++j;
                        //紀錄幾個輸入
                        inputData[j] = new InputData(Int32.Parse(dt1.Rows[i][1].ToString()));
                        inputData[j].SetData(dt1.Rows[i][2].ToString(), dt1.Rows[i][3].ToString(), dt1.Rows[i][9].ToString(), dt1.Rows[i][4].ToString());
                        k = 0;
                    }
                    inputData[j].SetData(k, dt1.Rows[i][5].ToString(), dt1.Rows[i][6].ToString(), dt1.Rows[i][7].ToString(), dt1.Rows[i][8].ToString());
                    count++;
                    InputNumber = j + 1;
                }
                //讀取輸出在excel的欄位
                while (!dt1.Rows[count][1].ToString().Equals("測試編號"))
                {
                    count++;
                }
                if (dt1.Rows[count][1].ToString() != "測試編號" && dt1.Rows[count][2].ToString() != "輸入編號" && dt1.Rows[count][3].ToString() != "量測點A" && dt1.Rows[count][4].ToString() != "量測點B" && dt1.Rows[count][5].ToString() != "量測點A連結的relay" && dt1.Rows[count][6].ToString() != "COM1" && dt1.Rows[count][7].ToString() != "COM2" && dt1.Rows[count][8].ToString() != "量測點B連結的relay" && dt1.Rows[count][9].ToString() != "COM1" && dt1.Rows[count][10].ToString() != "COM2" && dt1.Rows[count][11].ToString() != "量測目的")
                {
                    MessageBox.Show("標題錯誤");
                }

                //讀取輸出欄位
                for (int j = 0; !string.IsNullOrEmpty(dt1.Rows[count][1].ToString()); count++, j++)
                {
                    for (int i = 0; i < 11; i++)
                    {
                        outputData[j, i] = dt1.Rows[count][i + 1].ToString();
                    }
                    TestNumber = j;
                }

                conn.Close();
            }
            catch (Exception x)
            {
                MessageBox.Show("錯誤" + x.ToString());
            }
            Form4 Form4 = new Form4(ChapterNunber, InputNumber, inputData, TestNumber, outputData);

            Form4.Visible = true;
            this.Hide();
        }
Exemplo n.º 2
0
        private void btn_lista_Click(object sender, EventArgs e)
        {
            Form4 formu4 = new Form4();

            formu4.ShowDialog();
        }
Exemplo n.º 3
0
        private void button3_Click(object sender, EventArgs e)
        {
            Form4 F4 = new Form4();

            F4.Show();
        }