Exemple #1
0
        // TODO: ja - move to Config??
        private void GetLabelTypesFromDataBase()
        {
            string ConnectionString = ConfigValues.GetConnectionString();

            SqlDataReader myReader      = null;
            SqlConnection TheConnection = null;

            try
            {
                string sPartNumber  = GetPartNumber();
                string sPartVersion = GetPartVersion();

                TheConnection = new SqlConnection(ConnectionString);

                // TEMP
                //MessageBox.Show(ConnectionString);

                TheConnection.Open();

                // ja - get the label information from the database view
                SqlCommand myCommand = new SqlCommand("select * from label_Data where Part_Number = '" + sPartNumber + "' and Part_Version = '" + sPartVersion + "'", TheConnection);
                myReader = myCommand.ExecuteReader();

                // ja - loop through all of the assigned label types
                while (myReader.Read())
                {
                    // ja - get the information from the database
                    string sLocation     = myReader["Location_Name"].ToString();
                    string sType         = myReader["Label_Type_Name"].ToString();
                    string sQty          = myReader["Print_Qty"].ToString();
                    string sCustomerName = myReader["Customer_Name"].ToString();

                    int nRow = dataGridView1.Rows.Add();

                    dataGridView1.Rows[nRow].Cells[0].Value = true;
                    dataGridView1.Rows[nRow].Cells[1].Value = sLocation;
                    dataGridView1.Rows[nRow].Cells[2].Value = sType;
                    dataGridView1.Rows[nRow].Cells[3].Value = sQty;
                    dataGridView1.Rows[nRow].Cells[4].Value = sCustomerName;
                }

                myReader.Close();
                TheConnection.Close();
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.ToString());
                myReader.Close();
                TheConnection.Close();
            }
        }