Exemplo n.º 1
0
        public void RegistrarDetalle(VentaDET ventaDET)
        {
            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_ventaDET";
                this.sqlComando.Parameters.AddWithValue("@idVenta", ventaDET.Idventa);
                this.sqlComando.Parameters.AddWithValue("@idMoto", ventaDET.Idmoto);
                this.sqlComando.Parameters.AddWithValue("@cantidad", ventaDET.Cantidad);
                this.sqlComando.Parameters.AddWithValue("@montoFleteEnvio", ventaDET.MontoFleteEnvio);
                this.sqlComando.Parameters.AddWithValue("@montoImpuestoAduana", ventaDET.MontoImpuestoAduana);
                this.sqlComando.Parameters.AddWithValue("@montoGanancia", ventaDET.MontoGanancia);
                this.sqlComando.Parameters.AddWithValue("@montoIVA", ventaDET.MontoIVA);
                this.sqlComando.Parameters.AddWithValue("@subTotal", ventaDET.SubTotal);
                this.sqlComando.Parameters.AddWithValue("@total", ventaDET.Total);
                this.sqlComando.ExecuteNonQuery();

                this.sqlConexion.Close();
                this.sqlComando.Dispose();
                this.sqlConexion.Dispose();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 2
0
        private void btnAgregarDetalle_Click(object sender, EventArgs e)
        {
            try
            {
                bool existe = VerificarMotosDetalle();

                if (existe)
                {
                    MessageBox.Show("No puede ingresar la misma moto", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    MotoADO motoADO = new MotoADO(ConfigurationManager.ConnectionStrings["StringVehiculo"].ConnectionString);
                    Moto    moto    = motoADO.ConsultarMoto(Convert.ToInt32(cbxMotos.SelectedValue));

                    VentaDET ventaDet = new VentaDET(Convert.ToInt32(txtCodigo.Text), moto.IDMoto, Convert.ToInt32(txtCantidad.Value));

                    VentaDET venta = ventaDet.CalcularMontos(moto, ventaDet);

                    dtgDetalle.Rows.Add("" + moto.IDMoto, "" + moto.Nombre, "" + venta.Cantidad, "" + venta.MontoFleteEnvio, "" + venta.MontoImpuestoAduana,
                                        "" + venta.MontoGanancia, "" + venta.MontoIVA, "" + venta.SubTotal, "" + venta.Total);

                    //Actualizar subtotal automaticamente
                    cantidadMotos += venta.Cantidad;
                    double subtotal = Convert.ToDouble(txtSubtotal.Text);
                    subtotal        += Math.Round(venta.Total, 3);
                    txtSubtotal.Text = "" + subtotal;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Este evento elimina la fila seleccionada por el usuario para una posible modificacion
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dtgDetalle_RowHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            MotoADO motoADO = new MotoADO(ConfigurationManager.ConnectionStrings["StringVehiculo"].ConnectionString);
            Moto    moto    = motoADO.ConsultarMoto(Convert.ToInt32(dtgDetalle.Rows[e.RowIndex].Cells[0].Value));

            VentaDET ventaDet = new VentaDET(Convert.ToInt32(txtCodigo.Text), moto.IDMoto, Convert.ToInt32(dtgDetalle.Rows[e.RowIndex].Cells[2].Value));



            VentaDET venta = ventaDet.CalcularMontos(moto, ventaDet);


            //Esto es para restar la fila selecciona y recalcular el subtotal
            double subtotal = Convert.ToDouble(txtSubtotal.Text);

            subtotal         = subtotal - Math.Round(venta.Total, 3);
            txtSubtotal.Text = "" + subtotal;
            cantidadMotos    = cantidadMotos - venta.Cantidad;

            //se selecciona la moto y la cantidad seleccionada
            cbxMotos.SelectedValue = dtgDetalle.Rows[e.RowIndex].Cells[0].Value;
            txtCantidad.Value      = Convert.ToDecimal(dtgDetalle.Rows[e.RowIndex].Cells[2].Value);
            dtgDetalle.Rows.RemoveAt(e.RowIndex);
        }
Exemplo 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);
            }
        }