Example #1
0
        FacturasEmitidas(Core.LogicaNegocio.Entidades.Factura entidad)

        {
            IList <Core.LogicaNegocio.Entidades.Factura> factura1 = null;

            Core.LogicaNegocio.Comandos.ComandoReporte.FacturasEmitidas comando;

            comando = FabricaComandosReporte.CrearComandoFacturasEmitidas(entidad);

            factura1 = comando.Ejecutar();

            return(factura1);
        }
        /// <summary>
        /// Metodo que recibe una factura con su ID y la busca en la BD
        /// </summary>
        /// <param name="factura">Factura a buscar </param>
        /// <returns>Factura encontrada</returns>
        public Factura ConsultarFacturaID(Factura factura)
        {
            try
            {

                factura.Prop = new Propuesta();

                SqlParameter[] arParms = new SqlParameter[1];

                arParms[0] = new SqlParameter("@IdFactura", SqlDbType.Int);

                arParms[0].Value = factura.Numero;

                DbDataReader reader = SqlHelper.ExecuteReader(GetConnection(),
                                        "ConsultarFacturaID", arParms);

                if (reader.Read())
                {
                    factura.Numero = int.Parse(reader["IdFactura"].ToString());

                    factura.Titulo = reader["Titulo"].ToString();

                    factura.Descripcion = reader["Descripcion"].ToString();

                    factura.Procentajepagado = float.Parse(reader["Porcentaje"].ToString());

                    factura.Fechapago = DateTime.Parse(reader["Fecha"].ToString());

                    factura.Fechaingreso = DateTime.Parse(reader["FechaIngreso"].ToString());

                    factura.Estado = reader["EstadoFactura"].ToString();

                    factura.Prop.Titulo = reader["Titulopropuesta"].ToString();

                    factura.Prop.MontoTotal = float.Parse(reader["Monto"].ToString());

                }

                return factura;
            }
            catch (SqlException e)
            {
                throw new ConsultarException("Error de SQL consultando una factura en la Base de Datos", e);
            }
            catch (Exception e)
            {
                throw new ConsultarException("Error consultando la factura en la Base de Datos", e);
            }

            return factura;
        }
Example #3
0
        FacturasPorCobrar(Core.LogicaNegocio.Entidades.Factura entidad)
        {
            IList <Core.LogicaNegocio.Entidades.Factura> facturaRetorno = null;

            entidad.Fechapago = Convert.ToDateTime("01/01/" + _vista.Anios.SelectedItem.Text);

            Core.LogicaNegocio.Comandos.ComandoReporte.FacturasPorCobrarAnuales comandoFacturasPorCobrar;

            comandoFacturasPorCobrar = FabricaComandosReporte.CrearComandoFacturasPorCobrarAnuales(entidad);

            facturaRetorno = comandoFacturasPorCobrar.Ejecutar();

            return(facturaRetorno);
        }
Example #4
0
        /// <summary>
        /// Acción del Botón Buscar (por rango de fechas)
        /// </summary>

        public void OnBotonBuscar()
        {
            Core.LogicaNegocio.Entidades.Factura factura = new Core.LogicaNegocio.Entidades.Factura();

            try
            {
                factura.Fechaingreso = Convert.ToDateTime(_vista.FechaInicio.Text);

                factura.Fechapago = Convert.ToDateTime(_vista.FechaFin.Text);

                IList <Core.LogicaNegocio.Entidades.Factura> listadoF = FacturasEmitidas(factura);

                _vista.GridViewReporteFactura3b.DataSource = null;

                _vista.GridViewReporteFactura3b.DataBind();


                if (listadoF.Count > 0)
                {
                    _vista.GridViewReporteFactura3b.DataSource = listadoF;

                    _vista.GridViewReporteFactura3b.DataBind();
                }
                else
                {
                    _vista.PintarInformacion(ManagerRecursos.GetString
                                                 ("MensajeConsulta"), "mensajes");
                    _vista.InformacionVisible = true;
                }
            }
            catch (WebException e)
            {
                _vista.PintarInformacion
                    (ManagerRecursos.GetString("mensajeErrorWeb"), "mensajes");
                _vista.InformacionVisible = true;
            }
            catch (ConsultarException e)
            {
                _vista.PintarInformacion
                    (ManagerRecursos.GetString("mensajeErrorConsultar"), "mensajes");
                _vista.InformacionVisible = true;
            }
            catch (Exception e)
            {
                _vista.PintarInformacion
                    (ManagerRecursos.GetString("mensajeErrorGeneral"), "mensajes");
                _vista.InformacionVisible = true;
            }
        }
