Esempio n. 1
0
        public static void CreateBusiness(Business business)
        {
            String querySql = $"INSERT INTO BUSINESS(name, description) VALUES('{business.Name}'," +
                              $"'{business.Description}');";

            ConnectionDB.ExecuteNonQuery(querySql);
        }
Esempio n. 2
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     ConnectionDB.ExecuteNonQuery($"insert into address(iduser, address) values({iduser}, '{textBox1.Text}')");
     MessageBox.Show("¡Se ha agregado correctamente!",
                     "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
     actualizar();
 }
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Equals("") ||
                textBox2.Equals(""))

            {
                MessageBox.Show("No puede dejar los campos vacios!");
            }
            else
            {
                try
                {
                    ConnectionDB.ExecuteNonQuery(
                        $"INSERT INTO BUSINESS(name, description) VALUES(" +
                        $"'{textBox1.Text}'," +
                        $"'{textBox2.Text}')");

                    MessageBox.Show("Negocio Añadido");
                }
                catch (Exception esg)
                {
                    MessageBox.Show("Ha ocurrido un error");
                }
            }
        }
Esempio n. 4
0
        private void btnAddBuisness_Click(object sender, EventArgs e)
        {
            string name        = txtNameBuisness.Text;
            string description = txtdescripcion.Text;
            int    iduser      = 0;
            string query       =
                $"INSERT INTO BUSINESS(name, description) VALUES ('{name}', '{description}');";

            try
            {
                if (txtNameBuisness.Text.Equals("") || txtdescripcion.Text.Equals(""))
                {
                    MessageBox.Show("No se permiten campos vacios.");
                }
                else if (txtNameBuisness.Text.Length < 3 || txtdescripcion.Text.Length < 10)
                {
                    throw new UnreachedMinimumNumberOfCharacters("No alcanzó los requerimientos minimos." +
                                                                 "\nLongitud minima para el nombre de la empresa: 3 caracteres." +
                                                                 "\nLongitud minima para la descripcion del negocio: 10 caracteres.");
                }
                else
                {
                    ConnectionDB.ExecuteNonQuery(query);
                    MessageBox.Show("Negocion agregado con exito!!");
                }
            }catch (UnreachedMinimumNumberOfCharacters exc) {
                MessageBox.Show("Intente nuevamente.");
            }catch (Exception ex) {
                MessageBox.Show("Intente nuevamente.");
            }
        }
Esempio n. 5
0
        public static void DeleteProduct(Product product, int idBusiness)
        {
            String querySql = $"DELETE FROM PRODUCT WHERE name = '{product.Name}' AND idbusiness = {idBusiness} " +
                              $"AND idproduct = {product.IdProduct};";

            ConnectionDB.ExecuteNonQuery(querySql);
        }
Esempio n. 6
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Equals("") ||
                textBox2.Equals(""))

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

                    MessageBox.Show("USUARIO ANADIDO");
                }
                catch (Exception esg)
                {
                    MessageBox.Show("Ha ocurrido un error");
                }
            }
        }
Esempio n. 7
0
        public static void UpdateAddress(Address address)
        {
            String querySql = $"UPDATE ADDRESS SET address = '{address.SAddress}' WHERE idaddress = " +
                              $"{address.IdAddress};";

            ConnectionDB.ExecuteNonQuery(querySql);
        }
Esempio n. 8
0
        private void button3_Click(object sender, EventArgs e)
        {
            string Location = txtNewLocation.Text;
            int    iduser   = 0;
            string query    =
                $"INSERT INTO ADDRESS(idUser, address) INSERT INTO ADDRESS({iduser}, '{Location}')";

            try
            {
                if (txtNewLocation.Text.Equals(""))
                {
                    MessageBox.Show("No se permiten campos vacios.");
                }
                else if (txtNewLocation.Text.Length < 6)
                {
                    throw new UnreachedMinimumNumberOfCharacters("No alcanzó los requerimientos minimos." +
                                                                 "\nLongitud minima para la direccion: 6 caracteres.");
                }
                else
                {
                    ConnectionDB.ExecuteNonQuery(query);
                    MessageBox.Show("Ubicacion agregada exitosamente!!");
                }
            }catch (UnreachedMinimumNumberOfCharacters exc) {
                MessageBox.Show("Intente nuevamente.");
            }catch (Exception ex) {
                MessageBox.Show("Intente nuevamente.");
            }
        }
Esempio n. 9
0
        public static void DeleteAddress(Address address)
        {
            String querySql = $"DELETE FROM ADDRESS WHERE idaddress = {address.IdAddress} " +
                              $"AND iduser = {address.IdUser}";

            ConnectionDB.ExecuteNonQuery(querySql);
        }
