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

.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 BusinessLogicLayer;
  14. using Model;
  15. namespace Web.SysAdmin
  16. {
  17.     public partial class ModifyBook : System.Web.UI.Page
  18.     {
  19.         protected void Page_Load(object sender, EventArgs e)
  20.         {
  21.             if (!IsPostBack)
  22.             {
  23.                 BindTable();
  24.             }
  25.           
  26.         }
  27.         public void BindTable()
  28.         {
  29.          
  30.             BLLBook bllBook = new BLLBook();
  31.             string bookID = Request["bookID"].ToString();
  32.             BookInfo bookIf= bllBook.GetBookInfo(bookID);
  33.             //绑定所有文本框
  34.             this.txtName.Text = bookIf.BookName;
  35.             this.txtIndex.Text = bookIf.BookIndex;
  36.             
  37.             this.txtAuthor.Text = bookIf.Author;
  38.             this.txtPublish.Text = bookIf.Publish;
  39.             this.txtPrice.Text = bookIf.Price.ToString("F02");//显示小数点后2位
  40.             this.txtSubject.Text = bookIf.Keyword;
  41.             this.txtDescription.Text = bookIf.Abstrac;
  42.             //绑定图书类型
  43.             int bookType = bookIf.BookTypeID;
  44.             switch(bookType){
  45.                 case 1:
  46.                     this.rblClassify.SelectedIndex=0;
  47.                     break;
  48.                 case 2:
  49.                     this.rblClassify.SelectedIndex=1;
  50.                     break;
  51.                 case 3:
  52.                      this.rblClassify.SelectedIndex=2;
  53.                      break;
  54.                 case 4:
  55.                     this.rblClassify.SelectedIndex=3;
  56.                      break;
  57.             }
  58.             //绑定出版时间
  59.             DateTime publishDate = bookIf.PublishDate;
  60.             int year = publishDate.Year;
  61.             int month = publishDate.Month;
  62.             int day = publishDate.Day;
  63.             for (int i = 1999; i < 2010; i++)
  64.             {
  65.                 ddlYear.Items.Add(i.ToString());
  66.              
  67.                
  68.             }
  69.             for (int i = 1; i < 13; i++)
  70.             {
  71.                 ddlMonth.Items.Add(i.ToString());
  72.             }
  73.             for (int i = 1; i < 32; i++)
  74.             {
  75.                 ddlDay.Items.Add(i.ToString());
  76.             }
  77.             //显示对应的值
  78.             ddlYear.SelectedValue = year.ToString();
  79.             ddlMonth.SelectedValue = month.ToString();
  80.             ddlDay.SelectedValue = day.ToString();
  81.         }
  82.         protected void imgBtnUpdate_Click(object sender, ImageClickEventArgs e)
  83.         {
  84.             //取得各个控件的值,创建bookInfo对象
  85.             BookInfo bkInfo = new BookInfo();
  86.             bkInfo.BookID = Request["bookID"].ToString().Trim();
  87.             bkInfo.BookName = txtName.Text.Trim();
  88.             bkInfo.BookIndex = txtIndex.Text.Trim();
  89.             bkInfo.Author = txtAuthor.Text.Trim();
  90.             bkInfo.Publish = txtPublish.Text.Trim();
  91.             bkInfo.Price = Convert.ToDouble(txtPrice.Text.Trim());
  92.             bkInfo.Keyword = txtSubject.Text.Trim();
  93.             bkInfo.Abstrac = txtDescription.Text.Trim();
  94.             bkInfo.BookTypeID = Convert.ToInt16(rblClassify.SelectedValue) + 1;
  95.             bkInfo.PublishDate = Convert.ToDateTime(ddlYear.SelectedItem.Text + "-" + ddlMonth.SelectedItem.Text + "-" + ddlDay.SelectedItem.Text);
  96.             //交给BBL处理
  97.             BLLBook bllBook = new BLLBook();
  98.             if (bllBook.UpdateBookInfo(bkInfo))
  99.                 lblMessage.Text = "修改成功!!";
  100.                //  Response.Write("<scritp language=javascript> alert('修改成功')</scritp>");
  101.             else
  102.                 Response.Write("<scritp language=javascript> alert('修改失败')</scritp>");
  103.                // lblMessage.Text = "修改失败!!";
  104.            // BindTable();6
  105.         }
  106.         protected void imgBtnReturn_Click(object sender, ImageClickEventArgs e)
  107.         {
  108.             Response.Redirect("BookList.aspx");
  109.         }
  110.     }
  111. }