Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            int           id = int.Parse(Request["id"]);
            dcDataContext dc = new dcDataContext();

            result = dc.CMSGetNewsByID(id).SingleOrDefault();
        }
        protected void savebtn_Click(object sender, EventArgs e)
        {
            string        str1          = this.Request.QueryString["action"];
            dcDataContext dcDataContext = new dcDataContext();

            if (str1 == "edit")
            {
                int num = int.Parse(this.Request.QueryString["id"]);
                CMSGetNewsByIDResult getNewsByIdResult = dcDataContext.CMSGetNewsByID(new int?(num)).Single <CMSGetNewsByIDResult>();
                string str2;
                if (this.pdf.HasFile && this.Request["haspdf"] == "on")
                {
                    string extension = Path.GetExtension(this.pdf.FileName);
                    str2 = Guid.NewGuid().ToString() + extension;
                    if (extension != ".exe" && extension != ".aspx" && extension != "php" && extension != "asp")
                    {
                        this.pdf.SaveAs(this.Server.MapPath("~/Media/" + str2));
                    }
                }
                else
                {
                    str2 = getNewsByIdResult.pdf;
                }
                dcDataContext.UpdateNews(new int?(num), this.Request.Form["artitle"], this.Request.Form["entitle"], this.Request.Form["frtitle"], this.Request.Form["artext"], this.Request.Form["entext"], this.Request.Form["frtext"], str2);
            }
            else
            {
                string str2 = "";
                if (this.pdf.HasFile && this.Request["haspdf"] == "on")
                {
                    string extension = Path.GetExtension(this.pdf.FileName);
                    str2 = Guid.NewGuid().ToString() + extension;
                    if (extension != ".exe" && extension != ".aspx" && extension != "php" && extension != "asp")
                    {
                        this.pdf.SaveAs(this.Server.MapPath("~/Media/" + str2));
                    }
                }
                dcDataContext.AddNews(this.Request.Form["artitle"], this.Request.Form["entitle"], this.Request.Form["frtitle"], this.Request.Form["artext"], this.Request.Form["entext"], this.Request.Form["frtext"], new DateTime?(DateTime.Now), str2);
            }
            this.Response.Redirect("news.aspx");
        }