Esempio n. 10
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool type = false;

            try
            {
                if (textBox1.Text.Equals("") || textBox2.Text.Equals(""))
                {
                    MessageBox.Show("No se pueden dejar campos vacíos");
                }
                else
                {
                    if (radioButton1.Checked)
                    {
                        type = false;
                    }
                    else if (radioButton2.Checked)
                    {
                        type = true;
                    }

                    string query = $"INSERT INTO APPUSER (fullname, username, password, usertype) " +
                                   $"VALUES ('{textBox1.Text}', '{textBox2.Text}', '{textBox2.Text}', {type}); ";

                    ConnectionDB.ExecuteNonQuery(query);

                    MessageBox.Show("Se ha registrado al usuario");
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("Error");
            }
        }
Esempio n. 11
0
        public static void CreateUser(User user)
        {
            String querySql = $"INSERT INTO APPUSER(fullname,username,password,usertype)" +
                              $"VALUES ('{user.Fullname}','{user.Username}','{user.Password}', {user.UserType});";

            ConnectionDB.ExecuteNonQuery(querySql);
        }
Esempio n. 12
0
        private void btnCreateUser_Click(object sender, EventArgs e)
        {
            string Fullname = txtFullName.Text;
            string Username = txtUsername.Text;
            string query    =
                $"INSERT INTO APPUSER(fullname, username, password, userType) VALUES('{Fullname}', '{Username}', '{Username}', false);";

            try
            {
                if (txtUsername.Text.Equals("") || txtFullName.Text.Equals(""))
                {
                    MessageBox.Show("No se permiten campos vacios.");
                }
                else if (txtFullName.Text.Length < 10 || txtUsername.Text.Length < 5)
                {
                    throw new UnreachedMinimumNumberOfCharacters("No alcanzó los requerimientos minimos." +
                                                                 "\nLongitud minima para el nombre: 10 caracteres." +
                                                                 "\nLongitud minima para el nombre de usuario: 5 caracteres.");
                }
                else
                {
                    ConnectionDB.ExecuteNonQuery(query);
                    MessageBox.Show("Cuenta creada exitosamente, volviendo a pantalla principal." +
                                    "\n Recordando: su clave es igual a su nombre de usuario.");
                }
            }catch (UnreachedMinimumNumberOfCharacters exc) {
                MessageBox.Show("Intente nuevamente.");
            }catch (Exception ex) {
                MessageBox.Show("Intente nuevamente.");
            }
        }
Esempio n. 13
0
        public static void CreateOrder(Order order)
        {
            String querySql = $"INSERT INTO APPORDER(createdate,idproduct,idaddress) VALUES " +
                              $"('{order.CreateDate.ToString("d")}',{order.IdProduct}," +
                              $"{order.IdAddress});";

            ConnectionDB.ExecuteNonQuery(querySql);
        }
Esempio n. 14
0
        public static void DeleteOrder(int userID, int orderID)
        {
            String query = $"DELETE from apporder where idorder = {orderID} AND idaddress IN " +
                           $"(SELECT idaddress FROM ADDRESS WHERE iduser = "******"(SELECT iduser FROM APPUSER WHERE iduser = {userID}));";

            ConnectionDB.ExecuteNonQuery(query);
        }
Esempio n. 15
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         ConnectionDB.ExecuteNonQuery($"DELETE FROM APPORDER WHERE idOrder = {comboBox2.SelectedItem}");
         MessageBox.Show("Orden Eliminada con exito");
     }
     catch (Exception esg)
     {
         MessageBox.Show("Ha ocurrido un error");
     }
 }
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         ConnectionDB.ExecuteNonQuery($"DELETE FROM ADDRESS WHERE idAddress = {comboBox2.SelectedItem}");
         MessageBox.Show("Direccion Eliminada");
     }
     catch (Exception esg)
     {
         MessageBox.Show("Ha ocurrido un error");
     }
 }
 private void Eliminar_Click_1(object sender, EventArgs e)
 {
     try
     {
         ConnectionDB.ExecuteNonQuery($"DELETE FROM BUSINESS WHERE idBusiness = {comboBox1.SelectedItem}");
         MessageBox.Show("Negocio Eliminado");
     }
     catch (Exception esg)
     {
         MessageBox.Show("Ha cocurrido un problema");
     }
 }
Esempio n. 18
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         ConnectionDB.ExecuteNonQuery($"DELETE FROM PRODUCT WHERE idbusiness={comboBox1.SelectedItem} AND " +
                                      $"name='{comboBox2.SelectedItem}'");
         MessageBox.Show("Producto Eliminado");
     }
     catch (Exception esg)
     {
         MessageBox.Show("Ha cocurrido un problema");
     }
 }
