public DrugProductIngredient GetDrugProductIngredientById(int id, string lang) { var drugProductIngredient = new DrugProductIngredient(); string commandText = "SELECT * FROM CVPONL_OWNER.DRUG_PRODUCT_INGREDIENTS WHERE DRUG_PRODUCT_INGREDIENT_ID = " + id; //using (SqlConnection con = new SqlConnection(DpdDBConnection)) 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 DrugProductIngredient(); item.drug_product_ingredient_id = dr["DRUG_PRODUCT_INGREDIENT_ID"] == DBNull.Value ? 0 : Convert.ToInt32(dr["DRUG_PRODUCT_INGREDIENT_ID"]); item.drug_product_id = dr["DRUG_PRODUCT_ID"] == DBNull.Value ? 0 : Convert.ToInt32(dr["DRUG_PRODUCT_ID"]); item.product_id = dr["PRODUCT_ID"] == DBNull.Value ? 0 : Convert.ToInt32(dr["PRODUCT_ID"]); item.active_ingredient_id = dr["ACTIVE_INGREDIENT_ID"] == DBNull.Value ? 0 : Convert.ToInt32(dr["ACTIVE_INGREDIENT_ID"]); item.drug_name = dr["DRUGNAME"] == DBNull.Value ? string.Empty : dr["DRUGNAME"].ToString().Trim(); item.active_ingredient_name = dr["ACTIVE_INGREDIENT_NAME"] == DBNull.Value ? string.Empty : dr["ACTIVE_INGREDIENT_NAME"].ToString().Trim(); drugProductIngredient = item; } } } } catch (Exception ex) { string errorMessages = string.Format("DbConnection.cs - GetDrugProductIngredientById()"); ExceptionHelper.LogException(ex, errorMessages); Console.WriteLine(errorMessages); } finally { if (con.State == ConnectionState.Open) con.Close(); } } return drugProductIngredient; }
public DrugProductIngredient Get(int id, string lang) { _drugProductIngredient = dbConnection.GetDrugProductIngredientById(id, lang); return _drugProductIngredient; }
public DrugProductIngredient Get(Int64 id) { _drugProductIngredient = dbConnection.GetDrugProductIngredientById(id); return(_drugProductIngredient); }