Ejemplo n.º 1
0
        public void actualizarControles()
        {
            List <AppUser>  lista  = AppUserDAO.getListaP(usuario.idUser);
            List <Order>    listO  = OrderDAO.getOListP(usuario.idUser);
            List <Address>  listA  = AddressDAO.getPList(usuario.idUser);
            List <Business> listaB = BusinessDAO.getBList();
            List <Product>  listaP = ProductDAO.getPList(Convert.ToInt32(comboBox2.SelectedValue));

            comboBox3.DataSource    = null;
            comboBox3.ValueMember   = "idProduct";
            comboBox3.DisplayMember = "name";
            comboBox3.DataSource    = listaP;

            comboBox1.DataSource    = null;
            comboBox1.ValueMember   = "idUser";
            comboBox1.DisplayMember = "userName";
            comboBox1.DataSource    = lista;

            comboBox2.DataSource    = null;
            comboBox2.ValueMember   = "idBusiness";
            comboBox2.DisplayMember = "name";
            comboBox2.DataSource    = listaB;

            comboBox5.DataSource    = null;
            comboBox5.ValueMember   = "idOrder";
            comboBox5.DisplayMember = "idProduct";
            comboBox5.DataSource    = listO;

            dataGridView1.DataSource = null;
            dataGridView1.DataSource = listO;

            dataGridView2.DataSource = null;
            dataGridView2.DataSource = listA;
        }
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox4.Text.Length >= 16)
                {
                    BusinessDAO.crearBusiness(textBox3.Text, textBox4.Text);
                    MessageBox.Show("¡Negocio agregado exitosamente!",
                                    "Hugo App", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    textBox3.Clear();
                    textBox4.Clear();
                    actualizarControles();
                }
                else
                {
                    MessageBox.Show("Favor digite una descripcion (longitud minima, 25 caracteres)",
                                    "Hugo App", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show("No fue posible registrar el nuevo negocio",
                                "Hugo App", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void button4_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("¿Seguro que desea eliminar el negocio " + comboBox2.Text + "?",
                                "Hugo App", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                BusinessDAO.eliminar(comboBox2.Text);

                MessageBox.Show("¡Negocio eliminado exitosamente!",
                                "Hugo App", MessageBoxButtons.OK, MessageBoxIcon.Information);

                actualizarControles();
            }
        }
        private void actualizarControles()
        {
            // Realizar consulta a la base de datos
            List <AppUser>  lista   = AppUserDAO.getLista();
            List <Business> listaB  = BusinessDAO.getBList();
            List <Product>  listaP  = ProductDAO.getPList(Convert.ToInt32(comboBox3.SelectedValue));
            List <Product>  listaPP = ProductDAO.getPList(Convert.ToInt32(comboBox4.SelectedValue));

            List <Order> listaO = OrderDAO.getOList();

            // Tabla (data grid view)
            dataGridView1.DataSource = null;
            dataGridView1.DataSource = lista;
            // Menu desplegable (combo box)
            comboBox1.DataSource    = null;
            comboBox1.ValueMember   = "password";
            comboBox1.DisplayMember = "userName";
            comboBox1.DataSource    = lista;

            comboBox2.DataSource    = null;
            comboBox2.ValueMember   = "name";
            comboBox2.DisplayMember = "name";
            comboBox2.DataSource    = listaB;

            comboBox3.DataSource    = null;
            comboBox3.ValueMember   = "idBusiness";
            comboBox3.DisplayMember = "name";
            comboBox3.DataSource    = listaB;

            comboBox4.DataSource    = null;
            comboBox4.ValueMember   = "idBusiness";
            comboBox4.DisplayMember = "name";
            comboBox4.DataSource    = listaB;

            comboBox5.DataSource    = null;
            comboBox5.ValueMember   = "idProduct";
            comboBox5.DisplayMember = "name";
            comboBox5.DataSource    = listaPP;

            dataGridView2.DataSource = null;
            dataGridView2.DataSource = listaB;

            dataGridView3.DataSource = null;
            dataGridView3.DataSource = listaP;

            dataGridView4.DataSource = null;
            dataGridView4.DataSource = listaO;
        }