예제 #1
0
        private void btnFinalizar_Click(object sender, EventArgs e)
        {
            int     FormadePago    = 0;
            decimal valorMedioPago = 0;
            string  placa          = "";
            bool    band           = false;
            string  Kilometraje    = "0";

            CantidaGalonesTemporal = 0;
            Dictionary <int, decimal> oFormasPago = new Dictionary <int, decimal>();

            try
            {
                foreach (DataGridViewRow Fila in grdTurnos.Rows)
                {
                    FormadePago             = Convert.ToInt16(Fila.Cells["dgvFormaPago"].Value.ToString());
                    valorMedioPago          = Convert.ToDecimal(Fila.Cells["dgvValor"].Value.ToString());
                    CantidaGalonesTemporal += Convert.ToDecimal(Fila.Cells["dgvCantidad"].Value.ToString());
                    band = true;

                    if (FormadePago != 25)
                    {
                        if (oFormasPago.ContainsKey(FormadePago))
                        {
                            valorMedioPago          += oFormasPago[FormadePago];
                            oFormasPago[FormadePago] = valorMedioPago;
                        }
                        else
                        {
                            oFormasPago.Add(FormadePago, valorMedioPago);
                        }
                    }
                }

                if (!band)
                {
                    if (MessageBox.Show("Desea Guardar el total de la venta en efectivo ?", "Confirmación", System.Windows.Forms.MessageBoxButtons.YesNo,
                                        System.Windows.Forms.MessageBoxIcon.Question, System.Windows.Forms.MessageBoxDefaultButton.Button1) == DialogResult.No)
                    {
                        return;
                    }
                    else
                    {
                        if (sumValorTotalEfectivo < ValorTotal)
                        {
                            FormadePago    = 4;
                            valorMedioPago = Convert.ToDecimal(ValorTotal - sumValorTotalEfectivo);
                            oFormasPago.Add(FormadePago, valorMedioPago);
                            txtCantidad.Text       = Cantidad.ToString();
                            txtCantidad.Text       = Cantidad.ToString();
                            CantidaGalonesTemporal = Convert.ToDecimal(txtCantidad.Text);
                        }
                    }
                }



                decimal canttemp;
                if (decimal.TryParse(CantidaGalonesTemporal.ToString(), out canttemp))
                {
                    string venta = "Se genero el recibo # ";
                    Recibo         = ODatos.InsertarVentaGTRecuperadaFullStation(Convert.ToInt16(Manguera), canttemp, oFormasPago, placa, Kilometraje, Guid.NewGuid().ToString(), Turno, IdBloqueo.ToString()).ToString();
                    venta          = venta + Recibo;
                    lblrecibo.Text = venta;
                    ODatos.HabilitarMangueraConVentasFueraDelSistemaFullStation(Manguera, IdBloqueo, false);
                    MessageBox.Show("Registro exitoso", "Gasolutions", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Cantidad              = Cantidad - canttemp;
                    txtCantidad.Text      = Cantidad.ToString();
                    txtValorTotal.Text    = (Cantidad * Precio).ToString();
                    ValorTotal            = (Cantidad * Precio);
                    sumValorTotalEfectivo = 0;
                    Limpiar();
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message, "Gasolutions", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
예제 #2
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            decimal temp;

            try
            {
                if (decimal.TryParse(txtValorFormaPago.Text, out temp))
                {
                    temp = Convert.ToDecimal(Utilidades.ModificarFormatoDecimal(txtValorFormaPago.Text));

                    if (temp > 0)
                    {
                        if (temp <= ValorTotal)
                        {
                            if ((sumValorTotalEfectivo + temp) <= ValorTotal)
                            {
                                decimal gal;
                                if (!string.IsNullOrEmpty(txtCantidad.Text.Trim()))
                                {
                                    if (Decimal.TryParse(txtCantidad.Text.Trim(), out gal))
                                    {
                                        if (gal <= Cantidad)
                                        {
                                            txtValorFormaPago.Clear();
                                            grdTurnos.Rows.Add(IdBloqueo.ToString(), Turno.ToString(), Manguera.ToString(), Producto.ToString(), cmbFormaPago.SelectedValue.ToString(), Precio.ToString(), txtCantidad.Text.Trim(), temp.ToString());
                                            sumValorTotalEfectivo += temp;
                                        }
                                        else
                                        {
                                            MessageBox.Show("La Catidad de Galones supera la cantidad total", "Agregar Cantidad", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                        }
                                    }
                                    else
                                    {
                                        MessageBox.Show("La Catidad de Galones es numerica", "Agregar Cantidad", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                    }
                                }
                                else
                                {
                                    MessageBox.Show("La Catidad de Galones es obligatoria", "Agregar Cantidad", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                }
                            }
                            else
                            {
                                MessageBox.Show("El valor supera al total de la venta", "Agregar Cantidad", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            }
                        }
                        else
                        {
                            MessageBox.Show("El valor supera al total de la venta", "Agregar Cantidad", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }
                    else
                    {
                        MessageBox.Show("El valor debe ser mayor que cero", "Agregar Cantidad", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    MessageBox.Show("El valor debe ser numerico", "Agregar Cantidad", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }

            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message, "Gasolutions", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }