示例#1
0
        private void BuscarButton_Click(object sender, EventArgs e)
        {
            int    id;
            double p;

            if (FiltrarComboBox.SelectedIndex == 0)
            {
                id      = int.Parse(CriterioTextBox.Text);
                filtrar = t => t.IdFactura == id;
            }
            else if (FiltrarComboBox.SelectedIndex == 1)
            {
                filtrar = t => t.Observacion.Contains(CriterioTextBox.Text);
            }
            else if (FiltrarComboBox.SelectedIndex == 2)
            {
                p       = double.Parse(CriterioTextBox.Text);
                filtrar = t => t.Monto == p;
            }
            else if (FiltrarComboBox.SelectedIndex == 3)
            {
                filtrar = t => (t.Fecha >= FechaInicialDateTimePicker.Value) && (t.Fecha <= FechaFinalDateTimePicker.Value);
            }

            TiposDePersonasDataGridView.DataSource = FacturaDetalleBLL.GetList1(filtrar);
        }
示例#2
0
    protected void GridProducto_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        int detalleID = 0;

        try
        {
            detalleID = Convert.ToInt32(e.CommandArgument);
        }
        catch (Exception ex)
        {
        }
        if (detalleID <= 0)
        {
            return;
        }


        if (e.CommandName == "Eliminar")
        {
            try
            {
                FacturaDetalleBLL.DeleteFacturaDetalle(detalleID);
                Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "ShowMensaje('success', 'Eliminación Exitosa.')", true);

                GridProducto.DataBind();
                CargarFactura(Convert.ToInt32(FacturaIdHD.Value));
            }
            catch (Exception ex)
            {
                Console.Write(ex.Message);
                throw new Exception("Error al eliminar");
            }
        }
    }
示例#3
0
        private void GuardarButton_Click(object sender, EventArgs e)
        {
            int ID;

            int.TryParse(IDNumericUpDown.Text, out ID);
            Facturas f1 = FacturaDetalleBLL.Buscar(ID);

            if (f1 == null)
            {
                Facturas f = LlenarClase();
                if (FacturaDetalleBLL.Guardar(f))
                {
                    MessageBox.Show("Factura Guardada");
                }
                else if (!FacturaDetalleBLL.Guardar(f))
                {
                    MessageBox.Show("Esta Factura No Pudo Ser Guardada");
                }
            }
            else
            {
                edit(f1);
                if (FacturaDetalleBLL.Modificar(f1))
                {
                    MessageBox.Show("Acaba de Modificar Esta Persona");
                }
                else
                {
                    MessageBox.Show("No Se Pudo Modificar Esta Persona");
                }
            }
            ClearAll();
        }
示例#4
0
        private void EliminarButton_Click(object sender, EventArgs e)
        {
            int ID = int.Parse(IDNumericUpDown.Text);

            if (FacturaDetalleBLL.Eliminar(ID))
            {
                MessageBox.Show("Factura Eliminada");
            }
            else
            {
                errorProvider1.SetError(EliminarButton, "No se puede eliminar una Factura que no existe");
            }
            ClearAll();
        }
示例#5
0
        private void DetallecomboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            int ID, id;

            id = Convert.ToInt32(IDcomboBox.Text);
            ID = Convert.ToInt32(DetallecomboBox.Text);
            if (facturas.Detalle.Count() == 0)
            {
                facturas.Detalle = FacturaDetalleBLL.GetList(x => x.FacturaId == id);
            }
            foreach (var item in facturas.Detalle)
            {
                if (item.Id == ID)
                {
                    DescripcionProductotextBox.Text = item.Descripcion;
                    PreciotextBox.Text          = item.Precio.ToString();
                    ProductoIdcomboBox.Text     = item.ProductoId.ToString();
                    CantidadnumericUpDown.Value = item.Cantidad;
                }
            }
        }
示例#6
0
    protected void btnGuardarDetalle_Click(object sender, EventArgs e)
    {
        try
        {
            if (string.IsNullOrEmpty(AlmacenList.SelectedValue) || AlmacenList.SelectedValue == "0")
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "ShowMensaje('warning', 'Debe seleccionar una Almacén.')", true);
                return;
            }

            decimal        monto = Convert.ToDecimal(PrecioTextBox.Text) * Convert.ToDecimal(PesoKGTextBox.Text);
            FacturaDetalle obj   = new FacturaDetalle()
            {
                FacturaId  = Convert.ToInt32(FacturaIdHD.Value),
                ProductoId = Convert.ToInt32(ProductosList.SelectedValue),
                Monto      = monto,
                PesoKG     = Convert.ToDecimal(PesoKGTextBox.Text),
                AlmacenId  = Convert.ToInt32(AlmacenList.SelectedValue)
            };

            int detalleId = FacturaDetalleBLL.InsertFacturaDetalle(obj);

            if (detalleId <= 0)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "ShowMensaje('warning', 'La cantidad de KG ingresados rebasa la capacidad de almacén seleccionado.')", true);
                return;
            }
        }
        catch (Exception)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "ShowMensaje('error', 'Error al registrar Factura. Ingrese datos correctos')", true);
            return;
        }
        Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "ShowMensaje('success', 'Producto añadido.')", true);
        GridProducto.DataBind();
        ShowModalHD.Value = "false";
        ClearDetalle();
        CargarFactura(Convert.ToInt32(FacturaIdHD.Value));
    }
