Example #1
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);
            }
        }