private void SaveCommonFields()
 {
     Stories dao = new Stories();
     if (fuImage.HasFile)
     {
         if (dao.UpdateImage(this.GroupID, fuImage.FileBytes))
             btnDeleteImage.Visible = true;
     }
     //save pages
     //dao.ShowOnPages(this.GroupID, cp.GetSelectedIDs());
     //save sections
     dao.ShowInSections(this.GroupID, cs.GetSelectedIDs());
 }
 protected void btnDeleteImage_Click(object sender, EventArgs e)
 {
     Stories dao = new Stories();
     if (dao.DeleteImage(this.GroupID))
         btnDeleteImage.Visible = false;
 }
        private void BindCommonFields()
        {
            Stories dao = new Stories();
            Story item = dao.GetByLangGroup("ru", GroupID);

            if (item != null)
            {
                //dpStoryDate.SelectedDate = item.Date;
                //ip.CheckItem(item.ImagePosition);
                btnDeleteImage.Visible = item.HasImage;

                List<int> pages = dao.GetContentPagesIDs(item.GroupID);
                List<int> sections = dao.GetContentSectionsIDs(item.GroupID);

                //cp.CheckItems(pages);
                cs.CheckItems(sections);
            }
        }
Example #4
0
        public void ProcessRequest(HttpContext context)
        {
            string name = context.Request.QueryString["name"];
            string type = context.Request.QueryString["type"];
            string GroupID = context.Request.QueryString["groupid"];
            string Lang = context.Request.QueryString["lang"];
            if (!string.IsNullOrEmpty(name))
            {
                string filename = context.Server.MapPath(string.Format("~/files/{0}", name)).ToLower();
                string path = Path.GetDirectoryName(filename);
                if (filename.EndsWith(".pdf") && path.EndsWith("files") && File.Exists(filename))
                {
                    context.Response.Clear();
                    context.Response.ClearHeaders();

                    string attachment = String.Format("attachment; filename={0}", name);
                    context.Response.AddHeader("content-disposition", attachment);
                    context.Response.ContentType = "Application/pdf";
                    context.Response.AddHeader("Pragma", "public");

                    context.Response.WriteFile(filename);
                }
                else
                {
                    context.Response.Write("file not found");
                }
            }
            else if (!string.IsNullOrEmpty(type) && !string.IsNullOrEmpty(GroupID) && !string.IsNullOrEmpty(Lang))
            {
                switch (type)
                {
                    case "1":
                        Erc.Apple.Data.SuccessStories ss = new Erc.Apple.Data.SuccessStories();
                        try
                        {
                            SuccessStory s = ss.GetPdfFile(Lang, Int32.Parse(GroupID));
                            if (s != null)
                            {
                                string attachment = String.Format("attachment; filename={0}", s.PdfFileName);
                                context.Response.AddHeader("content-disposition", attachment);
                                //context.Response.ContentType = "Application/pdf";
                                context.Response.AddHeader("Pragma", "public");
                                context.Response.BinaryWrite(s.PdfFile);
                                context.Response.Flush();
                            }
                        }
                        catch (Exception)
                        {
                            context.Response.WriteFile("file not found");
                        }
                        break;
                    case "2":
                        Erc.Apple.Data.Stories sss = new Erc.Apple.Data.Stories();
                        try
                        {
                            Story st = sss.GetPdfFile(Lang, Int32.Parse(GroupID));
                            if (st != null)
                            {
                                string attachment = String.Format("attachment; filename={0}", st.PdfFileName);
                                context.Response.AddHeader("content-disposition", attachment);
                                //context.Response.ContentType = "Application/pdf";
                                context.Response.AddHeader("Pragma", "public");
                                context.Response.BinaryWrite(st.PdfFile);
                                context.Response.Flush();
                            }
                        }
                        catch (Exception)
                        {
                            context.Response.WriteFile("file not found");
                        }
                        break;
                }

            }
        }
        public void SaveItem()
        {
            if (DetailsViewEditItem.CurrentMode == DetailsViewMode.Insert)
            {
                DetailsViewEditItem.InsertItem(false);
            }
            else if (DetailsViewEditItem.CurrentMode == DetailsViewMode.Edit)
            {
                DetailsViewEditItem.UpdateItem(false);
            }

             //Save Pdf file for item
            FileUpload fuUpload = this.DetailsViewEditItem.FindControl("fuImage") as FileUpload;
            if (fuUpload != null && fuUpload.HasFile)
            {
                Stories s = new Stories();
                if (s.UpdatePdfFile(this.GroupID, this.LangCode, fuUpload.FileBytes, fuUpload.FileName))
                {
                    ImageButton btnDeletePdfFile = this.DetailsViewEditItem.FindControl("btnDeletePdfFile") as ImageButton;
                    if (btnDeletePdfFile != null)
                    {
                        btnDeletePdfFile.Visible = true;
                    }
                    Button b = this.DetailsViewEditItem.FindControl("PdfName") as Button;
                    if (b != null)
                    {
                        b.Text = fuUpload.FileName;
                        b.Visible = true;
                        b.Click += new EventHandler(GetPdfFile);
                    }
                }
            }
        }
 protected void GetPdfFile(object sender, EventArgs e)
 {
     Stories ss = new Stories();
     Story sstory = ss.GetPdfFile(this.LangCode, this.GroupID);
     if (sstory != null && sstory.PdfFile != null && sstory.PdfFile.Length > 0 && !string.IsNullOrEmpty(sstory.PdfFileName))
     {
         Response.Clear();
         Response.AppendHeader("content-disposition", "attachment; filename=" + sstory.PdfFileName);
         Response.BinaryWrite(sstory.PdfFile);
         Response.Flush();
     }
 }
 protected void btnDeletePdfFile_Click(object sender, EventArgs e)
 {
     Stories ss = new Stories();
     if (ss.DeletePdfFile(LangCode, GroupID))
     {
         ImageButton btnDeletePdfFile = this.DetailsViewEditItem.FindControl("btnDeletePdfFile") as ImageButton;
         if (btnDeletePdfFile != null)
         {
             btnDeletePdfFile.Visible = false;
         }
         Button b = this.DetailsViewEditItem.FindControl("PdfName") as Button;
         if (b != null)
         {
             b.Visible = false;
         }
     }
 }