示例#7
0
        private void IDcomboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            LimpiarProvider();
            int idfactura = Convert.ToInt32(IDcomboBox.Text);

            facturas = FacturacionBLL.Buscar(Convert.ToInt32(IDcomboBox.Text));
            CLienteIDcomboBox.Text          = facturas.ClienteID.ToString();
            DescripciponFacturatextBox.Text = facturas.Descripcion;
            DevueltatextBox.Text            = facturas.Devuelta.ToString();
            MontotextBox.Text           = facturas.Monto.ToString();
            Monto                       = facturas.Monto;
            FechadateTimePicker.Value   = facturas.Fecha;
            EfectivonumericUpDown.Value = facturas.EfectivoRecibido;
            facturas.Detalle            = FacturaDetalleBLL.GetList(x => x.FacturaId == idfactura);
            LlenarDetalleComboBox();
            DetallecomboBox.Enabled = true;
            EliminarDetalle.Enabled = true;
            foreach (var item in facturas.Detalle)
            {
                item.Importe = FacturacionBLL.Importedemas(item.Cantidad, item.Precio);
            }
            FacturadataGridView.DataSource = facturas.Detalle;
            Detalle = new List <FacturaDetalle>();
        }
示例#8
0
        private void BuscarFacturaButton_Click(object sender, EventArgs e)
        {
            int            ID      = int.Parse(IDNumericUpDown.Text);
            Facturas       Factura = new Facturas();
            FacturaDetalle Detalle = new FacturaDetalle();

            Factura = FacturaDetalleBLL.Buscar(ID);

            if (Factura != null)
            {
                MessageBox.Show("Factura Encontrada");
                IdPersonasNumericUpDown.Value  = Factura.IdPersona;
                IdProductoNumericUpDown.Value  = Detalle.IdProducto;
                FechadateTimePicker.Value      = Factura.Fecha;
                ObservacionTextBox.Text        = Factura.Observacion;
                MontoTextBox.Text              = (Factura.Monto).ToString();
                FacturaDataGridView.DataSource = FacturaDetalleBLL.GetList(X => X.IdFactura == (int)IDNumericUpDown.Value);
                IdProductoNumericUpDown.Value  = Detalle.IdProducto;
            }
            else
            {
                MessageBox.Show("Factura No encontada");
            }
        }
示例#9
0
        private void Agregarbutton_Click_1(object sender, EventArgs e)
        {
            LimpiarProvider();
            RepositoryBase <Producto> repositoryBase = new RepositoryBase <Producto>();

            if (SetError(6) || SetError(7))
            {
                MessageBox.Show("Debe de completar los campos marcados");
                return;
            }
            if (repositoryBase.Buscar(Convert.ToInt32(ProductoIdcomboBox.Text)).Cantidad - Convert.ToInt32(CantidadnumericUpDown.Value) < 0)
            {
                MessageBox.Show("Cantidad insuficiente del producto solicitado");
                MessageBox.Show("Disponibles " + repositoryBase.Buscar(Convert.ToInt32(ProductoIdcomboBox.Text)).Cantidad.ToString());
                return;
            }
            if (IDcomboBox.Text == string.Empty)
            {
                facturas.Detalle.Add(new FacturaDetalle(0, facturas.FacturaId, Convert.ToInt32(ProductoIdcomboBox.Text), Convert.ToInt32(CantidadnumericUpDown.Value), Convert.ToDecimal(PreciotextBox.Text), DescripcionProductotextBox.Text, Convert.ToDecimal(ImportetextBox.Text)));
            }
            else
            {
                int idfactura = Convert.ToInt32(IDcomboBox.Text);
                if (facturas.Detalle.Count == 0)
                {
                    facturas.Detalle = FacturaDetalleBLL.GetList(x => x.FacturaId == idfactura);
                }
                if (DetallecomboBox.Text == string.Empty)
                {
                    var Idproducto = Convert.ToInt32(ProductoIdcomboBox.Text);
                    if (facturas.Detalle.Exists(x => x.ProductoId == Idproducto))
                    {
                        foreach (var item in facturas.Detalle)
                        {
                            if (item.ProductoId == Idproducto)
                            {
                                item.Cantidad += Convert.ToInt32(CantidadnumericUpDown.Value);
                            }
                        }
                    }
                    else
                    {
                        facturas.Detalle.Add(new FacturaDetalle(0, Convert.ToInt32(IDcomboBox.Text), Convert.ToInt32(ProductoIdcomboBox.Text), Convert.ToInt32(CantidadnumericUpDown.Value), Convert.ToDecimal(PreciotextBox.Text), DescripcionProductotextBox.Text, Convert.ToDecimal(ImportetextBox.Text)));
                    }
                }
                else
                {
                    Monto -= FacturacionBLL.DescontarImporte(facturas.Detalle, Convert.ToInt32(DetallecomboBox.Text));

                    foreach (var item in facturas.Detalle)
                    {
                        item.Importe = FacturacionBLL.Importe(item.Cantidad, CantidadnumericUpDown.Value, item.Precio, Convert.ToInt32(ProductoIdcomboBox.Text), item.ProductoId);
                    }
                    facturas.Detalle = FacturacionBLL.Editar(facturas.Detalle, new FacturaDetalle(Convert.ToInt32(DetallecomboBox.Text), Convert.ToInt32(IDcomboBox.Text), Convert.ToInt32(ProductoIdcomboBox.Text), Convert.ToInt32(CantidadnumericUpDown.Value), Convert.ToDecimal(PreciotextBox.Text), DescripcionProductotextBox.Text, Convert.ToDecimal(ImportetextBox.Text)));
                }
            }
            Monto            += FacturacionBLL.CalcularMonto(Convert.ToDecimal(ImportetextBox.Text));
            MontotextBox.Text = Monto.ToString();
            if (paso)
            {
                AsignarDevuelta();
            }
            FacturadataGridView.DataSource = null;
            FacturadataGridView.DataSource = facturas.Detalle;
            LimpiarProducto();
            LlenarDetalleComboBox();
            EliminarDetalle.Enabled = true;
        }
示例#10
0
        private void Guardarbutton_Click_1(object sender, EventArgs e)
        {
            LimpiarProvider();
            if (SetError(2))
            {
                MessageBox.Show("Llenar Campos vacios");
                return;
            }
            Factura factura = LlenaClase();

            if (IDcomboBox.Text == string.Empty)
            {
                if (FacturacionBLL.Guardar(factura))
                {
                    MessageBox.Show("Guardado!!");
                    LlenarComboBox();
                    FacturacionBLL.DescontarProductos(facturas.Detalle);
                    var result = MessageBox.Show("Desea Imprimir un recibo?", " ",
                                                 MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        RepositoryBase <Cliente> repositorio = new RepositoryBase <Cliente>();
                        var            usuario = repositorio.Buscar(factura.ClienteID);
                        DetalleReporte reporte = new DetalleReporte(facturas.Detalle, UsuariotextBox.Text, usuario.Nombre);
                        reporte.Show();
                    }
                    Clean();
                }
                else
                {
                    MessageBox.Show("No se pudo Guardar!!");
                }
            }
            else
            {
                var result = MessageBox.Show("Seguro de Modificar?", " ",
                                             MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    if (FacturacionBLL.Modificar(LlenaClase()))
                    {
                        MessageBox.Show("Modificado !");
                        if (Detalle.Count != 0)
                        {
                            foreach (var item in Detalle)
                            {
                                FacturaDetalleBLL.Eliminar(item.Id);
                            }
                        }
                        if (Arreglar)
                        {
                            FacturacionBLL.ArreglarProductoList(Detalle);
                            Arreglar = false;
                        }
                        var resultado = MessageBox.Show("Desea Imprimir un recibo?", " ",
                                                        MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                        if (result == DialogResult.Yes)
                        {
                            Factura facturas = LlenaClase();
                            RepositoryBase <Cliente> repositorio = new RepositoryBase <Cliente>();
                            var            usuario = repositorio.Buscar(factura.ClienteID);
                            DetalleReporte reporte = new DetalleReporte(facturas.Detalle, UsuariotextBox.Text, usuario.Nombre);
                            reporte.Show();
                        }
                        Clean();
                    }
                    else
                    {
                        MessageBox.Show("No se pudo modificar!");
                    }
                }
            }
        }
示例#11
0
        private void ImprimirButton_Click(object sender, EventArgs e)
        {
            ImprimirFacturas ifac = new ImprimirFacturas(FacturaDetalleBLL.GetList1(filtrar));

            ifac.Show();
        }