Пример #1
0
 private void button5_Click(object sender, EventArgs e)
 {
     try
     {
         if (textBox1.Text.Equals("") ||
             textBox2.Text.Equals(""))
         {
             MessageBox.Show("No dejes espacios en blancos");
         }
         else
         {
             var idU = ConectionBD.ExecuteQuery($"SELECT idUser FROM APPUSER " +
                                                $"WHERE username='******'");
             var idUs   = idU.Rows[0];
             int idUser = Convert.ToInt32(idUs[0].ToString());
             ConectionBD.ExecuteNonQuery($"UPDATE APPUSER SET password = '******' " +
                                         $"WHERE idUser='******'");
             MessageBox.Show("Has modificado la contraseña!");
             Login win = new Login();
             win.Show();
             this.Hide();
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show("Ocurrió un error! Vuelva a intentarlo");
     }
 }
Пример #2
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox6.Text.Equals(""))
                {
                    MessageBox.Show("No puede dejar campos vacíos!");
                }
                else
                {
                    var idA = ConectionBD.ExecuteQuery($"SELECT idAddress FROM ADDRESS " +
                                                       $"WHERE address='{comboBox3.SelectedItem}'");
                    var idAs      = idA.Rows[0];
                    int idAddress = Convert.ToInt32(idAs[0].ToString());
                    ConectionBD.ExecuteNonQuery($"UPDATE ADDRESS SET address = '{textBox6.Text}' " +
                                                $"WHERE idAddress={idAddress}");
                    MessageBox.Show("Dirección modificada con éxito!");
                    //Actualizando Datos
                    UsuarioNormal_Load(sender, e);
                }
            }

            catch (Exception exception)
            {
                MessageBox.Show("Ocurrió un error! Vuelva a intentarlo");
            }
        }
Пример #3
0
        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                DateTime date = DateTime.Now;

                var idP = ConectionBD.ExecuteQuery($"SELECT idProduct FROM PRODUCT " +
                                                   $"WHERE name = '{comboBox2.SelectedItem}'");
                var idProd    = idP.Rows[0];
                int idProduct = Convert.ToInt32(idProd[0].ToString());

                var idA = ConectionBD.ExecuteQuery($"SELECT idAddress FROM ADDRESS " +
                                                   $"WHERE address = '{comboBox4.SelectedItem}'");
                var idAd      = idA.Rows[0];
                int idAddress = Convert.ToInt32(idAd[0].ToString());

                ConectionBD.ExecuteNonQuery($"INSERT INTO APPORDER(createDate, idProduct, idAddress) " +
                                            $"VALUES('{date}',{idProduct},'{idAddress}')");

                MessageBox.Show("Orden realizada con éxito!");
                //Actualizando Datos
                UsuarioNormal_Load(sender, e);
            }
            catch (Exception exception)
            {
                MessageBox.Show("Ocurrió un error! Vuelva a intentarlo");
            }
        }
Пример #4
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         if (textBox1.Text.Equals(""))
         {
             MessageBox.Show("No puede dejar campos vacíos!");
         }
         else
         {
             var idU = ConectionBD.ExecuteQuery($"SELECT idUser FROM APPUSER " +
                                                $"WHERE username='******'");
             var idUs   = idU.Rows[0];
             int idUser = Convert.ToInt32(idUs[0].ToString());
             ConectionBD.ExecuteNonQuery($"INSERT INTO ADDRESS(idUser, address) " +
                                         $"VALUES('{idUser}','{textBox1.Text}')");
             MessageBox.Show("Dirección agregada con éxito!");
             //Actualizando Datos
             UsuarioNormal_Load(sender, e);
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show("Ocurrió un error! Vuelva a intentarlo");
     }
 }
Пример #5
0
 private void button5_Click(object sender, EventArgs e)
 {
     try
     {
         if (textBox6.Text.Equals(""))
         {
             MessageBox.Show("No puede dejar campos vacíos!");
         }
         else
         {
             var idB = ConectionBD.ExecuteQuery($"SELECT idBusiness FROM BUSINESS " +
                                                $"WHERE name='{comboBox3.SelectedItem}'");
             var idBus      = idB.Rows[0];
             int idBusiness = Convert.ToInt32(idBus[0].ToString());
             ConectionBD.ExecuteNonQuery($"INSERT INTO PRODUCT(idBusiness, name) " +
                                         $"VALUES({idBusiness},'{textBox6.Text}')");
             MessageBox.Show("Producto Agregado con éxito!");
             //Actualizando Datos
             Administrador_Load(sender, e);
         }
     }
     catch (Exception exception)
     {
         MessageBox.Show("Ocurrió un error! Vuelva a intentarlo");
     }
 }
Пример #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox3.Text.Equals("") ||
                    textBox1.Text.Equals(""))
                {
                    MessageBox.Show("No puede dejar campos vacíos!");
                }
                else
                {
                    string User  = textBox3.Text;
                    var    users = ConectionBD.ExecuteQuery("SELECT username FROM APPUSER");
                    bool   equal = false;

                    foreach (DataRow row in users.Rows)
                    {
                        if (User.Equals(row[0].ToString()))
                        {
                            equal = true;
                        }
                    }

                    if (equal == false)
                    {
                        if (radioButton1.Checked)
                        {
                            ConectionBD.ExecuteNonQuery($"INSERT INTO APPUSER(fullname, username, password, userType)" +
                                                        $" VALUES('{textBox1.Text}','{textBox3.Text}','{textBox3.Text}',true)");
                            MessageBox.Show("Usuario agregado exitosamente");
                        }
                        else
                        {
                            ConectionBD.ExecuteNonQuery($"INSERT INTO APPUSER(fullname, username, password, userType)" +
                                                        $" VALUES('{textBox1.Text}','{textBox3.Text}','{textBox3.Text}',false)");
                            MessageBox.Show("Usuario agregado exitosamente");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Ese nombre ya exite! Elige otro");
                    }

                    //Actualizando Datos
                    Administrador_Load(sender, e);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("Ocurrió un error! Vuelva a intentarlo");
            }
        }
Пример #7
0
        private void comboBox4_SelectionChangeCommitted(object sender, EventArgs e)
        {
            var producto      = ConectionBD.ExecuteQuery("SELECT name FROM PRODUCT");
            var productoCombo = new List <string>();

            foreach (DataRow row in producto.Rows)
            {
                productoCombo.Add(row[0].ToString());
            }
            comboBox5.DataSource = null;
            comboBox5.Items.Clear();
            comboBox5.DataSource = productoCombo;
        }
Пример #8
0
 private void button3_Click(object sender, EventArgs e)
 {
     try
     {
         var idA = ConectionBD.ExecuteQuery($"SELECT idAddress FROM ADDRESS " +
                                            $"WHERE address='{comboBox1.SelectedItem}'");
         var idAs      = idA.Rows[0];
         int idAddress = Convert.ToInt32(idAs[0].ToString());
         ConectionBD.ExecuteNonQuery($"DELETE FROM ADDRESS WHERE idAddress={idAddress}");
         MessageBox.Show("Dirección eliminada con éxito!");
         //Actualizando Datos
         UsuarioNormal_Load(sender, e);
     }
     catch (Exception exception)
     {
         MessageBox.Show("Ocurrió un error! Vuelva a intentarlo");
     }
 }
Пример #9
0
 private void button6_Click(object sender, EventArgs e)
 {
     try
     {
         var idP = ConectionBD.ExecuteQuery($"SELECT idProduct FROM PRODUCT " +
                                            $"WHERE name='{comboBox5.SelectedItem}'");
         var idPr      = idP.Rows[0];
         int idProduct = Convert.ToInt32(idPr[0].ToString());
         ConectionBD.ExecuteNonQuery($"DELETE FROM PRODUCT WHERE idProduct='{idProduct}'");
         MessageBox.Show("Producto Eliminado!");
         //Actualizando Datos
         Administrador_Load(sender, e);
     }
     catch (Exception exception)
     {
         MessageBox.Show("Ocurrió un error! Vuelva a intentarlo");
     }
 }
Пример #10
0
 private void button4_Click(object sender, EventArgs e)
 {
     try
     {
         var idB = ConectionBD.ExecuteQuery($"SELECT idBusiness FROM BUSINESS " +
                                            $"WHERE name='{comboBox2.SelectedItem}'");
         var idBus      = idB.Rows[0];
         int idBusiness = Convert.ToInt32(idBus[0].ToString());
         ConectionBD.ExecuteNonQuery($"DELETE FROM BUSINESS WHERE idBusiness='{idBusiness}'");
         MessageBox.Show("Negocio Eliminado!");
         //Actualizando Datos
         Administrador_Load(sender, e);
     }
     catch (Exception exception)
     {
         MessageBox.Show("Ocurrió un error! Vuelva a intentarlo");
     }
 }
Пример #11
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                var idU = ConectionBD.ExecuteQuery($"SELECT idUser FROM APPUSER " +
                                                   $"WHERE username='******'");
                var idUs   = idU.Rows[0];
                int idUser = Convert.ToInt32(idUs[0].ToString());
                ConectionBD.ExecuteNonQuery($"DELETE FROM APPUSER WHERE idUser='******'");

                //Actualizando datos
                Administrador_Load(sender, e);
                MessageBox.Show("Usuario eliminado!");
            }
            catch (Exception exception)
            {
                MessageBox.Show("Ocurrió un error! Vuelva a intentarlo");
            }
        }
Пример #12
0
        private void button5_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox1.Text.Equals("") ||
                    textBox2.Text.Equals(""))
                {
                    MessageBox.Show("No dejes espacios en blancos");
                }
                else
                {
                    String User = textBox2.Text;

                    var pass = ConectionBD.ExecuteQuery($"SELECT password FROM APPUSER " +
                                                        $"WHERE username = '******'");
                    var    passw    = pass.Rows[0];
                    String passWord = passw[0].ToString();

                    if (textBox1.Text.Equals(passWord))
                    {
                        var ad = ConectionBD.ExecuteQuery($"SELECT userType FROM APPUSER " +
                                                          $"WHERE username = '******'");
                        var  adm   = ad.Rows[0];
                        bool admin = Convert.ToBoolean(adm[0].ToString());

                        MessageBox.Show("Bienvenido " + textBox2.Text);
                        Form1 win = new Form1(User, admin);
                        win.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("Contraseña incorrecta!");
                    }
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("Ocurrió un error! Vuelva a intentarlo");
            }
        }
Пример #13
0
        private void Administrador_Load(object sender, EventArgs e)
        {
            try
            {
                var user          = ConectionBD.ExecuteQuery("SELECT username FROM APPUSER");
                var negocio       = ConectionBD.ExecuteQuery("SELECT name FROM BUSINESS");
                var producto      = ConectionBD.ExecuteQuery("SELECT name FROM PRODUCT");
                var dt            = ConectionBD.ExecuteQuery("SELECT * FROM APPUSER");
                var dt2           = ConectionBD.ExecuteQuery("SELECT * FROM APPORDER");
                var userCombo     = new List <string>();
                var negocioCombo  = new List <string>();
                var productoCombo = new List <string>();

                foreach (DataRow row in user.Rows)
                {
                    userCombo.Add(row[0].ToString());
                }

                foreach (DataRow row in negocio.Rows)
                {
                    negocioCombo.Add(row[0].ToString());
                }

                foreach (DataRow row in producto.Rows)
                {
                    productoCombo.Add(row[0].ToString());
                }

                comboBox1.DataSource     = userCombo;
                comboBox2.DataSource     = negocioCombo;
                comboBox3.DataSource     = negocioCombo;
                comboBox4.DataSource     = negocioCombo;
                dataGridView1.DataSource = dt;
                dataGridView2.DataSource = dt2;
            }
            catch (Exception exception)
            {
                MessageBox.Show("Ocurrió un error! Vuelva a intentarlo");
            }
        }
Пример #14
0
        private void UsuarioNormal_Load(object sender, EventArgs e)
        {
            try
            {
                var idU = ConectionBD.ExecuteQuery($"SELECT idUser FROM APPUSER " +
                                                   $"WHERE username='******'");
                var idUs   = idU.Rows[0];
                int idUser = Convert.ToInt32(idUs[0].ToString());


                var address = ConectionBD.ExecuteQuery($"SELECT address FROM ADDRESS " +
                                                       $"WHERE idUser='******'");


                var dt = ConectionBD.ExecuteQuery($"SELECT address FROM ADDRESS " +
                                                  $"WHERE idUser='******'");


                var producto = ConectionBD.ExecuteQuery("SELECT name FROM PRODUCT");


                var orden = ConectionBD.ExecuteQuery($"SELECT ao.idOrder " +
                                                     $"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 = '******'");


                var dt2 = ConectionBD.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 = '******'");

                var addressCombo  = new List <String>();
                var productoCombo = new List <String>();
                var ordenCombo    = new List <String>();


                foreach (DataRow row in address.Rows)
                {
                    addressCombo.Add(row[0].ToString());
                }
                foreach (DataRow row in producto.Rows)
                {
                    productoCombo.Add(row[0].ToString());
                }
                foreach (DataRow row in orden.Rows)
                {
                    ordenCombo.Add(row[0].ToString());
                }

                comboBox3.DataSource     = addressCombo;
                comboBox1.DataSource     = addressCombo;
                comboBox2.DataSource     = productoCombo;
                comboBox4.DataSource     = addressCombo;
                comboBox5.DataSource     = ordenCombo;
                dataGridView1.DataSource = dt;
                dataGridView2.DataSource = dt2;
            }
            catch (Exception exception)
            {
                MessageBox.Show("Ocurrió un error! Vuelva a intentarlo");
            }
        }