protected void btnGrabarModelo_Click(object sender, EventArgs e)
    {
        Int32    retorno;
        ModeloBL oModeloBL = new ModeloBL();

        oModeloBL.ErrorEvent += new ModeloBL.ErrorDelegate(Master.Transaction_ErrorEvent);

        try
        {
            CargarEntidadModeloDesdeForm();
            ModeloBE oModeloBEMad = new ModeloBE();

            oModeloBEMad = oModeloBL.GetById(oModeloBE.nid_modelo);
            if (this.oModeloBE.nid_modelo == 0)
            {
                this.oModeloBE.sfe_cambio = String.Empty;
            }

            //retorno = oModelosBL.grabarModelo(this.oModeloBE);
            retorno = oModeloBL.Grabar(this.oModeloBE);

            if (retorno > 0)
            {
                if (this.oModeloBE.nid_modelo == 0)
                {
                    JavaScriptHelper.Alert(this, Message.keyGrabar, String.Empty);
                }
                else
                {
                    JavaScriptHelper.Alert(this, Message.keyActualizar, String.Empty);
                }
            }
            else
            {
                if (retorno == -41)
                {
                    JavaScriptHelper.Alert(this, Message.KeyModeloExistSGSNET, String.Empty);
                }
                else if (retorno == -4)
                {
                    JavaScriptHelper.Alert(this, Message.keyErrorGrabarLlave, String.Empty);
                }
                else if (retorno == -3)
                {
                    JavaScriptHelper.Alert(this, Message.keyErrorGrabarNulo, String.Empty);
                }
                else if (retorno == -2)
                {
                    JavaScriptHelper.Alert(this, Message.keyErrorGrabarCodDuplicado, String.Empty);
                }
                else if (retorno == -1)
                {
                    JavaScriptHelper.Alert(this, Message.keyErrorGrabar, String.Empty);
                }
                else
                {
                    JavaScriptHelper.Alert(this, Message.keyErrorGrabar, String.Empty);
                }
            }

            this.txtCodModeloPoput.Text = String.Empty;
            this.txtNomModeloPoput.Text = String.Empty;
            this.cboNegocioModeloPoput.SelectedValue = String.Empty;
            cboNegocioModeloPoput_OnSelectedIndexChanged(null, null);
            this.cboLineaModeloPoput.SelectedValue          = String.Empty;
            this.cboLineaComercialModeloPoput.SelectedValue = String.Empty;
            this.cboEstadoModeloPoput.SelectedValue         = String.Empty;

            this.btnBuscarModelo_Click(null, null);
        }
        catch (Exception ex)
        {
            Master.Web_ErrorEvent(this, ex);
            JavaScriptHelper.Alert(this, Message.keyErrorGrabar, String.Empty);
        }
    }