示例#1
0
 private void Caja_Load(object sender, EventArgs e)
 {
     //ubicaciones de los objetos
     dVCaja.Width          = this.Width;
     dVCaja.Height         = this.Height - 200;
     TBcaja.Width          = this.Width;
     TBcaja.Location       = new Point(0, this.Height - TBcaja.Height - 5); //acomodo del textbox de codigos
     lbMarca.Location      = new Point(this.Width / 2 - lbMarca.Width / 2, 5);
     lbEslogan.Location    = new Point(this.Width / 2 - lbEslogan.Width / 2, 60);
     lbfecha.Location      = new Point(this.Width - lbfecha.Width, 5);
     labelversion.Location = new Point(this.Width - labelversion.Width, 60);
     lbLeAtiende.Text      = "Le Atiende: " + Inicio.nombre + " " + Inicio.ApellidoP + " " + Inicio.ApellidoM;
     lbLeAtiende.Location  = new Point(this.Width - lbLeAtiende.Width, 40);
     lbTotalFinal.Location = new Point(this.Width - lbTotalFinal.Width - 80, dVCaja.Height + 100);
     lbTotal.Location      = new Point(this.Width - lbTotal.Width - 150, dVCaja.Height + 100);
     TBcaja.Focus();
 }
示例#2
0
        public void CerrarVenta()  //cierra venta, manda a imprimir ticket y guarda log en base de datos
        {
            //inicio de mensajes de diaganostico
            //MessageBox.Show("Label Total: "+lbTotalFinal.Text);
            //MessageBox.Show("Ingreso: "+TBcaja.Text);
            //lbTotalFinal.Text = lbTotalFinal.Text.Substring(6,6);
            //fin de mensajea de diagnostico

            if (float.Parse(lbTotalFinal.Text) >= total) //carga los datos en el log de ventas en BD
            {
                cambio = float.Parse(lbTotalFinal.Text) - total;
                MessageBox.Show("Su cambio es: " + (float.Parse(TBcaja.Text) - float.Parse(lbTotalFinal.Text)));
                //Guardar en BD
                con = new MySqlConnection("Server = 127.0.0.1;Database=integradora;Uid=root;Pwd=alvarez");  //offline
                con.Open();
                string query = "INSERT INTO ventas VALUES (null, curdate(), curtime())";
                com = new MySqlCommand(query, con);
                MySqlDataReader Lector = com.ExecuteReader();
                con.Close();
                foreach (DataGridViewRow R in dVCaja.Rows)
                {
                    con = new MySqlConnection("Server = 127.0.0.1;Database=integradora;Uid=root;Pwd=alvarez");
                    con.Open();
                    query = "INSERT INTO venta_detalle VALUES ((select max(id_venta) FROM ventas),'" + R.Cells[1].Value.ToString() + "', " + R.Cells[3].Value.ToString() + ");";
                    com   = new MySqlCommand(query, con);
                    com.ExecuteNonQuery();
                    con.Close();
                }
                Imprimir();                 // llama imprimir
                lbTotalFinal.Text = "0.00"; //reinicioa label de total a 0
                dVCaja.Rows.Clear();
                TBcaja.SelectAll();
                TBcaja.Clear();
                TBcaja.Focus();
            }
        }
示例#3
0
 private void TBcaja_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == 13)
     {
         try
         {
             if (TBcaja.Text.IndexOf('*') != -1) //multiplica el articulo (ejemplo 10*cosigo de barras)
             {
                 string[] cantCodigo = TBcaja.Text.Split('*');
                 double   bProducto  = double.Parse(cantCodigo[1]);
                 con = new MySqlConnection("Server = 127.0.0.1;Database=integradora;Uid=root;Pwd=alvarez");  //offline
                 con.Open();
                 string query = "SELECT * FROM productos WHERE Cod_Bar = '" + bProducto + "'";
                 com = new MySqlCommand(query, con);
                 MySqlDataReader Lector = com.ExecuteReader();
                 while (Lector.Read())                                                                                            //datos de la bd
                 {
                     double subTotal = double.Parse(cantCodigo[0]) * Lector.GetDouble(2);                                         //multiplicacion de cantidad por precio
                     dVCaja.Rows.Add(cantCodigo[0], Lector.GetString(1), Lector.GetDouble(2), double.Parse(subTotal.ToString())); // si esta null
                 }
             }
             else // si no hay multiplicación
             {
                 con = new MySqlConnection("Server = 127.0.0.1;Database=integradora;Uid=root;Pwd=alvarez");  //offline
                 con.Open();
                 string query = "SELECT * FROM productos WHERE Cod_Bar = '" + TBcaja.Text + "'";
                 com = new MySqlCommand(query, con);
                 MySqlDataReader Lector = com.ExecuteReader();
                 while (Lector.Read())                                                                  //datos de la bd
                 {
                     dVCaja.Rows.Add(1, Lector.GetString(1), Lector.GetString(2), Lector.GetString(2)); // si esta null
                 }
             }
             gentotal();
             TBcaja.Clear();
         }
         catch (Exception Error)
         {
             MessageBox.Show("Codigo de barras inexistente verificalo");
             TBcaja.Clear();
             TBcaja.Focus();
         }
     }
     else if (e.KeyChar == (char)Keys.Escape)  //cancelar utlimo articulo
     {
         if (dVCaja.Rows.Count > 0)
         {
             dVCaja.Rows.RemoveAt(dVCaja.Rows.Count - 1);
         }
         gentotal();
     }
     else if (e.KeyChar == (char)Keys.Tab) //repetir ultimo articulo
     {
         if (dVCaja.Rows.Count > 0)
         {
             dVCaja.Rows.Add(dVCaja[0, dVCaja.Rows.Count - 1].Value.ToString(), dVCaja[1, dVCaja.Rows.Count - 1].Value.ToString(), dVCaja[2, dVCaja.Rows.Count - 1].Value.ToString(), dVCaja[3, dVCaja.Rows.Count - 1].Value.ToString());
         }
         gentotal();
     }
     else if (e.KeyChar == 'x') //imprime ticket :)
     {
         Imprimir();            //llama a imprimir
         TBcaja.Focus();
         TBcaja.Clear();
     }
     else if (e.KeyChar == '.')
     {
         if (dVCaja.Rows.Count > 0)
         {
             CerrarVenta();
         }
     }
     else if (e.KeyChar == '-') //sale de la ventana
     {
         this.Close();
     }
 }