public static bool Insert(YouCom.DTO.Servicio.ServiciosDTO myServiciosDTO) { bool retorno = false; YouCom.Service.BD.SQLHelper wobjSQLHelper = new YouCom.Service.BD.SQLHelper(); DataTable pobjDataTable = new DataTable(); try { //Seteo Parámetros. //==================================================================================== wobjSQLHelper.SetParametro("@pIdCondominio", SqlDbType.Decimal, -1, myServiciosDTO.TheCondominioDTO.IdCondominio); wobjSQLHelper.SetParametro("@pIdComunidad", SqlDbType.Decimal, -1, myServiciosDTO.TheComunidadDTO.IdComunidad); wobjSQLHelper.SetParametro("@pNombreServicio", SqlDbType.VarChar, 200, myServiciosDTO.NombreServicio); wobjSQLHelper.SetParametro("@pDescripcionServicio", SqlDbType.Text, -1, myServiciosDTO.DescripcionServicio); wobjSQLHelper.SetParametro("@pIdCategoria", SqlDbType.Decimal, -1, myServiciosDTO.TheCategoriaDTO.IdCategoria); wobjSQLHelper.SetParametro("@pFechaInicio", SqlDbType.DateTime, -1, myServiciosDTO.FechaInicio); wobjSQLHelper.SetParametro("@pFechaTermino", SqlDbType.DateTime, -1, myServiciosDTO.FechaTermino); wobjSQLHelper.SetParametro("@pImagenServicio", SqlDbType.VarChar, 200, myServiciosDTO.ImagenServicio); wobjSQLHelper.SetParametro("@pUsuarioIngreso", SqlDbType.VarChar, 20, myServiciosDTO.UsuarioIngreso); wobjSQLHelper.SetParametroOut("@identity", SqlDbType.BigInt, -1); if (wobjSQLHelper.Ejecutar("INS_Servicio", "YouCom", pobjDataTable) <= 0) { myServiciosDTO.IdServicio = decimal.Parse(wobjSQLHelper.GetParametro("@identity").ToString()); } //==================================================================================== retorno = true; } #region Catch catch (Exception eobjException) { throw eobjException; } #endregion return(retorno); }
public static bool Insert(YouCom.DTO.AccesoHogar.AccesoHogarDTO myAccesoHogarDTO) { bool retorno = false; YouCom.Service.BD.SQLHelper wobjSQLHelper = new YouCom.Service.BD.SQLHelper(); try { //Seteo Parámetros. //==================================================================================== wobjSQLHelper.SetParametro("@pIdCasa", SqlDbType.Decimal, -1, myAccesoHogarDTO.TheCasaDTO.IdCasa); wobjSQLHelper.SetParametro("@pIdTipoVisita", SqlDbType.Decimal, -1, myAccesoHogarDTO.TheTipoVisitaDTO.IdTipoVisita); wobjSQLHelper.SetParametro("@pIdFrecuencia", SqlDbType.Decimal, -1, myAccesoHogarDTO.TheFrecuenciaDTO.IdFrecuencia); wobjSQLHelper.SetParametro("@pIdFamilia", SqlDbType.Decimal, -1, myAccesoHogarDTO.TheFamiliaDTO.IdFamilia); wobjSQLHelper.SetParametro("@pFechaInicio", SqlDbType.DateTime, -1, myAccesoHogarDTO.FechaInicio); wobjSQLHelper.SetParametro("@pFechaTermino", SqlDbType.DateTime, -1, myAccesoHogarDTO.FechaTermino); wobjSQLHelper.SetParametro("@pHoraInicio", SqlDbType.VarChar, -1, myAccesoHogarDTO.HoraInicio); wobjSQLHelper.SetParametro("@pHoraTermino", SqlDbType.VarChar, -1, myAccesoHogarDTO.HoraTermino); wobjSQLHelper.SetParametro("@pNombreVisita", SqlDbType.VarChar, 200, myAccesoHogarDTO.NombreVisita); wobjSQLHelper.SetParametro("@pApellidoPaternoVisita", SqlDbType.VarChar, 200, myAccesoHogarDTO.ApellidoPaternoVisita); wobjSQLHelper.SetParametro("@pApellidoMaternoVisita", SqlDbType.VarChar, 200, myAccesoHogarDTO.ApellidoMaternoVisita); wobjSQLHelper.SetParametro("@pRutVisita", SqlDbType.VarChar, 20, myAccesoHogarDTO.RutVisita); wobjSQLHelper.SetParametro("@pEmailVisita", SqlDbType.VarChar, 200, myAccesoHogarDTO.EmailVisita); wobjSQLHelper.SetParametro("@pAvisar", SqlDbType.Char, 2, myAccesoHogarDTO.Avisar); wobjSQLHelper.SetParametro("@pUsuarioIngreso", SqlDbType.VarChar, 20, myAccesoHogarDTO.UsuarioIngreso); wobjSQLHelper.SetParametro("@pIdCondominio", SqlDbType.Decimal, -1, myAccesoHogarDTO.TheCondominioDTO.IdCondominio); wobjSQLHelper.SetParametro("@pIdComunidad", SqlDbType.Decimal, -1, myAccesoHogarDTO.TheComunidadDTO.IdComunidad); wobjSQLHelper.SetParametroOut("@identity", SqlDbType.Decimal, -1); //==================================================================================== //Ejecuto SP. //==================================================================================== switch (wobjSQLHelper.EjecutarNQ("INS_AccesoHogar", "YouCom")) { case 0: throw new Exception("No se pudo grabar."); case -1: throw new Exception("Hubo un error."); case -2: throw new Exception("Hubo un error."); } //==================================================================================== myAccesoHogarDTO.IdAccesoHogar = decimal.Parse(wobjSQLHelper.GetParametro("@identity").ToString()); retorno = true; } #region Catch catch (Exception eobjException) { throw eobjException; } #endregion return(retorno); }