AddBook.aspx.cs
上传用户:gooyliu
上传日期:2018-09-29
资源大小:5816k
文件大小:2k
源码类别:

.net编程

开发平台:

C#

  1. using System;
  2. using System.Collections;
  3. using System.Configuration;
  4. using System.Data;
  5. using System.Linq;
  6. using System.Web;
  7. using System.Web.Security;
  8. using System.Web.UI;
  9. using System.Web.UI.WebControls;
  10. using System.Web.UI.WebControls.WebParts;
  11. using System.Web.UI.HtmlControls;
  12. using System.Xml.Linq;
  13. using Model;
  14. using BusinessLogicLayer;
  15. namespace Web.SysAdmin
  16.     
  17. {
  18.     public partial class AddBook : System.Web.UI.Page
  19.     {
  20.         BLLBook bllBook = new BLLBook();   //BLLBook必须Public
  21.         protected void Page_Load(object sender, EventArgs e)
  22.         {
  23.             //foreach (Control ctrl in Page.Controls)
  24.             //{
  25.             //    ctrl.EnableViewState = false;
  26.             //}
  27.            
  28.             if (!this.IsPostBack)
  29.             {
  30.                 for (int i = 1999; i < 2010; i++)
  31.                 {
  32.                     ddlYear.Items.Add(i.ToString());
  33.                 }
  34.                 for (int i = 1; i < 13; i++)
  35.                 {
  36.                     ddlMonth.Items.Add(i.ToString());
  37.                 }
  38.                 for (int i = 1; i < 32; i++)
  39.                 {
  40.                     ddlDay.Items.Add(i.ToString());
  41.                 }
  42.                 ddlYear.SelectedIndex = 0;
  43.                 ddlMonth.SelectedIndex = 0;
  44.                 ddlDay.SelectedIndex = 0;
  45.             }
  46.             else
  47.             { }
  48.         }
  49.         protected void imgBtnAdd_Click(object sender, ImageClickEventArgs e)
  50.         {
  51.             BookInfo bkInfo = new BookInfo();
  52.             bkInfo.BookID = txtISBN.Text.Trim();
  53.             bkInfo.BookName = txtName.Text.Trim();
  54.             bkInfo.BookIndex = txtIndex.Text.Trim();
  55.             bkInfo.BookTypeID = Convert.ToInt16(rblClassify.SelectedValue) + 1;
  56.             bkInfo.Author = txtAuthor.Text.Trim();
  57.             bkInfo.Publish = txtPublish.Text.Trim();
  58.             bkInfo.Price = Convert.ToDouble(txtPrice.Text.Trim());
  59.             bkInfo.PublishDate =Convert.ToDateTime(ddlYear.SelectedItem.Text + "-" + ddlMonth.SelectedItem.Text + "-" + ddlDay.SelectedItem.Text);
  60.             bkInfo.Abstrac = txtDescription.Text.Trim();
  61.             bkInfo.Keyword = txtSubject.Text.Trim();
  62.             bkInfo.BookStatus = 1;
  63.             bkInfo.RegisteDate = DateTime.Now;
  64.             if (bllBook.AddBook(bkInfo))
  65.                 lblMessage.Text = "Add Success!!";
  66.             else
  67.                 lblMessage.Text = "Not Add!!";
  68.         }
  69.     }
  70. }