コード例 #1
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                string resp = "";

                if (txtNome.Text == string.Empty)
                {
                    MensagemErro("Preencha todos os campos...");
                    errorIcone.SetError(txtNome, "Insira o nome!");
                }
                else
                {
                    if (this.Novo)
                    {
                        // Trim ignora espaços vazios existentes na caixa de texto
                        resp = NApresentacao.Inserir(txtNome.Text.Trim().ToUpper(), txtDescricao.Text.Trim());
                    }
                    else
                    {
                        resp = NApresentacao.Editar(Convert.ToInt32(this.txtIdCategoria.Text),
                                                    this.txtNome.Text.Trim().ToUpper(),
                                                    this.txtDescricao.Text.Trim());
                    }

                    if (resp.Equals("OK"))
                    {
                        if (this.Novo)
                        {
                            this.MensagemOk("Registro efetuado com sucesso!");
                        }
                        else
                        {
                            this.MensagemOk("Edição efetuada com sucesso!");
                        }
                    }
                    else
                    {
                        this.MensagemErro(resp);
                    }

                    this.Novo   = false;
                    this.Editar = false;
                    this.HabilitarButton();
                    this.Limpar();
                    this.Consultar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
コード例 #2
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                string resp = "";
                if (this.txtNome.Text == string.Empty)
                {
                    MensagemErro("Preencha todos os campos");
                    errorIcone.SetError(txtNome, "Insira o nome");
                }
                else
                {
                    if (this.eNovo)
                    {
                        resp = NApresentacao.Inserir(this.txtNome.Text.Trim().ToUpper(), this.txtDescricao.Text.Trim());
                    }
                    else
                    {
                        resp = NApresentacao.Editar(Convert.ToInt32(this.txtIdApresentacao.Text),
                                                    this.txtNome.Text.Trim().ToUpper(),
                                                    this.txtDescricao.Text.Trim());
                    }

                    if (resp.Equals("OK"))
                    {
                        if (this.eNovo)
                        {
                            this.MensagemOk("Registro salvo com sucesso");
                        }
                        else
                        {
                            this.MensagemOk("Registro editado com sucesso");
                        }
                    }
                    else
                    {
                        this.MensagemErro(resp);
                    }

                    this.eNovo   = false;
                    this.eEditar = false;
                    this.botoes();
                    this.Limpar();
                    this.Mostrar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }