Example #1
0
        public HomePage_Client()
        {
            InitializeComponent();
            instituto1Descricao.Document.Blocks.Clear();
            instituto1Descricao.Document.Blocks.Add(new Paragraph(new Run("Alcance a beleza desejada com o Martina"))
            {
                FontSize = 14
            });


            instituto2Descricao.Document.Blocks.Clear();
            instituto2Descricao.Document.Blocks.Add(new Paragraph(new Run("Instituto de Beleza preparado para dar o melhor dos cuidados às pessoas de Aveiro"))
            {
                FontSize = 14
            });

            barbeariaDescricao.Document.Blocks.Clear();
            barbeariaDescricao.Document.Blocks.Add(new Paragraph(new Run("Barba aparada, conte connosco"))
            {
                FontSize = 12
            });

            limpezaDescricao.Document.Blocks.Clear();
            limpezaDescricao.Document.Blocks.Add(new Paragraph(new Run("Para obter a pele que sempre desejou"))
            {
                FontSize = 12
            });

            LoginPage logPage = new LoginPage();

            currentUser = logPage.getCurrentUser();
            RegisterPage          registerPage = new RegisterPage();
            List <UtilizadorInfo> utilizadores = registerPage.readRegisto();

            foreach (UtilizadorInfo u in utilizadores)
            {
                if (u.id == currentUser.id)
                {
                    currentUser.tipoConta  = u.tipoConta;
                    currentUser.email      = u.email;
                    currentUser.password   = u.password;
                    currentUser.localidade = u.localidade;
                    currentUser.foto       = u.foto;
                }
            }
            nomePessoa1.Text = currentUser.username;

            if (currentUser.tipoConta == 2)
            {
                mudarConta.Opacity   = 1;
                mudarConta.IsEnabled = true;
            }
            else
            {
                mudarConta.Opacity   = 0;
                mudarConta.IsEnabled = false;
            }
        }
Example #2
0
        public void loadInfo()
        {
            institutoPage        institutoPagina = new institutoPage(-1, this);
            List <InstitutoInfo> institutos      = new List <InstitutoInfo>();

            institutos      = institutoPagina.readInstituto();
            listaInstitutos = institutos;
            LoginPage logPage = new LoginPage();

            currentUser = logPage.getCurrentUser();
        }
Example #3
0
        private void loadInfo()
        {
            LoginPage pagina = new LoginPage();

            currentUser = pagina.getCurrentUser();
            institutoPage pagina2 = new institutoPage(-1, this);

            listaInstiutos = pagina2.readInstituto();
            servicePage pagina3 = new servicePage(-1, this);

            listaServicos = pagina3.readService();
        }
Example #4
0
 private void FavIcon_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     int id = Convert.ToInt32(sender.ToString().Replace("seta", ""));
     LoginPage logPage = new LoginPage();
     currentUser = logPage.getCurrentUser();
     List<String> novoConteudoFicheiro = new List<String>();
     RegisterPage registerpageobject = new RegisterPage();
     List<UtilizadorInfo> utilizadores = registerpageobject.readRegisto();
     bool adicionar = true;
     foreach (UtilizadorInfo u in utilizadores)
     {
         if (u.id == currentUser.id)
         {
             foreach (int i in u.favoritos)
             {
                 if (i==id)
                 {
                     adicionar = false;
                 }
             }
             if (adicionar == true)
             {
                 u.favoritos.Add(id);
             } else
             {
                 u.favoritos.Remove(id);
             }
         }
         string conteudo = u.id + "-" + u.tipoConta + "-" + u.email + "-" + u.username + "-" + u.password + "-" + u.localidade + "-" + u.foto + "-{";
         foreach (int i in u.favoritos)
         {
             conteudo = conteudo + i + ",";
         }
         conteudo = conteudo + "}-{";
         foreach (string s in u.reservas)
         {
             conteudo = conteudo + s + ",";
         }
         conteudo = conteudo + "}-{";
         foreach (int i in u.user_institutos_id)
         {
             conteudo = conteudo + i + ",";
         }
         conteudo = conteudo + "}";
         novoConteudoFicheiro.Add(conteudo);
     }
     registarAlteracoes(novoConteudoFicheiro);
     institutoPage nova = new institutoPage(currentInstituto.id, paginaAnterior);
     this.NavigationService.Navigate(nova);
 }
Example #5
0
        public PersonalInformation(int tipo, int id)
        {
            Console.WriteLine(id);
            this.tipo = tipo;
            InitializeComponent();
            LoginPage             logPage      = new LoginPage();
            RegisterPage          registerPage = new RegisterPage();
            List <UtilizadorInfo> utilizadores = registerPage.readRegisto();

            if (id == -1)
            {
                currentUser = logPage.getCurrentUser();
            }
            else
            {
                foreach (UtilizadorInfo u in utilizadores)
                {
                    if (u.id == id)
                    {
                        Console.WriteLine("entrei");
                        Console.WriteLine(u.id);
                        Console.WriteLine(u);
                        currentUser = u;
                    }
                }
            }
            nomeUtilizador.Content = currentUser.username;
            EmailBox.Document.Blocks.Clear();
            EmailBox.Document.Blocks.Add(new Paragraph(new Run(currentUser.email)));
            Localidade.Document.Blocks.Clear();
            if (currentUser.localidade != "null")
            {
                Localidade.Document.Blocks.Add(new Paragraph(new Run(currentUser.localidade)));
            }
            if (currentUser.foto != "null")
            {
                ImageBrush myBrush = new ImageBrush();
                Image      image   = new Image();
                image.Source = new BitmapImage(
                    new Uri(
                        BaseUriHelper.GetBaseUri(this), currentUser.foto));
                myBrush.ImageSource = image.Source;
                userfotoelipse.Fill = myBrush;
            }
        }
Example #6
0
        public void loadInfo()
        {
            LoginPage loginPagina = new LoginPage();

            currentUser = loginPagina.getCurrentUser();
            servicePage   servicoPagina   = new servicePage(-1, this);
            institutoPage institutoPagina = new institutoPage(-1, this);

            listaServicos   = servicoPagina.readService();
            listaInstitutos = institutoPagina.readInstituto();
            foreach (InstitutoInfo i in listaInstitutos)
            {
                if (currentUser.user_institutos_id.Contains(i.id) && institutosBox.Items.Contains(i.nome) == false)
                {
                    institutosBox.Items.Add(i.nome);
                }
            }
            this.getListaUtitilizadores();
        }
Example #7
0
        private void BinIcon_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            string[]  partes   = sender.ToString().Replace("bin", "").Split("separador");
            string    aremover = partes[0] + "|" + partes[1] + ":" + partes[2] + "|" + partes[3];
            LoginPage logPage  = new LoginPage();

            currentUser = logPage.getCurrentUser();
            List <String>         novoConteudoFicheiro = new List <String>();
            RegisterPage          registerpageobject   = new RegisterPage();
            List <UtilizadorInfo> utilizadores         = registerpageobject.readRegisto();

            foreach (UtilizadorInfo u in utilizadores)
            {
                if (u.id == currentUser.id)
                {
                    u.reservas.Remove(aremover);
                }
                string conteudo = u.id + "-" + u.tipoConta + "-" + u.email + "-" + u.username + "-" + u.password + "-" + u.localidade + "-" + u.foto + "-{";
                foreach (int i in u.favoritos)
                {
                    conteudo = conteudo + i + ",";
                }
                conteudo = conteudo + "}-{";
                foreach (string s in u.reservas)
                {
                    conteudo = conteudo + s + ",";
                }
                conteudo = conteudo + "}-{";
                foreach (int i in u.user_institutos_id)
                {
                    conteudo = conteudo + i + ",";
                }
                conteudo = conteudo + "}";
                novoConteudoFicheiro.Add(conteudo);
            }
            registarAlteracoes(novoConteudoFicheiro);
            MinhasReservas nova = new  MinhasReservas();

            this.NavigationService.Navigate(nova);
        }
Example #8
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            LoginPage logPage = new LoginPage();

            currentUser = logPage.getCurrentUser();
            if (data.SelectedIndex != 0 && hora.SelectedIndex != 0)
            {
                List <String>         novoConteudoFicheiro = new List <String>();
                RegisterPage          registerpageobject   = new RegisterPage();
                List <UtilizadorInfo> utilizadores         = registerpageobject.readRegisto();
                foreach (UtilizadorInfo u in utilizadores)
                {
                    if (u.id == currentUser.id)
                    {
                        Console.WriteLine(currentService.id);
                        u.reservas.Add(currentService.id + "|" + hora.SelectedItem + "|" + data.SelectedItem);
                    }
                    string conteudo = u.id + "-" + u.tipoConta + "-" + u.email + "-" + u.username + "-" + u.password + "-" + u.localidade + "-" + u.foto + "-{";
                    foreach (int i in u.favoritos)
                    {
                        conteudo = conteudo + i + ",";
                    }
                    conteudo = conteudo + "}-{";
                    foreach (string s in u.reservas)
                    {
                        conteudo = conteudo + s + ",";
                    }
                    conteudo = conteudo + "}-{";
                    foreach (int i in u.user_institutos_id)
                    {
                        conteudo = conteudo + i + ",";
                    }
                    conteudo = conteudo + "}";
                    novoConteudoFicheiro.Add(conteudo);
                }
                registarAlteracoes(novoConteudoFicheiro);
                HomePage_Client homePage = new HomePage_Client();
                this.NavigationService.Navigate(homePage);
            }
        }
Example #9
0
        public void loadInformation()
        {
            LoginPage logPage = new LoginPage();

            currentUser = logPage.getCurrentUser();
            RegisterPage          registerPage = new RegisterPage();
            List <UtilizadorInfo> utilizadores = registerPage.readRegisto();

            foreach (UtilizadorInfo u in utilizadores)
            {
                if (u.id == currentUser.id)
                {
                    currentUser.tipoConta  = u.tipoConta;
                    currentUser.email      = u.email;
                    currentUser.password   = u.password;
                    currentUser.localidade = u.localidade;
                    currentUser.foto       = u.foto;
                }
            }
            nomeUtilizador.Content = currentUser.username;
            EmailBox.Document.Blocks.Clear();
            EmailBox.Document.Blocks.Add(new Paragraph(new Run(currentUser.email)));
            Localidade.Document.Blocks.Clear();
            if (currentUser.localidade != "null")
            {
                Localidade.Document.Blocks.Add(new Paragraph(new Run(currentUser.localidade)));
            }
            if (currentUser.foto != "null")
            {
                ImageBrush myBrush = new ImageBrush();
                Image      image   = new Image();
                image.Source = new BitmapImage(
                    new Uri(
                        BaseUriHelper.GetBaseUri(this), currentUser.foto));
                myBrush.ImageSource = image.Source;
                userfotoelipse.Fill = myBrush;
            }
        }
Example #10
0
        public MinhasReservas()
        {
            InitializeComponent();
            LoginPage logPage = new LoginPage();

            currentUser = logPage.getCurrentUser();
            int flag = 0;

            foreach (String reserva in currentUser.reservas)
            {
                if (reserva != "")
                {
                    int      servico_id = -1;
                    string   data       = "";
                    string[] cadaparte  = reserva.Split("|");
                    servico_id = Convert.ToInt32(cadaparte[0]);
                    data       = cadaparte[2] + "           " + cadaparte[1];
                    servicePage ServicePage = new servicePage(servico_id, this);
                    ServiceInfo servico     = ServicePage.getCurrentService();
                    Grid        novaGrid    = new Grid();
                    novaGrid.Height = 50;
                    ColumnDefinition colDef0 = new ColumnDefinition();
                    colDef0.Width = new GridLength(30, GridUnitType.Star);
                    ColumnDefinition colDef1 = new ColumnDefinition();
                    colDef1.Width = new GridLength(40, GridUnitType.Star);
                    ColumnDefinition colDef2 = new ColumnDefinition();
                    colDef2.Width = new GridLength(130, GridUnitType.Star);
                    ColumnDefinition colDef3 = new ColumnDefinition();
                    colDef3.Width = new GridLength(100, GridUnitType.Star);
                    ColumnDefinition colDef4 = new ColumnDefinition();
                    colDef4.Width = new GridLength(40, GridUnitType.Star);
                    ColumnDefinition colDef5 = new ColumnDefinition();
                    colDef5.Width = new GridLength(30, GridUnitType.Star);

                    novaGrid.ColumnDefinitions.Add(colDef0);
                    novaGrid.ColumnDefinitions.Add(colDef1);
                    novaGrid.ColumnDefinitions.Add(colDef2);
                    novaGrid.ColumnDefinitions.Add(colDef3);
                    novaGrid.ColumnDefinitions.Add(colDef4);
                    novaGrid.ColumnDefinitions.Add(colDef5);

                    var binicon = new nova {
                        Kind = PackIconKind.Bin
                    };
                    binicon.Width               = 25;
                    binicon.Height              = 25;
                    binicon.VerticalAlignment   = VerticalAlignment.Center;
                    binicon.HorizontalAlignment = HorizontalAlignment.Left;
                    binicon.SetValue(Grid.ColumnProperty, 1);
                    string hora    = cadaparte[1].Split(":")[0];
                    string minutos = cadaparte[1].Split(":")[1];
                    binicon.Name = "bin" + servico_id + "separador" + hora + "separador" + minutos + "separador" + cadaparte[2];
                    binicon.PreviewMouseLeftButtonDown += BinIcon_PreviewMouseLeftButtonDown;
                    TextBlock newTextBox = new TextBlock();
                    newTextBox.Text = servico.tipo;
                    newTextBox.VerticalAlignment   = VerticalAlignment.Center;
                    newTextBox.HorizontalAlignment = HorizontalAlignment.Left;
                    newTextBox.FontSize            = 16;
                    newTextBox.SetValue(Grid.ColumnProperty, 2);
                    TextBlock newTextBox2 = new TextBlock();
                    newTextBox2.Text                = data;
                    newTextBox2.FontSize            = 16;
                    newTextBox2.VerticalAlignment   = VerticalAlignment.Center;
                    newTextBox2.HorizontalAlignment = HorizontalAlignment.Left;
                    newTextBox2.SetValue(Grid.ColumnProperty, 3);
                    var icon = new nova {
                        Kind = PackIconKind.ArrowRight
                    };
                    icon.Width               = 25;
                    icon.Height              = 25;
                    icon.VerticalAlignment   = VerticalAlignment.Center;
                    icon.HorizontalAlignment = HorizontalAlignment.Right;
                    icon.SetValue(Grid.ColumnProperty, 4);
                    icon.Name = "seta" + servico_id;
                    icon.PreviewMouseLeftButtonDown += PackIcon_PreviewMouseLeftButtonDown;
                    painel.Children.Add(novaGrid);
                    novaGrid.Children.Add(binicon);
                    novaGrid.Children.Add(newTextBox);
                    novaGrid.Children.Add(newTextBox2);
                    novaGrid.Children.Add(icon);

                    if (flag % 2 == 0)
                    {
                        var converter = new System.Windows.Media.BrushConverter();
                        var brush     = (Brush)converter.ConvertFromString("#FFD0EDED");
                        novaGrid.Background = brush;
                    }
                    else
                    {
                        var converter = new System.Windows.Media.BrushConverter();
                        var brush     = (Brush)converter.ConvertFromString("#FFC2DCDC");
                        novaGrid.Background = brush;
                    }
                    flag++;
                }
            }
        }
Example #11
0
        private void Button_Click(object sender, RoutedEventArgs e2)
        {
            painel.Children.Clear();
            tabelatop_filtro.Visibility = Visibility.Collapsed;
            LoginPage logPage = new LoginPage();

            currentUser = logPage.getCurrentUser();
            bool   valido = true;
            string nomeservico;

            try
            {
                nomeservico = tiposervico.SelectedItem.ToString();
            }
            catch
            {
                nomeservico = "";
            }
            string localizacao = localizacaoBox.Text;
            double precomin    = 0;

            if (!(minpreco.Text == ""))
            {
                try
                {
                    precomin = Convert.ToDouble(minpreco.Text);
                }
                catch
                {
                    MessageBox.Show("Please provide valid price input value (Number)!");
                    valido = false;
                }
            }
            double precomax = 999999;

            if (!(maxpreco.Text == ""))
            {
                try
                {
                    precomax = Convert.ToDouble(maxpreco.Text);
                }
                catch
                {
                    MessageBox.Show("Please provide valid price input value (Number)!");
                    valido = false;
                }
            }
            double precoservico = -1;

            loadInfo();
            foreach (ServiceInfo s in listaServicos)
            {
                valido = true;
                try
                {
                    precoservico = Convert.ToDouble(s.preco);
                }
                catch
                {
                    valido = false;
                }

                if (valido == true)
                {
                    if ((s.tipo.Equals(nomeservico) || nomeservico.Equals("")) && precomin <= precoservico && precoservico <= precomax)
                    {
                        foreach (InstitutoInfo i in listaInstitutos)
                        {
                            if (i.id == s.instituto_id && i.localizacao.StartsWith(localizacao))
                            {
                                Grid novaGrid = new Grid();
                                novaGrid.Height = 40;
                                ColumnDefinition colDef0 = new ColumnDefinition();
                                colDef0.Width = new GridLength(15, GridUnitType.Star);
                                ColumnDefinition colDef1 = new ColumnDefinition();
                                colDef1.Width = new GridLength(30, GridUnitType.Star);
                                ColumnDefinition colDef2 = new ColumnDefinition();
                                colDef2.Width = new GridLength(160, GridUnitType.Star);
                                ColumnDefinition colDef3 = new ColumnDefinition();
                                colDef3.Width = new GridLength(85, GridUnitType.Star);
                                ColumnDefinition colDef4 = new ColumnDefinition();
                                colDef4.Width = new GridLength(50, GridUnitType.Star);
                                novaGrid.ColumnDefinitions.Add(colDef0);
                                novaGrid.ColumnDefinitions.Add(colDef1);
                                novaGrid.ColumnDefinitions.Add(colDef2);
                                novaGrid.ColumnDefinitions.Add(colDef3);
                                novaGrid.ColumnDefinitions.Add(colDef4);
                                var icon = new nova {
                                    Kind = PackIconKind.StarBorder
                                };
                                foreach (int l in currentUser.favoritos)
                                {
                                    if (l == s.id)
                                    {
                                        icon = new nova {
                                            Kind = PackIconKind.Star
                                        };
                                    }
                                }
                                icon.Width  = 30;
                                icon.Height = 45;
                                icon.HorizontalAlignment = HorizontalAlignment.Center;
                                icon.SetValue(Grid.ColumnProperty, 1);
                                icon.Name = "seta" + s.id;
                                icon.PreviewMouseLeftButtonDown += FavIcon_PreviewMouseLeftButtonDown;
                                nova2 novo = new nova2();
                                novo.SetValue(Grid.ColumnProperty, 1);
                                novo.Width   = 30;
                                novo.Height  = 45;
                                novo.Opacity = 0;
                                novaGrid.Children.Add(novo);
                                novo.Name = "seta" + s.id;
                                novo.PreviewMouseLeftButtonDown += FavIcon_PreviewMouseLeftButtonDown;
                                TextBlock newTextBox = new TextBlock();
                                newTextBox.Text = s.tipo;
                                newTextBox.VerticalAlignment = VerticalAlignment.Center;
                                newTextBox.Margin            = new Thickness(10, 10, 0, 0);
                                newTextBox.FontSize          = 18;
                                newTextBox.SetValue(Grid.ColumnProperty, 2);
                                TextBlock newTextBox2 = new TextBlock();
                                newTextBox2.Text              = s.preco + "  €";
                                newTextBox2.FontSize          = 18;
                                newTextBox2.Margin            = new Thickness(10, 10, 0, 0);
                                newTextBox2.VerticalAlignment = VerticalAlignment.Center;
                                newTextBox2.SetValue(Grid.ColumnProperty, 3);
                                var icon2 = new nova {
                                    Kind = PackIconKind.ArrowRight
                                };
                                icon2.Width               = 25;
                                icon2.Height              = 25;
                                icon2.VerticalAlignment   = VerticalAlignment.Center;
                                icon2.HorizontalAlignment = HorizontalAlignment.Left;
                                icon2.SetValue(Grid.ColumnProperty, 4);
                                icon2.Name = "seta" + s.id;
                                icon2.PreviewMouseLeftButtonDown += PackIcon_PreviewMouseLeftButtonDown;
                                painel.Children.Add(novaGrid);
                                novaGrid.Children.Add(newTextBox);
                                novaGrid.Children.Add(newTextBox2);
                                novaGrid.Children.Add(icon);
                                novaGrid.Children.Add(icon2);
                            }
                        }
                    }
                }
            }
            filtros.Visibility        = Visibility.Collapsed;
            scrollViewer.Margin       = new Thickness(0, 0, 10, 44);
            minpreco.Text             = "";
            maxpreco.Text             = "";
            localizacaoBox.Text       = "";
            tiposervico.SelectedIndex = -1;
        }
Example #12
0
        public servicossearch()
        {
            InitializeComponent();
            this.loadInfo();

            LoginPage logPage = new LoginPage();

            currentUser = logPage.getCurrentUser();

            foreach (ServiceInfo s in listaServicos)
            {
                Grid novaGrid = new Grid();
                novaGrid.Height = 40;
                ColumnDefinition colDef0 = new ColumnDefinition();
                colDef0.Width = new GridLength(15, GridUnitType.Star);
                ColumnDefinition colDef1 = new ColumnDefinition();
                colDef1.Width = new GridLength(30, GridUnitType.Star);
                ColumnDefinition colDef2 = new ColumnDefinition();
                colDef2.Width = new GridLength(160, GridUnitType.Star);
                ColumnDefinition colDef3 = new ColumnDefinition();
                colDef3.Width = new GridLength(85, GridUnitType.Star);
                ColumnDefinition colDef4 = new ColumnDefinition();
                colDef4.Width = new GridLength(50, GridUnitType.Star);
                novaGrid.ColumnDefinitions.Add(colDef0);
                novaGrid.ColumnDefinitions.Add(colDef1);
                novaGrid.ColumnDefinitions.Add(colDef2);
                novaGrid.ColumnDefinitions.Add(colDef3);
                novaGrid.ColumnDefinitions.Add(colDef4);
                var icon = new nova {
                    Kind = PackIconKind.StarBorder
                };
                foreach (int i in currentUser.favoritos)
                {
                    if (i == s.id)
                    {
                        icon = new nova {
                            Kind = PackIconKind.Star
                        };
                    }
                }
                icon.Width  = 30;
                icon.Height = 45;
                icon.SetValue(Grid.ColumnProperty, 1);
                icon.Name = "seta" + s.id;
                icon.PreviewMouseLeftButtonDown += FavIcon_PreviewMouseLeftButtonDown;
                nova2 novo = new nova2();
                novo.SetValue(Grid.ColumnProperty, 1);
                novo.Width   = 30;
                novo.Height  = 45;
                novo.Opacity = 0;
                novaGrid.Children.Add(novo);
                novo.Name = "seta" + s.id;
                novo.PreviewMouseLeftButtonDown += FavIcon_PreviewMouseLeftButtonDown;
                TextBlock newTextBox = new TextBlock();
                newTextBox.Text = s.tipo;
                newTextBox.VerticalAlignment = VerticalAlignment.Center;
                newTextBox.FontSize          = 18;
                newTextBox.Margin            = new Thickness(10, 10, 0, 0);
                newTextBox.SetValue(Grid.ColumnProperty, 2);
                TextBlock newTextBox2 = new TextBlock();
                newTextBox2.Text              = s.preco + "  €";
                newTextBox2.FontSize          = 18;
                newTextBox2.Margin            = new Thickness(10, 10, 0, 0);
                newTextBox2.VerticalAlignment = VerticalAlignment.Center;
                newTextBox2.SetValue(Grid.ColumnProperty, 3);
                var icon2 = new nova {
                    Kind = PackIconKind.ArrowRight
                };
                icon2.Width               = 25;
                icon2.Height              = 25;
                icon2.VerticalAlignment   = VerticalAlignment.Center;
                icon2.HorizontalAlignment = HorizontalAlignment.Left;
                icon2.SetValue(Grid.ColumnProperty, 4);
                icon2.Name = "seta" + s.id;
                icon2.PreviewMouseLeftButtonDown += PackIcon_PreviewMouseLeftButtonDown;
                painel.Children.Add(novaGrid);
                novaGrid.Children.Add(newTextBox);
                novaGrid.Children.Add(newTextBox2);
                novaGrid.Children.Add(icon);
                novaGrid.Children.Add(icon2);
            }
        }
