Example #1
0
    protected void btnSalvar_Click(object sender, EventArgs e)
    {
        if (txtMotivo.Text.Trim() == "")
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "MyKey", "erro('Informe o motivo!');", true);
            return;
        }



        Cancelado cancelado = new Cancelado();

        cancelado.Motivo = txtMotivo.Text;
        cancelado.Pedido = lblGuid.Text;

        CanceladoBD bd = new CanceladoBD();

        if (bd.Insert(cancelado))
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "MyKey", "sucesso();", true);
            txtMotivo.Text = "";
            txtMotivo.Focus();
        }
        else
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "MyKey", "erro('Ocorreu um erro ao salvar!');", true);
        }
    }
    protected void btnSalvar_Click(object sender, EventArgs e)
    {
        Cancelado cancelado = new Cancelado();

        cancelado.Motivo = txtMotivo.Text;
        cancelado.Pedido = lblGuid.Text;

        CanceladoBD bd = new CanceladoBD();

        if (bd.Insert(cancelado))
        {
            lblMensagem.Text = "Motivo de Cancelamento Salvo com Sucesso";
            txtMotivo.Text   = "";
            txtMotivo.Focus();
        }
        else
        {
            lblMensagem.Text = "Erro ao salvar.";
        }
    }