Esempio n. 1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";

            object username = context.Session["admin"];

            if (username == null)
            {
                context.Response.Write("未登录!");
                return;
            }
            Admin admin = new Admin(username.ToString());

            News news = new News();

            news.type_id      = int.Parse(context.Request["type_id"]);
            news.title        = context.Request["title"];
            news.contents     = context.Request["content"];
            news.author_id    = admin.id;
            news.author       = admin.name;
            news.publish_time = DateTime.Parse(context.Request["publish_time"]);

            int add = News.AddNews(news);

            if (add == 1)
            {
                context.Response.Write("OK");
                return;
            }
            context.Response.Write("发表失败!");
        }
Esempio n. 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         string title     = textBox1.Text;
         int    topicID   = Convert.ToInt32(comboBox1.SelectedValue);
         string shortDesc = textBox2.Text;
         string longDesc  = richTextBox1.Text;
         string img       = imgLink;
         //E:\C#\Project\ProjectWeb\Images
         string   imgfix   = imgLink.Substring(24);
         DateTime dateTime = DateTime.Now;
         string   datetime = dateTime.ToString();
         n = new News(title, shortDesc, longDesc, imgfix, datetime, topicID, writer);
         n.AddNews();
         MessageBox.Show("Add Succesfully");
         Project.Files.WriteFile("Add New Post by " + writer + " ");
         this.Dispose();
     }catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }