Exemplo n.º 1
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.º 2
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);
        }