Exemple #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            bool    x = false;
            Cliente c = new Cliente();

            if (nome.Text.Length != 0 && idade.Text.Length != 0 && nif.Text.Length != 0 && numTel.Text.Length != 0 && numC.Text.Length != 0 && numH.Text.Length != 0)
            {
                c = new Cliente(nome.Text, Int32.Parse(idade.Text), Int32.Parse(nif.Text), Int32.Parse(numTel.Text), Int32.Parse(numC.Text));
                x = ControlaClientes.AddCliente(c, Int32.Parse(numH.Text));
            }
            else
            {
                MessageBox.Show("Campos por preencher!!!");
            }
            try
            {
                c = new Cliente(nome.Text, Int32.Parse(idade.Text), Int32.Parse(nif.Text), Int32.Parse(numTel.Text), Int32.Parse(numC.Text));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

            if (x == false)
            {
                MessageBox.Show("Cliente " + nome.Text + " adicionado!");
                this.Hide();
            }
            this.Close();
            m1 = new Thread(volta_Menu);
            m1.TrySetApartmentState(ApartmentState.STA);
            m1.Start();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            Cliente c = new Cliente();

            if (numC.Text.Length != 0 && numH.Text.Length != 0)
            {
                ControlaClientes.GetCliente(Int32.Parse(numC.Text), Int32.Parse(numH.Text));
                if (Int32.Parse(numC.Text) == c.NumeroCliente)
                {
                    MessageBox.Show("Cliente Encontrado");
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Cliente não existe!");
                }
            }
            else
            {
                MessageBox.Show("Campos por preencher!!!");
            }
            this.Close();
            m1 = new Thread(volta_Menu);
            m1.TrySetApartmentState(ApartmentState.STA);
            m1.Start();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            bool x = false;

            if (codC.Text.Length != 0 && codH.Text.Length != 0)
            {
                x = ControlaClientes.RemoveCliente(Int32.Parse(codC.Text), Int32.Parse(codH.Text));
            }
            else
            {
                MessageBox.Show("Campos por preencher!!!");
            }

            if (x)
            {
                MessageBox.Show("O cliente foi removido com sucesso.");
                this.Hide();
            }
            else
            {
                MessageBox.Show("Cliente não existe!");
            }
            this.Close();
            m1 = new Thread(volta_Menu);
            m1.TrySetApartmentState(ApartmentState.STA);
            m1.Start();
        }
Exemple #4
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            Cliente c = new Cliente();

            if (codC.Text.Length != 0 && codH.Text.Length != 0)
            {
                ControlaClientes.RegistoCliente(Int32.Parse(codC.Text), Int32.Parse(codH.Text));
                if (Int32.Parse(codC.Text) == c.NumeroCliente)
                {
                    dataGridView1.DataSource = ControlaClientes.RegistoCliente(Int32.Parse(codC.Text), Int32.Parse(codH.Text));
                }
                else
                {
                    MessageBox.Show("Cliente não existe!");
                }
            }
            else
            {
                MessageBox.Show("Campos por preencher!!!");
            }
        }