Beispiel #1
0
    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        // we only process commands with a datasource (our image buttons)
        if (e.CommandSource == null)
        {
            return;
        }
        string typeOfControl = e.CommandSource.GetType().ToString();

        if (typeOfControl.Equals("System.Web.UI.WebControls.ImageButton"))
        {
            int         id   = 0;
            ImageButton imgb = (ImageButton)e.CommandSource;
            if (imgb.ID != "New" && imgb.ID != "Exit")
            {
                id = (int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex][e.Item.OwnerTableView.DataKeyNames[0]];
            }
            switch (imgb.ID)
            {
            case "Select":
                break;

            case "Edit":
                break;

            case "Delete":
                try
                {
                    ModeloDispositivo modelo = CntLainsaSci.GetModeloDispositivo(id, ctx);
                    CntLainsaSci.CTXEliminar(modelo, ctx);
                    CntLainsaSci.CTXGuardar(ctx);
                    RefreshGrid(true);
                }
                catch (Exception ex)
                {
                    ControlDeError(ex);
                }
                break;
            }
        }
    }
Beispiel #2
0
    protected void Page_Init(object sender, EventArgs e)
    {
        // it gets an appropiate context (LainsaSciCTX -> web.config)
        ctx = new LainsaSci("LainsaSciCTX");
        // verify if a Usuario is logged
        usuario = CntWinWeb.IsSomeoneLogged(this, ctx);
        if (usuario == null)
        {
            Response.Redirect("Default.aspx");
        }
        else
        {
            Session["UsuarioId"] = usuario.UsuarioId;
        }
        //
        // si llega aquí está autorizado
        permiso = CntLainsaSci.GetPermiso(usuario.GrupoUsuario, "Modelogrid", ctx);
        if (permiso == null)
        {
            RadNotification1.Text = String.Format("<b>{0}</b><br/>{1}",
                                                  (string)GetGlobalResourceObject("ResourceLainsaSci", "Warning"),
                                                  (string)GetGlobalResourceObject("ResourceLainsaSci", "NoPermissionsAssigned"));
            RadNotification1.Show();
            RadAjaxManager1.ResponseScripts.Add("closeWindow();");
        }
        btnAccept.Visible = permiso.Modificar;
        // Si esto no va antes de ModeloDispositivoID tendrás problemas.
        if (Request.QueryString["Caller"] != null)
        {
            caller = Request.QueryString["Caller"];
            caller = caller.Replace("'", "");
        }
        if (Request.QueryString["TipoId"] != null)
        {
            tipo = CntLainsaSci.GetTipoDispositivo(int.Parse(Request.QueryString["TipoId"]), ctx);
            rdcTipo.Items.Clear();
            rdcTipo.Items.Add(new RadComboBoxItem(tipo.Nombre, tipo.TipoId.ToString()));
            rdcTipo.SelectedValue = tipo.TipoId.ToString();
            imgTipo.Enabled       = false;
            rdcTipo.Enabled       = false;
            if (tipo.Empresa != null)
            {
                rdcEmpresa.Items.Clear();
                rdcEmpresa.Items.Add(new RadComboBoxItem(tipo.Empresa.Nombre, tipo.Empresa.EmpresaId.ToString()));
                rdcEmpresa.SelectedValue = tipo.Empresa.EmpresaId.ToString();
                imgEmpresa.Enabled       = false;
                rdcEmpresa.Enabled       = false;
            }
            if (tipo.Instalacion != null)
            {
                rdcInstalacion.Items.Clear();
                rdcInstalacion.Items.Add(new RadComboBoxItem(tipo.Instalacion.Nombre, tipo.Instalacion.InstalacionId.ToString()));
                rdcInstalacion.SelectedValue = tipo.Instalacion.InstalacionId.ToString();
                imgInstalacion.Enabled       = false;
                rdcInstalacion.Enabled       = false;
            }
        }

        // Is it a new record or not?
        if (Request.QueryString["ModeloId"] != null)
        {
            modeloDispositivo = CntLainsaSci.GetModeloDispositivo(int.Parse(Request.QueryString["ModeloId"]), ctx);
            LoadData(modeloDispositivo);
            newRecord = false;
        }
        else
        {
            newRecord = true;
            if (usuario.Empresa != null)
            {
                rdcEmpresa.Items.Clear();
                rdcEmpresa.Items.Add(new RadComboBoxItem(usuario.Empresa.Nombre, usuario.Empresa.EmpresaId.ToString()));
                rdcEmpresa.SelectedValue = usuario.Empresa.EmpresaId.ToString();
                imgEmpresa.Enabled       = false;
                rdcEmpresa.Enabled       = false;
            }
            if (usuario.Instalacion != null)
            {
                rdcInstalacion.Items.Clear();
                rdcInstalacion.Items.Add(new RadComboBoxItem(usuario.Instalacion.Nombre, usuario.Instalacion.InstalacionId.ToString()));
                rdcInstalacion.SelectedValue = usuario.Instalacion.InstalacionId.ToString();
                imgInstalacion.Enabled       = false;
                rdcInstalacion.Enabled       = false;
            }
        }
        // control de skin
        if (Session["Skin"] != null)
        {
            RadSkinManager1.Skin = Session["Skin"].ToString();
        }
    }