Example #13
0
        private void FavIcon_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Console.WriteLine(sender);
            int       id      = Convert.ToInt32(sender.ToString().Replace("seta", ""));
            LoginPage logPage = new LoginPage();

            currentUser = logPage.getCurrentUser();
            List <String>         novoConteudoFicheiro = new List <String>();
            RegisterPage          registerpageobject   = new RegisterPage();
            List <UtilizadorInfo> utilizadores         = registerpageobject.readRegisto();
            bool adicionar = true;

            foreach (UtilizadorInfo u in utilizadores)
            {
                if (u.id == currentUser.id)
                {
                    foreach (int i in u.favoritos)
                    {
                        if (i == id)
                        {
                            adicionar = false;
                        }
                    }
                    if (adicionar == true)
                    {
                        u.favoritos.Add(id);
                    }
                    else
                    {
                        u.favoritos.Remove(id);
                    }
                }
                string conteudo = u.id + "-" + u.tipoConta + "-" + u.email + "-" + u.username + "-" + u.password + "-" + u.localidade + "-" + u.foto + "-{";
                foreach (int i in u.favoritos)
                {
                    conteudo = conteudo + i + ",";
                }
                conteudo = conteudo + "}-{";
                foreach (string s in u.reservas)
                {
                    conteudo = conteudo + s + ",";
                }
                conteudo = conteudo + "}-{";
                foreach (int i in u.user_institutos_id)
                {
                    conteudo = conteudo + i + ",";
                }
                conteudo = conteudo + "}";
                novoConteudoFicheiro.Add(conteudo);
            }
            registarAlteracoes(novoConteudoFicheiro);
            currentUser = logPage.getCurrentUser();
            painel.Children.Clear();
            bool   valido = true;
            string nomeservico;

            try
            {
                nomeservico = tiposervico.SelectedItem.ToString();
            }
            catch
            {
                nomeservico = "";
            }
            string localizacao = localizacaoBox.Text;
            double precomin    = 0;

            if (!(minpreco.Text == ""))
            {
                try
                {
                    precomin = Convert.ToDouble(minpreco.Text);
                }
                catch
                {
                    valido = false;
                }
            }
            double precomax = 999999;

            if (!(maxpreco.Text == ""))
            {
                try
                {
                    precomax = Convert.ToDouble(maxpreco.Text);
                }
                catch
                {
                    valido = false;
                }
            }
            double precoservico = -1;

            loadInfo();
            foreach (ServiceInfo s in listaServicos)
            {
                try
                {
                    precoservico = Convert.ToDouble(s.preco);
                }
                catch
                {
                    valido = false;
                }
                if (valido == true)
                {
                    if ((s.tipo.Equals(nomeservico) || nomeservico.Equals("")) && precomin <= precoservico && precoservico <= precomax)
                    {
                        foreach (InstitutoInfo i in listaInstitutos)
                        {
                            if (i.id == s.instituto_id && i.localizacao.StartsWith(localizacao))
                            {
                                Grid novaGrid = new Grid();
                                novaGrid.Height = 40;
                                ColumnDefinition colDef0 = new ColumnDefinition();
                                colDef0.Width = new GridLength(15, GridUnitType.Star);
                                ColumnDefinition colDef1 = new ColumnDefinition();
                                colDef1.Width = new GridLength(30, GridUnitType.Star);
                                ColumnDefinition colDef2 = new ColumnDefinition();
                                colDef2.Width = new GridLength(160, GridUnitType.Star);
                                ColumnDefinition colDef3 = new ColumnDefinition();
                                colDef3.Width = new GridLength(85, GridUnitType.Star);
                                ColumnDefinition colDef4 = new ColumnDefinition();
                                colDef4.Width = new GridLength(50, GridUnitType.Star);
                                novaGrid.ColumnDefinitions.Add(colDef0);
                                novaGrid.ColumnDefinitions.Add(colDef1);
                                novaGrid.ColumnDefinitions.Add(colDef2);
                                novaGrid.ColumnDefinitions.Add(colDef3);
                                novaGrid.ColumnDefinitions.Add(colDef4);
                                var icon = new nova {
                                    Kind = PackIconKind.StarBorder
                                };
                                foreach (int l in currentUser.favoritos)
                                {
                                    if (l == s.id)
                                    {
                                        icon = new nova {
                                            Kind = PackIconKind.Star
                                        };
                                    }
                                }
                                icon.Width  = 30;
                                icon.Height = 45;
                                icon.HorizontalAlignment = HorizontalAlignment.Center;
                                icon.SetValue(Grid.ColumnProperty, 1);
                                icon.Name = "seta" + s.id;
                                icon.PreviewMouseLeftButtonDown += FavIcon_PreviewMouseLeftButtonDown;
                                nova2 novo = new nova2();
                                novo.SetValue(Grid.ColumnProperty, 1);
                                novo.Width   = 30;
                                novo.Height  = 45;
                                novo.Opacity = 0;
                                novaGrid.Children.Add(novo);
                                novo.Name = "seta" + s.id;
                                novo.PreviewMouseLeftButtonDown += FavIcon_PreviewMouseLeftButtonDown;
                                TextBlock newTextBox = new TextBlock();
                                newTextBox.Text = s.tipo;
                                newTextBox.VerticalAlignment = VerticalAlignment.Center;
                                newTextBox.Margin            = new Thickness(10, 10, 0, 0);
                                newTextBox.FontSize          = 18;
                                newTextBox.SetValue(Grid.ColumnProperty, 2);
                                TextBlock newTextBox2 = new TextBlock();
                                newTextBox2.Text              = s.preco + "  €";
                                newTextBox2.FontSize          = 18;
                                newTextBox2.Margin            = new Thickness(10, 10, 0, 0);
                                newTextBox2.VerticalAlignment = VerticalAlignment.Center;
                                newTextBox2.SetValue(Grid.ColumnProperty, 3);
                                var icon2 = new nova {
                                    Kind = PackIconKind.ArrowRight
                                };
                                icon2.Width               = 25;
                                icon2.Height              = 25;
                                icon2.VerticalAlignment   = VerticalAlignment.Center;
                                icon2.HorizontalAlignment = HorizontalAlignment.Left;
                                icon2.SetValue(Grid.ColumnProperty, 4);
                                icon2.Name = "seta" + s.id;
                                icon2.PreviewMouseLeftButtonDown += PackIcon_PreviewMouseLeftButtonDown;
                                painel.Children.Add(novaGrid);
                                novaGrid.Children.Add(newTextBox);
                                novaGrid.Children.Add(newTextBox2);
                                novaGrid.Children.Add(icon);
                                novaGrid.Children.Add(icon2);
                            }
                        }
                    }
                }
            }
        }
