コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            // cadena de insertado para la tabla de logeo
            string sesion_abierta = funciones.id_sesion();

            if (sesion_abierta == null)
            {
                if (textBox1.Text.Trim() != "" && textBox2.Text.Trim() != "")
                {
                    DialogResult resutado = MessageBox.Show("Cajero :  " + textBox1.Text + "\nFondo : " + textBox2.Text, "INICIAR SESSION", MessageBoxButtons.YesNo, MessageBoxIcon.Information);;
                    if (resutado == DialogResult.Yes)
                    {
                        string cadena = "INSERT INTO logeo (nombre,fondo,status) VALUES('" + textBox1.Text + "','" + textBox2.Text + "','" + (int)satatus.session_iniciada + "')";
                        funciones.insertar(cadena);
                        Ventana_emergente ventana_Emergente = new Ventana_emergente("SESION ABIERTA"); /// ventana de cambio
                        ventana_Emergente.StartPosition = FormStartPosition.CenterParent;
                        ventana_Emergente.ShowDialog();
                    }
                }
                else
                {
                    MessageBox.Show("Campos vacios", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                MessageBox.Show("Tienes la sesion abierta \n Realize el corte e intente ingresar de nuevo", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
コード例 #2
0
 private void button1_Click(object sender, EventArgs e)// ingresar entradas
 {
     if (textBox1.Text.Trim() != "" && textBox2.Text.Trim() != "")
     {
         DialogResult resultado = MessageBox.Show("Descripcion :" + textBox1.Text + "\n Cantidad $ " + textBox2.Text, "VERIFICAR", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
         if (resultado == DialogResult.OK)
         {
             string id       = funciones.id_sesion();
             string entradas = "INSERT INTO entrada (descripcion,cantidad,id_sesion) VALUES ('" + textBox1.Text + "','" + textBox2.Text + "','" + id + "');";
             funciones.insertar(entradas);
             textBox1.Text = null;
             textBox2.Text = null;
         }
     }
     else
     {
         MessageBox.Show("Campos vacios", "Intwnte de nuevo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #3
0
        public void Realizar_venta()
        {
            change    = cambio(efectivo_entrante, tarjeta_entrante); // realiza el cambio
            id_sesion = funcionesSQL.id_sesion();                    // retorna la ultima sesion abierta
            conexion.Open();
            using (MySqlCommand ingresar_num_venta = new MySqlCommand())
            {
                using (MySqlTransaction transaction = conexion.BeginTransaction())
                {
                    try
                    {
                        // inicio de la transaccion
                        Ingresar_venta = "INSERT INTO venta (fyh,id_sesion) VALUES(now(),'" + id_sesion + "')";
                        ingresar_num_venta.CommandText = Ingresar_venta;
                        ingresar_num_venta.Connection  = conexion;
                        ingresar_num_venta.Transaction = transaction;
                        ingresar_num_venta.ExecuteNonQuery();
                        for (int i = 0; i < tabla.Rows.Count; i++)
                        {                                                                                            //  folio_venta                |      id_articulo   |  cantidad vendida del mismo articulo | precio actuial del producto
                            Ingresar_detalle_venta         = "INSERT INTO detalle_venta VALUES((SELECT folio_venta FROM venta  ORDER BY folio_venta DESC limit 1),'" + tabla[3, i].Value + "','" + tabla[0, i].Value + "','" + tabla[2, i].Value + "')";
                            ingresar_num_venta.CommandText = Ingresar_detalle_venta;
                            ingresar_num_venta.Connection  = conexion;
                            ingresar_num_venta.Transaction = transaction;
                            ingresar_num_venta.ExecuteNonQuery();
                            cantitad_articulos += Convert.ToDouble(tabla[0, i].Value);   // contar el total de los articulos vendidos
                            if (tabla[3, i].Value.ToString() == "272")
                            {
                                numRepeticion = 2;
                            }
                        }
                        Ingresar_pago = "INSERT INTO detalles_pagos VALUES ((SELECT folio_venta FROM venta  ORDER BY folio_venta DESC limit 1),'" + total_compra + "','" + efectivo_entrante + "','" + tarjeta_entrante + "')";
                        ingresar_num_venta.CommandText = Ingresar_pago;
                        ingresar_num_venta.Connection  = conexion;
                        ingresar_num_venta.Transaction = transaction;
                        ingresar_num_venta.ExecuteNonQuery();
                        transaction.Commit();

                        Ventana_emergente ventana_Emergente = new Ventana_emergente("Su cambio es \n" + " $" + change);
                        ventana_Emergente.StartPosition = FormStartPosition.CenterScreen;
                        ventana_Emergente.ShowDialog();
                        select_impresora();
                        imprecion_ticket(tabla, id_sesion, total_compra, efectivo_entrante, tarjeta_entrante, change, cantitad_articulos.ToString());
                        efectivo_entrante = 0; tarjeta_entrante = 0; tabla.Rows.Clear(); total_compra = 0;
                    }
                    catch
                    {
                        MessageBox.Show("error al ingresar", "");
                        transaction.Rollback();
                    }
                }
            }
            conexion.Close();
            conexion.Dispose();
        }