protected void OpenButtonClick(object sender, EventArgs e) { SaveDates(); Button button = (Button)sender; { CompetitionDataContext competitionDataBase = new CompetitionDataContext(); zDocumentsTable currentDocument = (from a in competitionDataBase.zDocumentsTable where a.ID == Convert.ToInt32(button.CommandArgument) select a).FirstOrDefault(); if (currentDocument != null) { if (currentDocument.LinkOut != null) { Response.Redirect(currentDocument.LinkOut); } else if (currentDocument.Name != null) { String path = Server.MapPath("~/documents/byApplication") + "\\\\" + currentDocument.FK_ApplicationTable.ToString() + "\\\\" + currentDocument.Name; // Response.Redirect(,false); HttpContext.Current.Response.ContentType = "application/x-zip-compressed"; HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment; filename=" + currentDocument.Name); HttpContext.Current.Response.BinaryWrite(ReadByteArryFromFile(path)); HttpContext.Current.Response.End(); Response.End(); } } } }
protected void NewLink(int applicationId, string linkOut) { CompetitionDataContext competitionDataBase = new CompetitionDataContext(); zDocumentsTable newDocument = new zDocumentsTable(); newDocument.Active = true; newDocument.FK_ApplicationTable = applicationId; newDocument.Name = null; newDocument.LinkOut = linkOut; newDocument.AddDateTime = DateTime.Now; competitionDataBase.zDocumentsTable.InsertOnSubmit(newDocument); competitionDataBase.SubmitChanges(); }
protected void DeleteButtonClick(object sender, EventArgs e) { SaveDates(); Button button = (Button)sender; { CompetitionDataContext competitionDataBase = new CompetitionDataContext(); zDocumentsTable currentDocument = (from a in competitionDataBase.zDocumentsTable where a.ID == Convert.ToInt32(button.CommandArgument) select a).FirstOrDefault(); if (currentDocument != null) { currentDocument.Active = false; competitionDataBase.SubmitChanges(); } Response.Redirect("ChooseApplicationAction.aspx"); } }