Example #1
0
 private void btnAcciones_Click(object sender, EventArgs e)
 {
     if (sel >= 0)
     {
         Scurp = val[0];
         frmGrafica a = new frmGrafica("comprasAcciones", 4);
         a.ShowDialog();
         dgv.Hide();
         SetupDataGridView();
         PopulateDataGridView("");
         actualiza();
     }
     else
     {
         MessageBox.Show("Selecciona un Cliente");
     }
 }
Example #2
0
        private void movimiento(int cant, String c, String a)
        {
            int            i, nq;
            My_SQL         buy;
            OdbcDataReader res;


            buy = new My_SQL();
            res = buy.hazConsulta(c);
            String[] cliente = new String[3];
            if (res.HasRows)
            {
                while (res.Read())
                {
                    for (i = 0; i < 3; i++)
                    {
                        cliente[i] = res.GetString(i);
                    }
                }
            }
            else
            {
                MessageBox.Show("El cliente" + val[0] + " dejo de existir");
                return;
            }
            buy = new My_SQL();
            res = buy.hazConsulta(a);
            String[] accion = new String[4];
            if (res.HasRows)
            {
                while (res.Read())
                {
                    for (i = 0; i < 4; i++)
                    {
                        accion[i] = res.GetString(i);
                    }
                }
            }
            else
            {
                MessageBox.Show("Las acciones" + val[2] + " dejaron de existir");
                return;
            }
            float saldo  = float.Parse(cliente[2]);
            float precio = float.Parse(accion[2]);
            int   stock  = int.Parse(accion[1]);

            if (uso == "Comprar")
            {
                if (cant * precio > saldo)
                {
                    MessageBox.Show(cliente[1] + " no tiene saldo Suficiente");
                }
                else
                {
                    if (stock < cant)
                    {
                        MessageBox.Show(accion[0] + " no tiene acciones suficientes");
                    }
                    else
                    {
                        buy = new My_SQL();
                        nq  = buy.hazNoConsulta("update clientes set saldo='" + (saldo - (precio * cant)).ToString() + "' where curp='" + cliente[0] + "'");
                        buy = new My_SQL();
                        nq  = buy.hazNoConsulta("update acciones set stock='" + (stock - cant).ToString() + "' where clave='" + accion[0] + "'");
                        buy = new My_SQL();
                        res = buy.hazConsulta("select * from detalle where curp='" + cliente[0] + "' and clave='" + accion[0] + "'");
                        String[] detalle = new String[3];
                        if (res.HasRows)
                        {
                            while (res.Read())
                            {
                                for (i = 0; i < 3; i++)
                                {
                                    detalle[i] = res.GetString(i);
                                }
                            }
                            buy = new My_SQL();
                            nq  = int.Parse(detalle[0]);
                            nq  = buy.hazNoConsulta("update detalle set cant='" + (nq + cant).ToString() + "' where curp='" + cliente[0] + "' && clave='" + accion[0] + "'");
                        }
                        else
                        {
                            buy = new My_SQL();
                            nq  = buy.hazNoConsulta("insert into detalle values('" + cant.ToString() + "','" + cliente[0] + "','" + accion[0] + "')");
                        }
                        frmGrafica reporte = new frmGrafica("Reporte", 5);
                        reporte.Show();
                        this.Close();
                    }
                }
            }
            else
            {
                nq = int.Parse(val[4]);
                if (cant > nq)
                {
                    MessageBox.Show(cliente[1] + " no tiene Acciones Suficientes");
                }
                else
                {
                    buy = new My_SQL();
                    nq  = buy.hazNoConsulta("update clientes set saldo='" + (saldo + (precio * cant)).ToString() + "' where curp='" + cliente[0] + "'");
                    buy = new My_SQL();
                    nq  = buy.hazNoConsulta("update acciones set stock='" + (stock + cant).ToString() + "' where clave='" + accion[0] + "'");
                    nq  = int.Parse(val[4]);
                    nq -= cant;
                    if (nq > 0)
                    {
                        buy = new My_SQL();
                        nq  = buy.hazNoConsulta("update detalle set cant='" + nq.ToString() + "' where curp='" + cliente[0] + "' and clave='" + accion[0] + "'");
                    }
                    else
                    {
                        buy = new My_SQL();
                        nq  = buy.hazNoConsulta("delete from detalle where curp='" + val[0] + "' and clave='" + val[2] + "'");
                    }
                    this.Close();
                }
            }
        }
Example #3
0
        private void btnVenta_Click(object sender, EventArgs e)
        {
            frmGrafica reporte = new frmGrafica("ventasReporte", 5);

            reporte.ShowDialog();
        }
Example #4
0
        private void btnCompra_Click(object sender, EventArgs e)
        {
            frmGrafica a = new frmGrafica("comprasClientes", 3);

            a.ShowDialog();
        }
Example #5
0
        private void btnAcciones_Click(object sender, EventArgs e)
        {
            frmGrafica a = new frmGrafica("acciones", 4);

            a.ShowDialog();
        }
Example #6
0
        private void btnClientes_Click(object sender, EventArgs e)
        {
            frmGrafica c = new frmGrafica("clientes", 3);

            c.ShowDialog();
        }