Example #1
0
        private void btnBuscar_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtApartamento.Text == "")
                {
                    lblMessagem1.Text = "* Insira o número do apartamento *";
                }
                else
                {
                    int Apartamento = Convert.ToInt32(txtApartamento.Text);

                    ProprietariosController pc = new ProprietariosController();
                    Proprietarios           p  = pc.PesquisarPorApartamento(Apartamento);

                    if (p != null)
                    {
                        txtCPF.Text            = p.CPF;
                        txtRG.Text             = p.RG;
                        txtNomeCompleto.Text   = p.NomeCompleto;
                        txtTelefone.Text       = p.Telefone;
                        txtEmail.Text          = p.Email;
                        this.btnEditar.Enabled = true;
                    }
                    else
                    {
                        lblMessagem1.Text = "Apartamento não encontrado";
                    }
                }
            }
            catch (Exception ex)
            {
                lblMessagem2.Text = ex.Message;
            }
        }
Example #2
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtNomeCompleto.Text == "" || txtCPF.Text == "" || txtRG.Text == "" || txtEmail.Text == "" || txtTelefone.Text == "")
                {
                    lblMessagem1.Text = " Por favor, Preencher todos os campos do formulário...";
                }
                else
                {
                    Proprietarios p = new Proprietarios();
                    p.NomeCompleto = txtNomeCompleto.Text;
                    p.CPF          = txtCPF.Text;
                    p.RG           = txtRG.Text;
                    p.Email        = txtEmail.Text;
                    p.Telefone     = txtTelefone.Text;
                    p.Apartamento  = Convert.ToInt32(txtApartamento.Text);

                    ProprietariosController pc = new ProprietariosController();
                    pc.Update(p);

                    lblMessagem2.Text = "O Morador do Apartamento  '" + txtApartamento.Text + "' Foi Atualizado com Sucesso!";

                    this.txtNomeCompleto.Text     = "";
                    this.txtRG.Text               = "";
                    this.txtCPF.Text              = "";
                    this.txtEmail.Text            = "";
                    this.txtTelefone.Text         = "";
                    this.txtNomeCompleto.ReadOnly = true;
                    this.txtCPF.ReadOnly          = true;
                    this.txtRG.ReadOnly           = true;
                    this.txtTelefone.ReadOnly     = true;
                    this.txtEmail.ReadOnly        = true;
                    this.btnCancelar.Enabled      = false;
                    this.btnEditar.Enabled        = false;
                    this.btnSalvar.Enabled        = false;
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        private void btnCadastrar_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtNomeCompleto.Text == "" || txtCPF.Text == "" || txtRG.Text == "" || txtEmail.Text == "" || txtApartamento.Text == "" || txtTelefone.Text == "")
                {
                    lblMessage.Text = " Por favor, Preencher todos os campos do formulário...";
                }
                else
                {
                    Proprietarios p = new Proprietarios();
                    p.NomeCompleto = txtNomeCompleto.Text;
                    p.CPF          = txtCPF.Text;
                    p.RG           = txtRG.Text;
                    p.Email        = txtEmail.Text;
                    p.Apartamento  = Convert.ToInt32(txtApartamento.Text);
                    p.Telefone     = txtTelefone.Text;

                    ProprietariosController pc = new ProprietariosController();
                    pc.Create(p);

                    lblMessage.Text = "O Morador '" + txtNomeCompleto.Text + "' Foi Cadastrado com Sucesso!";

                    this.txtNomeCompleto.Text = "";
                    this.txtRG.Text           = "";
                    this.txtCPF.Text          = "";
                    this.txtApartamento.Text  = "";
                    this.txtEmail.Text        = "";
                    this.txtTelefone.Text     = "";
                    this.txtNomeCompleto.Focus();
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }