private void GetSpecialLabelTypesFromDataBase() { string ConnectionString = ConfigValues.GetConnectionString(); SqlDataReader myReader = null; SqlConnection TheConnection = null; try { TheConnection = new SqlConnection(ConnectionString); TheConnection.Open(); SqlCommand myCommand = new SqlCommand("select Condition_Name, Attribute_Value from part_flags where Part_Number = '" + PartNumber + "' and Part_Version = '" + PartVersion + "'", TheConnection); myReader = myCommand.ExecuteReader(); while (myReader.Read()) { string sCondition = myReader["Condition_Name"].ToString(); string sAttribute = myReader["Attribute_Value"].ToString(); // TODO: ja - store these in config? SpecialAttributes.Add(sCondition); } myReader.Close(); TheConnection.Close(); } catch (System.Exception ex) { Console.WriteLine(ex.ToString()); myReader.Close(); TheConnection.Close(); } }
// ja - new way .... // TODO: ja - move to new class? private void AssignLabelTypesFromDataBase() { string ConnectionString = ConfigValues.GetConnectionString(); SqlDataReader myReader = null; SqlConnection TheConnection = null; try { TheConnection = new SqlConnection(ConnectionString); TheConnection.Open(); // ja - get the label information from the database view SqlCommand myCommand = new SqlCommand("select * from label_Data where Part_Number = '" + PartNumber + "' and Part_Version = '" + PartVersion + "'", 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(); LabelTypes type = (LabelTypes)Enum.Parse(typeof(LabelTypes), sType); PrinterArea area = (PrinterArea)Enum.Parse(typeof(PrinterArea), sLocation); // ja - if the printer area matches the passed in area (Physical Printer) add to queue if (area == ePrinterArea) { LabelProperitys lp = new LabelProperitys { CustomerName = sCustomerName, LabelQuanity = Convert.ToInt32(sQty), AssingedLabel = type }; AssignedLabels.Add(lp); } } myReader.Close(); TheConnection.Close(); } catch (System.Exception ex) { Console.WriteLine(ex.ToString()); myReader.Close(); TheConnection.Close(); } }