Ejemplo n.º 1
0
        public VentaENC ConsultarEncabezado(int idventa)
        {
            try
            {
                VentaENC      ventaEnc = null;
                SqlDataReader lectura;
                this.sqlConexion = new SqlConnection(this.StringConexion);
                this.sqlComando  = new SqlCommand();
                this.sqlConexion.Open();
                this.sqlComando.Connection  = this.sqlConexion;
                this.sqlComando.CommandType = System.Data.CommandType.StoredProcedure;
                this.sqlComando.CommandText = "Sp_Cns_ventaEnc";
                this.sqlComando.Parameters.AddWithValue("@idVenta", idventa);

                lectura = this.sqlComando.ExecuteReader();
                if (lectura.Read())
                {
                    ventaEnc = new VentaENC(Convert.ToInt32(lectura.GetValue(0)), Convert.ToInt32(lectura.GetValue(1)),
                                            Convert.ToDateTime(lectura.GetValue(2)), (string)lectura.GetValue(3),
                                            Convert.ToDouble(lectura.GetValue(4)), Convert.ToDouble(lectura.GetValue(5)),
                                            Convert.ToDouble(lectura.GetValue(6)), Convert.ToDouble(lectura.GetValue(7)));
                }
                return(ventaEnc);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 2
0
        public void RegistrarEncabezado(VentaENC ventaENC)
        {
            try
            {
                this.sqlConexion = new SqlConnection(this.StringConexion);
                this.sqlComando  = new SqlCommand();

                this.sqlConexion.Open();
                this.sqlComando.Connection  = this.sqlConexion;
                this.sqlComando.CommandType = System.Data.CommandType.StoredProcedure;
                this.sqlComando.CommandText = "Sp_Ins_ventaEnc";
                this.sqlComando.Parameters.AddWithValue("@idVenta", ventaENC.IDVenta);
                this.sqlComando.Parameters.AddWithValue("@cedula", ventaENC.Cedula);
                this.sqlComando.Parameters.AddWithValue("@fecha", ventaENC.Fecha);
                this.sqlComando.Parameters.AddWithValue("@tipoPago", ventaENC.TipoPago);
                this.sqlComando.Parameters.AddWithValue("@montoDescuento", ventaENC.MontoDescuento);
                this.sqlComando.Parameters.AddWithValue("@subtotal", ventaENC.Subtotal);
                this.sqlComando.Parameters.AddWithValue("@totalDolares", ventaENC.TotalDolares);
                this.sqlComando.Parameters.AddWithValue("@total", ventaENC.Total);
                this.sqlComando.ExecuteNonQuery();

                this.sqlConexion.Close();
                this.sqlComando.Dispose();
                this.sqlConexion.Dispose();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 3
0
        private void btnConsultar_Click(object sender, EventArgs e)
        {
            try
            {
                VentaENCADO ventaEncabezadoADO = new VentaENCADO(ConfigurationManager.ConnectionStrings["StringVehiculo"].ConnectionString);
                VentaENC    ventaENC           = ventaEncabezadoADO.ConsultarEncabezado(Convert.ToInt32(txtCodigo.Text));

                if (ventaENC != null)
                {
                    Cliente cliente = new ClienteADO(ConfigurationManager.ConnectionStrings["StringVehiculo"].ConnectionString).ConsultarCliente(ventaENC.Cedula);


                    ListarPagos(cliente);
                    txtCedula.Text           = "" + ventaENC.Cedula;
                    txtNombre.Text           = cliente.Nombre;
                    cbxTipoPago.SelectedItem = "" + ventaENC.TipoPago;
                    txtDescuento.Text        = "" + ventaENC.MontoDescuento;
                    txtTotal.Text            = "" + ventaENC.Total;
                    txtSubtotal.Text         = "" + ventaENC.Subtotal;
                    txtTotalDolares.Text     = "" + ventaENC.TotalDolares;


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

                    dataGridView1.DataSource = ventaDetalleAdo.ListaDetalles(ventaENC.IDVenta).Tables[0];
                    dataGridView1.Visible    = true;

                    HabilitarModEli();
                }
                else
                {
                    DialogResult respuesta = MessageBox.Show("La venta no se encuentra registrada\n¿Desea agregarla?", "Mensaje", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                    if (respuesta == DialogResult.Yes)
                    {
                        HabilitarAgregar();
                    }//fin if dialogo
                    else
                    {
                        this.EstadoInicial();
                    }//fin de else dialogo
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 4
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);
            }
        }