Example #5
0
        public void onBotonBuscar()
        {
            Core.LogicaNegocio.Entidades.Factura factura = new Core.LogicaNegocio.Entidades.Factura();

            IList <Core.LogicaNegocio.Entidades.Factura> facturasPorCobrar = FacturasPorCobrar(factura);

            try
            {
                if (facturasPorCobrar != null)
                {
                    _vista.GetObjectContainerReporte8c.DataSource = facturasPorCobrar;
                    _vista.LabelContador.Text = _vista.LabelContador.Text
                                                + facturasPorCobrar.Count.ToString();
                    _vista.LabelContador.Visible = true;
                }
            }

            catch (WebException e)
            {
                //Mensaje de error al usuario
            }
        }
        public void onBotonBuscar()
        {
            Core.LogicaNegocio.Entidades.Factura factura = new Core.LogicaNegocio.Entidades.Factura();

            IList<Core.LogicaNegocio.Entidades.Factura> facturasPorCobrar = FacturasPorCobrar(factura);

            try
            {
                if (facturasPorCobrar != null)
                {
                    _vista.GetObjectContainerReporte8c.DataSource = facturasPorCobrar;
                    _vista.LabelContador.Text = _vista.LabelContador.Text
                        + facturasPorCobrar.Count.ToString();
                    _vista.LabelContador.Visible = true;
                }
            }

            catch (WebException e)
            {
                //Mensaje de error al usuario
            }
        }
Example #7
0
        //Método que prueba el funcionamiento del Reporte Facturas emitidas en un rango de fecha

        public void PruebaConsultaFacturaEmitida()
        {
            string FechaInicio = "01/01/2000";

            string FechaFin = "01/01/2015";

            Core.LogicaNegocio.Entidades.Factura factura = new Core.LogicaNegocio.Entidades.Factura();

            Core.LogicaNegocio.Comandos.ComandoReporte.FacturasEmitidas comando;

            IList <Core.LogicaNegocio.Entidades.Factura> listaFactura =
                new List <Core.LogicaNegocio.Entidades.Factura>();

            IList <Core.LogicaNegocio.Entidades.Factura> listaFacturaEmitida =
                new List <Core.LogicaNegocio.Entidades.Factura>();

            factura.Fechaingreso = Convert.ToDateTime(FechaInicio);

            factura.Fechapago = Convert.ToDateTime(FechaFin);

            comando = Core.LogicaNegocio.Fabricas.FabricaComandosReporte.CrearComandoFacturasEmitidas(factura);

            listaFactura = comando.Ejecutar();


            for (int i = 0; i < listaFactura.Count; i++)
            {
                if (listaFactura[i].Fechaingreso.CompareTo(DateTime.Parse(FechaInicio)) >= 0)
                {
                    if (listaFactura[i].Fechaingreso.CompareTo(DateTime.Parse(FechaFin)) <= 0)
                    {
                        listaFacturaEmitida.Add(listaFactura[i]);
                    }
                }
            }

            Assert.AreNotEqual(listaFacturaEmitida.Count, 0);
        }
        public void PruebaConsultaFacturaEmitida()
        {
            string FechaInicio = "01/01/2000";

            string FechaFin = "01/01/2015";

            Core.LogicaNegocio.Entidades.Factura factura = new Core.LogicaNegocio.Entidades.Factura();

            Core.LogicaNegocio.Comandos.ComandoReporte.FacturasEmitidas comando;

            IList<Core.LogicaNegocio.Entidades.Factura> listaFactura =
                                            new List<Core.LogicaNegocio.Entidades.Factura>();

            IList<Core.LogicaNegocio.Entidades.Factura> listaFacturaEmitida =
                                            new List<Core.LogicaNegocio.Entidades.Factura>();

            factura.Fechaingreso = Convert.ToDateTime(FechaInicio);

            factura.Fechapago = Convert.ToDateTime(FechaFin);

            comando = Core.LogicaNegocio.Fabricas.FabricaComandosReporte.CrearComandoFacturasEmitidas                         (factura);

            listaFactura = comando.Ejecutar();

            for (int i = 0; i < listaFactura.Count ; i++)
            {
                if (listaFactura[i].Fechaingreso.CompareTo(DateTime.Parse(FechaInicio)) >= 0 )
                {
                    if (listaFactura[i].Fechaingreso.CompareTo(DateTime.Parse(FechaFin)) <= 0)
                    {
                        listaFacturaEmitida.Add(listaFactura[i]);
                    }
                }

            }

            Assert.AreNotEqual(listaFacturaEmitida.Count, 0);
        }
Example #9
0
        public void IngresarPropuesta()
        {
            try
            {
                Core.LogicaNegocio.Entidades.Factura Factura = new Core.LogicaNegocio.Entidades.Factura();

                Factura.Titulo           = _vista.Titulo.Text;
                Factura.Descripcion      = _vista.Descripcion.Text;
                Factura.Prop             = _propuesta;
                Factura.Fechaingreso     = DateTime.Now;
                Factura.Estado           = _vista.Estado.SelectedItem.Text;
                Factura.Fechapago        = DateTime.Now;
                Factura.Procentajepagado = float.Parse(_vista.Porcentaje.Text);

                Core.LogicaNegocio.Comandos.ComandoFactura.Ingresar Ingresar;
                Ingresar = Core.LogicaNegocio.Fabricas.FabricaComandosFactura.CrearComandoIngresar(Factura);
                Ingresar.Ejecutar();

                _vista.Pintar("La factura se agrego con exito");
                _vista.MensajeVisible = true;
            }
            catch (WebException e)
            {
                _vista.Pintar("Error WEB al ingresar la factura");
                _vista.MensajeVisible = true;
            }
            catch (IngresarException e)
            {
                _vista.Pintar(e.Message);
                _vista.MensajeVisible = true;
            }
            catch (Exception e)
            {
                _vista.Pintar(e.Message);
                _vista.MensajeVisible = true;
            }
        }
        public void ConsultarFactura()
        {
            try
            {
                Core.LogicaNegocio.Entidades.Factura factura =
                    new Core.LogicaNegocio.Entidades.Factura();

                factura.Numero = int.Parse(_vista.NumeroFactura.Text);

                Core.LogicaNegocio.Comandos.ComandoFactura.ConsultarxFacturaID comandoConsultar =
                    Core.LogicaNegocio.Fabricas.FabricaComandosFactura.CrearComandoConsultarxFacturaID(factura);

                factura = comandoConsultar.Ejecutar();

                List<Core.LogicaNegocio.Entidades.Factura> lista = new List<Core.LogicaNegocio.Entidades.Factura>();
                lista.Add(factura);

                _vista.DetalleFactura.DataSource = lista;
                _vista.DetalleFactura.DataBind();

            }
            catch (WebException e)
            {
                _vista.Pintar("Error WEB consultando");
                _vista.MensajeVisible = true;
            }
            catch (ConsultarException e)
            {
                _vista.Pintar(e.Message);
                _vista.MensajeVisible = true;
            }
            catch (Exception e)
            {
                _vista.Pintar(e.Message);
                _vista.MensajeVisible = true;
            }
        }
        public void CargarDatos()
        {
            try
            {
                _factura        = new Core.LogicaNegocio.Entidades.Factura();
                _factura.Numero = int.Parse(_vista.ParametroTexto2.Text);
                Core.LogicaNegocio.Comandos.ComandoFactura.ConsultarxFacturaID ComandoConsultarFactura;
                ComandoConsultarFactura = Core.LogicaNegocio.Fabricas.FabricaComandosFactura.CrearComandoConsultarxFacturaID(_factura);

                _factura = ComandoConsultarFactura.Ejecutar();


                _vista.Titulo.Text       = _factura.Titulo;
                _vista.Descripcion.Text  = _factura.Descripcion;
                _vista.FechaIngreso.Text = _factura.Fechaingreso.ToShortDateString().ToString();
                _vista.FechaPago.Text    = _factura.Fechapago.ToShortDateString().ToString();
                _vista.Estado.Text       = _factura.Estado;
                _vista.Porcentaje.Text   = _factura.Procentajepagado.ToString();

                _vista.MultiViewFacturas.Visible         = true;
                _vista.MultiViewFacturas.ActiveViewIndex = 1;
            }
            catch (WebException e)
            {
                _vista.Pintar("Error WEB consultando");
            }
            catch (ConsultarException e)
            {
                _vista.Pintar(e.Message);
                _vista.MensajeVisible = true;
            }
            catch (Exception e)
            {
                _vista.Pintar(e.Message);
                _vista.MensajeVisible = true;
            }
        }
        public void CargarDatos()
        {
            try
            {
                _factura = new Core.LogicaNegocio.Entidades.Factura();
                _factura.Numero = int.Parse(_vista.ParametroTexto2.Text);
                Core.LogicaNegocio.Comandos.ComandoFactura.ConsultarxFacturaID ComandoConsultarFactura;
                ComandoConsultarFactura = Core.LogicaNegocio.Fabricas.FabricaComandosFactura.CrearComandoConsultarxFacturaID(_factura);

                _factura = ComandoConsultarFactura.Ejecutar();

                _vista.Titulo.Text = _factura.Titulo;
                _vista.Descripcion.Text = _factura.Descripcion;
                _vista.FechaIngreso.Text = _factura.Fechaingreso.ToShortDateString().ToString();
                _vista.FechaPago.Text = _factura.Fechapago.ToShortDateString().ToString();
                _vista.Estado.Text = _factura.Estado;
                _vista.Porcentaje.Text = _factura.Procentajepagado.ToString();

                _vista.MultiViewFacturas.Visible = true;
                _vista.MultiViewFacturas.ActiveViewIndex = 1;
            }
            catch (WebException e)
            {
                _vista.Pintar("Error WEB consultando");
            }
            catch (ConsultarException e)
            {
                _vista.Pintar(e.Message);
                _vista.MensajeVisible = true;
            }
            catch (Exception e)
            {
                _vista.Pintar(e.Message);
                _vista.MensajeVisible = true;
            }
        }
Example #13
0
        public void Test1IngresarFactura()
        {
            Factura factura = new Factura();
            IList<Propuesta> propuestas;

            propuestas = new DAOPropuestaSQLServer().ConsultarPropuestaNueva(1,"Automatizacion de la Certificacion de Empleados");

            factura.Titulo = "Prueba Ingresar";
            factura.Descripcion = "Esto es una Prueba de Ingresar";
            factura.Procentajepagado = 1;
            factura.Fechapago = DateTime.Now;
            factura.Fechaingreso = DateTime.Now;
            factura.Estado = "Por Cobrar";
            factura.Prop = propuestas.ElementAt(0);
            Core.LogicaNegocio.Comandos.ComandoFactura.Ingresar ComandoIngresar;
            ComandoIngresar = Core.LogicaNegocio.Fabricas.FabricaComandosFactura.CrearComandoIngresar(factura);
            ComandoIngresar.Ejecutar();

            Core.LogicaNegocio.Comandos.ComandoFactura.ConsultarxNomPro ComandoConsulta;
            ComandoConsulta = Core.LogicaNegocio.Fabricas.FabricaComandosFactura.CrearComandoConsultarxNomPro(propuestas.ElementAt(0));
            IList<Factura> listaFactura = ComandoConsulta.Ejecutar();

            Assert.AreEqual(listaFactura.ElementAt(listaFactura.Count - 1).Titulo,"Prueba Ingresar");
        }
Example #14
0
        public void ConsultarFactura()
        {
            try
            {
                Core.LogicaNegocio.Entidades.Factura factura =
                    new Core.LogicaNegocio.Entidades.Factura();

                factura.Numero = int.Parse(_vista.NumeroFactura.Text);

                Core.LogicaNegocio.Comandos.ComandoFactura.ConsultarxFacturaID comandoConsultar =
                    Core.LogicaNegocio.Fabricas.FabricaComandosFactura.CrearComandoConsultarxFacturaID(factura);

                factura = comandoConsultar.Ejecutar();

                List <Core.LogicaNegocio.Entidades.Factura> lista = new List <Core.LogicaNegocio.Entidades.Factura>();
                lista.Add(factura);

                _vista.DetalleFactura.DataSource = lista;
                _vista.DetalleFactura.DataBind();
            }
            catch (WebException e)
            {
                _vista.Pintar("Error WEB consultando");
                _vista.MensajeVisible = true;
            }
            catch (ConsultarException e)
            {
                _vista.Pintar(e.Message);
                _vista.MensajeVisible = true;
            }
            catch (Exception e)
            {
                _vista.Pintar(e.Message);
                _vista.MensajeVisible = true;
            }
        }
 public static ConsultarxFacturaID CrearComandoConsultarxFacturaID(Factura factura)
 {
     return new ConsultarxFacturaID(factura);
 }
