Ejemplo n.º 1
0
        private void btnImprimir_Click(object sender, EventArgs e)
        {
            MyTicket();
            Interfaz_1 mainMenu = new Interfaz_1();

            mainMenu.Show();
            try
            {
                numero_letra = totalText.Text;
                CrearImpresion.lineasSeparacion();
                Ticket.TextLeft("N° articulos: " + numProd.Text);
                Ticket.TextoDerecha("  Total:   $" + totalText.Text);
                Ticket.TextoDerecha("Pago:  $" + importeText.Text);
                Ticket.TextoDerecha("Cambio: " + cambioText.Text);
                Ticket.TextLeft("(" + con.enletras(numero_letra).ToLower());
                CrearImpresion.lineasSeparacion(); //-----------------------------------------
                Ticket.TextoCentro("¡Gracias por su compra!");
                CrearImpresion.lineasSeparacion(); //-----------------------------------------
                Ticket.ImprimirTiket();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            this.Close();
        }
Ejemplo n.º 2
0
        private void imprimir_Click(object sender, EventArgs e)
        {
            CrearImpresion Ticket = new CrearImpresion();
            Conversion     letras = new Conversion();

            Ticket.TextLeft("          ");
            Ticket.TextLeft("          ");
            Ticket.TextoCentro("Velia Perez Zavala");
            Ticket.TextLeft("     R.F.C. PEZV-690103-270");
            Ticket.TextLeft("     Aquiles Serdan #105 OTE");
            Ticket.TextLeft("     Colonia Centro");
            Ticket.TextLeft("     Gpe. Victoria,DGO C.P 34700");
            CrearImpresion.lineasSeparacion();                             //-----------------------------------------
            Ticket.TextoCentro("Corte del día");
            Ticket.TextLeft("Fecha: " + dateTimePicker1.Value.ToString()); //DateTime.Today.Day + "/" + DateTime.Today.Month + "/" + DateTime.Today.Year);
            CrearImpresion.lineasSeparacion();                             //-----------------------------------------
            CrearImpresion.EncabezadoTicket();

            foreach (DataGridViewRow fila in dataGridView1.Rows)
            {
                int desc = Convert.ToInt32(fila.Cells[6].Value);
                if (desc == 0)
                {
                    Ticket.TextLeft(fila.Cells[3].Value.ToString()); //Codigo producto
                    Ticket.TextLeft(fila.Cells[4].Value.ToString()); // Nombre producto

                    //                                                      cantidad                             Precio unitario                             Precio*cantidad
                    Ticket.TextLeft("                 " + "      " + fila.Cells[8].Value.ToString() + "      " + fila.Cells[5].Value.ToString() + "      " + fila.Cells[9].Value.ToString());
                }
                else
                {
                    Ticket.TextLeft(fila.Cells[3].Value.ToString()); // codigo producto
                    //              Nombre producto                   MENOS         tanto porciento
                    Ticket.TextLeft(fila.Cells[4].Value.ToString() + "  -" + fila.Cells[6].Value.ToString() + " %");
                    //                                                      precio unitario - lo que es de porcentaje
                    Ticket.TextLeft("                        " + "p.u $" + fila.Cells[5].Value.ToString() + "   -" + fila.Cells[7].Value.ToString());//total-descuento

                    //                                                      cantidad                             Precio unitario                             Precio*cantidad
                    Ticket.TextLeft("                 " + "      " + fila.Cells[8].Value.ToString() + "      " + fila.Cells[5].Value.ToString() + "      " + fila.Cells[9].Value.ToString());
                }
            }

            if (labelAnticipos.Text != "0")
            {
                Ticket.TextoCentro("-------------APARTADOS------------");
                foreach (DataGridViewRow item in totalApartados.Rows)
                {
                    string celdaCodigo = item.Cells[0].Value.ToString();

                    if (celdaCodigo != null)
                    {
                        //Ticket.TextLeft(item.Cells[0].Value.ToString()); //Codigo Apartado
                        Ticket.TextLeft(item.Cells[2].Value.ToString()); // Nombre cliente

                        //Ticket.TextLeft("                 " + "      " + "Anticipo: " + "      " + item.Cells[3].Value.ToString() + "      " + "---");
                        Ticket.TextLeft("Anticipo: " + "      " + item.Cells[3].Value.ToString() + "      " + "---");
                    }
                }
            }
            if (labelPagoText.Text != "0")
            {
                foreach (DataGridViewRow fila in pagosDiarios.Rows)
                {
                    string celdaCodigo = fila.Cells[0].Value.ToString();

                    if (celdaCodigo != null)
                    {
                        //Ticket.TextLeft(fila.Cells[0].Value.ToString()); //Codigo Pago
                        Ticket.TextLeft(fila.Cells[1].Value.ToString()); // Nombre cliente

                        //Ticket.TextLeft("                 " + "      " + "Anticipo: " + "      " + item.Cells[3].Value.ToString() + "      " + "---");
                        Ticket.TextLeft("Pago: " + "      " + fila.Cells[4].Value.ToString() + "      " + "---");
                    }
                }
            }

            CrearImpresion.lineasSeparacion();                     //-------------------------------------------
            Ticket.TextLeft("Ventas: $" + totalEnTexto.Text);      //nombre
            Ticket.TextLeft("Anticipos: $" + labelAnticipos.Text); //nombre
            Ticket.TextLeft("Pagos: $" + labelPagoText.Text);      //nombre
            Ticket.TextLeft("TOTAL DÍA: $" + totalDiario.Text);    //nombre
            Ticket.TextLeft("(" + letras.enletras(totalDiario.Text).ToLower());
            Ticket.ImprimirTiket();
        }
Ejemplo n.º 3
0
        private void guardarInformacion_Click(object sender, EventArgs e)
        {
            //Variables para insertar
            float montoTotal = Convert.ToSingle(totalSumapts.Text);
            float anticipo   = Convert.ToSingle(cajaAnticipotxt.Text);
            float restante   = Convert.ToSingle(cantidadRestante.Text);

            idCte = idClientetxt.Text;

            apartados operacion = new apartados();


            if (idCte != null && codigoProducto != null && nombreProducto != null)
            {
                SqlConnection conectar = BDConnect.connection();
                //operaciones de comprobacion xd

                SqlDataReader lector;
                SqlCommand    command = new SqlCommand(string.Format("SELECT * FROM cuenta_apartado WHERE id_cliente = '{0}'", new string[] { idClientetxt.Text }), conectar);
                lector = command.ExecuteReader();
                try
                {
                    if (lector.Read())
                    {
                        string id         = idClientetxt.Text;
                        string encontrado = lector.GetInt32(1).ToString();
                        if (id == encontrado)
                        {
                            int cantidad_productos = 0;

                            SqlCommand insertar = new SqlCommand("insertarApartados", conectar);
                            insertar.Parameters.Clear();

                            insertar.CommandType = CommandType.StoredProcedure;

                            foreach (DataGridViewRow fila in tablaProductos.Rows)
                            {
                                insertar.Parameters.Clear();
                                insertar.Parameters.AddWithValue("@idCliente", idClientetxt.Text);
                                insertar.Parameters.AddWithValue("@codigo", Convert.ToInt32(fila.Cells[0].Value));
                                insertar.Parameters.AddWithValue("@precio", Convert.ToDouble(fila.Cells[3].Value));
                                insertar.Parameters.AddWithValue("@cantidad", Convert.ToInt32(fila.Cells[1].Value));
                                insertar.Parameters.AddWithValue("@fecha", Convert.ToDateTime(dateTimePicker1.Text));
                                cantidad_productos += Convert.ToInt32(fila.Cells[1].Value);
                                insertar.ExecuteNonQuery();
                                insertar.Parameters.Clear();
                            }
                        }
                    }
                    else
                    {
                        lector.Close();
                        int cantidad_productos = 0;

                        SqlCommand insertar = new SqlCommand("insertarApartados", conectar);
                        insertar.Parameters.Clear();

                        insertar.CommandType = CommandType.StoredProcedure;

                        foreach (DataGridViewRow fila in tablaProductos.Rows)
                        {
                            insertar.Parameters.Clear();
                            insertar.Parameters.AddWithValue("@idCliente", idClientetxt.Text);
                            insertar.Parameters.AddWithValue("@codigo", Convert.ToInt32(fila.Cells[0].Value));
                            insertar.Parameters.AddWithValue("@precio", Convert.ToDouble(fila.Cells[3].Value));
                            insertar.Parameters.AddWithValue("@cantidad", Convert.ToInt32(fila.Cells[1].Value));
                            insertar.Parameters.AddWithValue("@fecha", Convert.ToDateTime(dateTimePicker1.Text));
                            cantidad_productos += Convert.ToInt32(fila.Cells[1].Value);
                            insertar.ExecuteNonQuery();
                            insertar.Parameters.Clear();
                        }
                        bool res = operacion.registraApartado(conectar, idCte, cantidad_productos, montoTotal, anticipo, restante, dateTimePicker1.Text);

                        if (insertar != null && res)
                        {
                            DialogResult resultado = MessageBox.Show("Apartado realizado exitosamente", "INFORMACIÓN", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                            if (resultado == DialogResult.OK)
                            {
                                imprimirComprobante();
                                CrearImpresion.ImprimirTiket();
                            }
                        }
                    }
                }
                catch (Exception msg)
                {
                    MessageBox.Show(msg.Message);
                }
                finally
                {
                    lector.Close();
                }
            }
            else
            {
                MessageBox.Show("Llena los campos faltantes,\n si el error aparece de nuevo comuniquese con su proveedor", "ERROR AL INSERTAR LOS DATOS");
            }
        }
Ejemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            apartados ap      = new apartados();
            float     importe = float.Parse(cajaPagotxt.Text);
            float     abono   = float.Parse(cajaAbonotxt.Text);
            float     total   = float.Parse(montoTotaltxt.Text);

            //restante= total-abono


            pagoClienteLabel.Text = importe.ToString();
            abonoLabel.Text       = abono.ToString();
            cambioLabel.Text      = Convert.ToString(resta(importe, abono));

            if (abono >= total)
            {
                restanteLabel.Text = Convert.ToString(resta(abono, total));
                cambioLabel.Text   = Convert.ToString(resta(abono, total));

                SqlConnection con = BDConnect.connection();


                float  restante = float.Parse(restanteLabel.Text);
                int    idApart  = Convert.ToInt32(idApartLabel.Text);
                int    idClie   = Convert.ToInt32(idClientLabel.Text);
                float  restAnt  = float.Parse(montoTotaltxt.Text);//restante Anterior
                float  pagoNvo  = float.Parse(cajaAbonotxt.Text);
                float  debe     = restante;
                string fecha    = dateTimePicker1.Text;

                if (restante <= total)
                {
                    bool update = ap.ActualizarRestante(con, restante.ToString(), abonoLabel.Text, idApartLabel.Text);
                    bool insert = ap.RegistraPgo(con, idApart, idClie, restAnt, pagoNvo, debe, fecha);
                    if (insert && update)
                    {
                        restanteLabel.Text = "" + 0;
                        MessageBox.Show("Apartado liquidado");
                        tableCuentas.DataSource = ap.listaApartados(con);
                        bajaInventario(idproducto_label.Text, Convert.ToInt32(cantidadProductolabel.Text));
                        ap.eliminarPtoApartado(con, idPtoApartadoLabel.Text);

                        flag = true;
                    }

                    imprimirComprobante();
                    CrearImpresion.ImprimirTiket();

                    //update tabla productos resta cantidad del producto a el producto
                    //delete apartado x id
                    //delete pagos x id
                    //imprimir ticket
                }
                else if (restante >= total)
                {
                    bool update = ap.ActualizarRestante(con, restante.ToString(), abonoLabel.Text, idApartLabel.Text);
                    bool insert = ap.RegistraPgo(con, idApart, idClie, restAnt, pagoNvo, debe, fecha);

                    if (insert && update)
                    {
                        restanteLabel.Text = "" + 0;
                        MessageBox.Show("Apartado liquidado");
                        tableCuentas.DataSource = ap.listaApartados(con);
                    }

                    /*imprimirComprobante();
                     * CrearImpresion.ImprimirTiket();*/
                }
            }
            else if (abono <= total)
            {
                restanteLabel.Text = Convert.ToString(resta(total, abono));
                float restante = float.Parse(restanteLabel.Text);
                //variables insertar
                int    idApart = Convert.ToInt32(idApartLabel.Text);
                int    idClie  = Convert.ToInt32(idClientLabel.Text);
                float  restAnt = float.Parse(montoTotaltxt.Text);//restante Anterior
                float  pagoNvo = float.Parse(cajaAbonotxt.Text);
                float  debe    = restante;
                string fecha   = dateTimePicker1.Text;

                SqlConnection con = BDConnect.connection();

                if (restante < total)
                {
                    try
                    {
                        bool update = ap.ActualizarRestante(con, restante.ToString(), abonoLabel.Text, idApartLabel.Text);
                        bool insert = ap.RegistraPgo(con, idApart, idClie, restAnt, pagoNvo, debe, fecha);
                        if (update && insert)
                        {
                            MessageBox.Show("Actualizacion Exitosa", "PAGO REGISTRADO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            tableCuentas.DataSource = ap.listaApartados(con);
                        }
                        else
                        {
                            MessageBox.Show(insert.ToString());
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    //registrar el pago
                }
            }

            /*imprimirComprobante();
             * CrearImpresion.ImprimirTiket();*/
        }