예제 #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
                {
                    Documento documento   = CntLainsaSci.GetDocumento(id, ctx);
                    string    newFileName = String.Format("{0:000000000}.", documento.DocumentoId) + documento.Extension;
                    string    repodir     = ConfigurationManager.AppSettings["Repositorio"];
                    string    origen      = repodir + "\\" + newFileName;

                    if (documento.InformeProgramados != null)
                    {
                        foreach (InformeProgramado ip in documento.InformeProgramados)
                        {
                            ip.Documento = null;
                        }
                    }
                    CntLainsaSci.CTXEliminar(documento, ctx);
                    CntLainsaSci.CTXGuardar(ctx);

                    // Además hay que borrarlo físicamente
                    File.Delete(origen);
                    RefreshGrid(true);
                }
                catch (Exception ex)
                {
                    ControlDeError(ex);
                }
                break;
            }
        }
    }
예제 #2
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" && imgb.ID != "Generar")
            {
                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
                {
                    Revision revision = CntLainsaSci.GetRevision(id, ctx);
                    //PlanificacionRevision plan = revision.PlanificacionRevision;
                    //plan.Revisions.Remove(revision);
                    foreach (DatosRevision item in revision.DatosRevisions)
                    {
                        CntLainsaSci.CTXEliminar(item, ctx);
                    }
                    CntLainsaSci.CTXEliminar(revision, ctx);
                    //plan.FechaUltimaRevision = CntLainsaSci.GetFUltimarevision(plan, ctx);
                    CntLainsaSci.CTXGuardar(ctx);

                    RefreshGrid(true);
                }
                catch (Exception ex)
                {
                    ControlDeError(ex);
                }
                break;

            case "Generar":
                CntLainsaSci.ProgramarRevisiones(dispositivo, ctx);
                RefreshGrid(true);
                break;
            }
        }
    }
예제 #3
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.Parse(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex][e.Item.OwnerTableView.DataKeyNames[0]].ToString());
                }
                switch (imgb.ID)
                {
                case "Select":
                    break;

                case "Edit":
                    break;

                case "Delete":
                    try
                    {
                        string          file;
                        CargaTerminales p = CntLainsaSci.GetCargaTerminal(id, ctx);
                        file = p.Archivo;
                        CntLainsaSci.CTXEliminar(p, ctx);
                        CntLainsaSci.CTXGuardar(ctx);
                        RefreshGrid(true);
                        string path = String.Format("{0}BDII\\{1}", this.MapPath("/"), file);
                        if (System.IO.File.Exists(path))
                        {
                            System.IO.File.Delete(path);
                        }
                    }
                    catch (Exception ex)
                    {
                        ControlDeError(ex);
                    }
                    break;
                }
            }
        }
예제 #4
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
                {
                    Campo campo = CntLainsaSci.GetCampo(id, ctx);
                    foreach (DatosRevision dr in campo.DatosRevisions)
                    {
                        CntLainsaSci.CTXEliminar(dr, ctx);
                    }
                    CntLainsaSci.CTXEliminar(campo, ctx);
                    CntLainsaSci.CTXGuardar(ctx);
                    RefreshGrid(true);
                }
                catch (Exception ex)
                {
                    ControlDeError(ex);
                }
                break;
            }
        }
    }
    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.Parse(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex][e.Item.OwnerTableView.DataKeyNames[0]].ToString());
            }
            switch (imgb.ID)
            {
            case "Select":
                break;

            case "Edit":
                break;

            case "Delete":
                try
                {
                    ProgramacionInforme p = CntInforme.GetProgramacionInforme(id, ctx);
                    foreach (InformeProgramado ip in p.InformeProgramados)
                    {
                        ip.ProgramacionInforme = null;
                    }
                    CntLainsaSci.CTXEliminar(p, ctx);
                    CntLainsaSci.CTXGuardar(ctx);
                    RefreshGrid(true);
                }
                catch (Exception ex)
                {
                    ControlDeError(ex);
                }
                break;
            }
        }
    }
예제 #6
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" && imgb.ID != "Program")
                {
                    id = (int)e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex][e.Item.OwnerTableView.DataKeyNames[0]];
                }
                switch (imgb.ID)
                {
                case "Select":
                    break;

                case "Edit":
                    break;

                case "Program":
                    bool     firstTime = true;
                    Programa prog      = null;
                    string   jCommand  = "";
                    foreach (GridDataItem dataItem in RadGrid1.MasterTableView.Items)
                    {
                        if (dataItem.Selected == true)
                        {
                            if (firstTime)
                            {
                                // Creamos el programa
                                prog             = new Programa();
                                prog.Usuario     = usuario;
                                prog.Comentarios = String.Format("Programación creada el {0:dd/MM/yyyy hh:mm:ss}", DateTime.Now);
                                firstTime        = false;
                            }
                            id = (int)dataItem.OwnerTableView.DataKeyValues[dataItem.ItemIndex][dataItem.OwnerTableView.DataKeyNames[0]];
                            Revision r = CntLainsaSci.GetRevision(id, ctx);
                            if (r != null)
                            {
                                r.Programa = prog;
                                r.Estado   = "PROGRAMADA";
                                prog.Revisions.Add(r);
                                CntLainsaSci.AgruparCompanyeros(r, prog, ctx);
                            }
                        }
                    }
                    CntLainsaSci.EliminarProgramadasInferiores(prog);
                    CntLainsaSci.ProgramarSustituciones(prog, ctx);
                    if (!CntLainsaSci.ProgramaMezclado(prog))
                    {
                        CntLainsaSci.CTXGuardar(ctx);
                        if (!firstTime)
                        {
                            //var url = "RevisionForm.aspx?Caller=ProgramarGrid&RevisionId=" + id;
                            //var name = "RevisionForm";
                            //openOutSide(url, name);
                            string url = String.Format("ProgramaForm.aspx?Caller=ProgramarGrid&ProgramaId={0}", prog.ProgramaId);
                            jCommand = String.Format("openOutSide('{0}','{1}');", url, "ProgramaForm");
                            RadAjaxManager1.ResponseScripts.Add(jCommand);
                        }
                    }
                    else
                    {
                        RadNotification1.Text = "No debe mezclar instalaciones";
                        RadNotification1.Show();
                    }
                    RefreshGrid(true);
                    break;

                case "Delete":
                    try
                    {
                        Revision revision = CntLainsaSci.GetRevision(id, ctx);
                        //PlanificacionRevision plan = revision.PlanificacionRevision;
                        //plan.Revisions.Remove(revision);
                        foreach (DatosRevision item in revision.DatosRevisions)
                        {
                            CntLainsaSci.CTXEliminar(item, ctx);
                        }
                        CntLainsaSci.CTXEliminar(revision, ctx);

                        //plan.FechaUltimaRevision = CntLainsaSci.GetFUltimarevision(plan, ctx);
                        CntLainsaSci.CTXGuardar(ctx);

                        RefreshGrid(true);
                    }
                    catch (Exception ex)
                    {
                        ControlDeError(ex);
                    }
                    break;
                }
            }
        }