示例#1
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            //Verificar txt en blanco
            if (txtPantalla.Text != "")
            {
                //Verificar si existe el registro
                Persona persona = control.buscarUsuarioAlInsertarHistorial(txtPantalla.Text);

                if (persona.Codigo == 1)
                {
                    //No se pueden imprimir tiquestes hasta que no se configure la impresora
                    if (control.NombreInstitucion == "" || control.NombreImpresora == "")
                    {
                        MessageBox.Show("Debes configurar la impresora y el nombre de la institución", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        //Insetar registro en la tabla Historial
                        string fecha = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                        string hora  = DateTime.Now.ToString("HH:mm:ss");

                        Historial historial = new Historial
                        {
                            Fecha          = fecha,
                            Identificacion = txtPantalla.Text,
                            Hora           = hora
                        };

                        Resultado result = HistorialBLL.InsertarHistorial(historial);

                        if (result.Codigo == 1)
                        {
                            //Si se inserta el registro correctamente sale la ficha
                            MessageBox.Show("Tome su ficha", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            //crear e imprmir tiquete
                            control.CrearTickete(persona, historial);
                        }
                        else
                        {
                            MessageBox.Show("Problemas al insertar intente de nuevo", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Usuario no encontrado", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                MessageBox.Show("Ingrese un registro", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            txtPantalla.Text = "";
            data             = "";
        }
示例#2
0
        public void ObtenerNumeroFactura()
        {
            //Obtener numeroFactura
            Factura f = HistorialBLL.ultimoRegistro();

            if (f != null)
            {
                lblNumFactura.Text = (f.NumeroFactura + 1).ToString();
            }
            else
            {
                lblNumFactura.Text = "1";
            }
        }
示例#3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (txtNombre.Text == "" || txtCedula.Text == "" || txtVenta.Text == "" || txtDescuento.Text == "" ||
                txtSubTotal.Text == "" || txtIVA.Text == "" || txtTotalVenta.Text == "" || tablaLinea.RowCount <= 0)
            {
                MessageBox.Show("No puedes dejar campos en blanco");
            }
            else
            {
                Factura historial = new Factura
                {
                    Identificacion = txtCedula.Text,
                    Fecha          = DateTime.Now.ToString("yyyy-MM-dd"),
                    Hora           = DateTime.Now.ToString("HH:mm:ss"),
                    TotalVenta     = Convert.ToDouble(txtTotalVenta.Text),
                    Descuento      = Convert.ToDouble(txtDescuento.Text),
                    SubTotal       = Convert.ToDouble(txtSubTotal.Text),
                    IVA            = Convert.ToDouble(txtIVA.Text),
                    PorcentajeIVA  = cmbIVA.SelectedValue.ToString() + "%"
                };

                //Se inserta la factura
                Resultado r = HistorialBLL.InsertarHistorial(historial);

                if (r.Codigo == 1)
                {
                    // insetar linea factura
                    for (int i = 0; i < tablaLinea.RowCount; i++)
                    {
                        LineaDetalle l = new LineaDetalle
                        {
                            NumeroFactura  = Convert.ToInt32(lblNumFactura.Text),
                            IdLinea        = i + 1,
                            IdProducto     = Convert.ToInt32(tablaLinea.Rows[i].Cells["Codigo"].Value),
                            Cantidad       = Convert.ToInt32(tablaLinea.Rows[i].Cells["Cantidad"].Value),
                            PrecioProducto = Convert.ToDouble(tablaLinea.Rows[i].Cells["PrecioUnit"].Value)
                        };
                        ProductoBLL.InsertarLinea(l);
                    }


                    ObtenerNumeroFactura();


                    //llenar objetos para crear el ticket

                    Persona persona = PersonasBLL.BuscarUnaPersona(txtCedula.Text);

                    Factura factura = HistorialBLL.ultimoRegistro();

                    List <ProductosLineaDetalle> ListadoProductosLineaDetalle = ProductoBLL.ListadoProductosLineaDetalle(factura.NumeroFactura);

                    control.CrearTickete(persona, ListadoProductosLineaDetalle, factura);

                    MessageBox.Show("Tomar el tiquete", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);

                    limpiarTxt();

                    this.Visible = false;

                    control.AbrirFormPrincipal();
                }
                else
                {
                    MessageBox.Show(r.Mensaje, "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }