Exemplo n.º 1
0
 public Schedule Get(int id, string lang)
 {
     _schedule = dbConnection.GetScheduleByDrugCode(id, lang);
     return _schedule;
 }
Exemplo n.º 2
0
 public Schedule GetScheduleByDrugCode(int id, string lang)
 {
     var schedule = new Schedule();
     string commandText = "SELECT * FROM DPD_ONLINE_OWNER.WQRY_SCHEDULE 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 Schedule();
                         item.drug_code = dr["DRUG_CODE"] == DBNull.Value ? 0 : Convert.ToInt32(dr["DRUG_CODE"]);
                         item.schedule_code = dr["SCHEDULE_CODE"] == DBNull.Value ? 0 : Convert.ToInt32(dr["SCHEDULE_CODE"]);
                         item.inactive_date = dr["INACTIVE_DATE"] == DBNull.Value ? (DateTime?)null : Convert.ToDateTime(dr["INACTIVE_DATE"]);
                         if (lang.Equals("fr"))
                         {
                             item.schedule_name = dr["SCHEDULE_F"] == DBNull.Value ? string.Empty : dr["SCHEDULE_F"].ToString().Trim();
                         }
                         else
                         {
                             item.schedule_name = dr["SCHEDULE"] == DBNull.Value ? string.Empty : dr["SCHEDULE"].ToString().Trim();
                         }
                         schedule = item;
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             string errorMessages = string.Format("DbConnection.cs - GetScheduleByDrugCode()");
             ExceptionHelper.LogException(ex, errorMessages);
         }
         finally
         {
             if (con.State == ConnectionState.Open)
                 con.Close();
         }
     }
     return schedule;
 }