Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string query = $"SELECT EXISTS (SELECT * FROM appuser WHERE username = '******' " +
                               $"AND password = '******')";
                var dt = ConnectionDB.executeQuery(query);
                var dr = dt.Rows[0][0];
                if ((bool)dr)
                {
                    string quer = $"SELECT * FROM appuser WHERE username = '******' " +
                                  $"AND password = '******'";

                    var dte = ConnectionDB.executeQuery(quer);

                    Program.activeUser.Id       = Convert.ToInt32(dte.Rows[0][0]);
                    Program.activeUser.Name     = Convert.ToString(dte.Rows[0][1]);
                    Program.activeUser.Nickname = Convert.ToString(dte.Rows[0][2]);
                    Program.activeUser.Password = Convert.ToString(dte.Rows[0][3]);
                    Program.activeUser.Type     = Convert.ToBoolean(dte.Rows[0][4]);

                    this.Hide();
                    new Form1().Show();
                }
                else
                {
                    MessageBox.Show("La combinación de usuario y contraseña no existe");
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("Ha ocurrido un Error");
            }
        }
Ejemplo n.º 2
0
        private void Orders_load(object sender, EventArgs e)
        {
            if (Program.activeUser.Type)
            {
                tabControl1.TabPages.RemoveByKey("tabPage2");
                textBox3.Visible = false;
                button2.Visible  = false;
                var dt = ConnectionDB.executeQuery("SELECT * FROM apporder");
                dataGridView1.DataSource = dt;
            }
            else
            {
                var dt = ConnectionDB.executeQuery($"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 = {Program.activeUser.Id.ToString()};");
                dataGridView1.DataSource = dt;

                var det = ConnectionDB.executeQuery($"SELECT * FROM product");
                dataGridView2.DataSource = det;

                var address = ConnectionDB.executeQuery("SELECT * FROM address " +
                                                        $"WHERE idUser = {Program.activeUser.Id.ToString()}");
                var addressCombo = new List <string>();

                foreach (DataRow dr in address.Rows)
                {
                    addressCombo.Add(dr[0].ToString());
                }
            }
        }
Ejemplo n.º 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            var query = ConnectionDB.executeQuery($"SELECT idBusiness FROM business WHERE name = '{comboBox2.SelectedItem}'");
            var dr    = query.Rows[0][0];


            if (textBox2.Text.Equals(""))
            {
                MessageBox.Show("No se pueden dejar campos vacíos");
            }
            else
            {
                try
                {
                    ConnectionDB.ExecuteNonQuery("INSERT INTO product(idBusiness, name)" +
                                                 "VALUES(" +
                                                 $"{dr}," +
                                                 $"'{textBox2.Text}')");

                    MessageBox.Show("Agregado exitosamente");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Ha ocurrido un error");
                }
            }
        }
Ejemplo n.º 4
0
        private void CrudProduct_Load(object sender, EventArgs e)
        {
            var dt = ConnectionDB.executeQuery("SELECT * FROM product");

            dataGridView1.DataSource = dt;

            var business      = ConnectionDB.executeQuery("SELECT name FROM business");
            var businessCombo = new List <string>();

            foreach (DataRow dr in business.Rows)
            {
                businessCombo.Add(dr[0].ToString());
            }
            comboBox2.DataSource = businessCombo;
        }
Ejemplo n.º 5
0
        private void CrudBusiness_Load(object sender, EventArgs e)
        {
            var dt = ConnectionDB.executeQuery("SELECT * FROM business");

            dataGridView1.DataSource = dt;
        }