public void BuscarTest()
        {
            Facturas facturas = new Facturas();

            facturas = FacturasBLL.Buscar(2);
            Assert.IsNotNull(facturas);
        }
Beispiel #2
0
        public void BuscarTest()
        {
            int      id       = 3;
            Facturas facturas = new Facturas();

            facturas = FacturasBLL.Buscar(id);
            Assert.IsNotNull(facturas);
        }
Beispiel #3
0
        private void buttonGuardar_Click(object sender, EventArgs e)
        {
            if (ValidarFactura())
            {
                int id = Convert.ToInt32(comboBoxCliente.SelectedValue);
                if (ClientesBLL.Buscar(x => x.ClienteId == id, false))
                {
                    id = 0;
                    int.TryParse(maskedTextBoxId.Text, out id);
                    Factura factura = new Factura(id, ClientesBLL.clienteReturned.ClienteId, ((FormaDePago)comboBoxFormaDePago.SelectedItem).FormaDePagoId, DateTime.Now, float.Parse(labelTotal.Text), 1);



                    if (!FacturasBLL.Buscar(x => x.FacturaId == factura.FacturaId, true))
                    {
                        foreach (DataGridViewRow producto in dataGridView.Rows)
                        {
                            if (!string.IsNullOrEmpty(Convert.ToString(producto.Cells[0].Value)) && !string.IsNullOrWhiteSpace(Convert.ToString(producto.Cells[0].Value)))
                            {
                                int productoId = Convert.ToInt32(producto.Cells[0].Value);
                                ProductosBLL.Buscar(x => x.ProductoId == productoId, false);
                                factura.Productos.Add(new ProductoFactura(ProductosBLL.productoReturned.ProductoId, factura.FacturaId, Convert.ToInt32(producto.Cells[2].Value), Convert.ToInt32(producto.Cells[3].Value)));
                            }
                        }
                        if (FacturasBLL.Guardar(factura))
                        {
                            maskedTextBoxId.Text = FacturasBLL.facturaReturned.FacturaId.ToString();
                        }
                    }
                    else
                    {
                        for (int i = 0; i < dataGridView.Rows.Count; i++)
                        {
                            if (!string.IsNullOrEmpty(Convert.ToString(dataGridView.Rows[i].Cells[0].Value)) && !string.IsNullOrWhiteSpace(Convert.ToString(dataGridView.Rows[i].Cells[0].Value)))
                            {
                                int productoId       = Convert.ToInt32(dataGridView.Rows[i].Cells[0].Value);
                                int productoCantidad = Convert.ToInt32(dataGridView.Rows[i].Cells[2].Value);
                                factura.Productos.Add(new ProductoFactura(productoId, factura.FacturaId, productoCantidad, Convert.ToInt32(dataGridView.Rows[i].Cells[3].Value)));
                            }
                        }
                        factura.Pagos = null;

                        if (FacturasBLL.Modificar(factura))
                        {
                            maskedTextBoxId.Text = FacturasBLL.facturaReturned.FacturaId.ToString();
                            CalcularFactura();
                        }
                    }
                    FacturasBLL.Buscar(x => x.FacturaId == factura.FacturaId, true);
                    VerificarPagos(FacturasBLL.facturaReturned);
                }
                else
                {
                }
            }
        }
Beispiel #4
0
        public void BuscarTest()
        {
            int         id          = 1;
            FacturasBLL repositorio = new FacturasBLL();
            Facturas    factura     = new Facturas();
            bool        paso        = factura.Detalles.Count > 0;

            factura = FacturasBLL.Buscar(id);
            Assert.IsNotNull(factura);
        }
Beispiel #5
0
        public void ModificarTest()
        {
            FacturasBLL repositorio = new FacturasBLL();
            int         id          = 2;
            var         factura     = FacturasBLL.Buscar(id);

            factura.Detalles.Add(new FacturasDetalles(1, 2, 1, 5, 500, 2500));
            bool paso = FacturasBLL.Modificar(factura);

            Assert.AreEqual(true, paso);
        }
Beispiel #6
0
 private void buttonEliminar_Click(object sender, EventArgs e)
 {
     if (UtilidadesFormularios.Validar(maskedTextBoxId))
     {
         int id = int.Parse(maskedTextBoxId.Text);
         if (FacturasBLL.Buscar(x => x.FacturaId == id, false))
         {
             FacturasBLL.Eliminar(FacturasBLL.facturaReturned);
             LimpiarFactura();
         }
     }
 }
