Beispiel #1
0
    protected void btnaceptar_Click(object sender, EventArgs e)
    {
        try
        {
            if (this.txtdescripcion.Text.Trim() != "")
            {
                try
                {
                    TipoDenuncia tipodenuncia = new TipoDenuncia();
                    tipodenuncia.descTipoDenuncia = this.txtdescripcion.Text.Trim();



                    if (hAccion.Value == "agregar")
                    {
                        int Est;
                        if (this.cboestado.SelectedIndex == 0)
                        {
                            Est = 1;
                        }
                        else
                        {
                            Est = 0;
                        }

                        tipodenuncia.estado         = Convert.ToBoolean(Est);
                        tipodenuncia.idTipoDenuncia = NegocioMantenimiento.TraerIdTipoDenuncia();


                        this.cboestado.Enabled = true;
                        NegocioMantenimiento.AgregarTipoDenuncia(tipodenuncia);

                        MostrarMensaje("Un nuevo Tipo de Denuncia ha sido agregada satisfactoriamente");
                        txtdescripcion.Text     = "";
                        cboestado.SelectedIndex = 0;
                        txtdescripcion.Enabled  = false;
                    }

                    else
                    {
                        tipodenuncia.idTipoDenuncia = int.Parse(GvTipoDenuncias.SelectedRow.Cells[1].Text);


                        if (cboestado.SelectedItem.Text == "Activo")
                        {
                            int Est = 1;

                            tipodenuncia.estado = Convert.ToBoolean(Est);
                        }
                        else
                        {
                            int Est = 0;

                            tipodenuncia.estado = Convert.ToBoolean(Est);
                        }



                        NegocioMantenimiento.ModificarTipoDenuncia(tipodenuncia);

                        MostrarMensaje("Usted ha modificado el Tipo de denuncia:  " + tipodenuncia.descTipoDenuncia + ", satisfactoriamente.");
                        txtdescripcion.Text     = "";
                        cboestado.SelectedIndex = 0;


                        txtdescripcion.Enabled = false;
                    }



                    CargarGrillaTipoDenuncias();
                    this.txttipodenuncia.Text          = "";
                    this.txtdescripcion.Text           = "";
                    this.cboestado.Enabled             = false;
                    this.GvTipoDenuncias.SelectedIndex = -1;
                }
                catch (Exception ex)
                {
                    Response.Redirect("Errores.aspx?error=" + ex.Message);
                }
            }
            else
            {
                MostrarMensaje("Por Favor, complete todos los campos antes de realizar esta función.");

                this.txtdescripcion.Text           = "";
                this.txttipodenuncia.Text          = "";
                this.txtdescripcion.Enabled        = false;
                this.cboestado.Enabled             = false;
                this.GvTipoDenuncias.SelectedIndex = -1;
            }
        }

        catch (Exception ex)
        {
            Response.Redirect("Errores.aspx?error=" + ex.Message);
        }
        habilitarBotones(true);
    }