コード例 #1
0
 public DrugVeterinarySpecies Get(int id, string lang)
 {
     _veterinarySpecies = dbConnection.GetDrugVeterinarySpeciesByDrugCode(id, lang);
     return _veterinarySpecies;
 }
コード例 #2
0
ファイル: DBConnection.cs プロジェクト: hres/api-dpd
 public DrugVeterinarySpecies GetDrugVeterinarySpeciesByDrugCode(int id, string lang)
 {
     var veterinarySpecies = new DrugVeterinarySpecies();
     string commandText = "SELECT * FROM DPD_ONLINE_OWNER.WQRY_VETERINARY_SPECIES WHERE DRUG_CODE = " + id;
     using (
     OracleConnection con = new OracleConnection(DpdDBConnection))
     {
         OracleCommand cmd = new OracleCommand(commandText, con);
         try
         {
             con.Open();
             using (OracleDataReader dr = cmd.ExecuteReader())
             {
                 if (dr.HasRows)
                 {
                     while (dr.Read())
                     {
                         var item = new DrugVeterinarySpecies();
                         item.drug_code = dr["DRUG_CODE"] == DBNull.Value ? 0 : Convert.ToInt32(dr["DRUG_CODE"]);
                         item.vet_species_code = dr["VET_SPECIES_CODE"] == DBNull.Value ? 0 : Convert.ToInt32(dr["VET_SPECIES_CODE"]);
                         if (lang.Equals("fr"))
                         {
                             item.vet_species_name = dr["VET_SPECIES_F"] == DBNull.Value ? string.Empty : dr["VET_SPECIES_F"].ToString().Trim();
                         }
                         else
                         {
                             item.vet_species_name = dr["VET_SPECIES"] == DBNull.Value ? string.Empty : dr["VET_SPECIES"].ToString().Trim();
                         }
                         veterinarySpecies = item;
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             string errorMessages = string.Format("DbConnection.cs - GetDrugVeterinarySpeciesByDrugCode()");
             ExceptionHelper.LogException(ex, errorMessages);
         }
         finally
         {
             if (con.State == ConnectionState.Open)
                 con.Close();
         }
     }
     return veterinarySpecies;
 }