Example #1
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                if (MessageBox.Show("Desea eliminar la factura", "Eliminar Factura", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                {
                    if (cbxTipoPago.SelectedItem.Equals("Cheque"))
                    {
                        ChequeADO chequeADO = new ChequeADO(ConfigurationManager.ConnectionStrings["StringVehiculo"].ConnectionString);
                        chequeADO.EliminarCheque(Convert.ToInt32(txtCodigo.Text));
                    }

                    VentaENCADO     ventaEncabezadoADO = new VentaENCADO(ConfigurationManager.ConnectionStrings["StringVehiculo"].ConnectionString);
                    VentaDetalleADO ventaDetalleAdo    = new VentaDetalleADO(ConfigurationManager.ConnectionStrings["StringVehiculo"].ConnectionString);

                    ventaDetalleAdo.EliminarDetalles(Convert.ToInt32(txtCodigo.Text));
                    ventaEncabezadoADO.EliminarEncabezado(Convert.ToInt32(txtCodigo.Text));
                    MessageBox.Show("Factura Eliminada Correctamente", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);

                    EstadoInicial();
                }
                else
                {
                    EstadoInicial();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            try
            {
                int numFila = dtgDetalle.RowCount - 1;

                if (calcular && numFila > 0)
                {
                    int    idMoto     = 0;
                    int    cantidad   = 0;
                    double montoFlete = 0;
                    double impAduana  = 0;
                    double ganancia   = 0;
                    double iva        = 0;
                    double subtotal   = 0;
                    double total      = 0;

                    VentaENC ventaENC = new VentaENC(Convert.ToInt32(txtCodigo.Text), Convert.ToInt32(txtCedula.Text), Convert.ToDateTime(dtpFecha.Text),
                                                     "" + cbxTipoPago.SelectedItem, Convert.ToDouble(txtDescuento.Text), Convert.ToDouble(txtSubtotal.Text),
                                                     Convert.ToDouble(txtTotalDolares.Text), Convert.ToDouble(txtTotal.Text));
                    VentaENCADO ventaEncabezadoADO = new VentaENCADO(ConfigurationManager.ConnectionStrings["StringVehiculo"].ConnectionString);
                    ventaEncabezadoADO.RegistrarEncabezado(ventaENC);


                    VentaDetalleADO ventaDetalleAdo = new VentaDetalleADO(ConfigurationManager.ConnectionStrings["StringVehiculo"].ConnectionString);
                    VentaDET        ventaDet        = null;
                    //Agregar los detalles
                    numFila = dtgDetalle.RowCount - 1;
                    for (int i = 0; i < numFila; i++)
                    {
                        idMoto     = Convert.ToInt32(dtgDetalle.Rows[i].Cells[0].Value);
                        cantidad   = Convert.ToInt32(dtgDetalle.Rows[i].Cells[2].Value);
                        montoFlete = Convert.ToDouble(dtgDetalle.Rows[i].Cells[3].Value);
                        impAduana  = Convert.ToDouble(dtgDetalle.Rows[i].Cells[4].Value);
                        ganancia   = Convert.ToDouble(dtgDetalle.Rows[i].Cells[5].Value);
                        iva        = Convert.ToDouble(dtgDetalle.Rows[i].Cells[6].Value);
                        subtotal   = Convert.ToDouble(dtgDetalle.Rows[i].Cells[7].Value);
                        total      = Convert.ToDouble(dtgDetalle.Rows[i].Cells[8].Value);

                        ventaDet = new VentaDET(ventaENC.IDVenta, idMoto, cantidad, montoFlete, impAduana,
                                                ganancia, iva, subtotal, total);

                        ventaDetalleAdo.RegistrarDetalle(ventaDet);
                    }

                    if (cbxTipoPago.SelectedItem.Equals("Cheque"))
                    {
                        ChequeADO chequeADO = new ChequeADO(ConfigurationManager.ConnectionStrings["StringVehiculo"].ConnectionString);
                        chequeGlobal.IdVenta = ventaENC.IDVenta;

                        chequeADO.RegistrarCheque(chequeGlobal);
                    }



                    EstadoInicial();

                    MessageBox.Show("Factura Registrada correctamente", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    throw new Exception("Debe calcular los montos o no hay detalles incluidos");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }