public void bindBookType() { string sql = "select * from
tb_bookType";
//获取所有图书类型
ddlBookType.DataSource = dataOperate.getDataset(sql,
"tb_bookType");
//将图书类型绑定到 DropDownList 控件上
ddlBookType.DataTextField = "TypeName"; //设置 DropDownList 控件
的显示文本
ddlBookType.DataValueField = "TypeID"; //设置 DropDownList 控件的值
ddlBookType.DataBind(); } //绑定书架下拉列表
public void bindBookcase() { string sql = "select * from
tb_bookcase";
ddlBookcase.DataSource = dataOperate.getDataset(sql,
"tb_bookcase"); ddlBookcase.DataTextField = "bookcaseName";
ddlBookcase.DataValueField = "bookcaseID";
ddlBookcase.DataBind(); } //生成条形码 public string barcode() { //获
取当前日期的年,月,日转换成字符串类型用于表示条形码
string date = DateTime.Now.Year.ToString() +
DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString(); //获
取当前时间的小时,分钟转换成字符串类型用于表示条形码
string time = DateTime.Now.Hour.ToString()
+DateTime.Now.Second.ToString() ;
return "10"+date +time; //返回一个13位的条形码 }
protected void btnSave_Click(object sender, EventArgs e) { string
bookBarcode = txtBarCode.Text; //获取图书条形码信息
string bookName = txtBookName.Text; //获取图书名称信息
string bookType = ddlBookType.SelectedValue; //获取图书类型信息
string bookcase = ddlBookcase.SelectedValue; //获取书架信息