Example #1
0
        private void CellClick_metroGridSearchResult(object sender, DataGridViewCellEventArgs e)
        {
            //if click is on new row or header row
            if (e.RowIndex == metroGridSearchRes.NewRowIndex || e.RowIndex < 0)
            {
                return;
            }

            int    indexSelected = e.RowIndex;
            long   idDocument    = 0;
            long   id_temp       = 0;
            string tipoDocumento = "";
            string urlPdf        = "";

            switch (_selectedTab)
            {
            case 0:
                id_temp       = _tesisServices.TesisId[indexSelected];
                idDocument    = _tesisServices.GetTesisById(id_temp).Documentid;
                tipoDocumento = "Tesis";
                break;

            case 1:
                id_temp       = _bookServices.BooksId[indexSelected];
                idDocument    = _bookServices.GetBookById(id_temp).Documentid;
                tipoDocumento = "Libro";
                break;

            case 2:
                id_temp       = _articleServices.ArticlesId[indexSelected];
                idDocument    = _articleServices.GetArticleById(id_temp).Documentid;
                tipoDocumento = "Articulo";
                break;

            default:
                idDocument    = _documentServices.DocumentsId[indexSelected].Id;
                tipoDocumento = _documentServices.DocumentsId[indexSelected].TipoDocumento;
                break;
            }

            List <string> datos = new List <string>();

            urlPdf = _documentServices.URLById(idDocument);

            //Me aseguro de no pasar por los iconos en el DataGrid
            for (int i = 0; i < metroGridSearchRes.Columns.Count; i++)
            {
                if (metroGridSearchRes.Rows[e.RowIndex].Cells[i].Value != null)
                {
                    datos.Add(metroGridSearchRes.Rows[e.RowIndex].Cells[i].Value.ToString());
                }
            }

            datos.Add(urlPdf);

            if (_selectedTab != 4)
            {
                if (e.ColumnIndex == metroGridSearchRes.Columns["imageDownloadDocument"].Index)
                {
                    CheckAndOpenUrlPdf(urlPdf);
                }
                else
                {
                    FormDocumentView doc = new FormDocumentView(datos, idDocument, tipoDocumento);
                    doc.ShowDialog();
                }
            }
            else
            {
                if (e.ColumnIndex == metroGridSearchRes.Columns["imageUpdate"].Index)
                {
                    var        documentsParList = _documentServices.DocumentsId;
                    FormInsert doc = new FormInsert(datos, idDocument, tipoDocumento, documentsParList);
                    doc.ShowDialog();
                    CreateForm();
                }
                if (e.ColumnIndex == metroGridSearchRes.Columns["imageDelete"].Index)
                {
                    DeleteDocument(idDocument, urlPdf);
                }
            }

            if (_selectedTab != 4)
            {
            }
        }