コード例 #1
0
        private void PopulateDataGridView(String cond)
        {
            My_SQL         mysql = new My_SQL();
            OdbcDataReader res;

            res = mysql.hazConsulta("select " + cam[0] + "," + cam[1] + "," + cam[2] + "," + cam[3] + " from clientes,acciones,detalle where clientes.curp=detalle.curp and acciones.clave=detalle.clave and clientes.curp='" + val[0] + "'");
            int   i;
            float acc, tot = 0;

            String[] row = new String[4];
            if (res.HasRows)
            {
                while (res.Read())
                {
                    for (i = 0; i < 3; i++)
                    {
                        row[i] = res.GetString(i);
                    }
                    acc    = float.Parse(res.GetString(i)) * int.Parse(row[2]);
                    tot   += acc;
                    row[3] = acc.ToString();
                    dgv.Rows.Add(row);
                }
            }
            total.Text = tot.ToString();
        }
コード例 #2
0
 private void btnEliminar_Click(object sender, EventArgs e)
 {
     if (sel >= 0)
     {
         My_SQL         mysql;
         OdbcDataReader res;
         int            nq;
         mysql = new My_SQL();
         res   = mysql.hazConsulta("select * from detalle where " + cam[0] + "='" + val[0] + "'");
         if (res.HasRows)
         {
             MessageBox.Show("El registro esta vinculado a una transaccion");
         }
         else
         {
             mysql = new My_SQL();
             nq    = mysql.hazNoConsulta("delete from " + roll + " where " + cam[0] + " = '" + val[0] + "'");
             dgv.Hide();
             SetupDataGridView();
             PopulateDataGridView("");
             actualiza();
             MessageBox.Show("Registro Borrado");
         }
     }
 }
コード例 #3
0
        private void dgv_RowsRemoved(object sender, DataGridViewRowsRemovedEventArgs e)
        {
            My_SQL         mysql;
            OdbcDataReader res;
            int            nq;

            mysql = new My_SQL();
            res   = mysql.hazConsulta("select * from detalle where " + cam[0] + "='" + val[0] + "'");
            if (res.HasRows)
            {
                MessageBox.Show("El registro esta vinculado a una transaccion");
            }
            else
            {
                mysql = new My_SQL();
                nq    = mysql.hazNoConsulta("delete from " + roll + " where " + cam[0] + " = '" + val[0] + "'");
                int row = e.RowIndex;
                if (row >= e.RowCount)
                {
                    row = e.RowCount - 1;
                }
                if (row >= 0 && e.RowCount > 1)
                {
                    DataGridView ob = (DataGridView)sender;
                    for (int i = 0; i < colums; i++)
                    {
                        val[i] = (String)ob.Rows[e.RowIndex].Cells[i].Value;
                    }
                    sel = row;
                }
                MessageBox.Show("Registro Borrado");
            }
        }
コード例 #4
0
        private void PopulateDataGridView(String cond)
        {
            My_SQL         mysql = new My_SQL();
            OdbcDataReader res;

            if (roll == "clientes" || roll == "acciones")
            {
                res = mysql.hazConsulta("select * from " + roll + "" + cond);
            }
            else
            {
                if (roll == "comprasClientes")
                {
                    res = mysql.hazConsulta("select * from clientes" + cond);
                }
                else
                {
                    if (roll == "comprasAcciones")
                    {
                        res = mysql.hazConsulta("select * from acciones" + cond);
                    }
                    else
                    {
                        res = mysql.hazConsulta("select " + cam[0] + "," + cam[1] + "," + cam[2] + "," + cam[3] + "," + cam[4] + " from clientes,acciones,detalle where clientes.curp=detalle.curp and acciones.clave=detalle.clave" + cond);
                    }
                }
            }
            int i;

            String[] row = new String[colums];
            if (res.HasRows)
            {
                while (res.Read())
                {
                    for (i = 0; i < colums; i++)
                    {
                        row[i] = res.GetString(i);
                    }
                    dgv.Rows.Add(row);
                }
            }
        }
コード例 #5
0
        private void PopulateDataGridView(String cond)
        {
            My_SQL         mysql = new My_SQL();
            OdbcDataReader res   = mysql.hazConsulta("select * from clientes" + cond);
            int            i;

            String[] row = new String[3];
            if (res.HasRows)
            {
                while (res.Read())
                {
                    for (i = 0; i < 3; i++)
                    {
                        row[i] = res.GetString(i);
                    }
                    dgv.Rows.Add(row);
                    p++;
                }
            }
        }
コード例 #6
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();
                }
            }
        }