Ejemplo n.º 1
0
        public static List <Listas.ListaSocioNegocio> ObtenerDatosSolicitud(string solicitud)
        {
            SqlConnection conexion = null;
            SqlDataReader reader   = null;
            SqlCommand    comando  = new SqlCommand();

            DatosSN.Clear();
            itemDatosSN = null;
            try
            {
                conexion            = Conexiones.ConexionSQL.ObtenerConexionSQL();
                comando.Connection  = conexion;
                comando.CommandText = @"SELECT TOP 1
                                                T3.firstName AS codigoAsistente ,
                                                CONCAT(T3.middleName, ' ', T3.lastName) AS NombrePromotor ,
                                                CASE WHEN T3.U_Esquema_pago LIKE '%SUELDO%' THEN 'SUELDO'
                                                     ELSE T3.U_Esquema_pago
                                                END AS Esquema
                                        FROM    dbo.OWTR T0
                                                INNER JOIN dbo.WTR1 T1 ON T0.DocEntry = T1.DocEntry
                                                INNER JOIN dbo.OSLP T2 ON T0.SlpCode = T2.SlpCode
                                                INNER JOIN dbo.OHEM T3 ON T2.SlpCode = T3.salesPrson
                                                INNER JOIN dbo.[@COMISIONES] T4 ON T4.U_Prefijo_Sol = SUBSTRING(T1.U_Serie,
                                                              1, 6)
                                        WHERE   T1.[U_Serie] = '" + solicitud + "' " +
                                      "AND T0.CANCELED <> 'Y' " +
                                      "AND T0.DataSource <> 'N' " +
                                      "AND ( T0.U_TipoMov = 'OFICINAS - PROMOTORES' " +
                                      "OR T0.U_TipoMov = 'ADMON CONTRATOS - PROMOTOR' " +
                                      ")" +
                                      "ORDER BY T0.DocEntry DESC";
                reader = comando.ExecuteReader();
                if (reader.HasRows == true)
                {
                    if (reader.Read())
                    {
                        itemDatosSN = new Listas.ListaSocioNegocio();
                        itemDatosSN.codigoAsistente = reader["CodigoAsistente"].ToString();
                        itemDatosSN.NombreAsistente = reader["NombrePromotor"].ToString();
                        itemDatosSN.Esquema         = reader["Esquema"].ToString();
                        DatosSN.Add(itemDatosSN);
                    }
                }
                return(DatosSN);
            }
            catch (Exception ex)
            {
                throw new Exception("Error al obtener datos SN solicitud: " + ex.Message);
            }
            finally
            {
                conexion.Close();
                SqlConnection.ClearPool(conexion);
                conexion.Dispose();
            }
        }
Ejemplo n.º 2
0
        public static List <Listas.ListaSocioNegocio> ObtenerDatosSN(string solicitud)
        {
            SqlConnection conexion = null;
            SqlDataReader reader   = null;
            SqlCommand    comando  = new SqlCommand();

            DatosSN.Clear();
            itemDatosSN = null;
            try
            {
                conexion            = Conexiones.ConexionSQL.ObtenerConexionSQL();
                comando.Connection  = conexion;
                comando.CommandText = @"SELECT  ISNULL(T0.U_CodigoPromotor, '') AS CodigoAsistente ,
                                                ISNULL(T0.U_NomProm, '') AS NombrePromotor ,
                                                CONCAT(T0.U_Dia, '/', T0.U_Mes, '/', T0.U_Year) AS FechaNacimiento ,
                                                ISNULL(T1.Address2, '') AS Telefono ,
                                                ISNULL(T0.CardName, '') AS NombreSN ,
                                                ISNULL(T1.Street, '') AS Direccion ,
                                                ISNULL(T1.Building, '') AS EntreCalles ,
                                                ISNULL(T1.City, '') AS Municipio ,
                                                ISNULL(T1.Block, '') AS Colonia ,
                                                ISNULL(T0.U_ComentarioContrato, '') AS Observaciones ,
                                                ISNULL(T0.U_PersonaNvoIngreso, '') AS PersonaNvoIngreso ,
                                                ISNULL(T1.ZipCode, '') AS CodigoPostal ,
                                                ISNULL(T0.LicTradNum, '') AS RFC ,
                                                ISNULL(T0.U_CodigoActivacion, '') AS CodigoActivacion ,
                                                ISNULL(T0.U_QCapturaContrato, '') AS QuienCaptura ,
                                                CASE WHEN T0.U_Esquema_pago IS NULL
                                                         THEN CASE WHEN T2.U_Esquema_pago LIKE '%SUELDO%' THEN 'SUELDO'
                                                                   ELSE T2.U_Esquema_pago
                                                              END
                                                         ELSE T0.U_Esquema_pago
                                                    END AS Esquema
                                        FROM    dbo.OCRD T0
                                                LEFT JOIN dbo.CRD1 T1 ON T0.CardCode = T1.CardCode
                                                                         AND T1.Address = 'DIRECCION 1'
                                                INNER JOIN dbo.OHEM T2 ON T0.U_CodigoPromotor = T2.firstName
                                        WHERE   U_SolicitudInt = '" + solicitud + "'";
                reader = comando.ExecuteReader();
                if (reader.HasRows == true)
                {
                    if (reader.Read())
                    {
                        itemDatosSN = new Listas.ListaSocioNegocio();
                        itemDatosSN.codigoAsistente  = reader["CodigoAsistente"].ToString();
                        itemDatosSN.NombreAsistente  = reader["NombrePromotor"].ToString();
                        itemDatosSN.FechaNacimiento  = Convert.ToDateTime(reader["FechaNacimiento"]);
                        itemDatosSN.Telefono         = reader["Telefono"].ToString();
                        itemDatosSN.NombreSN         = reader["NombreSN"].ToString();
                        itemDatosSN.Direccion        = reader["Direccion"].ToString();
                        itemDatosSN.EntreCalles      = reader["EntreCalles"].ToString();
                        itemDatosSN.Municipio        = reader["Municipio"].ToString();
                        itemDatosSN.Colonia          = reader["Colonia"].ToString();
                        itemDatosSN.Observaciones    = reader["Observaciones"].ToString();
                        itemDatosSN.NvoIngreso       = reader["PersonaNvoIngreso"].ToString();
                        itemDatosSN.CodigoPostal     = reader["CodigoPostal"].ToString();
                        itemDatosSN.RFC              = reader["RFC"].ToString();
                        itemDatosSN.CodigoActivacion = reader["CodigoActivacion"].ToString();
                        itemDatosSN.QuienCaptura     = reader["QuienCaptura"].ToString();
                        itemDatosSN.Esquema          = reader["Esquema"].ToString();
                        DatosSN.Add(itemDatosSN);
                    }
                }
                return(DatosSN);
            }
            catch (Exception ex)
            {
                throw new Exception("Error al obtener datos SN: " + ex.Message);
            }
            finally
            {
                conexion.Close();
                SqlConnection.ClearPool(conexion);
                conexion.Dispose();
            }
        }