Example #14
0
        public favoritesPage()
        {
            InitializeComponent();
            LoginPage logPage = new LoginPage();

            currentUser = logPage.getCurrentUser();


            foreach (int service_id in currentUser.favoritos)
            {
                servicePage ServicePage = new servicePage(service_id, this);
                ServiceInfo servico     = ServicePage.getCurrentService();
                Grid        novaGrid    = new Grid();
                novaGrid.Height = 50;
                ColumnDefinition colDef0 = new ColumnDefinition();
                colDef0.Width = new GridLength(30, GridUnitType.Star);
                ColumnDefinition colDef1 = new ColumnDefinition();
                colDef1.Width = new GridLength(40, GridUnitType.Star);
                ColumnDefinition colDef2 = new ColumnDefinition();
                colDef2.Width = new GridLength(130, GridUnitType.Star);
                ColumnDefinition colDef3 = new ColumnDefinition();
                colDef3.Width = new GridLength(100, GridUnitType.Star);
                ColumnDefinition colDef4 = new ColumnDefinition();
                colDef4.Width = new GridLength(40, GridUnitType.Star);
                ColumnDefinition colDef5 = new ColumnDefinition();
                colDef5.Width = new GridLength(30, GridUnitType.Star);
                novaGrid.ColumnDefinitions.Add(colDef0);
                novaGrid.ColumnDefinitions.Add(colDef1);
                novaGrid.ColumnDefinitions.Add(colDef2);
                novaGrid.ColumnDefinitions.Add(colDef3);
                novaGrid.ColumnDefinitions.Add(colDef4);
                novaGrid.ColumnDefinitions.Add(colDef5);
                var bin = new nova {
                    Kind = PackIconKind.Bin
                };
                bin.Width               = 25;
                bin.Height              = 25;
                bin.VerticalAlignment   = VerticalAlignment.Center;
                bin.HorizontalAlignment = HorizontalAlignment.Left;
                bin.SetValue(Grid.ColumnProperty, 1);
                bin.Name = "bin" + service_id;
                bin.PreviewMouseLeftButtonDown += BinIcon_PreviewMouseLeftButtonDown;
                TextBlock newTextBox = new TextBlock();
                newTextBox.Text = servico.tipo;
                newTextBox.VerticalAlignment = VerticalAlignment.Center;
                newTextBox.FontSize          = 16;
                newTextBox.SetValue(Grid.ColumnProperty, 2);
                TextBlock newTextBox2 = new TextBlock();
                newTextBox2.Text              = servico.instituto_nome;
                newTextBox2.FontSize          = 16;
                newTextBox2.VerticalAlignment = VerticalAlignment.Center;
                newTextBox2.SetValue(Grid.ColumnProperty, 3);
                var icon = new nova {
                    Kind = PackIconKind.ArrowRight
                };
                icon.Width               = 25;
                icon.Height              = 25;
                icon.VerticalAlignment   = VerticalAlignment.Center;
                icon.HorizontalAlignment = HorizontalAlignment.Right;
                icon.SetValue(Grid.ColumnProperty, 4);
                icon.Name = "seta" + service_id;
                icon.PreviewMouseLeftButtonDown += PackIcon_PreviewMouseLeftButtonDown;
                painel.Children.Add(novaGrid);
                novaGrid.Children.Add(bin);
                novaGrid.Children.Add(newTextBox);
                novaGrid.Children.Add(newTextBox2);
                novaGrid.Children.Add(icon);

                if (flag % 2 == 0)
                {
                    var converter = new System.Windows.Media.BrushConverter();
                    var brush     = (Brush)converter.ConvertFromString("#FFD0EDED");
                    novaGrid.Background = brush;
                }
                else
                {
                    var converter = new System.Windows.Media.BrushConverter();
                    var brush     = (Brush)converter.ConvertFromString("#FFC2DCDC");
                    novaGrid.Background = brush;
                }
                flag++;
            }
        }
Example #15
0
        public institutoPage(int id, Page paginaanterior)
        {
            if (id == -1)
            {
                return;
            }
            InitializeComponent();
            paginaAnterior = paginaanterior;
            Console.WriteLine(paginaAnterior);
            List<InstitutoInfo> institutos = readInstituto();
            foreach (InstitutoInfo i in institutos)
            {
                if (i.id == id)
                {
                    currentInstituto = i;
                }
            }

            nomeInstituto.Content = currentInstituto.nome;
            rating.Content = currentInstituto.rating;

            descricaoServico.Document.Blocks.Clear();
            descricaoServico.Document.Blocks.Add(new Paragraph(new Run(currentInstituto.descricao)) { FontSize = 18 });

            if (currentInstituto.foto != "null")
            {
                ImageBrush myBrush = new ImageBrush();
                Image image = new Image();
                image.Source = new BitmapImage(
                    new Uri(
                       BaseUriHelper.GetBaseUri(this), currentInstituto.foto));
                myBrush.ImageSource = image.Source;
                userfotogrid.Background = myBrush;
            }

            int flag = 0;

            LoginPage logPage = new LoginPage();
            currentUser = logPage.getCurrentUser();

            foreach (int service_id in currentInstituto.servicos_id)
            {
                servicePage ServicePage = new servicePage(service_id,paginaAnterior);
                ServiceInfo servico = ServicePage.getCurrentService();
                Grid novaGrid = new Grid();
                novaGrid.Height = 40;
                ColumnDefinition colDef0 = new ColumnDefinition();
                colDef0.Width = new GridLength(15, GridUnitType.Star);
                ColumnDefinition colDef1 = new ColumnDefinition();
                colDef1.Width = new GridLength(30, GridUnitType.Star);
                ColumnDefinition colDef2 = new ColumnDefinition();
                colDef2.Width = new GridLength(160, GridUnitType.Star);
                ColumnDefinition colDef3 = new ColumnDefinition();
                colDef3.Width = new GridLength(85, GridUnitType.Star);
                ColumnDefinition colDef4 = new ColumnDefinition();
                colDef4.Width = new GridLength(50, GridUnitType.Star);
                novaGrid.ColumnDefinitions.Add(colDef0);
                novaGrid.ColumnDefinitions.Add(colDef1);
                novaGrid.ColumnDefinitions.Add(colDef2);
                novaGrid.ColumnDefinitions.Add(colDef3);
                novaGrid.ColumnDefinitions.Add(colDef4);
                var icon = new nova { Kind = PackIconKind.StarBorder };
                foreach (int i in currentUser.favoritos)
                {
                    if (i == service_id)
                    {
                        icon = new nova { Kind = PackIconKind.Star };
                    }
                }
                icon.Width = 30;
                icon.Height = 45;
                icon.SetValue(Grid.ColumnProperty, 1);
                icon.Name = "seta" + service_id;
                icon.PreviewMouseLeftButtonDown += FavIcon_PreviewMouseLeftButtonDown;
                nova2 novo = new nova2();
                novo.SetValue(Grid.ColumnProperty, 1);
                novo.Width = 30;
                novo.Height = 45;
                novo.Opacity = 0;
                novaGrid.Children.Add(novo);
                novo.Name = "seta" + service_id;
                novo.PreviewMouseLeftButtonDown += FavIcon_PreviewMouseLeftButtonDown;
                TextBlock newTextBox = new TextBlock();
                newTextBox.Text = servico.tipo;
                newTextBox.VerticalAlignment = VerticalAlignment.Center;
                newTextBox.FontSize = 18;
                newTextBox.Margin = new Thickness(10, 10, 0, 0);
                newTextBox.SetValue(Grid.ColumnProperty, 2);
                TextBlock newTextBox2 = new TextBlock();
                newTextBox2.Text = servico.preco + "  €";
                newTextBox2.FontSize = 18;
                newTextBox2.Margin = new Thickness(10, 10, 0, 0);
                newTextBox2.VerticalAlignment = VerticalAlignment.Center;
                newTextBox2.SetValue(Grid.ColumnProperty, 3);
                var icon2 = new nova { Kind = PackIconKind.ArrowRight };
                icon2.Width = 25;
                icon2.Height = 25;
                icon2.VerticalAlignment = VerticalAlignment.Center;
                icon2.HorizontalAlignment = HorizontalAlignment.Left;
                icon2.SetValue(Grid.ColumnProperty, 4);
                icon2.Name = "seta" + service_id;
                icon2.PreviewMouseLeftButtonDown += PackIcon_PreviewMouseLeftButtonDown;
                painel.Children.Add(novaGrid);
                novaGrid.Children.Add(newTextBox);
                novaGrid.Children.Add(newTextBox2);
                novaGrid.Children.Add(icon);
                novaGrid.Children.Add(icon2);

                if (flag % 2 == 0)
                {
                    var converter = new System.Windows.Media.BrushConverter();
                    var brush = (Brush)converter.ConvertFromString("#FFD0EDED");
                    novaGrid.Background = brush;
                }
                else
                {
                    var converter = new System.Windows.Media.BrushConverter();
                    var brush = (Brush)converter.ConvertFromString("#FFC2DCDC");
                    novaGrid.Background = brush;
                }
                flag++;
            }
            Console.WriteLine(paginaAnterior);
        }
Example #16
0
        public servicePage(int id, Page paginaanterior)
        {
            InitializeComponent();
            if (id == -1)
            {
                return;
            }
            paginaAnterior = paginaanterior;
            LoginPage logPage = new LoginPage();

            currentUser = logPage.getCurrentUser();
            List <ServiceInfo> servicos = readService();

            foreach (ServiceInfo s in servicos)
            {
                if (s.id == id)
                {
                    currentService = s;
                }
            }
            descricaoServico.Document.Blocks.Clear();
            descricaoServico.Document.Blocks.Add(new Paragraph(new Run(currentService.descricao))
            {
                FontSize = 16
            });

            preco.Document.Blocks.Clear();
            preco.Document.Blocks.Add(new Paragraph(new Run(currentService.preco))
            {
                FontSize = 18
            });

            nomeservico.Content = currentService.tipo;
            //nomeservico.Document.Blocks.Clear();
            //nomeservico.Document.Blocks.Add(new Paragraph(new Run(currentService.tipo)) { FontSize = 18 });

            nomeinstituto.Document.Blocks.Clear();
            nomeinstituto.Document.Blocks.Add(new Paragraph(new Run(currentService.instituto_nome))
            {
                FontSize = 18
            });

            if (currentService.foto != "null")
            {
                ImageBrush myBrush = new ImageBrush();
                Image      image   = new Image();
                image.Source = new BitmapImage(
                    new Uri(
                        BaseUriHelper.GetBaseUri(this), currentService.foto));
                myBrush.ImageSource     = image.Source;
                userfotogrid.Background = myBrush;
            }

            data.Items.Insert(0, "Data");
            data.SelectedIndex = 0;
            hora.Items.Insert(0, "Hora");
            hora.SelectedIndex = 0;

            institutoPage        InstitutoPage = new institutoPage(-1, this);
            List <InstitutoInfo> institutos    = InstitutoPage.readInstituto();

            foreach (InstitutoInfo i in institutos)
            {
                if (i.id == currentService.instituto_id)
                {
                    respectiveInstitute = i;
                }
            }

            foreach (int dia in respectiveInstitute.dias)
            {
                data.Items.Insert(data.Items.Count, dia);
            }
            foreach (string h in respectiveInstitute.horas)
            {
                hora.Items.Insert(hora.Items.Count, h);
            }

            foreach (int favoritoid in currentUser.favoritos)
            {
                if (favoritoid == currentService.id)
                {
                    favoritos.Kind = MaterialDesignThemes.Wpf.PackIconKind.Star;
                    flag++;
                }
            }
        }