public static Dye GetbyName(string dyeCode) { try { using (SQLiteConnection conn = new SQLiteConnection("Data Source=" + m_filePath)) { conn.Open(); SQLiteCommand cmd = conn.CreateCommand(); cmd.CommandText = "SELECT * FROM [" + m_tableName + "] where DyeCode=@DyeCode;"; cmd.Parameters.Add(new SQLiteParameter("DyeCode", dyeCode)); SQLiteDataReader dr = cmd.ExecuteReader(); if (dr.Read()) { Dye d = new Dye(dr.GetString(0), (DyeType)dr.GetInt32(1), dr.GetString(2), dr.GetInt32(3)); return(d); } else { return(null); } } } catch (Exception) { return(null); } }
public static List <string> GetNamesByType(DyeType dt) { try { using (SQLiteConnection conn = new SQLiteConnection("Data Source=" + m_filePath)) { conn.Open(); SQLiteCommand cmd = conn.CreateCommand(); int intUT = (int)dt; cmd.CommandText = "SELECT * FROM [" + m_tableName + "] where DyeType=" + intUT.ToString() + ";"; SQLiteDataReader dr = cmd.ExecuteReader(); List <string> dyeCodes = new List <string>(); while (dr.Read()) { Dye d = new Dye(dr.GetString(0), (DyeType)dr.GetInt32(1), dr.GetString(2), dr.GetInt32(3)); dyeCodes.Add(d.DyeCode); } return(dyeCodes); } } catch (Exception) { return(null); } }
public static bool Update(Dye dye) { try { using (SQLiteConnection conn = new SQLiteConnection("Data Source=" + m_filePath)) { conn.Open(); SQLiteCommand cmd = conn.CreateCommand(); cmd.CommandText = "update [" + m_tableName + "] set DyeType=@DyeType, DyeName=@DyeName, DyeValve=@DyeValve where DyeCode=@DyeCode;"; cmd.Parameters.Add(new SQLiteParameter("DyeCode", dye.DyeCode)); cmd.Parameters.Add(new SQLiteParameter("DyeType", dye.DyeType)); cmd.Parameters.Add(new SQLiteParameter("DyeName", dye.DyeName)); cmd.Parameters.Add(new SQLiteParameter("DyeValve", dye.DyeValve)); int i = cmd.ExecuteNonQuery(); return(i == 1); } } catch (Exception) { return(false); } }
public static List <Dye> GetAllDyes(DyeType dt) { try { using (SQLiteConnection conn = new SQLiteConnection("Data Source=" + m_filePath)) { conn.Open(); SQLiteCommand cmd = conn.CreateCommand(); cmd.CommandText = "SELECT * FROM [" + m_tableName + "] where DyeType = @DyeType;"; cmd.Parameters.Add(new SQLiteParameter("DyeType", dt)); SQLiteDataReader dr = cmd.ExecuteReader(); List <Dye> dyes = new List <Dye>(); while (dr.Read()) { Dye d = new Dye(dr.GetString(0), (DyeType)dr.GetInt32(1), dr.GetString(2), dr.GetInt32(3)); dyes.Add(d); } return(dyes); } } catch (Exception) { return(null); } }
public Order(string orderID, float liquorRatio1, int yarnCount, string machineCode, string colorNumber, int creelCount, float yarnWeight, float liquorRatio2, float waterWeight, string prescriptionCode, string pat, string storTime, int stepCount, string[] stepCodes, int prescriptionCount, string[] dyeCodes, float[] density ) { m_orderID = orderID; m_liquorRatio1 = liquorRatio1; m_yarnCount = yarnCount; m_machineCode = machineCode; m_colorNumber = colorNumber; m_creelCount = creelCount; m_yarnWeight = yarnWeight; m_liquorRatio2 = liquorRatio2; m_waterWight = waterWeight; m_prescriptionCode = prescriptionCode; m_pattern = pat; m_storeTime = storTime; m_stepCount = stepCount; for (int i = 0; i < m_stepCount; i++) { m_stepCodes[i] = stepCodes[i]; } m_prescriptionCount = prescriptionCount; for (int i = 0; i < m_prescriptionCount; i++) { m_dyeCodes[i] = dyeCodes[i]; m_density[i] = density[i]; m_weight[i] = (int)(m_density[i] * m_liquorRatio2 * m_yarnWeight); Dye dye = DyeDB.GetRecord(m_dyeCodes[i]); if (dye != null) { m_dyeNames[i] = dye.DyeName; m_valve[i] = dye.DyeValve; } } m_elements = new List <TableElement>(); m_elements.Add(new TableElement("OrderID", m_orderID)); m_elements.Add(new TableElement("LiquorRatio1", m_liquorRatio1)); m_elements.Add(new TableElement("YarnCount", m_yarnCount)); m_elements.Add(new TableElement("MachineCode", m_machineCode)); m_elements.Add(new TableElement("ColorNumber", m_colorNumber)); m_elements.Add(new TableElement("CreelCount", m_creelCount)); m_elements.Add(new TableElement("YarnWeight", m_yarnWeight)); m_elements.Add(new TableElement("LiquorRatio2", m_liquorRatio2)); m_elements.Add(new TableElement("WaterWeight", m_waterWight)); m_elements.Add(new TableElement("PrescriptionCode", m_prescriptionCode)); m_elements.Add(new TableElement("Pattern", m_pattern)); m_elements.Add(new TableElement("StoreTime", m_storeTime)); m_elements.Add(new TableElement("StepCount", m_stepCount)); for (int i = 0; i < m_stepCount; i++) { int index = i + 1; m_elements.Add(new TableElement("StepCode" + index.ToString(), m_stepCodes[i])); } for (int i = m_stepCount; i < MAX_STEP_COUNT; i++)//填充 { int index = i + 1; m_elements.Add(new TableElement("StepCode" + index.ToString(), "")); } m_elements.Add(new TableElement("PrescriptionCount", m_prescriptionCount)); for (int i = 0; i < m_prescriptionCount; i++) { int index = i + 1; m_elements.Add(new TableElement("DyeCode" + index.ToString(), m_dyeCodes[i])); m_elements.Add(new TableElement("Density" + index.ToString(), m_density[i])); } for (int i = m_prescriptionCount; i < MAX_PRESCRIPTION_COUNT; i++)//填充 { int index = i + 1; m_elements.Add(new TableElement("DyeCode" + index.ToString(), "")); m_elements.Add(new TableElement("Density" + index.ToString(), 0.0f)); } }