Exemple #1
0
        public void DatosComisiones(List <Comisiones> list, string path)
        {
            String stringConexion = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path;

            Console.WriteLine("EL PATH ES !!!! " + path);
            using (OleDbConnection connection = new OleDbConnection(stringConexion))
            {
                connection.Open();
                OleDbDataReader reader  = null;
                OleDbCommand    command = new OleDbCommand("select * FROM PAQUETES", connection);
                reader = command.ExecuteReader();
                Comisiones aux;
                while (reader.Read())
                {
                    aux = new Comisiones();
                    aux.tablasComisiones = reader["TABLACOMISIONES"].ToString();

                    aux.comisionTotal = float.Parse(reader["COMISIONTOTAL"].ToString());

                    aux.comisionPromotor = float.Parse(reader["COMISIONPROMOTOR"].ToString());
                    aux.comisionGerente  = float.Parse(reader["COMISIONGERENTE"].ToString());
                    aux.paquetes         = reader["PAQUETES"].ToString();

                    list.Add(aux);
                }
                reader.Close();

                connection.Close();
            }
        }
Exemple #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            OleDbConnection con;//Representa una conexión abierta a un origen de datos
            String          stringConexion = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path;

            using (OleDbConnection connection = new OleDbConnection(stringConexion))
            {
                connection.Open();


                OleDbCommand command = new OleDbCommand("UPDATE Paquetes SET TABLACOMISIONES = '" + textBox4.Text + "', COMISIONTOTAL = " + textBox1.Text + ", COMISIONPROMOTOR = '" + textBox2.Text + "', COMISIONGERENTE = " + textBox3.Text + ", PAQUETES = '" + comboBox1.Text + "' WHERE PAQUETES = " + "'" + comboBox1.Text + "'");
                command.Connection = connection;
                if (connection.State != ConnectionState.Open)
                {
                    connection.Open();
                }

                try
                {
                    command.ExecuteNonQuery();
                    MessageBox.Show("Data Update");
                    Comisiones nuevo = new Comisiones();
                    nuevo.comisionGerente  = float.Parse(textBox3.Text);
                    nuevo.comisionPromotor = float.Parse(textBox2.Text);
                    nuevo.tablasComisiones = textBox4.Text;
                    nuevo.comisionTotal    = float.Parse(textBox1.Text);
                    nuevo.paquetes         = comboBox1.Text;
                    int aux = 0;
                    foreach (Comisiones i in Comision)
                    {
                        if (i.paquetes == comboBox1.Text)
                        {
                            Console.WriteLine("i.paquetes:::::" + i.paquetes);
                            Console.WriteLine("combox1" + comboBox1.Text);
                            aux = Comision.IndexOf(i);
                        }
                    }
                    Comision.RemoveAt(aux);
                    Comision.Add(nuevo);
                    connection.Close();
                }
                catch (OleDbException ex)
                {
                    MessageBox.Show("error al editar en la BD");
                    Console.WriteLine(ex);
                    connection.Close();
                }
            }
        }
Exemple #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            OleDbConnection con;//Representa una conexión abierta a un origen de datos
            String          stringConexion = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path;

            using (OleDbConnection connection = new OleDbConnection(stringConexion))
            {
                connection.Open();


                OleDbCommand command = new OleDbCommand("INSERT into Paquetes (TABLACOMISIONES, COMISIONTOTAL, COMISIONPROMOTOR, COMISIONGERENTE, PAQUETES) VALUES " + "('" + textBox1.Text + "'," + textBox2.Text + "," + textBox3.Text + "," + textBox4.Text + "," + "'" + comboBox1.Text + "')");
                command.Connection = connection;
                if (connection.State != ConnectionState.Open)
                {
                    connection.Open();
                }

                try
                {
                    command.ExecuteNonQuery();
                    MessageBox.Show("Data Added");
                    Comisiones nuevo = new Comisiones();

                    nuevo.comisionGerente  = float.Parse(textBox3.Text);
                    nuevo.comisionPromotor = float.Parse(textBox2.Text);
                    nuevo.tablasComisiones = textBox4.Text;
                    nuevo.comisionTotal    = float.Parse(textBox1.Text);
                    nuevo.paquetes         = comboBox1.Text;



                    Comision.Add(nuevo);
                    connection.Close();
                }
                catch (OleDbException ex)
                {
                    MessageBox.Show("error al agregar en la BD");
                    Console.WriteLine(ex);
                    connection.Close();
                }
            }
        }