Example #16
0
        public void TestConsultarFacturaID()
        {
            Factura factura = new Factura();
            Factura facturaNueva = new Factura();
            factura.Numero = 1;

            Core.LogicaNegocio.Comandos.ComandoFactura.ConsultarxFacturaID ComandoConsulta;
            ComandoConsulta = Core.LogicaNegocio.Fabricas.FabricaComandosFactura.CrearComandoConsultarxFacturaID(factura);
            facturaNueva = ComandoConsulta.Ejecutar();

            Assert.AreNotEqual(factura, new Factura());
        }
        /// <summary>
        /// Metodo que consulta las facturas de la BD
        /// </summary>
        /// <returns>Una lista con las facturas de la BD</returns>
        public IList<Factura> ConsultarFacturas()
        {
            IList<Factura> facturas = new List<Factura>();

            try
            {
                DbDataReader reader = SqlHelper.ExecuteReader(GetConnection(),
                                        "ConsultarFacturas");

                int i = 0;

                while (reader.Read())
                {
                    Factura factura = new Factura();

                    factura.Numero = (int)reader["IdFactura"];

                    factura.Titulo = (string)reader["Titulo"];

                    factura.Descripcion = (string)reader["Descripcion"];

                    factura.Procentajepagado = float.Parse(reader["Porcentaje"].ToString());

                    factura.Fechapago = (DateTime)reader["Fecha"];

                    factura.Fechaingreso = (DateTime)reader["FechaIngreso"];

                    factura.Estado = (string)reader["Estado"];

                    //factura.Prop = propuesta;

                    facturas.Insert(i, factura);
                    i++;

                }
                if (facturas.Count == 0)
                    throw new ConsultarFacturaADException();

            }
            catch (SqlException e)
            {
                throw new Core.LogicaNegocio.Excepciones.Facturas.AccesoDatos.ConsultarFacturaADException("Error de SQL consultando una factura en la Base de Datos", e);
            }
            catch (ConsultarFacturaADException e)
            {
                throw new ConsultarFacturaADException("No se encontraron facturas", e);
            }
            catch (Exception e)
            {
                throw new ConsultarFacturaADException("Error consultando una factura en la Base de Datos", e);
            }

            return facturas;
        }
        /// <summary>
        /// Metodo que recibe una propuesta y se encarga de buscar las facturas de esa
        /// propuesta por su ID
        /// </summary>
        /// <param name="propuesta">Propuesta con el ID </param>
        /// <returns>Lista con las facturas correspondientes a la propuesta</returns>
        public IList<Factura> ConsultarFacturasIDPro(Propuesta propuesta)
        {
            IList<Propuesta> propuestas = ConsultarPropuesta();

            List<Factura> facturas = new List<Factura>();

            try
            {
                foreach (Propuesta propuestaAux in propuestas)
                {

                    if (propuesta.Id == propuestaAux.Id)
                    {
                        int i = 0;

                        SqlParameter[] arParms = new SqlParameter[1];

                        arParms[0] = new SqlParameter("@idpropuesta", SqlDbType.Int);

                        arParms[0].Value = propuesta.Id;

                        DbDataReader reader = SqlHelper.ExecuteReader(GetConnection(),
                                                "ConsultarFacturaIDPro", arParms);

                        while (reader.Read())
                        {
                            Factura factura = new Factura();

                            factura.Numero = (int)reader["IdFactura"];

                            factura.Titulo = (string)reader["Titulo"];

                            factura.Descripcion = (string)reader["Descripcion"];

                            factura.Procentajepagado = float.Parse(reader["Porcentaje"].ToString());

                            factura.Fechapago = (DateTime)reader["Fecha"];

                            factura.Fechaingreso = (DateTime)reader["FechaIngreso"];

                            factura.Estado = (string)reader["Estado"];

                            factura.Prop = propuesta;

                            facturas.Insert(i, factura);
                            i++;

                        }
                        //if (facturas.Count == 0)
                        //    throw new ConsultarFacturaADException();
                    }
                }
            }
            catch (SqlException e)
            {
                throw new Core.LogicaNegocio.Excepciones.Facturas.AccesoDatos.ConsultarFacturaADException("Error de SQL consultando la factura por el ID de la propuesta  en la Base de Datos", e);
            }
            catch (ConsultarFacturaADException e)
            {
                throw new ConsultarFacturaADException("No se pudo realizar la consulta, se recibio un parametro de busqueda vacio, en este caso, el ID la propuesta", e);
            }
            catch (Exception e)
            {
                throw new ConsultarFacturaADException("Error consultando la factura por el ID de la propuesta  en la Base de Datos", e);
            }

            return facturas;
        }
        public void IngresarPropuesta()
        {
            try
            {
                Core.LogicaNegocio.Entidades.Factura Factura = new Core.LogicaNegocio.Entidades.Factura();

                Factura.Titulo = _vista.Titulo.Text;
                Factura.Descripcion = _vista.Descripcion.Text;
                Factura.Prop = _propuesta;
                Factura.Fechaingreso = DateTime.Now;
                Factura.Estado = _vista.Estado.SelectedItem.Text;
                Factura.Fechapago = DateTime.Now;
                Factura.Procentajepagado = float.Parse(_vista.Porcentaje.Text);

                Core.LogicaNegocio.Comandos.ComandoFactura.Ingresar Ingresar;
                Ingresar = Core.LogicaNegocio.Fabricas.FabricaComandosFactura.CrearComandoIngresar(Factura);
                Ingresar.Ejecutar();

                _vista.Pintar("La factura se agrego con exito");
                _vista.MensajeVisible = true;
            }
            catch (WebException e)
            {
                _vista.Pintar("Error WEB al ingresar la factura");
                _vista.MensajeVisible = true;
            }
            catch (IngresarException e)
            {
                _vista.Pintar(e.Message);
                _vista.MensajeVisible = true;
            }
            catch (Exception e)
            {
                _vista.Pintar(e.Message);
                _vista.MensajeVisible = true;
            }
        }
        /// <summary>
        /// Metodo para el reporte de facturas por cobrar en un año especifico
        /// </summary>
        /// <param name="entidad">Entidad Factura</param>
        /// <returns>Objeto Factura</returns>
        /// 
        public IList<Core.LogicaNegocio.Entidades.Factura> ObtenerFacturasPorCobrar(Factura facturas)
        {
            IList<Core.LogicaNegocio.Entidades.Factura> factura =
                                                new List<Core.LogicaNegocio.Entidades.Factura>();
            try
            {

            SqlParameter[] parametro = new SqlParameter[1];

            parametro[0] = new SqlParameter("@yearFecha", SqlDbType.DateTime);

            parametro[0].Value = facturas.Fechapago;

            DbDataReader reader = SqlHelper.ExecuteReader(_conexion.GetConnection(), "FacturasPorCobrarAnuales", parametro);

            int i = 0;

            while (reader.Read())
            {

                Factura _factura = new Factura();

                Propuesta _propuesta = new Propuesta();

                _factura.Numero = (int)reader["IdFactura"];

                _factura.Titulo = (string)reader["Titulo"];

                _factura.Descripcion = (string)reader["Descripcion"];

                _factura.Fechaingreso = (DateTime)reader["FechaIngreso"];

                _factura.Estado = (string)reader["Nombre"];

                _factura.Fechapago = (DateTime)reader["Fecha"];

                _factura.Procentajepagado = float.Parse(reader["Porcentaje"].ToString());

                factura.Add(_factura);
            }
            }
            catch (ConsultarException e)
            {
                throw new ConsultarException("Error al consultar",e);
            }
            catch (Exception e)
            {
                throw new ConsultarException("error", e);
            }
            return factura;
        }
        /// <summary>
        /// Metodo para el reporte de facturas emitidas en un rango de fechas
        /// </summary>
        /// <param name="entidad">fechas de entidad Factura</param>
        /// <returns>Objeto Factura</returns>
        public IList<Core.LogicaNegocio.Entidades.Factura> FacturasEmitidas(Factura entidad)
        {
            IList<Core.LogicaNegocio.Entidades.Factura> factura =
                                                new List<Core.LogicaNegocio.Entidades.Factura>();

            try
            {
                SqlParameter[] arParms = new SqlParameter[2];

                arParms[0] = new SqlParameter("@FechaIngreso1", SqlDbType.SmallDateTime);

                arParms[0].Value = entidad.Fechaingreso.ToShortDateString();

                arParms[1] = new SqlParameter("@FechaIngreso2", SqlDbType.SmallDateTime);

                arParms[1].Value = entidad.Fechapago.ToShortDateString();

                DbDataReader reader = SqlHelper.ExecuteReader(_conexion.GetConnection(),
                                        "FacturasEmitidas", arParms);

                while (reader.Read())
                {
                    Factura _factura = new Factura();

                    Propuesta _propuesta = new Propuesta();

                    _factura.Prop = new Propuesta();

                    _factura.Numero = (int)reader.GetValue(0);

                    _factura.Titulo = (string)reader.GetValue(1);

                    _factura.Descripcion = (string)reader.GetValue(2);

                    _factura.Fechaingreso = (DateTime)reader.GetValue(3);

                    _factura.Estado = (string)reader.GetValue(4);

                    _propuesta.Titulo = (string)reader.GetValue(5);

                    _factura.Prop.Titulo = _propuesta.Titulo;

                    factura.Add(_factura);
                }

                return factura;

            }

            catch (SqlException e)
            {
                throw new ReportesException("Error al consultar en la base de datos", e);
            }
            catch (Exception e)
            {
                throw new ReportesException("Error en consultar facturas emitidas", e);
            }

            return factura;
        }
        /// <summary>
        /// Metodo que recibe una propuesta y se encarga de buscar las facturas de esa
        /// propuesta por su nombre
        /// </summary>
        /// <param name="propuesta">Propuesta con el nombre </param>
        /// <returns>Lista con las facturas correspondientes a la propuesta</returns>
        public IList<Factura> ConsultarFacturasNomPro(Propuesta propuesta)
        {
            List<Factura> facturas = new List<Factura>();

            try
            {

                int i = 0;

                SqlParameter[] arParms = new SqlParameter[1];

                arParms[0] = new SqlParameter("@Titulo", SqlDbType.VarChar);

                arParms[0].Value = propuesta.Titulo;

                DbDataReader reader = SqlHelper.ExecuteReader(GetConnection(),
                                        "ConsultarFacturaNomPro", arParms);

                while (reader.Read())
                {
                    Factura factura = new Factura();

                    factura.Prop = new Propuesta();

                    factura.Numero = int.Parse(reader["IdFactura"].ToString());

                    factura.Titulo = reader["Titulo"].ToString();

                    factura.Descripcion = reader["Descripcion"].ToString();

                    factura.Procentajepagado = float.Parse(reader["Porcentaje"].ToString());

                    factura.Fechapago = DateTime.Parse(reader["Fecha"].ToString());

                    factura.Fechaingreso = DateTime.Parse(reader["FechaIngreso"].ToString());

                    factura.Estado = reader["EstadoFactura"].ToString();

                    factura.Prop.Titulo = reader["Titulopropuesta"].ToString();

                    factura.Prop.MontoTotal = float.Parse(reader["Monto"].ToString());

                    facturas.Add(factura);

                    //reader.NextResult();

                    i++;

                }

                //if (facturas.Count == 0)
                //    throw new ConsultarFacturaADException();

            }
            catch (SqlException e)
            {
                throw new Core.LogicaNegocio.Excepciones.Facturas.AccesoDatos.ConsultarFacturaADException("Error SQL consultando factura por el nombre de la propuesta en la Base de Datos", e);
            }
            catch (Exception e)
            {
                throw new ConsultarException("Error consultando la factura por el nombre de la propuesta en la Base de Datos", e);
            }

            return facturas;
        }
 public static FacturasPorCobrarAnuales CrearComandoFacturasPorCobrarAnuales(Factura entidad)
 {
     return new FacturasPorCobrarAnuales(entidad);
 }
 public static FacturasEmitidasAnuales CrearComandoFacturasEmitidasAnuales(Factura entidad)
 {
     return new FacturasEmitidasAnuales(entidad);
 }
        /// <summary>
        /// Metodo utilizado para generar una lista de facturas parametrizada por un rango de fechas
        /// y por el tipo de factura
        /// </summary>
        /// <param name="desde">Fecha Inicial(DateTime)</param>
        /// <param name="hasta">Fecha fin(DateTime)</param>
        /// <param name="cobradas">Si la factura es de tipo "cobrada" true;
        /// Si es de tipo "por cobrar" false</param>
        /// <returns>Una lista de facturas</returns>
        public IList<Factura> ConsultarFacturasPorEstado(DateTime desde, DateTime hasta, Boolean cobradas)
        {
            try
            {
                DbDataReader reader;

                SqlParameter[] arParms = new SqlParameter[2];

                arParms[0] = new SqlParameter("@Fecha1", SqlDbType.SmallDateTime);
                arParms[0].Value = desde;
                arParms[1] = new SqlParameter("@Fecha2", SqlDbType.SmallDateTime);
                arParms[1].Value = hasta;

                if (cobradas)
                    reader = SqlHelper.ExecuteReader(GetConnection(), "ConsultarFacturasCobradas", arParms);
                else
                    reader = SqlHelper.ExecuteReader(GetConnection(), "ConsultarFacturasPorCobrar", arParms);

                Factura factura;
                Propuesta propuesta;
                IList<Factura> listaFacturas = new List<Factura>();
                DateTime fecha;

                while (reader.Read())
                {
                    factura = new Factura();

                    factura.Numero = int.Parse(reader["IdFactura"].ToString());
                    factura.Titulo = reader["Titulo"].ToString();
                    factura.Descripcion = reader["Descripcion"].ToString();
                    factura.Procentajepagado = float.Parse(reader["Porcentaje"].ToString());
                    fecha = DateTime.Parse(reader["Fecha"].ToString());
                    factura.Fechapago = DateTime.Parse(fecha.ToShortTimeString());
                    fecha = DateTime.Parse(reader["FechaIngreso"].ToString());
                    factura.Fechaingreso = DateTime.Parse(reader["FechaIngreso"].ToString());
                    factura.Estado = reader["Estado"].ToString();
                    propuesta = new Propuesta();
                    propuesta.Titulo = reader["NombrePropuesta"].ToString();
                    propuesta.MontoTotal = float.Parse(reader["Monto"].ToString());
                    factura.Prop = propuesta;

                    listaFacturas.Add(factura);
                }
                return listaFacturas;
            }
            catch (SqlException e)
            {
                throw new Core.LogicaNegocio.Excepciones.Facturas.AccesoDatos.ConsultarFacturaADException("Error de SQL consultando las facturas por estado en la Base de Datos", e);
            }
            catch (Exception e)
            {
                throw new ConsultarFacturaADException("Error consultando las facturas por estado en la Base de Datos", e);
            }
        }
        /// <summary>
        /// Metodo que recibe una factura y la ingresa en la BD
        /// </summary>
        /// <param name="factura">Factura a ingresar </param>
        /// <returns>Factura a ingresar</returns>
        public Factura IngresarFactura(Factura factura)
        {
            //IList<Propuesta> propuestas = ConsultarPropuesta();

            try
            {
                //foreach (Propuesta propuestaAux in propuestas)
                //{
                //if (propuestaAux.Id == factura.Prop.Id)
                //{
                SqlParameter[] arparms = new SqlParameter[7];

                arparms[0] = new SqlParameter("@Titulo", SqlDbType.VarChar);
                arparms[0].Value = factura.Titulo;

                arparms[1] = new SqlParameter("@Descripcion", SqlDbType.VarChar);
                arparms[1].Value = factura.Descripcion;

                arparms[2] = new SqlParameter("@Porcentaje", SqlDbType.Float);
                arparms[2].Value = factura.Procentajepagado;

                arparms[3] = new SqlParameter("@Fecha", SqlDbType.SmallDateTime);
                arparms[3].Value = factura.Fechapago.ToShortDateString();

                arparms[4] = new SqlParameter("@FechaIngreso", SqlDbType.SmallDateTime);
                arparms[4].Value = factura.Fechaingreso.ToShortDateString();

                arparms[5] = new SqlParameter("@Estado", SqlDbType.VarChar);
                arparms[5].Value = factura.Estado;

                arparms[6] = new SqlParameter("@TituloPropuesta", SqlDbType.VarChar);
                arparms[6].Value = factura.Prop.Titulo;

                int result = SqlHelper.ExecuteNonQuery(GetConnection(), "IngresarFactura", arparms);

                //}
                //}
                return factura;
            }
            catch (SqlException e)
            {
                throw new IngresarException("Error de SQL insertando factura en la Base de Datos", e);
            }
            catch (Exception e)
            {
                throw new IngresarException("Error insertando la factura en la Base de Datos", e);
            }
        }
 public static Modificar CrearComandoModificar(Factura factura)
 {
     return new Modificar(factura);
 }
        /// <summary>
        /// Metodo para el reporte de facturas emitidas en un año especifico
        /// </summary>
        /// <param name="entidad">Entidad Factura</param>
        /// <returns>Objeto Factura</returns>
        /// 
        public IList<Core.LogicaNegocio.Entidades.Factura> ObtenerFacturasEmitidas(Factura factura)
        {
            IList<Core.LogicaNegocio.Entidades.Factura> facturas =
                                                new List<Core.LogicaNegocio.Entidades.Factura>();

            SqlParameter[] parametro = new SqlParameter[1];

            parametro[0] = new SqlParameter("@yearFecha", SqlDbType.DateTime);

            parametro[0].Value = factura.Fechapago;

            DbDataReader reader = SqlHelper.ExecuteReader(_conexion.GetConnection(), "FacturasEmitidasAnuales", parametro);

            int i = 0;

            while (reader.Read())
            {

                Factura _factura = new Factura();

                Propuesta _propuesta = new Propuesta();

                _factura.Numero = (int)reader["IdFactura"];

                _factura.Titulo = (string)reader["Titulo"];

                _factura.Descripcion = (string)reader["Descripcion"];

                _factura.Fechaingreso = (DateTime)reader["FechaIngreso"];

             //               _factura.Estado = (int)reader["Estado"];

                _factura.Fechapago = (DateTime)reader["Fecha"];

                _factura.Procentajepagado = float.Parse(reader["Porcentaje"].ToString());

                facturas.Add(_factura);
            }

            return facturas;
        }
        /// <summary>
        /// Metodo que recibe una factura y la la modifica en la BD
        /// en este caso modifica el detalle de cobro
        /// </summary>
        /// <param name="factura">Factura a modificar </param>
        /// <returns>Factura modificada</returns>
        public Factura UpdateFactura(Factura factura)
        {
            bool valido = false;
            try
            {
                SqlParameter[] arparms = new SqlParameter[1];

                arparms[0] = new SqlParameter("@NumeroFactura", SqlDbType.Int);
                arparms[0].Value = factura.Numero;

                int result = SqlHelper.ExecuteNonQuery(GetConnection(), "UpdateFactura", arparms);

                valido = true;
            }
            catch (SqlException e)
            {
                throw new Core.LogicaNegocio.Excepciones.Facturas.AccesoDatos.ModificarFacturaADException("Error de SQL modificando una factura en la Base de Datos", e);
            }
            catch (Exception e)
            {
                throw new ModificarFacturaADException("Error modificando una factura en la Base de Datos", e);
            }

            if (valido)
                return factura;
            else
                return new Factura();
        }
 public static Ingresar CrearComandoIngresar(Factura factura)
 {
     return new Ingresar(factura);
 }
        /// <summary>
        /// Acción del Botón Buscar (por rango de fechas)
        /// </summary>
        public void OnBotonBuscar()
        {
            Core.LogicaNegocio.Entidades.Factura factura = new Core.LogicaNegocio.Entidades.Factura();

            try
            {
            factura.Fechaingreso = Convert.ToDateTime(_vista.FechaInicio.Text);

            factura.Fechapago = Convert.ToDateTime(_vista.FechaFin.Text);

            IList<Core.LogicaNegocio.Entidades.Factura> listadoF = FacturasEmitidas(factura);

            _vista.GridViewReporteFactura3b.DataSource = null;

            _vista.GridViewReporteFactura3b.DataBind();

                if (listadoF.Count > 0)
                {

                    _vista.GridViewReporteFactura3b.DataSource = listadoF;

                    _vista.GridViewReporteFactura3b.DataBind();

                }
                else
                {
                    _vista.PintarInformacion(ManagerRecursos.GetString
                                            ("MensajeConsulta"), "mensajes");
                    _vista.InformacionVisible = true;

                }
            }
            catch (WebException e)
            {
                _vista.PintarInformacion
                    (ManagerRecursos.GetString("mensajeErrorWeb"),"mensajes");
                _vista.InformacionVisible = true;

            }
            catch (ConsultarException e)
            {
                _vista.PintarInformacion
                   (ManagerRecursos.GetString("mensajeErrorConsultar"), "mensajes");
                _vista.InformacionVisible = true;

            }
            catch (Exception e)
            {
                _vista.PintarInformacion
                   (ManagerRecursos.GetString("mensajeErrorGeneral"), "mensajes");
                _vista.InformacionVisible = true;
            }
        }