コード例 #1
0
        public void SaveTestData(CTestDataCommon testData)
        {
            try
            {
                conn.Open();
            }
            catch (Exception ex)
            {
                throw new Exception($"Unable to open SQL Server connection, {ex.Message}");
            }
            try
            {
                cmd.Connection  = conn;
                cmd.Transaction = conn.BeginTransaction();
                var strSql = $"insert into dbo.tx_rftest_pam4_common(spec_id,sn,operator,test_station,test_date,vcc1,vcc2,ppg_data_rate,ppg_channel,ppg_pattern,pre_cursor, main_cusor, post_cusor, inner_1, inner_2, tx_tec, tx_vb, tx_vea, tx_vg, ld_bias,pf) values({testData.Spec_id}, '{testData.SN}','{testData.Operator}','{SystemInformation.ComputerName}','{testData.Test_Date}','{testData.Vcc1}','{testData.Vcc2}','{testData.Ppg_data_rate}','{testData.Ppg_channel}','{testData.Ppg_pattern}','{testData.Pre_cursor}','{testData.Main_cursor}','{testData.Post_cursor}','{testData.Inner_1}','{testData.Inner_2}' ,'{testData.TxTEC}','{testData.TxVB}','{testData.TxVEA}','{testData.TxVG}','{testData.LDBias}','{testData.Pf}')";
                cmd.CommandType = CommandType.Text;
                cmd.CommandText = strSql;
                cmd.ExecuteNonQuery();

                strSql          = $"select max(id) as id from dbo.tx_rftest_pam4_common";
                cmd.CommandText = strSql;

                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    testData.ID = Convert.ToInt32(reader["id"]);
                }
                reader.Close();
                for (int i = 0; i < testData.lstTestData.Count; i++)
                {
                    CTestData data = testData.lstTestData[i];
                    data.Common_id = testData.ID;
                    strSql         = $"insert into dbo.tx_rftest_pam4_ret(common_id, temp_case, test_start_time, test_end_time,io,ea_voltage,temp_coc,cwl,smsr,tdecq, outer_er, outer_oma,aop,linearity,pf) values({data.Common_id}, '{data.Temp_case}','{data.Test_start_time}','{data.Test_end_time}','{data.Io}','{data.EA_Voltage}','{data.Temp_Coc}','{data.CWL}','{data.SMSR}','{data.TDECQ}','{data.OuterER}','{data.OuterOMA}','{data.Lanch_power}','{data.Linearity}','{testData.Pf}')";

                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = strSql;
                    cmd.ExecuteNonQuery();
                }
                cmd.Transaction.Commit();
            }
            catch (Exception ex)
            {
                cmd.Transaction.Rollback();
                throw new Exception($"Fail to save test data, {ex.Message}");
            }
            finally
            {
                conn.Close();
            }
        }
コード例 #2
0
 private void LoadTestSpec(object sender, EventArgs e)
 {
     TestDataCommon = new CTestDataCommon();
     TestSpec       = new CTestSpec();
     this.lstViewTestData.Items.Clear();
     this.lstViewLog.Items.Clear();
     TestDataCommon.lstTestData.Clear();
     if (this.cbxPN.SelectedIndex != -1)
     {
         PN       = this.cbxPN.SelectedItem.ToString();
         TestSpec = db.GetTestSpec(PN);
         TestDataCommon.Spec_id = TestSpec.ID;
         ReadTestPlan(PN);
     }
 }