private void Registar_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         string nome = (string)NomeCli.Text;
         bool   x    = int.TryParse(TelCli.Text, out int tel);
         if (x)
         {
             int n = ControloClientes.AddCliente(new Cliente(nome, tel));
             if (n == 1)
             {
                 MessageBox.Show("Adicionado com sucesso!!!");
             }
             else
             {
                 MessageBox.Show("Cliente já registado.");
             }
         }
         else
         {
             MessageBox.Show("Não é um numero de telefone/telemóvel!!!");
         }
     }
     catch (Exception t)
     {
         MessageBox.Show(string.Format("{0}", t));
     }
 }
Example #2
0
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     try
     {
         ControloClientes.GuardarDados();
     }
     catch (Exception t)
     {
         MessageBox.Show(string.Format("{0}", t));
     }
 }
Example #3
0
 public MainWindow()
 {
     InitializeComponent();
     try
     {
         ControloClientes.CarregarDados();
     }
     catch (Exception t)
     {
         MessageBox.Show(string.Format("{0}", t));
     }
 }
        private void Registar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                bool       z       = int.TryParse(numcli.Text, out int num);
                bool       x       = int.TryParse(Codigos.Text, out int n);
                bool       a       = false;
                List <int> codigos = new List <int>();
                while (n > 0)
                {
                    int b = n % 100;
                    a = ControloEmenta.ExisteProduto(b);
                    if (a == true)
                    {
                        codigos.Add(b);
                    }
                    else
                    {
                        MessageBox.Show(string.Format("O codigo {0} não existe!!!", b));
                    }
                    n = n / 100;
                }
                bool y = ControloClientes.ExisteCliente(num);

                if (a == true && y == true)
                {
                    int k = ControloRefeicoes.AddRefeicao(new Refeicao(num, codigos));
                    if (k == 1)
                    {
                        MessageBox.Show("Adicionada");
                    }
                    else
                    {
                        MessageBox.Show("Já existe");
                    }
                }
                else if (y == false)
                {
                    MessageBox.Show("O codigo do cliente não existe.");
                }
                else
                {
                    MessageBox.Show("Codigos dos produtos errados");
                }
            }
            catch (Exception t)
            {
                MessageBox.Show(string.Format("{0}", t));
            }
        }
        private void Voltar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ControloClientes.GuardarDados();
            }
            catch (Exception t)
            {
                MessageBox.Show(string.Format("{0}", t));
            }
            MainWindow main = new MainWindow();

            main.Show();
            this.Close();
        }
        private void Remover_Click(object sender, RoutedEventArgs e)
        {
            bool x = int.TryParse(CodRemove.Text, out int cod);

            if (x == true)
            {
                bool y = ControloClientes.RemoveCliente(cod);
                if (y == true)
                {
                    MessageBox.Show("Removido com sucesso.");
                }
                else
                {
                    MessageBox.Show("Cliente não existe");
                }
            }
            else
            {
                MessageBox.Show("Não é um codigo!!!");
            }
        }
 public AddReserva()
 {
     InitializeComponent();
     clientes.ItemsSource = ControloClientes.GetClientes();
 }
 public VerClientes()
 {
     InitializeComponent();
     clientes.ItemsSource = ControloClientes.GetClientes();
     Nclientes.Text       = ControloClientes.NClientes();
 }
 public AddRefei()
 {
     InitializeComponent();
     ementa.ItemsSource   = ControloEmenta.GetEmenta();
     clientes.ItemsSource = ControloClientes.GetClientes();
 }