Exemple #1
0
        public Entidad llenarAbonarCpp2(string nombreProveedor, Int64 codigoCuenta)
        {
            // instancio un objeto conexion y otro Sqlcommand para la BD
            ConexionDAOS  conex    = new ConexionDAOS();
            SqlCommand    command  = new SqlCommand();
            SqlDataReader reader   = null;
            Entidad       cuentaPP = FabricaEntidad.CrearCuentaPorPagar();

            try
            {
                conex.AbrirConexion();
                command.Connection     = conex.ObjetoConexion();
                command.CommandType    = System.Data.CommandType.StoredProcedure;
                command.CommandText    = "[dbo].[llenarAbonoCpp2]";
                command.CommandTimeout = 10;

                //Aqui van los parametros del store procesure
                command.Parameters.AddWithValue("@proveedor", nombreProveedor);
                command.Parameters.AddWithValue("@idCuentaPP", codigoCuenta);
                //Se indica que es un parametro de entrada
                command.Parameters["@proveedor"].Direction  = ParameterDirection.Input;
                command.Parameters["@idCuentaPP"].Direction = ParameterDirection.Input;

                //CuentaPorPagar cuentaPP = new CuentaPorPagar();
                reader = command.ExecuteReader();
                // guarda registro a registro cada objeto de tipo cuentaPorPagar
                if (reader.Read())
                {
                    NumeroCuentaBanco miNumeroCuentaBanco = new NumeroCuentaBanco();
                    miNumeroCuentaBanco.NroCuentaBanco = reader.GetString(0);
                    (cuentaPP as CuentaPorPagar).ListaNumeroCuentaBanco.Add(miNumeroCuentaBanco);

                    Banco miBanco = new Banco();
                    miBanco.NombreBanco = reader.GetString(1);
                    (cuentaPP as CuentaPorPagar).ListaNumeroCuentaBanco.ElementAt(0).Banco = miBanco;

                    (cuentaPP as CuentaPorPagar).TipoPago = reader.GetString(2);

                    Entidad miabono = FabricaEntidad.CrearAbono();
                    (miabono as Abono).MontoAbono = reader.GetDouble(3);
                    (cuentaPP as CuentaPorPagar).ListaAbono.Add(miabono as Abono);
                }
            }
            catch (SqlException)
            {
                throw new Exception();
            }

            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                conex.CerrarConexion();
            }
            return(cuentaPP);
        }
Exemple #2
0
        public List <Entidad> llenarGridAbonos(string nombreProveedor, Int64 codigoCuenta)
        {
            // instancio un objeto conexion y otro Sqlcommand para la BD
            ConexionDAOS   conex      = new ConexionDAOS();
            SqlCommand     command    = new SqlCommand();
            SqlDataReader  reader     = null;
            List <Entidad> listaAbono = new List <Entidad>();

            try
            {
                conex.AbrirConexion();
                command.Connection  = conex.ObjetoConexion();
                command.CommandType = System.Data.CommandType.StoredProcedure;
                // Aqui debo poner el nombre del storeProcedure que no esta hecho
                command.CommandText    = "[dbo].[llenarGridAbonos]";
                command.CommandTimeout = 10;

                //Aqui van los parametros del store procesure
                command.Parameters.AddWithValue("@proveedor", nombreProveedor);
                command.Parameters.AddWithValue("@idCuentaPP", codigoCuenta);
                //Se indica que es un parametro de entrada
                command.Parameters["@proveedor"].Direction  = ParameterDirection.Input;
                command.Parameters["@idCuentaPP"].Direction = ParameterDirection.Input;

                reader = command.ExecuteReader();
                // guarda registro a registro cada objeto de tipo cuentaPorPagar
                while (reader.Read())
                {
                    //Abono abonos = new Abono();
                    Entidad _abonos = FabricaEntidad.CrearAbono();
                    (_abonos as Abono).FechaAbono = String.Format("{0:dd/MM/yyyy}", reader.GetDateTime(0));
                    (_abonos as Abono).MontoAbono = reader.GetFloat(1);
                    (_abonos as Abono).Deuda      = reader.GetFloat(2);

                    //Lleno la lista de cuentas por pagar
                    listaAbono.Add(_abonos);
                }
            }
            catch (SqlException)
            {
                throw new Exception();
            }

            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                conex.CerrarConexion();
            }
            return(listaAbono);
        }
Exemple #3
0
        public List <Entidad> BuscarAbonos(int idfactura)
        {
            String         cadenaConexion = ConfigurationManager.ConnectionStrings["ConnUricao"].ToString();
            SqlConnection  conexion       = new SqlConnection();
            SqlCommand     cmd            = new SqlCommand();
            SqlDataReader  dr;
            Entidad        objetoUsuario = FabricaEntidad.CrearAbono();
            List <Entidad> miLista       = new List <Entidad>();

            // List<CuentaPorCobrar> lalista = new List<CuentaPorCobrar>();

            try
            {
                conexion = new SqlConnection(cadenaConexion);
                conexion.Open();
                cmd             = new SqlCommand("dbo.BuscarAbonos", conexion);
                cmd.CommandType = CommandType.StoredProcedure;
                //SqlParameter param = new SqlParameter("@cedula", "v-19293743");
                SqlParameter param = new SqlParameter("@idFactura", idfactura);
                cmd.Parameters.Add(param);
                // cmd.Parameters.AddWithValue("@cedula", "v-19293743");
                dr = cmd.ExecuteReader();

                while (dr.Read())
                {
                    objetoUsuario = new Abono();
                    (objetoUsuario as Abono).MontoAbono = Convert.ToDouble(dr.GetValue(0).ToString());
                    (objetoUsuario as Abono).Deuda      = Convert.ToDouble(dr.GetValue(1).ToString());
                    (objetoUsuario as Abono).FechaAbono = dr.GetValue(2).ToString();
                    miLista.Add(objetoUsuario);
                }

                db.CerrarConexion();
            }
            catch (Exception e)
            {
            }
            finally
            {
                db.CerrarConexion();
            }
            return(miLista);
        }