Esempio n. 1
0
        public LicenceType Get(string code, string lang = "")
        {
            DBConnection dbConnection = new DBConnection(lang);

            _licenceType = dbConnection.GetLicenceTypeByCode(code);
            return(_licenceType);
        }
Esempio n. 2
0
        public LicenceType GetLicenceTypeByCode(string code)
        {
            var type = new LicenceType();
            string commandText = "SELECT LICENCE_TYPE_CD, ";
            if (Lang.Equals("fr"))
            {
                commandText += " LICENCE_TYPE_DESC_F AS LICENCE_TYPE_DESC";
            }
            else {
                commandText += " LICENCE_TYPE_DESC_E AS LICENCE_TYPE_DESC";
            }
            commandText += " FROM PUB_ACS.PAS_LICENCE_TYPE";
            commandText += " WHERE LICENCE_TYPE_CD = '" + code.Trim() + "'";

            using ( OracleConnection con = new OracleConnection(MdallDBConnection))
            {
                OracleCommand cmd = new OracleCommand(commandText, con);
                try
                {
                    con.Open();
                    using (OracleDataReader dr = cmd.ExecuteReader())
                    {
                        if (dr.HasRows)
                        {
                            while (dr.Read())
                            {
                                var item = new LicenceType();
                                item.licence_type_cd = dr["LICENCE_TYPE_CD"] == DBNull.Value ? string.Empty : dr["LICENCE_TYPE_CD"].ToString().Trim();
                                item.licence_type_desc = dr["LICENCE_TYPE_DESC"] == DBNull.Value ? string.Empty : dr["LICENCE_TYPE_DESC"].ToString().Trim();

                                type = item;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    string errorMessages = string.Format("DbConnection.cs - GetLicenceTypeByCode()");
                    ExceptionHelper.LogException(ex, errorMessages);
                }
                finally
                {
                    if (con.State == ConnectionState.Open)
                        con.Close();
                }
            }
            return type;
        }
Esempio n. 3
0
 public LicenceType Get(string code, string lang = "")
 {
     DBConnection dbConnection = new DBConnection(lang);
     _licenceType = dbConnection.GetLicenceTypeByCode(code);
     return _licenceType;
 }