public Configuration getConfiguration(String tool, String part)
        {
            Configuration config = new Configuration();

            using (SQLiteConnection conn = new SQLiteConnection(connString))
            {
                StringBuilder query = new StringBuilder();
                query.Append("SELECT ");
                query.Append("program,part,tool,leak1,leak2,leak3,leak4,flow1,flow2,flow3,flow4,lotsize ");
                query.Append("FROM torch_settings WHERE ");
                query.Append("tool = @1 and part = @2 ORDER BY program");
                //MessageBox.Show(query.ToString());
                using (SQLiteCommand cmd = new SQLiteCommand(query.ToString(), conn))
                {
                    conn.Open();
                    SQLiteCommand command = conn.CreateCommand();
                    command.CommandText = query.ToString();
                    SQLiteParameter prm_tool = new SQLiteParameter();
                    prm_tool.ParameterName = "@1";
                    prm_tool.Value = tool;

                    SQLiteParameter prm_part = new SQLiteParameter();
                    prm_part.ParameterName = "@2";
                    prm_part.Value = part;
                    command.Parameters.Add(prm_tool);
                    command.Parameters.Add(prm_part);
                    SQLiteDataReader reader = command.ExecuteReader();

                    if (reader.HasRows)
                    {
                        while (reader.Read())
                        {
                            config.program = reader[0].ToString();
                            config.part = reader[1].ToString();
                            config.tool = reader[2].ToString();
                            config.leak1 = reader[3].ToString();
                            config.leak2 = reader[4].ToString();
                            config.leak3 = reader[5].ToString();
                            config.leak4 = reader[6].ToString();
                            config.flow1 = reader[7].ToString();
                            config.flow2 = reader[8].ToString();
                            config.flow3 = reader[9].ToString();
                            config.flow4 = reader[10].ToString();
                            config.lotsize = reader[11].ToString();

                        }
                    }

                    reader.Close();
                }
            }

            return config;
            //result = s == null || s == String.Empty;
        }
        private void bVerify_Click(object sender, EventArgs e)
        {
            Configuration data = new Configuration();
            data.program = tProgramNo.Text;
            data.part = tPartNo.Text;
            data.tool = tToolNo.Text;
            data.leak1 = tLeak1.Text;
            data.leak2 = tLeak2.Text;
            data.leak3 = tLeak3.Text;
            data.leak4 = tLeak4.Text;
            data.flow1 = tFlow1.Text;
            data.flow2 = tFlow2.Text;
            data.flow3 = tFlow3.Text;
            data.flow4 = tFlow4.Text;
            data.lotsize = txtLotSize.Text;

            tData.Add(data);
            data_new.Add(data);

            dataGridControl.EndEdit();
            dataGridControl.DataSource = null;
            dataGridControl.DataSource = tData;
        }
        private void setup()
        {
            List<List<String>> d = new List<List<String>>();
            d = conf.get_all();

            foreach (List<String> l in d)
            {
                Configuration data = new Configuration();
                data.program = l[0];
                data.part = l[1];
                data.tool = l[2];
                data.leak1 =l[3];
                data.leak2 = l[4];
                data.leak3 = l[5];
                data.leak4 = l[6];
                data.flow1 = l[7];
                data.flow2 = l[8];
                data.flow3 = l[9];
                data.flow4 = l[10];
                data.lotsize = l[11];
                tData.Add(data);
            }
            dataGridControl.DataSource = null;
            dataGridControl.DataSource = tData;
        }
        private void new_test()
        {
            if (current_test_number == NULL_PROG_NUMBER)
            {
                Configuration configuration;
                while (true)
                {
                    String tool = "";
                    String temp = "";
                    String part = "";

                    if (InputDialogBox.Show("Part",
                        "&Enter or Scan Part Number(Type 'exit' to exit, or enter Password)", ref temp) == DialogResult.OK)
                    {

                        int index = temp.IndexOf("*");
                        part  = index >= 0 ? temp.Substring(0, index) : temp;
                    }

                    if (temp == "exit")
                    {
                        Environment.Exit(0);
                    } else if (temp == "configure") {
                        frmConfig frm = new frmConfig();
                        frm.ShowDialog();
                    }

                    temp = "";

                    if (InputDialogBox.Show("tool",
                        "&Enter tool (Type 'exit' in the box to exit):", ref temp) == DialogResult.OK)
                    {
                        int index = temp.IndexOf("*");
                        tool = index >= 0 ? temp.Substring(0, index) : temp;
                    }
                    if (temp == "exit")
                    {
                        Environment.Exit(0);
                    } else if (temp == "configure") {
                        frmConfig frm = new frmConfig();
                        frm.ShowDialog();
                    }

                    if (!(tool == null || tool == String.Empty) &&
                        !(part == null || part == String.Empty))
                    {
                        configuration = DATABASE.getConfiguration(tool, part);
                        if (configuration.program == null || configuration.program == String.Empty) {
                            MessageBox.Show("No configuration exists with those parameters. Please Scan again");
                            continue;
                        }
                        CURRENT_RUNNING_CONFIG = configuration;

                        break;
                    }
                }
                //Done loop
            }
            //done checking if null test.
            String pgm = CURRENT_RUNNING_CONFIG.program;
            txtLotSize.Text = CURRENT_RUNNING_CONFIG.lotsize;
            TESTS_IN_LOT = int.Parse(CURRENT_RUNNING_CONFIG.lotsize);
            change_program(pgm);
            //comOptions.comPort.Write("M\\S1TCAP="+pgm + ENDL);
        }
        public void reset()
        {
            TESTS_IN_LOT = int.Parse(txtLotSize.Text);

            bmpBlank = new Bitmap(Torch2.Properties.Resources.blank);
            bmpFail = new Bitmap(Torch2.Properties.Resources.fail);
            bmpPass = new Bitmap(Torch2.Properties.Resources.pass);
            firstTests = true;
            RUNNING = false;
            READY_TO_TEST = true;
            failures = false;
            testResults = new Dictionary<int, double>();
            runResults = new Dictionary<int, double>();
            runResultsDates = new Dictionary<int, string>();
            queue = new List<List<string>>();
            thresholds = new List<double>();
            lotFailures = new List<int>();

            BUFFER = "";
            testNumber = 0;

            NULL_PROG = "M\\S1TCAP=" + NULL_PROG_NUMBER.ToString() + ENDL;
            current_test_number = NULL_PROG_NUMBER;
            CURRENT_RUNNING_CONFIG = null;
        }