图书管理系统 下载本文

计算机科学与工程学院

//定义一个包括数字、大写英文字母和小写英文字母的字符串 string strchar = \; //将strchar字符串转化为数组 //String.Split 方法返回包含此实例中的子字符串(由指定Char数组的元素分隔)的 String 数组。 string[] VcArray = strchar.Split(','); string VNum = \; //记录上次随机数值,尽量避免产生几个一样的随机数 int temp = -1; //采用一个简单的算法以保证生成随机数的不同 Random rand = new Random(); for (int i = 1; i < n + 1; i++) { if (temp != -1) { //unchecked 关键字用于取消整型算术运算和转换的溢出检查。 //DateTime.Ticks 属性获取表示此实例的日期和时间的刻度数。 rand = new Random(i * temp * unchecked((int)DateTime.Now.Ticks)); } //Random.Next 方法返回一个小于所指定最大值的非负随机数。 int t = rand.Next(36); if (temp != -1 && temp == t) { return RandomNum(n); } temp = t; VNum += VcArray[t]; } return VNum;//返回生成的随机数 } using System; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Data.OleDb; using System.Collections; public partial class _Default : System.Web.UI.Page 《数据库系统原理》实验报告

17

计算机科学与工程学院

{ protected void Page_Load(object sender, EventArgs e) { } CommonClass CC = new CommonClass(); protected void RegOK_Click(object sender, EventArgs e) { string uno = this.Uno.Text.ToString().Trim(); string uname = this.Uname.Text.ToString().Trim(); string usex= this.Usex.Text.ToString().Trim(); string udept = this.Udept.Text.ToString().Trim(); string utel = this.Utel.Text.ToString().Trim(); string Sql = \借书证号,姓名,性别,院系,联系方式) values ('\+ uno + \ + uname + \ + usex + \ + udept+ \ + utel + \; try { CC.ExecSQL(Sql); } catch (Exception ex) { Response.Write(CC.MessageBox(ex.Message)); } userreg.Visible = false; UserInfo.Visible = false; bkinfo.Visible = true; bbkinfo.Visible = false; } protected void regbtn_Click(object sender, EventArgs e) { Uno.Text = \; Uname.Text = \; Usex.Text = \; Udept.Text = \; Utel.Text = \; userreg.Visible = true; bkinfo.Visible = false; UserInfo.Visible = false; bbkinfo.Visible = false; } protected void RegCa_Click(object sender, EventArgs e) { userreg.Visible = false; UserInfo.Visible = false; bkinfo.Visible = true; bbkinfo.Visible = false; 《数据库系统原理》实验报告

18

计算机科学与工程学院

} protected void bkmbtn_Click(object sender, EventArgs e) { } protected void usmbtn_Click(object sender, EventArgs e) { seltUser.Text = \; TextBox1.Text = \; TextBox2.Text = \; TextBox3.Text = \; TextBox4.Text = \; bkinfo.Visible = false; UserInfo.Visible = true; userreg.Visible = false; seltUser.Enabled = true; bbkinfo.Visible = false; TextBox1.Enabled = false; TextBox2.Enabled = false; TextBox3.Enabled = false; TextBox4.Enabled = false; saveus.Enabled = false; } protected void upduse_Click(object sender, EventArgs e) { TextBox1.Enabled = true; TextBox2.Enabled = true; TextBox3.Enabled = true; TextBox4.Enabled = true; saveus.Enabled = true; } protected void selbtn_Click1(object sender, EventArgs e) { seltUser.Enabled = false; OleDbConnection conn = CC.GetConnection(); string uno = this.seltUser.Text.ToString().Trim(); string sqlstr = \借书证号='\ + uno+\ ; OleDbCommand cmd = new OleDbCommand(sqlstr, conn); conn.Open(); OleDbDataReader dr = cmd.ExecuteReader(); 《数据库系统原理》实验报告

19

bkinfo.Visible = true; userreg.Visible = false; UserInfo.Visible = false; bbkinfo.Visible = false; 计算机科学与工程学院

while (dr.Read()) { TextBox1.Text = dr[\姓名\].ToString(); TextBox2.Text = dr[\性别\].ToString(); TextBox3.Text = dr[\院系\].ToString(); TextBox4.Text = dr[\联系方式\].ToString(); } conn.Close(); } protected void saveus_Click(object sender, EventArgs e) { string uno = seltUser.Text.ToString().Trim(); string updname = TextBox1.Text.ToString().Trim(); string updsex = TextBox2.Text.ToString().Trim(); string upddept = TextBox3.Text.ToString().Trim(); string updtel = TextBox4.Text.ToString().Trim(); string Sql = \姓名='\ + updname + \性别='\ + updsex + \院系='\ + upddept + \联系方式='\ + updtel + \借书证号='\ + uno + \; try { CC.ExecSQL(Sql); } catch (Exception ex) { Response.Write(CC.MessageBox(ex.Message)); } } protected void back_Click(object sender, EventArgs e) { foreach (ListItem no in bbkList.Items) { if (no.Selected == true) { string uno = bbktext.Text.ToString().Trim(); string bname = no.Value; string Sql = \ [书籍名称]='\ + bname + \; try { CC.ExecSQL(Sql); } catch (Exception ex) { Response.Write(CC.MessageBox(ex.Message)); } } 《数据库系统原理》实验报告

20