Esempio n. 1
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            DALnew    dal  = new DALnew();
            newEntity news = new newEntity();

            news.Author = Session["adminID"].ToString();
            //news.Author = "admin";
            news.Content     = content.Value;
            news.ReleaseTime = DateTime.Parse(txtReleaseTime.Text);
            news.Title       = txtTitle.Text;
            if (FileUpload1.HasFile)
            {
                int    startPosition = FileUpload1.FileName.LastIndexOf(".");                   //获取后缀名的起始位置
                string extName       = FileUpload1.FileName.Substring(startPosition).ToLower(); //获取后缀名
                string path          = Server.MapPath("./File/");
                string fileName      = DateTime.Now.ToString("yyyyMMddHHmmss") + extName;

                string saveFile = path + fileName;      //实现上传的
                string showFile = "./File/" + fileName; //后期页面上显示的

                FileUpload1.SaveAs(saveFile);
                news.RelateFile = showFile;
            }
            dal.Addnews(news);
            this.Page.RegisterClientScriptBlock("", "<script>新闻发布成功!</script>");
            Response.Redirect("NewsManage.aspx");
        }
Esempio n. 2
0
        protected void submit_Click(object sender, EventArgs e)
        {
            DALnew    dal  = new DALnew();
            newEntity news = new newEntity();

            news.Title       = desc1.Value;
            news.Content     = content.Value;
            news.Author      = Session["name"].ToString();
            news.ReleaseTime = System.DateTime.Now;
            if (FileUpload1.HasFile)
            {
                int    startPosition = FileUpload1.FileName.LastIndexOf(".");
                string extName       = FileUpload1.FileName.Substring(startPosition).ToLower();
                string path          = Server.MapPath("./File/");
                string fileName      = DateTime.Now.ToString("yyyyMMddHHmmss") + extName;

                string saveFile = path + fileName;
                string showFile = "./File/" + fileName;

                FileUpload1.SaveAs(saveFile);
                news.RelateFile = showFile;
            }
            dal.Addnews(news);
            ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('新闻发布成功!');</script>");
        }
Esempio n. 3
0
        protected void submit_Click(object sender, EventArgs e)
        {
            DALnew    dal  = new DALnew();
            newEntity news = new newEntity();

            news.Title       = desc1.Value;
            news.Content     = desc.Value;
            news.Author      = Session["uName"].ToString();
            news.ReleaseTime = System.DateTime.Now;
            dal.Addnews(news);
            ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('新闻编辑成功');</script>");
        }