/Docs/07-Implementacion/Source/trunk/EDUAR_Regular/EDUAR/EDUAR_DataAccess/Shared/DAConfiguracionGlobal.cs
http://blpm.googlecode.com/ · C# · 79 lines · 61 code · 9 blank · 9 comment · 3 complexity · 54880f9c0ef52d64726f646a21919450 MD5 · raw file
- using System;
- using System.Data;
- using System.Data.SqlClient;
- using EDUAR_Utility.Enumeraciones;
- using EDUAR_Utility.Excepciones;
-
- namespace EDUAR_DataAccess.Shared
- {
- /// <summary>
- /// Clase que contiene la logica de acceso a datos de las configuraciones.
- /// </summary>
- public class DAConfiguracionGlobal
- {
- #region --[Atributos]--
- private readonly DATransaction ObjDATransaction;
- private const string ClassName = "DAConfiguracionGlobal";
- #endregion
-
- #region --[Constructores]--
- public DAConfiguracionGlobal()
- {
- ObjDATransaction = new DATransaction();
- }
-
- public DAConfiguracionGlobal(DATransaction objDATransaction)
- {
- ObjDATransaction = objDATransaction;
- }
-
- #endregion
-
- #region --[Métodos Publicos]--
- /// <summary>
- /// Método que obtiene el valor de una configuracion en particular.
- /// </summary>
- /// <param name="configuracion">Enumeracion con la configuracion que se quiere buscar.</param>
- /// <returns>Valor de la configuracion</returns>
- public string GetConfiguracion(enumConfiguraciones configuracion)
- {
- try
- {
- string valor = string.Empty;
- const string query = @"SELECT
- IdConfiguracion
- ,Nombre
- ,Descripcion
- ,Valor
- FROM
- Configuraciones
- WHERE
- Nombre = @Nombre";
-
-
- ObjDATransaction.DBcomand = ObjDATransaction.DataBase.GetSqlStringCommand(query);
-
- // Ańadir parámetros
- ObjDATransaction.DataBase.AddInParameter(ObjDATransaction.DBcomand, "@Nombre", DbType.String, configuracion.ToString());
- DataSet ds = ObjDATransaction.Transaction != null
- ? ObjDATransaction.DataBase.ExecuteDataSet(ObjDATransaction.DBcomand,ObjDATransaction.Transaction)
- : ObjDATransaction.DataBase.ExecuteDataSet(ObjDATransaction.DBcomand);
-
- if (ds.Tables[0].Rows.Count != 0)
- valor = ds.Tables[0].Rows[0]["Valor"].ToString();
- return valor;
- }
- catch (SqlException ex)
- {
- throw new CustomizedException(string.Format("Fallo en {0} - GetConfiguracion()", ClassName),
- ex, enuExceptionType.SqlException);
- }
- catch (Exception ex)
- {
- throw new CustomizedException(string.Format("Fallo en {0} - GetConfiguracion()", ClassName),
- ex, enuExceptionType.DataAccesException);
- }
- }
- #endregion
- }
- }