protected void gvDocuments_RowDeleting(object sender, GridViewDeleteEventArgs e) { GetSessionValues(); //Get the document dto.ArticleDocument artDoc = ArticleBF.ArticleDto.Documents[e.RowIndex]; try { File.Delete(artDoc.FullFileName); } catch (IOException ioEx) { DisplayPopup("An error occured deleting the document."); } //Remove from documents list ArticleBF.ArticleDto.Documents.RemoveAt(e.RowIndex); //Update session SetSessionValues(); //Reload the grid LoadDocGrid(); }
private dto.ArticleDocument GetDocValues() { dto.ArticleDocument artDoc = new dto.ArticleDocument(); artDoc.ArtDocTypeId = Convert.ToInt32(ddlArticleDocTypes.SelectedValue); artDoc.Comments = tbComments.Text.Trim(); artDoc.CreationUserId = UserInfo.UserDto.UserId; artDoc.IsActive = Convert.ToBoolean(Convert.ToInt32(ddlDocStatus.SelectedValue)); return(artDoc); }
protected void gvDocuments_RowDataBound(object sender, GridViewRowEventArgs e) { //If the item bound is a row item if (e.Row.RowType.Equals(DataControlRowType.DataRow)) { Label lblDocType = (Label)e.Row.FindControl("lblDocType"); dto.ArticleDocument artDoc = (dto.ArticleDocument)e.Row.DataItem; if (!(lblDocType == null || artDoc == null)) { ListItem liItem = ddlArticleDocTypes.Items.FindByValue(artDoc.ArtDocTypeId.ToString()); if (liItem != null) { lblDocType.Text = liItem.Text; } } } }
protected void btnAddDoc_Click(object sender, EventArgs e) { if (Page.IsValid) { //Init page objects from session GetSessionValues(); try { if (tbUploadDocument.HasFile && tbUploadDocument.PostedFile != null) { string fileName = SaveDocToTemp(tbUploadDocument); dto.ArticleDocument artDoc = GetDocValues(); artDoc.FullFileName = fileName; ArticleBF.ArticleDto.Documents.Add(artDoc); SetSessionValues(); LoadDocGrid(); ResetDocumentFormValues(); } else { DisplayPopup("The document cannot be empty. Please choose a document with content."); } } catch (IOException ioEx) { throw; } } }