コード例 #1
0
        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)
            {
                SuccessStories ss = new SuccessStories();
                if (ss.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);
                    }
                }

            }
        }
コード例 #2
0
 void gvSS_PageIndexChanging(object sender, GridViewPageEventArgs e)
 {
     gvSS.PageIndex = e.NewPageIndex;
     Erc.Apple.Data.SuccessStories ss = new Erc.Apple.Data.SuccessStories();
     ssList = ss.GetByLang(this.CurrentLanguage);
     if (ssList != null && ssList.Count > 0)
     {
         gvSS.DataSource = ssList;
         gvSS.DataBind();
     }
 }
コード例 #3
0
 //protected void rptSuccessStories_DataBound(object sender, RepeaterItemEventArgs e)
 //{
 //    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
 //    {
 //        SuccessStory s = e.Item.DataItem as SuccessStory;
 //        if (s != null)
 //        {
 //            if (s.HasPdfFile)
 //            {
 //                HyperLink b = rptSuccessStories.FindControl("hlPdfFile") as HyperLink;
 //                if (b != null)
 //                {
 //                    b.Visible = true;
 //                    b.Text = s.PdfFileName;
 //                }
 //            }
 //        }
 //    }
 //}
 protected void GetPdfFile(object sender, EventArgs e)
 {
     Erc.Apple.Data.SuccessStories ss = new Erc.Apple.Data.SuccessStories();
     SuccessStory sstory = ss.GetPdfFile(this.CurrentLanguage, 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();
     }
 }
コード例 #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                Erc.Apple.Data.SuccessStories ss = new Erc.Apple.Data.SuccessStories();
                ssList = ss.GetByLang(this.CurrentLanguage);
                if (ssList != null && ssList.Count > 0)
                {
                    //rptSuccessStories.DataBinding += new EventHandler(rptSuccessStories_DataBinding);
                    gvSS.DataSource = ssList;

                    gvSS.DataBind();
                }
            }
            gvSS.PageIndexChanging += new GridViewPageEventHandler(gvSS_PageIndexChanging);
        }
コード例 #5
0
 protected void btnDeletePdfFile_Click(object sender, EventArgs e)
 {
     SuccessStories ss = new SuccessStories();
     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;
         }
     }
 }
コード例 #6
0
ファイル: GetPDF.ashx.cs プロジェクト: trifonov-mikhail/Site1
        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;
                }

            }
        }
コード例 #7
0
        private void SaveCommonFields()
        {
            SuccessStories dao = new SuccessStories();
            if (fuImage.HasFile)
            {
                byte[] fileBytes = null;
                System.Drawing.Image image = byteArrayToImage(fuImage.FileBytes);
                int maxWidth = 320;
                try
                {
                    maxWidth = Int32.Parse(WebConfigurationManager.AppSettings["MaxWidthImageSuccessStories"]);
                }
                catch (Exception)
                {

                }
                if (image.Width > maxWidth)
                {
                    image = Resize(image, maxWidth);
                }
                fileBytes = imageToByteArray(image);
                if (fileBytes != null && dao.UpdateImage(this.GroupID, fileBytes))
                    btnDeleteImage.Visible = true;
            }
            //save pages
            //dao.ShowOnPages(this.GroupID, cp.GetSelectedIDs());
            //save sections
        }
コード例 #8
0
        private void BindCommonFields()
        {
            SuccessStories dao = new SuccessStories();
            SuccessStory 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);

            }
        }
コード例 #9
0
 protected void btnDeleteImage_Click(object sender, EventArgs e)
 {
     SuccessStories dao = new SuccessStories();
     if (dao.DeleteImage(this.GroupID))
         btnDeleteImage.Visible = false;
 }