Exemplo n.º 1
0
        private void AddOrder_Load(object sender, EventArgs e)
        {
            var bus      = BDconnection.realizarConsulta("SELECT idbusiness FROM BUSINESS");
            var busCombo = new List <string>();

            foreach (DataRow dr in bus.Rows)
            {
                busCombo.Add(dr[0].ToString());
            }
            comboBox1.DataSource = busCombo;

            var dir      = BDconnection.realizarConsulta("SELECT idaddress FROM ADDRESS");
            var dirCombo = new List <string>();

            foreach (DataRow ds in dir.Rows)
            {
                dirCombo.Add(ds[0].ToString());
            }
            comboBox2.DataSource = dirCombo;

            var prod      = BDconnection.realizarConsulta($"SELECT idProduct FROM PRODUCT WHERE idBusiness={comboBox1.Text}");
            var prodCombo = new List <string>();

            foreach (DataRow dt in prod.Rows)
            {
                prodCombo.Add(dt[0].ToString());
            }
            comboBox3.DataSource = prodCombo;
        }
Exemplo n.º 2
0
        private void button2_Click(object sender, EventArgs e)
        {
            var dn  = BDconnection.realizarConsulta($"SELECT username FROM APPUSER WHERE username = '******'");
            var dr1 = dn.Rows[0];

            var dc2 = BDconnection.realizarConsulta($"SELECT password FROM APPUSER WHERE username = '******'");
            var dr2 = dc2.Rows[0];


            if (dr1[0].ToString().Equals(textBox1.Text) && dr2[0].ToString().Equals(textBox2.Text))
            {
                var dt = BDconnection.realizarConsulta($"SELECT usertype FROM APPUSER WHERE username='******'");
                var dr = dt.Rows[0];

                if (dr[0].ToString() == "True")
                {
                    FormAdmon frmA = new FormAdmon();
                    frmA.Show();
                }
                else if (dr[0].ToString() == "False")
                {
                    FormNoAdmon frmN = new FormNoAdmon();
                    frmN.Show();
                }
            }
            else
            {
                MessageBox.Show("Datos incorrectos");
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string nonQuery = $"DELETE FROM ADDRESS WHERE idAddress='{comboBox1.SelectedItem.ToString()}'";

            BDconnection.realizarAccion(nonQuery);
            MessageBox.Show("Direccion Eliminada");
        }
Exemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox1.Equals("") ||
                comboBox2.Equals("") || comboBox3.Equals(""))

            {
                MessageBox.Show("No puede dejar los campos vacios!");
            }
            else
            {
                try
                {
                    BDconnection.realizarAccion($"INSERT INTO APPORDER(createDate, idProduct, idAddress) VALUES (" +
                                                $"'{DateTime.Today}'," +
                                                $"{comboBox1.SelectedItem}," +
                                                $"{comboBox2.SelectedItem})");

                    MessageBox.Show("ORDEN ANADIDA");
                }

                catch (Exception ex)
                {
                    MessageBox.Show("Ha ocurrido un error");
                }
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Equals(""))

            {
                MessageBox.Show("No puede dejar los campos vacios");
            }
            else
            {
                try
                {
                    string query     = $"SELECT idaddress FROM ADDRESS WHERE address ='{comboBox1.SelectedItem.ToString()}'";
                    var    dt        = BDconnection.realizarConsulta(query);
                    var    dr        = dt.Rows[0];
                    var    idaddress = Convert.ToInt32(dr[0].ToString());
                    string nonQuery  = $"UPDATE ADDRESS SET address = '{textBox1.Text}' WHERE idAddress = {idaddress}";


                    BDconnection.realizarAccion(nonQuery);
                    MessageBox.Show("Se ha modificado la direccion");
                }

                catch (Exception ex)
                {
                    MessageBox.Show("Ha ocurrido un error!");
                }
            }
        }
Exemplo n.º 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            var dn  = BDconnection.realizarConsulta($"SELECT username FROM APPUSER WHERE username = '******'");
            var dr1 = dn.Rows[0];

            var dc2 = BDconnection.realizarConsulta($"SELECT password FROM APPUSER WHERE username = '******'");
            var dr2 = dc2.Rows[0];


            if (dr1[0].ToString().Equals(textBox1.Text) && dr2[0].ToString().Equals(textBox2.Text))
            {
                try
                {
                    string query    = $"SELECT idUser FROM APPUSER WHERE username ='******'";
                    var    dt       = BDconnection.realizarConsulta(query);
                    var    dr       = dt.Rows[0];
                    var    idUser   = Convert.ToInt32(dr[0].ToString());
                    string nonQuery = $"UPDATE APPUSER SET password = '******' WHERE idUser = {idUser}";


                    BDconnection.realizarAccion(nonQuery);
                    MessageBox.Show("Se ha modificado la direccion");
                }

                catch (Exception ex)
                {
                    MessageBox.Show("Ha ocurrido un error!");
                }
            }
            else
            {
                MessageBox.Show("Datos incorrectos");
            }
        }
Exemplo n.º 7
0
        private void button6_Click(object sender, EventArgs e)
        {
            var dt = BDconnection.realizarConsulta("SELECT * FROM BUSINESS");

            dataGridView1.DataSource = dt;
            MessageBox.Show("Datos obtenidos exitosamente");
        }
Exemplo n.º 8
0
        private void button4_Click(object sender, EventArgs e)
        {
            var dt = BDconnection.realizarConsulta($"SELECT ad.idAddress, ad.address FROM ADDRESS ad WHERE idUser={textBox1.Text}");

            dataGridView1.DataSource = dt;
            MessageBox.Show("Datos obtenidos exitosamente");
        }
Exemplo n.º 9
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Equals("") ||
                textBox2.Equals(""))

            {
                MessageBox.Show("No puede dejar los campos vacios!");
            }
            else
            {
                try
                {
                    BDconnection.realizarAccion($"INSERT INTO APPUSER(fullname, username, password, userType) VALUES(" +
                                                $"'{textBox1.Text}'," +
                                                $"'{textBox2.Text}'," +
                                                $"'{textBox3.Text}'," +
                                                $"{comboBox1.SelectedItem})");

                    MessageBox.Show("USUARIO ANADIDO");
                }
                catch (Exception esg)
                {
                    MessageBox.Show("Ha ocurrido un error");
                }
            }
        }
Exemplo n.º 10
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Equals(""))

            {
                MessageBox.Show("No puede dejar los campos vacios");
            }
            else
            {
                //try
                // {
                var dt = BDconnection.realizarConsulta(
                    $"SELECT ao.idOrder, ao.createDate, pr.name, au.fullname, ad.address FROM APPORDER ao, ADDRESS ad, PRODUCT pr, APPUSER au WHERE ao.idProduct = pr.idProduct AND ao.idAddress = ad.idAddress AND ad.idUser = au.idUser AND au.idUser = {textBox1.Text}");


                dataGridView1.DataSource = dt;
                MessageBox.Show("Datos obtenidos exitosamente");
                //}

                /*catch (Exception esg)
                 *  {
                 *      MessageBox.Show("Ha cocurrido un problema");
                 *  }*/
            }
        }
Exemplo n.º 11
0
        private void button9_Click(object sender, EventArgs e)
        {
            var dt = BDconnection.realizarConsulta("SELECT ao.idOrder, ao.createDate, pr.name, au.fullname, ad.address " +
                                                   "FROM APPORDER ao, ADDRESS ad, PRODUCT pr, APPUSER au" +
                                                   " WHERE ao.idProduct = pr.idProduct " +
                                                   "AND ao.idAddress = ad.idAddress " +
                                                   "AND ad.idUser = au.idUser;");

            dataGridView1.DataSource = dt;
            MessageBox.Show("Datos obtenidos exitosamente");
        }
Exemplo n.º 12
0
        private void AddProduct_Load(object sender, EventArgs e)
        {
            var prod      = BDconnection.realizarConsulta("SELECT idbusiness FROM Business");
            var prodCombo = new List <string>();

            foreach (DataRow dr in prod.Rows)
            {
                prodCombo.Add(dr[0].ToString());
            }

            comboBox1.DataSource = prodCombo;
        }
Exemplo n.º 13
0
        private void ModidyAddress_Load(object sender, EventArgs e)
        {
            var address      = BDconnection.realizarConsulta("SELECT address FROM ADDRESS");
            var addressCombo = new List <string>();

            foreach (DataRow dr in address.Rows)
            {
                addressCombo.Add(dr[0].ToString());
            }

            comboBox1.DataSource = addressCombo;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            try{
                string nonQuery = $"DELETE FROM BUSINESS WHERE idBusiness = {textBox1.Text}";

                BDconnection.realizarAccion(nonQuery);
                MessageBox.Show("Negocio Eliminado");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ha ocurrido un error!");
            }
        }
Exemplo n.º 15
0
        private void button1_Click(object sender, EventArgs e)
        {
            //DELETE FROM APPORDER WHERE idOrder = 1

            try
            {
                string nonQuery = $"DELETE FROM APPORDER WHERE idOrder ='{textBox1.Text}'";
                BDconnection.realizarAccion(nonQuery);
                MessageBox.Show("Orden Eliminada");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ha ocurrido un error");
            }
        }
Exemplo n.º 16
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Equals(""))

            {
                MessageBox.Show("No puede dejar los campos vacios");
            }
            else
            {
                try
                {
                    BDconnection.realizarAccion($"INSERT INTO PRODUCT(idBusiness, name) VALUES({comboBox1.SelectedItem}, '{textBox1.Text}');");
                    MessageBox.Show("Se ha registrado el producto");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Ha ocurrido un error!");
                }
            }
        }
Exemplo n.º 17
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Equals(""))

            {
                MessageBox.Show("No puede dejar los campos vacios");
            }
            else
            {
                try
                {
                    BDconnection.realizarAccion($"INSERT INTO BUSINESS(name, description) VALUES('{textBox1.Text}', '{textBox2.Text}');");
                    MessageBox.Show("Se ha guardado el negocio");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Ha ocurrido un error!");
                }
            }
        }
Exemplo n.º 18
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Equals(""))
                
            {
                MessageBox.Show("No puede dejar los campos vacios");
            }
            else
            {
                try
                {
                    BDconnection.realizarAccion($"INSERT INTO ADDRESS(idUser, address)  VALUES ({textBox1.Text}, '{textBox2.Text}');");
                    MessageBox.Show("Se ha registrado la direccion");

                }
                catch (Exception ex)
                {
                    MessageBox.Show("Ha ocurrido un error!");
                }
            }
        }