addbook.aspx.cs

来自「2007年华中科技大学数据库课程设计参考程序[图书销售系统]+报告」· CS 代码 · 共 60 行

CS
60
字号
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections;
using System.Collections.Generic;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using OnlineBookSell.BLLFactory;
using OnlineBookSell.Model;
using OnlineBookSell.IBLL;
using OnlineBookSell.DBUtility;

public partial class ljian_admin_Addbook : System.Web.UI.Page
{

    public IBookBLL ibookdll = BLLFactory.getInstance().createBookBLL();
    public IUserBLL iuserdll = BLLFactory.getInstance().createUserBLL();


    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        BookInfo book = new BookInfo();
        book.Addtime = DateTime.Now;
        book.Author = zuozhe.Text.Trim();
        book.BookconcernID = Convert.ToInt32(chubanshe.SelectedValue);
        book.Bookname = bookname.Text.Trim();
        book.Class1 = Convert.ToInt32(bookclass.SelectedValue);
        book.Cost = Convert.ToDouble(cost.Text.Trim());
        book.Edition = edition.Text.Trim();
        book.Format = kaiben.Text.Trim();
        book.Isbn = isbn.Text.Trim();
        book.Price = Convert.ToDouble(price.Text.Trim());
        book.Publishtime = Convert.ToDateTime(mydate.Text.Trim());
        book.Stocks = Convert.ToInt32(kucunliang.Text.Trim());
        book.Summary = beizhu.Text.Trim();
        if(totalpages.Text.Trim()!="")
        book.Totalpages =Convert.ToInt32(totalpages.Text.Trim());
        //try
        //{
            if (ibookdll.AddBook(book))
                System.Web.UI.ScriptManager.RegisterClientScriptBlock(this.Button1, this.Button1.GetType(), "success", "alert('添加成功!');", true);
            else
                System.Web.UI.ScriptManager.RegisterClientScriptBlock(this.Button1, this.Button1.GetType(), "success", "alert('发生错误,请刷新页面重试!');", true);
        //}
        //catch (Exception ex)
        //{
        //    System.Web.UI.ScriptManager.RegisterClientScriptBlock(this.Button1, this.Button1.GetType(), "success", "alert('"+ex.ToString ()+"');", true);
        //}
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?