Esempio n. 19
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         ConnectionDB.ExecuteNonQuery(
             $"UPDATE ADDRESS SET address = 'nueva' WHERE idAddress = {comboBox1.SelectedItem}");
         MessageBox.Show("Direccion Modificada");
     }
     catch (Exception esg)
     {
         MessageBox.Show("Ha ocurrido un error");
     }
 }
Esempio n. 20
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                ConnectionDB.ExecuteNonQuery($"DELETE FROM APPUSER WHERE iduser = '******'");

                MessageBox.Show("Usuario eliminado correctamente");
            }
            catch (Exception exception)
            {
                MessageBox.Show("Error");
            }
        }
Esempio n. 21
0
 private void button4_Click(object sender, EventArgs e)
 {
     try
     {
         ConnectionDB.ExecuteNonQuery($"INSERT INTO ADDRESS(iduser, address) VALUES ('{LogUsu.Iduser}', '{textBox1.Text}')");
         PopulateControls3();
         MessageBox.Show("Dirección agregada");
     }
     catch
     {
         MessageBox.Show("No se ha podido guardar la dirección");
     }
 }
Esempio n. 22
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                string nonQuery = $"DELETE FROM APPUSER WHERE username='******'";

                ConnectionDB.ExecuteNonQuery(nonQuery);
                MessageBox.Show("Usuario Eliminado");
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ha ocurrido un error!");
            }
        }
Esempio n. 23
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         DateTime f = DateTime.Now;
         ConnectionDB.ExecuteNonQuery($"INSERT INTO APPORDER(createDate, idProduct, idAddress) VALUES('{f}', '{listBox2.SelectedValue}', '{comboBox1.SelectedValue}'); ");
         ActGrid();
         MessageBox.Show("Orden agregada");
     }
     catch (Exception ex)
     {
         MessageBox.Show("No se ha podido procesar su orden");
     }
 }
        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                ConnectionDB.ExecuteNonQuery($"DELETE FROM PRODUCT WHERE idProduct = '{comboBox2.SelectedValue}'");

                MessageBox.Show("Producto eliminado correctamente");
                PopulateControls2();
            }
            catch (Exception exception)
            {
                MessageBox.Show("Error");
            }
        }
Esempio n. 25
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         ConnectionDB.ExecuteNonQuery($"delete from apporder where idorder ='{ordenes.SelectedItem.ToString()}'");
         MessageBox.Show($"¡Orden eliminada!", "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         actualizarComponentes();
     }
     catch (Exception exception)
     {
         MessageBox.Show("¡Ha ocurrido un error!",
                         "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 26
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                ConnectionDB.ExecuteNonQuery("INSERT INTO PRODUCT(idBusiness, name)" +
                                             $"VALUES({comboBox1.SelectedItem}, '{textBox2.Text}')");

                MessageBox.Show("Producto Añadido");
            }

            catch (Exception esg)
            {
                MessageBox.Show("Ha ocurrido un error");
            }
        }
Esempio n. 27
0
 private void buttonDelete_Click(object sender, EventArgs e)
 {
     try
     {
         ConnectionDB.ExecuteNonQuery($"delete from address where iduser = {iduser} and address = '{comboBoxD.SelectedItem.ToString()}'");
         MessageBox.Show("¡Se ha eliminado correctamente!",
                         "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         actualizar();
     }
     catch (Exception exception)
     {
         MessageBox.Show("¡Ha ocurrido un error!",
                         "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 28
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                ConnectionDB.ExecuteNonQuery($"DELETE FROM BUSINESS WHERE idBusiness = {comboBox1.SelectedValue}");

                MessageBox.Show("Negocio eliminado correctamente");
            }
            catch (Exception exception)
            {
                MessageBox.Show("Error");
            }

            ActGrid();
        }
Esempio n. 29
0
 private void buttonAdd_Click(object sender, EventArgs e)
 {
     try
     {
         ConnectionDB.ExecuteNonQuery($"insert into business(name, description) values('{textBoxName.Text}', '{textBoxDesc.Text}')");
         MessageBox.Show("¡Negocio añadido correctamente!",
                         "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         actucombobox();
     }
     catch (Exception exception)
     {
         MessageBox.Show("¡Ha ocurrido un error!",
                         "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Esempio n. 30
0
 private void buttonAddP_Click(object sender, EventArgs e)
 {
     try
     {
         int id = idbusi(comboBoxnegocios.SelectedItem.ToString());
         ConnectionDB.ExecuteNonQuery($"insert into product(idBusiness, name) values({id}, '{textBoxNameP.Text}')");
         MessageBox.Show("¡Producto agregado exitosamente!",
                         "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
         actucombobox();
     }
     catch (Exception exception)
     {
         MessageBox.Show("¡Ha ocurrido un error!",
                         "Hugo", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }