protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsCallback)
        {
            try
            {
                if (Session["IDRED"] == null)
                {
                    try
                    {
                        Response.Redirect("~/SesionCaducadaModal.aspx", true);
                    }
                    catch (System.Threading.ThreadAbortException) { return; }
                }
                // Leer Empresa

                if (Request.QueryString["unidad"] != "")
                {
                    txtCodigo.Text = Utilidades.decodpar(Request.QueryString["unidad"].ToString());
                    short idUnidad = short.Parse(txtCodigo.Text);
                    if (idUnidad <= 0)
                    {
                        txtDenominacion.ReadOnly = true;
                    }
                    IB.SUPER.ADM.SIC.Models.UnidadPreventa oElem   = new IB.SUPER.ADM.SIC.Models.UnidadPreventa();
                    IB.SUPER.ADM.SIC.BLL.UnidadPreventa    oUnidad = new IB.SUPER.ADM.SIC.BLL.UnidadPreventa();

                    oElem = oUnidad.Select(idUnidad);
                    //PreventaUnidad oUnidad = PreventaUnidad.Select(null, short.Parse(txtCodigo.Text));
                    if (oElem.ta199_denominacion == "")
                    {
                        throw (new Exception("Unidad de preventa no existente."));
                    }
                    txtDenominacion.Text = oElem.ta199_denominacion;

                    if (oElem.ta199_estadoactiva)
                    {
                        chkActiva.Checked = true;
                    }
                    else
                    {
                        chkActiva.Checked = false;
                    }

                    oUnidad.Dispose();
                }
            }
            catch (Exception ex)
            {
                sErrores += SUPER.Capa_Negocio.Errores.mostrarError("Error al obtener los datos de la unidad de preventa", ex);
            }

            //1º Se indican (por este orden) la función a la que se va a devolver el resultado
            //   y la función que va a acceder al servidor
            string cbRespuesta = Page.ClientScript.GetCallbackEventReference(this, "arg", "RespuestaCallBack", "context", false);
            string cbLlamada   = "function RealizarCallBack(arg, context)" + "{" + cbRespuesta + ";" + "}";
            //2º Se "registra" la función que va a acceder al servidor.
            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "RealizarCallBack", cbLlamada, true);
        }
    }
    private string Grabar(string sCodigo,
                          string sDenominacion,
                          string sActiva
                          )
    {
        string sResul  = "";
        short  nID     = -1;
        bool   bActiva = false;

        if (sActiva == "1")
        {
            bActiva = true;
        }
        IB.SUPER.ADM.SIC.Models.UnidadPreventa oUnidad  = new IB.SUPER.ADM.SIC.Models.UnidadPreventa();
        IB.SUPER.ADM.SIC.Models.UnidadPreventa oUnidadD = new IB.SUPER.ADM.SIC.Models.UnidadPreventa();
        IB.SUPER.ADM.SIC.BLL.UnidadPreventa    oElem    = new IB.SUPER.ADM.SIC.BLL.UnidadPreventa();
        try
        {
            oUnidad.ta199_denominacion = sDenominacion;
            oUnidad.ta199_estadoactiva = bActiva;
            #region Datos Generales

            oUnidadD = oElem.SelectPorDenominacion(oUnidad.ta199_denominacion);
            if (sCodigo == "")
            {
                //nID = PreventaUnidad.Insert(tr,sDenominacion,bActiva);
                if (oUnidadD != null)
                {
                    return("AVISO@#@Ya existe una unidad con la misma denominación");
                }
                nID = oElem.Insert(oUnidad);
            }
            else //update
            {
                nID = short.Parse(sCodigo);
                if (oUnidadD != null && nID != oUnidadD.ta199_idunidadpreventa)
                {
                    return("AVISO@#@Ya existe una unidad con la misma denominación");
                }
                oUnidad.ta199_idunidadpreventa = nID;
                //PreventaUnidad.Update(tr, nID, sDenominacion, bActiva);
                oElem.Update(oUnidad);
            }
            #endregion

            sResul = "OK@#@" + nID.ToString();
        }
        catch (Exception ex)
        {
            sResul = "Error@#@" + Errores.mostrarError("Error al grabar los datos de la unidad de preventa", ex);
        }
        finally
        {
            oElem.Dispose();
        }
        return(sResul);
    }
Beispiel #3
0
    private string Eliminar(int nNivel, int nIDItem)
    {
        IB.SUPER.ADM.SIC.BLL.UnidadPreventa  oUnidad  = new IB.SUPER.ADM.SIC.BLL.UnidadPreventa();
        IB.SUPER.ADM.SIC.BLL.AreaPreventa    oArea    = new IB.SUPER.ADM.SIC.BLL.AreaPreventa();
        IB.SUPER.ADM.SIC.BLL.SubareaPreventa oSubArea = new IB.SUPER.ADM.SIC.BLL.SubareaPreventa();
        try
        {
            switch (nNivel)
            {
            case 1:
                oUnidad.Delete((short)nIDItem);
                oUnidad.Dispose();
                break;

            case 2:
                oArea.Delete(nIDItem);
                oArea.Dispose();
                break;

            case 3:
                oSubArea.Delete(nIDItem);
                oSubArea.Dispose();
                break;
            }

            return("OK@#@");
        }
        catch (Exception ex)
        {
            if (Errores.EsErrorIntegridad(ex))
            {
                return("Error@#@Operación rechazada.\n\n" + Errores.mostrarError("Error al obtener la estructura preventa", ex));
            }
            else
            {
                return("Error@#@" + Errores.mostrarError("Error al obtener la estructura preventa", ex));
            }
        }
        finally
        {
            switch (nNivel)
            {
            case 1:
                oUnidad.Dispose();
                break;

            case 2:
                oArea.Dispose();
                break;

            case 3:
                oSubArea.Dispose();
                break;
            }
        }
    }
Beispiel #4
0
    private void CargarUnidad(short idUnidad)
    {
        IB.SUPER.ADM.SIC.Models.UnidadPreventa oUnidad = new IB.SUPER.ADM.SIC.Models.UnidadPreventa();
        IB.SUPER.ADM.SIC.BLL.UnidadPreventa    oElem   = new IB.SUPER.ADM.SIC.BLL.UnidadPreventa();
        oUnidad = oElem.Select(idUnidad);
        //PreventaUnidad oUnidad = PreventaUnidad.Select(tr, idUnidad);
        txtUnidad.Text   = oUnidad.ta199_denominacion;
        hdnIdUnidad.Text = oUnidad.ta199_idunidadpreventa.ToString();

        oElem.Dispose();
    }