Beispiel #7
0
        private void BuscarButton_Click(object sender, EventArgs e)
        {
            Facturas facturas = FacturasBLL.Buscar((int)IdNumericUpDown.Value);

            if (facturas != null)
            {
                LlenaCampos(facturas);
            }
            else
            {
                MessageBox.Show("No Hay Resultados Para La Busqueda", "Fallo!!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                NuevoButton.PerformClick();
            }
        }
Beispiel #8
0
        private void VerificarPagos()
        {
            int id = int.Parse(maskedTextBoxId.Text);

            FacturasBLL.Buscar(x => x.FacturaId == id, true);

            factura = FacturasBLL.facturaReturned;

            double totalPagos = 0;

            dataGridView1.Rows.Clear();
            dataGridView1.Refresh();


            if (factura.Pagos.Count > 0)
            {
                foreach (var pago in factura.Pagos)
                {
                    if (dataGridView1.Rows.Count == 0)
                    {
                        dataGridView1.Rows.Add();
                        DataGridViewRow row = (DataGridViewRow)dataGridView1.Rows[0];
                        row.Cells[0].Value = pago.PagoId;
                        row.Cells[1].Value = pago.Fecha;
                        row.Cells[2].Value = pago.Monto;
                        totalPagos        += pago.Monto;
                    }
                    else
                    {
                        DataGridViewRow row = (DataGridViewRow)dataGridView1.Rows[0].Clone();
                        row.Cells[0].Value = pago.PagoId;
                        row.Cells[1].Value = pago.Fecha;
                        row.Cells[2].Value = pago.Monto;
                        dataGridView1.Rows.Add(row);
                        totalPagos += pago.Monto;
                    }
                }
            }

            if (totalPagos > factura.Total)
            {
                labelEstado.Text      = "Pagada";
                labelEstado.ForeColor = Color.Green;
            }
            else
            {
                labelEstado.Text      = "Debe";
                labelEstado.ForeColor = Color.Red;
            }
        }
        protected void GuardarButton_Click(object sender, EventArgs e)
        {
            bool        paso        = false;
            FacturasBLL repositorio = new FacturasBLL();
            Facturas    factura     = new Facturas();

            if (HayErrores())
            {
                return;
            }
            else
            {
                factura = LlenaClase();

                if (Utils.ToInt(FacturaIdTextbox.Text) == 0)
                {
                    paso = FacturasBLL.Guardar(factura);
                    Utils.ShowToastr(this, "Guardado", "Exito", "success");
                    Limpiar();
                }
                else
                {
                    FacturasBLL repository = new FacturasBLL();
                    int         id         = Utils.ToInt(FacturaIdTextbox.Text);
                    factura = FacturasBLL.Buscar(id);

                    if (factura != null)
                    {
                        paso = FacturasBLL.Modificar(LlenaClase());
                        Utils.ShowToastr(this, "Modificado", "Exito", "success");
                        Limpiar();
                    }
                    else
                    {
                        Utils.ShowToastr(this, "Id no existe", "Error", "error");
                    }
                }

                if (paso)
                {
                    Limpiar();
                }
                else
                {
                    Utils.ShowToastr(this, "No se pudo guardar", "Error", "error");
                }
            }
        }
Beispiel #10
0
        private void EliminarButton_Click(object sender, EventArgs e)
        {
            Facturas facturas = FacturasBLL.Buscar((int)IdNumericUpDown.Value);

            if (facturas != null)
            {
                FacturasBLL.Eliminar(facturas.FacturaId);
                //EliminarTotal();
                MessageBox.Show("Eliminado Correctamente", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information);
                NuevoButton.PerformClick();
            }
            else
            {
                MessageBox.Show("No Se Puso Eliminar", "Fallo", MessageBoxButtons.OK, MessageBoxIcon.Stop);
            }
        }
        protected void BuscarButton_Click(object sender, EventArgs e)
        {
            FacturasBLL repositorio = new FacturasBLL();

            var factura = FacturasBLL.Buscar(Utils.ToInt(FacturaIdTextbox.Text));

            if (factura != null)
            {
                LlenarCampos(factura);
                Utils.ShowToastr(this, "Busqueda exitosa", "Exito", "success");
            }
            else
            {
                Limpiar();
                Utils.ShowToastr(this, "No se pudo encontrar la factura", "Error", "error");
            }
        }
Beispiel #12
0
        private void BuscarBtn(object sender, RoutedEventArgs e)
        {
            Facturas anterior = FacturasBLL.Buscar(int.Parse(facturaIdTextBox.Text));

            if (anterior != null)
            {
                facturas = anterior;
                this.facturasDetalles = anterior.FacturasDetalles;
                Actualizar();
                Lista();
                Calcular();
            }
            else
            {
                MessageBox.Show("No encontrado");
            }
        }
Beispiel #13
0
        private void buttonImprimir_Click(object sender, EventArgs e)
        {
            if (UtilidadesFormularios.Validar(maskedTextBoxId))
            {
                int facturaId = int.Parse(maskedTextBoxId.Text);
                FacturasBLL.Buscar(x => x.FacturaId == facturaId, true);

                List <ProductosInFacturas> productos = new List <ProductosInFacturas>();
                ProductosFacturasBLL.GetList(x => x.FacturaId == facturaId, true);
                foreach (var producto in ProductosFacturasBLL.productoFacturaReturnedList)
                {
                    productos.Add(new ProductosInFacturas(producto.Producto.Nombre, producto.Cantidad, producto.Precio));
                }

                new ReporteFactura(FacturasBLL.facturaReturned, productos).Show();
            }
        }
Beispiel #14
0
        private void buttonBuscar_Click(object sender, EventArgs e)
        {
            if (UtilidadesFormularios.Validar(maskedTextBoxId))
            {
                int id = int.Parse(maskedTextBoxId.Text);

                if (FacturasBLL.Buscar(x => x.FacturaId == id, true))
                {
                    dataGridView.Rows.Clear();
                    dataGridView.Refresh();
                    Factura factura = FacturasBLL.facturaReturned;
                    comboBoxCliente.Text              = factura.Cliente.Nombres;
                    dateTimePicker1.Value             = factura.Fecha;
                    comboBoxFormaDePago.SelectedValue = factura.FormaDePagoId;

                    foreach (var producto in factura.Productos)
                    {
                        if (dataGridView.Rows.Count == 0)
                        {
                            dataGridView.Rows.Add();
                            DataGridViewRow row = (DataGridViewRow)dataGridView.Rows[0];
                            row.Cells[0].Value = producto.ProductoId;
                            row.Cells[1].Value = producto.Producto.Nombre;
                            row.Cells[2].Value = producto.Cantidad;
                            row.Cells[3].Value = producto.Precio;
                            row.Cells[4].Value = row.Cells[4].Value = Convert.ToDouble(row.Cells[2].Value) * Convert.ToDouble(row.Cells[3].Value);
                        }
                        else
                        {
                            DataGridViewRow row = (DataGridViewRow)dataGridView.Rows[0].Clone();
                            row.Cells[0].Value = producto.ProductoId;
                            row.Cells[1].Value = producto.Producto.Nombre;
                            row.Cells[2].Value = producto.Cantidad;
                            row.Cells[3].Value = producto.Precio;
                            row.Cells[4].Value = row.Cells[4].Value = Convert.ToDouble(row.Cells[2].Value) * Convert.ToDouble(row.Cells[3].Value);
                            dataGridView.Rows.Add(row);
                        }
                    }


                    CalcularFactura();
                    VerificarPagos(factura);
                }
            }
        }
Beispiel #15
0
        //Fin Metodos

        private void GuardarButton_Click(object sender, EventArgs e)
        {
            Facturas facturas = FacturasBLL.Buscar((int)IdNumericUpDown.Value);

            if (Validar())
            {
                MessageBox.Show("Hay Campos Que Deben Ser Revisados", "Validacion!!", MessageBoxButtons.OK, MessageBoxIcon.Question);
                MyErrorProvider.Clear();
                return;
            }


            if (facturas == null)
            {
                if (FacturasBLL.Guardar(LlenaClase()))
                {
                    if (CreditoRadioButton.Checked)
                    {
                        GuardarTotal();
                    }
                    MessageBox.Show("Guardado Correctamente", "Exito!!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Recibo();
                }
                else
                {
                    MessageBox.Show("No Se Pudo Registrar La Factura", "Fallo!!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            else
            {
                if (FacturasBLL.Modificar(LlenaClase()))
                {
                    if (CreditoRadioButton.Checked)
                    {
                        ModificarTotal();
                    }
                    MessageBox.Show("Modificado Correctamente", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Recibo();
                }
                else
                {
                    MessageBox.Show("No Se Pudo Modificar La Factura", "Fallo!!", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
            }
        }
Beispiel #16
0
        private void Buscar() // Funcion encargada de realizar la busqueda de la factura
        {
            MyErrorProvider.Clear();
            int      Id;
            Facturas Factura = new Facturas();

            int.TryParse(FacturaIdNumericUpDown.Text, out Id);
            Factura = FacturasBLL.Buscar(Id);

            if (Factura != null)
            {
                LlenaCampos(Factura);
                FacturaIdNumericUpDown.Enabled = false;
                BuscarButton.Enabled           = false;
                EliminarProductoButton.Visible = true;
            }
            else
            {
                MyErrorProvider.SetError(FacturaIdNumericUpDown, "No existe una factura con este código!");
                FacturaIdNumericUpDown.Focus();
            }
        }
        protected void EliminarButton_Click(object sender, EventArgs e)
        {
            FacturasBLL repositorio = new FacturasBLL();
            int         id          = Utils.ToInt(FacturaIdTextbox.Text);

            var factura = FacturasBLL.Buscar(id);

            if (factura != null)
            {
                if (FacturasBLL.Eliminar(id))
                {
                    Utils.ShowToastr(this, "Eliminado", "Exito", "success");
                    Limpiar();
                }
                else
                {
                    Utils.ShowToastr(this, "No se pudo eliminar", "Error", "error");
                }
            }
            else
            {
                Utils.ShowToastr(this, "No existe", "Error", "error");
            }
        }
        public JsonResult Buscar(int facturaId)
        {
            Facturas factura = FacturasBLL.Buscar(facturaId);

            return(Json(factura));
        }
Beispiel #19
0
        private bool Existe()
        {
            Facturas facturas = FacturasBLL.Buscar(Convert.ToInt32(facturaIdTextBox.Text));

            return(facturas != null);
        }