Esempio n. 1
0
        public void findAll()
        {
            db = new Database();

            brands.Clear();

            brandQuery = new MySqlCommand();

            brandQuery.Connection = db.Connection();

            brandQuery.CommandText = "SELECT * FROM brand ORDER BY brandname ASC";

            this.brandResult = brandQuery.ExecuteReader();

            while (brandResult.Read())
            {
                if (!brandResult.IsDBNull(0))
                {
                    idbrand = brandResult.GetInt32(0);
                }

                if (!brandResult.IsDBNull(1))
                {
                    brandname = brandResult.GetString(1);
                }

                brands.Add(new Brand { idbrand = this.idbrand, brandname = this.brandname});
            }

            db.Close();
        }
        public void findAll()
        {
            db = new Database();

            person_user_computerQuery = new MySqlCommand();

            person_user_computerQuery.Connection = db.Connection();

            person_user_computerQuery.CommandText = "SELECT * FROM person_user_computer";

            person_user_computerResult = person_user_computerQuery.ExecuteReader();

            while (person_user_computerResult.Read())
            {
                if (!person_user_computerResult.IsDBNull(0))
                {
                    idperson_user = person_user_computerResult.GetInt32(0);
                }

                if (!person_user_computerResult.IsDBNull(1))
                {
                    person = new Person();

                    person.idperson = person_user_computerResult.GetInt32(1);

                    person.findByIdperson();
                }

                if (!person_user_computerResult.IsDBNull(2))
                {
                    user = new User();

                    user.iduser = person_user_computerResult.GetInt32(2);

                    user.findByIdUser();
                }

                //if (!person_user_computerResult.IsDBNull(3))
                //{
                //    person_userstart = person_user_computerResult.GetDateTime(3);
                //}
                //else
                //{
                //    person_userstart = null;
                //}

                //if (!person_user_computerResult.IsDBNull(4))
                //{
                //    person_userfinish = person_user_computerResult.GetDateTime(4);
                //}
                //else
                //{
                //    person_userfinish = null;
                //}

                persons_users_computers.Add(new Person_User_Computer { idperson_user = this.idperson_user, person = this.person, user = this.user });
            }

            db.Close();
        }
        public void create()
        {
            db = new Database();

            if (officeVerification())
            {
                try
                {
                    officeQuery = new MySqlCommand();

                    officeQuery.Connection = db.Connection();

                    officeQuery.CommandText = "INSERT INTO office(officedescription) VALUES(@Description)";

                    officeQuery.Prepare();

                    officeQuery.Parameters.AddWithValue("@Description", officedescription);

                    officeQuery.ExecuteNonQuery();

                    MessageBox.Show("A Descrição Cargo Assinatura " + officedescription + " foi criada com sucesso.");
                }
                catch (MySqlException ex)
                {
                    MessageBox.Show("Ocurreu um erro");
                    Console.WriteLine("Error: {0}", ex.ToString());
                }
                finally
                {
                    db.Close();
                }
            }
        }
Esempio n. 4
0
        public void findAll()
        {
            db = new Database();

            space = new Space();

            paths.Clear();

            pathQuery = new MySqlCommand();

            pathQuery.Connection = db.Connection();

            pathQuery.CommandText = "SELECT * FROM path ORDER BY path ASC";

            pathResult = pathQuery.ExecuteReader();

            while (pathResult.Read())
            {
                if (!pathResult.IsDBNull(0))
                {
                    idpath = pathResult.GetInt32(0);
                }

                if (!pathResult.IsDBNull(1))
                {
                    path = pathResult.GetString(1);
                }

                paths.Add(new Path { idpath = this.idpath, path = this.path });
            }

            db.Close();
        }
Esempio n. 5
0
        public void create()
        {
            db = new Database();

            space = new Space();

            try
            {
                pathQuery = new MySqlCommand();

                pathQuery.Connection = db.Connection();

                pathQuery.CommandText = "INSERT INTO path(path) VALUES(@Path)";

                pathQuery.Prepare();

                pathQuery.Parameters.AddWithValue("@Path", path);

                pathQuery.ExecuteNonQuery();

                MessageBox.Show("O Caminho " + path + " foi criado com sucesso.");
            }
            catch (MySqlException ex)
            {
                MessageBox.Show("Ocurreu um erro");

                Console.WriteLine("Error: {0}", ex.ToString());
            }
            finally
            {
                db.Close();
            }
        }
        public void create()
        {
            db = new Database();

            if (categoryVerification())
            {
                try
                {
                    actiontypeQuery = new MySqlCommand();

                    actiontypeQuery.Connection = db.Connection();

                    actiontypeQuery.CommandText = "INSERT INTO actiontype(actiontypedescription) VALUES(@Description)";
                    actiontypeQuery.Prepare();

                    actiontypeQuery.Parameters.AddWithValue("@Description", actiontypedescription);

                    actiontypeQuery.ExecuteNonQuery();

                    MessageBox.Show("O tipo de ação " + actiontypedescription + " foi criado com sucesso.");
                }
                catch (MySqlException ex)
                {
                    MessageBox.Show("Ocurreu um erro");
                    Console.WriteLine("Error: {0}", ex.ToString());
                }
                finally
                {
                    db.Close();
                }
            }
        }
        public void create()
        {
            db = new Database();

            if (signatureVerification())
            {
                try
                {
                    signatureQuery = new MySqlCommand();

                    signatureQuery.Connection = db.Connection();

                    signatureQuery.CommandText = "INSERT INTO signature(signaturename) VALUES(@Name)";
                    signatureQuery.Prepare();

                    signatureQuery.Parameters.AddWithValue("@Name", signaturename);

                    signatureQuery.ExecuteNonQuery();

                    MessageBox.Show("A assinatura " + signaturename + " foi criada com sucesso.");
                }
                catch (MySqlException ex)
                {
                    MessageBox.Show("Ocurreu um erro");

                    Console.WriteLine("Error: {0}", ex.ToString());
                }
                finally
                {
                    db.Close();
                }
            }
        }
        public void create()
        {
            db = new Database();

            if (computerVerification())
            {
                try
                {
                    computerQuery = new MySqlCommand();

                    computerQuery.Connection = db.Connection();

                    computerQuery.CommandText = "INSERT INTO computer(idcomputer) VALUES(@ID)";
                    computerQuery.Prepare();

                    computerQuery.Parameters.AddWithValue("@ID", idcomputer);

                    computerQuery.ExecuteNonQuery();

                    MessageBox.Show("O computador com o número " + idcomputer + " foi criado com sucesso.");
                }
                catch (MySqlException ex)
                {
                    MessageBox.Show("Ocurreu um erro");
                    Console.WriteLine("Error: {0}", ex.ToString());
                }
                finally
                {
                    db.Close();
                }
            }
        }
        public void create()
        {
            db = new Database();

            if (vendorVerification())
            {
                try
                {
                    vendorQuery = new MySqlCommand();

                    vendorQuery.Connection = db.Connection();

                    vendorQuery.CommandText = "INSERT INTO vendor(vendorname) VALUES(@Name)";
                    vendorQuery.Prepare();

                    vendorQuery.Parameters.AddWithValue("@Name", vendorname);

                    vendorQuery.ExecuteNonQuery();

                    MessageBox.Show("O fornecedor " + vendorname + " foi criado com sucesso.");
                }
                catch (MySqlException ex)
                {
                    MessageBox.Show("Ocurreu um erro");
                    Console.WriteLine("Error: {0}", ex.ToString());
                }
                finally
                {
                    db.Close();
                }
            }
        }
Esempio n. 10
0
        public void create()
        {
            db = new Database();

            path = new Path();

            try
            {
                spaceQuery = new MySqlCommand();

                spaceQuery.Connection = db.Connection();

                spaceQuery.CommandText = "INSERT INTO space(spacedate,space,idpath) VALUES(@Date,@Space,@IDPath)";

                spaceQuery.Prepare();

                spaceQuery.Parameters.AddWithValue("@Date", spacedate);
                spaceQuery.Parameters.AddWithValue("@Space", space);
                spaceQuery.Parameters.AddWithValue("@IDPath", idpath);

                spaceQuery.ExecuteNonQuery();

                //MessageBox.Show("O Espaço " + username + " foi criado com sucesso.");
            }
            catch (MySqlException ex)
            {
                MessageBox.Show("Ocurreu um erro");

                Console.WriteLine("Error: {0}", ex.ToString());
            }
            finally
            {
                db.Close();
            }
        }
Esempio n. 11
0
        public void create()
        {
            db = new Database();

            if (userVerification())
            {
                try
                {
                    userQuery = new MySqlCommand();

                    userQuery.Connection = db.Connection();

                    userQuery.CommandText = "INSERT INTO user(username,useremail,iddepartment) VALUES(@Name,@Email,@Department)";

                    userQuery.Prepare();

                    userQuery.Parameters.AddWithValue("@Name", username);
                    userQuery.Parameters.AddWithValue("@Email", useremail);
                    userQuery.Parameters.AddWithValue("@Department", department.iddepartment);

                    userQuery.ExecuteNonQuery();

                    MessageBox.Show("O Utilizador " + username + " foi criado com sucesso.");
                }
                catch (MySqlException ex)
                {
                    if (ex.Message.Contains("Duplicate"))
                    {
                        MessageBox.Show("Já existe um Utilizador com o email " + useremail + ".");
                        Console.WriteLine("Error: {0}", ex.ToString());
                    }
                    else
                    {
                        MessageBox.Show("Ocurreu um erro");
                        Console.WriteLine("Error: {0}", ex.ToString());
                    }
                }
                finally
                {
                    db.Close();
                }
            }
        }
Esempio n. 12
0
        public void create()
        {
            db = new Database();

            if (personVerification())
            {
                try
                {
                    personQuery = new MySqlCommand();

                    personQuery.Connection = db.Connection();

                    personQuery.CommandText = "INSERT INTO person(personname,personemail,personstate) VALUES(@Name,@Email,@State)";
                    personQuery.Prepare();

                    personQuery.Parameters.AddWithValue("@Name", personname);
                    personQuery.Parameters.AddWithValue("@Email", personemail);
                    personQuery.Parameters.AddWithValue("@State", personstate.ToString());

                    personQuery.ExecuteNonQuery();

                    MessageBox.Show("A pessoa " + personname + " foi criada com sucesso.");
                }
                catch (MySqlException ex)
                {
                    if (ex.Message.Contains("Duplicate"))
                    {
                        MessageBox.Show("Já existe uma Pessoa com o email " + personemail + ".");
                        Console.WriteLine("Error: {0}", ex.ToString());
                    }
                    else
                    {
                        MessageBox.Show("Ocurreu um erro");
                        Console.WriteLine("Error: {0}", ex.ToString());
                    }
                }
                finally
                {

                    db.Close();
                }
            }
        }
Esempio n. 13
0
        public void findAll()
        {
            db = new Database();

            models.Clear();

            modelQuery = new MySqlCommand();

            modelQuery.Connection = db.Connection();

            modelQuery.CommandText = "SELECT * FROM model ORDER BY modeldescription ASC";

            this.modelResult = modelQuery.ExecuteReader();

            while (modelResult.Read())
            {
                if (!modelResult.IsDBNull(0))
                {
                    idmodel = modelResult.GetInt32(0);
                }

                if (!modelResult.IsDBNull(1))
                {
                    modeldescription = modelResult.GetString(1);
                }

                if (!modelResult.IsDBNull(2))
                {
                    idbrand = modelResult.GetInt32(2);
                }

                models.Add(new Model { idmodel = this.idmodel, modeldescription = this.modeldescription});
            }

            db.Close();
        }
Esempio n. 14
0
        public void findAll()
        {
            db = new Database();

            officeQuery = new MySqlCommand();

            officeQuery.Connection = db.Connection();

            officeQuery.CommandText = "SELECT * FROM office ORDER BY officedescription ASC";

            officeResult = officeQuery.ExecuteReader();

            while (officeResult.Read())
            {
                if (!officeResult.IsDBNull(0))
                {
                    idoffice = officeResult.GetInt32(0);
                }

                if (!officeResult.IsDBNull(1))
                {
                    officedescription = officeResult.GetString(1);
                }

                offices.Add(new Office { idoffice = this.idoffice, officedescription = this.officedescription });
            }

            db.Close();
        }
        public void edit()
        {
            db = new Database();

            if (categoryVerification())
            {
                try
                {
                    actiontypeQuery = new MySqlCommand();

                    actiontypeQuery.Connection = db.Connection();

                    actiontypeQuery.CommandText = "UPDATE actiontype SET actiontypedescription = @Description WHERE idactiontype = @IDActionType";
                    actiontypeQuery.Prepare();

                    actiontypeQuery.Parameters.AddWithValue("@Description", actiontypedescription);
                    actiontypeQuery.Parameters.AddWithValue("@IDActiontype", idactiontype);

                    actiontypeQuery.ExecuteNonQuery();

                    MessageBox.Show("O tipo de ação " + actiontypedescription + " foi editado com sucesso.");
                }
                catch (MySqlException ex)
                {
                    MessageBox.Show("Ocurreu um erro");
                    Console.WriteLine("Error: {0}", ex.ToString());
                }
                finally
                {
                    db.Close();
                }
            }
        }
        public void findAll()
        {
            db = new Database();

            salutations.Clear();

            salutationQuery = new MySqlCommand();

            salutationQuery.Connection = db.Connection();

            salutationQuery.CommandText = "SELECT * FROM salutation ORDER BY salutationdescription ASC";

            salutationResult = salutationQuery.ExecuteReader();

            while (salutationResult.Read())
            {
                if (!salutationResult.IsDBNull(0))
                {
                    idsalutation = salutationResult.GetInt32(0);
                }

                if (!salutationResult.IsDBNull(1))
                {
                    salutationdescription = salutationResult.GetString(1);
                }

                salutations.Add(new Salutation { idsalutation = this.idsalutation, salutationdescription = this.salutationdescription });
            }

            db.Close();
        }
        private void countByCategorydescription()
        {
            db = new Database();

            actiontypeQuery = new MySqlCommand();

            actiontypeQuery.Connection = db.Connection();

            actiontypeQuery.CommandText = "SELECT COUNT(*) FROM actiontype WHERE actiontypedescription = @Description";
            actiontypeQuery.Prepare();

            actiontypeQuery.Parameters.AddWithValue("@Description", actiontypedescription);

            actiontypeResult = actiontypeQuery.ExecuteReader();

            while (actiontypeResult.Read())
            {
                if (!actiontypeResult.IsDBNull(0))
                {
                    countCategory = actiontypeResult.GetInt32(0);
                }
            }
        }
        public void findByIdcategory()
        {
            db = new Database();

            actiontypeQuery = new MySqlCommand();

            actiontypeQuery.Connection = db.Connection();

            actiontypeQuery.CommandText = "SELECT * FROM actiontype WHERE idactiontype = @idactiontype";
            actiontypeQuery.Prepare();

            actiontypeQuery.Parameters.AddWithValue("@IDActiontype", idactiontype);

            actiontypeResult = actiontypeQuery.ExecuteReader();

            while (actiontypeResult.Read())
            {
                if (!actiontypeResult.IsDBNull(0))
                {
                    idactiontype = actiontypeResult.GetInt32(0);
                }

                if (!actiontypeResult.IsDBNull(1))
                {
                    actiontypedescription = actiontypeResult.GetString(1);
                }
            }
        }
        public void findAll()
        {
            db = new Database();

            actiontypes.Clear();

            actiontypeQuery = new MySqlCommand();

            actiontypeQuery.Connection = db.Connection();

            actiontypeQuery.CommandText = "SELECT * FROM actiontype ORDER BY actiontypedescription ASC";

            this.actiontypeResult = actiontypeQuery.ExecuteReader();

            while (actiontypeResult.Read())
            {
                if (!actiontypeResult.IsDBNull(0))
                {
                    idactiontype = actiontypeResult.GetInt32(0);
                }

                if (!actiontypeResult.IsDBNull(1))
                {
                    actiontypedescription = actiontypeResult.GetString(1);
                }

                actiontypes.Add(new ActionType { idactiontype = this.idactiontype, actiontypedescription = this.actiontypedescription });
            }

            db.Close();
        }
Esempio n. 20
0
        public void findByVendorname()
        {
            db = new Database();

            vendorQuery = new MySqlCommand();

            vendorQuery.Connection = db.Connection();

            vendorQuery.CommandText = "SELECT * FROM vendor WHERE vendorname = @Name";
            vendorQuery.Prepare();

            vendorQuery.Parameters.AddWithValue("@Name", vendorname);

            vendorResult = vendorQuery.ExecuteReader();

            while (vendorResult.Read())
            {
                if (!vendorResult.IsDBNull(0))
                {
                    idvendor = vendorResult.GetInt32(0);
                }

                if (!vendorResult.IsDBNull(1))
                {
                    vendorname = vendorResult.GetString(1);
                }
            }
        }
Esempio n. 21
0
        public void findByPath()
        {
            db = new Database();

            space = new Space();

            paths.Clear();

            pathQuery = new MySqlCommand();

            pathQuery.Connection = db.Connection();

            pathQuery.CommandText = "SELECT * FROM path WHERE path = @Path";
            pathQuery.Prepare();

            pathQuery.Parameters.AddWithValue("@Path", path);

            pathResult = pathQuery.ExecuteReader();

            while (pathResult.Read())
            {
                if (!pathResult.IsDBNull(0))
                {
                    idpath = pathResult.GetInt32(0);
                }

                if (!pathResult.IsDBNull(1))
                {
                    path = pathResult.GetString(1);
                }
            }

            db.Close();
        }
Esempio n. 22
0
        public void findAll()
        {
            db = new Database();

            vendors.Clear();

            vendorQuery = new MySqlCommand();

            vendorQuery.Connection = db.Connection();

            vendorQuery.CommandText = "SELECT * FROM vendor ORDER BY vendorname ASC";

            this.vendorResult = vendorQuery.ExecuteReader();

            while (vendorResult.Read())
            {
                if (!vendorResult.IsDBNull(0))
                {
                    idvendor = vendorResult.GetInt32(0);
                }

                if (!vendorResult.IsDBNull(1))
                {
                    vendorname = vendorResult.GetString(1);
                }

                vendors.Add(new Vendor { idvendor = this.idvendor, vendorname = this.vendorname });
            }

            db.Close();
        }
Esempio n. 23
0
        private void countBybrandname()
        {
            db = new Database();

            brandQuery = new MySqlCommand();

            brandQuery.Connection = db.Connection();

            brandQuery.CommandText = "SELECT COUNT(*) FROM brand WHERE brandname = @Name";
            brandQuery.Prepare();

            brandQuery.Parameters.AddWithValue("@Name", brandname);

            brandResult = brandQuery.ExecuteReader();

            while (brandResult.Read())
            {
                if (!brandResult.IsDBNull(0))
                {
                    countBrand = brandResult.GetInt32(0);
                }
            }
        }
Esempio n. 24
0
        public void edit()
        {
            db = new Database();

            if (vendorVerification())
            {
                try
                {
                    vendorQuery = new MySqlCommand();

                    vendorQuery.Connection = db.Connection();

                    vendorQuery.CommandText = "UPDATE vendor SET vendorname = @Name WHERE idvendor = @IDVendor";
                    vendorQuery.Prepare();

                    vendorQuery.Parameters.AddWithValue("@Name", vendorname);
                    vendorQuery.Parameters.AddWithValue("@IDVendor", idvendor);

                    vendorQuery.ExecuteNonQuery();

                    MessageBox.Show("O fornecedor " + vendorname + " foi editado com sucesso.");
                }
                catch (MySqlException ex)
                {
                    MessageBox.Show("Ocurreu um erro");
                    Console.WriteLine("Error: {0}", ex.ToString());
                }
                finally
                {
                    db.Close();
                }
            }
        }
Esempio n. 25
0
        public void findByOfficeDescription()
        {
            db = new Database();

            officeQuery = new MySqlCommand();

            officeQuery.Connection = db.Connection();

            officeQuery.CommandText = "SELECT * FROM salutation WHERE salutationdescription = @Description";
            officeQuery.Prepare();

            officeQuery.Parameters.AddWithValue("@Description", officedescription);

            officeResult = officeQuery.ExecuteReader();

            while (officeResult.Read())
            {
                idoffice = officeResult.GetInt32(0);
                officedescription = officeResult.GetString(1);
            }

            db.Close();
        }
        public void edit()
        {
            db = new Database();

            if (salutationVerification())
            {
                try
                {
                    salutationQuery = new MySqlCommand();
                    salutationQuery.Connection = db.Connection();
                    salutationQuery.CommandText = "UPDATE salutation SET salutationdescription = @Description WHERE idsalutation = @IDSalutation";
                    salutationQuery.Prepare();

                    salutationQuery.Parameters.AddWithValue("@Description", salutationdescription);
                    salutationQuery.Parameters.AddWithValue("@IDSalutation", idsalutation);

                    salutationQuery.ExecuteNonQuery();

                    MessageBox.Show("A Descrição Saudação Assinatura " + salutationdescription + " foi editada com sucesso.");
                }
                catch (MySqlException ex)
                {
                    MessageBox.Show("Ocurreu um erro");
                    Console.WriteLine("Error: {0}", ex.ToString());
                }
                finally
                {
                    db.Close();
                }
            }
        }
Esempio n. 27
0
        private void countBySalutationDescripiton()
        {
            db = new Database();

            officeQuery = new MySqlCommand();

            officeQuery.Connection = db.Connection();

            officeQuery.CommandText = "SELECT COUNT(*) FROM salutation WHERE salutationdescription = @Description";
            officeQuery.Prepare();

            officeQuery.Parameters.AddWithValue("@Description", officedescription);

            officeResult = officeQuery.ExecuteReader();

            while (officeResult.Read())
            {
                countOffice = officeResult.GetInt32(0);
            }

            db.Close();
        }
Esempio n. 28
0
        private void countByVendorname()
        {
            db = new Database();

            vendorQuery = new MySqlCommand();

            vendorQuery.Connection = db.Connection();

            vendorQuery.CommandText = "SELECT COUNT(*) FROM vendor WHERE vendorname = @Name";
            vendorQuery.Prepare();

            vendorQuery.Parameters.AddWithValue("@Name", vendorname);

            vendorResult = vendorQuery.ExecuteReader();

            while (vendorResult.Read())
            {
                if (!vendorResult.IsDBNull(0))
                {
                    countVendor = vendorResult.GetInt32(0);
                }
            }
        }
Esempio n. 29
0
        public void edit()
        {
            db = new Database();

            if (officeVerification())
            {
                try
                {
                    officeQuery = new MySqlCommand();
                    officeQuery.Connection = db.Connection();
                    officeQuery.CommandText = "UPDATE office SET officedescription = @Description WHERE idoffice = @IDOffice";
                    officeQuery.Prepare();

                    officeQuery.Parameters.AddWithValue("@Description", officedescription);
                    officeQuery.Parameters.AddWithValue("@IDOffice", idoffice);

                    officeQuery.ExecuteNonQuery();

                    MessageBox.Show("A Descrição Cargo Assinatura " + officedescription + " foi editada com sucesso.");
                }
                catch (MySqlException ex)
                {
                    MessageBox.Show("Ocurreu um erro");
                    Console.WriteLine("Error: {0}", ex.ToString());
                }
                finally
                {
                    db.Close();
                }
            }
        }
Esempio n. 30
0
        public void findBybrandname()
        {
            db = new Database();

            brandQuery = new MySqlCommand();

            brandQuery.Connection = db.Connection();

            brandQuery.CommandText = "SELECT * FROM brand WHERE brandname = @Name";
            brandQuery.Prepare();

            brandQuery.Parameters.AddWithValue("@Name", brandname);

            brandResult = brandQuery.ExecuteReader();

            while (brandResult.Read())
            {
                if (!brandResult.IsDBNull(0))
                {
                    idbrand = brandResult.GetInt32(0);
                }

                if (!brandResult.IsDBNull(1))
                {
                    brandname = brandResult.GetString(1);
                }
            }
        }