📄 updatebook.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
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 Model;
using BLL;
using BLL.interfaces;
public partial class updateBook : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
if (Session["userRole"] != null && Session["userRole"].ToString().Equals("管理员"))
{
if (Request["Id"]!=null)
{
ViewState["Id"] = int.Parse(Request["Id"].ToString());
showBookInfo((int)ViewState["Id"]);
}
}
}
}
private void showBookInfo(int id)
{
IBook bookMessage = Factory.greatBook();
List<Book> list = new List<Book>();
list= bookMessage.selctBookInfo(id);
DetailsView1.DataSource = list;
DetailsView1.DataBind();
foreach (Book b in list)
{
DropDownList pub = DetailsView1.FindControl("DropDownList1") as DropDownList;
pub.SelectedIndex = b.PublisherId - 1;
DropDownList cboRole = DetailsView1.FindControl("lstBookType") as DropDownList;
cboRole.SelectedIndex = b.BookTypeId-1;
RadioButtonList rdblst = DetailsView1.FindControl("RadioButtonList1") as RadioButtonList;
rdblst.SelectedIndex = b.Tuijian;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
TextBox txtTitle=DetailsView1.FindControl("txtTitle") as TextBox;
string title = txtTitle.Text;
DropDownList dpub=DetailsView1.FindControl("DropDownList1") as DropDownList;
int pub=dpub.SelectedIndex+1;
TextBox txtpubDate=DetailsView1.FindControl("txtPubData") as TextBox;
string pubDate=txtpubDate.Text;
DropDownList ddbookType=DetailsView1.FindControl("lstBookType") as DropDownList;
int booktype=ddbookType.SelectedIndex+1;
TextBox txtPrice=DetailsView1.FindControl("txtPrice") as TextBox;
string price = txtPrice.Text.Trim();
TextBox txtAotherName=DetailsView1.FindControl("txtAotherName") as TextBox;
string author = txtAotherName.Text;
TextBox txtEmi = DetailsView1.FindControl("txtEmi") as TextBox;
string emi = txtEmi.Text;
TextBox txtAuthorComment = DetailsView1.FindControl("txtAuthorComment") as TextBox;
string authorComments = txtAuthorComment.Text;
TextBox txtIsbn = DetailsView1.FindControl("txtIsbn") as TextBox;
string isbn = txtIsbn.Text.Trim();
TextBox txtwordCount = DetailsView1.FindControl("txtcounts") as TextBox;
string wordCount = txtwordCount.Text.Trim();
TextBox txttoc = DetailsView1.FindControl("txttoc") as TextBox;
string toc = txttoc.Text;
TextBox txtComments = DetailsView1.FindControl("txtcomments") as TextBox;
string comments = txtComments.Text;
RadioButtonList rdblstTJ = DetailsView1.FindControl("RadioButtonList1") as RadioButtonList;
int tuijian = rdblstTJ.SelectedIndex;
string imgUrl = "1";
Book book = new Book();
book.Id = (int)ViewState["Id"];
book.Title = title;
book.PublisherId = pub;
book.PublishDate = DateTime.Parse(pubDate);
book.TypeId = booktype;
book.UnitPrice = Double.Parse(price);
book.Author = author;
book.EditorComment = emi;
book.AuthorDescription = authorComments;
book.ISBN = isbn;
book.WordsCount = int.Parse(wordCount);
book.Img = imgUrl;
book.TOC = toc;
book.ContentDescription = comments;
book.SimplePY = "1241";
book.Tuijian = tuijian;
IBook bookMessage = Factory.greatBook();
if (bookMessage.updateBook(book))
{
ClientScript.RegisterStartupScript(typeof(string), "a", "alert('服务器已经接受您的新资料!\\n操作成功')", true);
}
else
{
Response.Redirect("error.aspx");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -