示例#1
0
        public Outcome GetOutcomeById(int id, string lang)
        {
            var outcome = new Outcome();
            string commandText = "SELECT DISTINCT OUTCOME_LX_ID, OUTCOME_CODE, ";
            if (lang.Equals("fr"))
            {
                commandText += " FR_DESC as OUTCOME,";

            }
            else
            {
                commandText += " EN_DESC as OUTCOME";

            }
            commandText += " FROM CVPONL_OWNER.OUTCOME_LX WHERE OUTCOME_LX_ID = " + 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 Outcome();
                                item.outcome_id = dr["OUTCOME_LX_ID"] == DBNull.Value ? 0 : Convert.ToInt32(dr["OUTCOME_LX_ID"]);
                                item.outcome_code = dr["OUTCOME_CODE"] == DBNull.Value ? string.Empty : dr["OUTCOME_CODE"].ToString().Trim();
                                item.outcome_name = dr["OUTCOME"] == DBNull.Value ? string.Empty : dr["OUTCOME"].ToString().Trim();

                                outcome = item;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    string errorMessages = string.Format("DbConnection.cs - GetOutcomeById()");
                    ExceptionHelper.LogException(ex, errorMessages);
                    Console.WriteLine(errorMessages);
                }
                finally
                {
                    if (con.State == ConnectionState.Open)
                        con.Close();
                }
            }
            return outcome;
        }
示例#2
0
 public Outcome Get(int id, string lang)
 {
     _outcome = dbConnection.GetOutcomeById(id, lang);
     return _outcome;
 }