private void butSure_Click(object sender, EventArgs e) { if (txtBookID.Text.Length == 0 || txtBookName.Text.Length == 0 || txtBookAhour.Text.Length == 0) { MessageBox.Show("图书编号、图书名称、图书作者均不能为空!", "提示"); } else { try { // DateTime time = Convert.ToDateTime(DateTime.Now.ToString()); Dbconnection db = new Dbconnection(); if (this.Text == "图书管理(修改)") { txtBookID.ReadOnly = true; if (MessageBox.Show("您将修改图书编号为:'" + txtBookID.Text.Trim() + "'的信息,是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (db.ExeInfochange("update Book set BookID='" + txtBookID.Text.Trim() + "',Strichcode='" + txtBookCode.Text.Trim() + "',SlassificationID='" + txtSlassificationID.Text.Trim() + "',BookName='" + txtBookName.Text.Trim() + "',Type1='" + cmbBookType.Text.Trim() + "',Author='" + txtBookAhour.Text.Trim() + "',Translator='" + txtTranslator.Text.Trim() + "',ISBN='" + txtISBN.Text.Trim() + "',Publisher='" + cmbBookPublisher.Text.Trim() + "',Revision='" + cmbRevision.Text.Trim() + "',Format='" + cmbFormat.Text.Trim() + "',Word='" + txtBookWord.Text.Trim() + "',Page='" + txtBookPage.Text.Trim() + "',Price='" + txtBookPrice.Text.Trim() + "',EnterTime ='" + dateTimePicker1.Text.Trim() + "',Qty='" + txtQty.Text.Trim() + "',Extant='" + txtBookExtant.Text.Trim() + "',Circulate='" + cmbCirculate.Text.Trim() + "' where BookID='" + txtBookID.Text.Trim() + "'") == 1) { db.ExeInfochange("update Borrow set BookName='" + txtBookName.Text.Trim() + "',Author='" + txtBookAhour.Text.Trim() + "',Publisher='" + cmbBookPublisher.Text.Trim() + "',Price=" + txtBookPrice.Text.Trim() + " where BookID='" + txtBookID.Text.Trim() + "'"); db.ExeInfochange("update OverdueInfo set BookName='" + txtBookName.Text.Trim() + "',Author='" + txtBookAhour.Text.Trim() + "',Publisher='" + cmbBookPublisher.Text.Trim() + "',Price=" + txtBookPrice.Text.Trim() + " where BookID='" + txtBookID.Text.Trim() + "'"); db.ExeInfochange("update HandleNote set BookName='" + txtBookName.Text.Trim() + "',Price=" + txtBookPrice.Text.Trim() + " where BookStrichcode='" + txtBookID.Text.Trim() + "'"); db.ExeInfochange("update ReserBroInfo set r_BookType='" + cmbBookType.Text.Trim() + "',r_BookName='" + txtBookName.Text.Trim() + "',r_BookAuthor='" + txtBookAhour.Text.Trim() + "',r_BookPrice=" + txtBookPrice.Text.Trim() + " where r_BookId='" + txtBookID.Text.Trim() + "'"); db.ExeInfochange("update Borrow set BookName='" + txtBookName.Text.Trim() + "' where BookID='" + txtBookID.Text.Trim() + "'"); db.ExeInfochange("update RenewNote set BookName='" + txtBookName.Text.Trim() + "',Author='" + txtBookAhour.Text.Trim() + "',Publisher='" + cmbBookPublisher.Text.Trim() + "',Price=" + txtBookPrice.Text.Trim() + " where BookID='" + txtBookID.Text.Trim() + "'"); this.Close(); } else { MessageBox.Show("数据格式不合法,图书修改失败!", "提示"); } } } if (this.Text == "图书管理(添加)") { //txtBookID.ReadOnly = true; //int MdiNumber= dbl.AutoNumber ("select Max(txtBookID) from Book"); //string LastNumber=Convert .ToString (MdiNumber); //txtBookID.Text = LastNumber.Trim(); if (MessageBox.Show("您将添加图书名为:'" + txtBookName.Text.Trim() + "'的信息,是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { int number = dbl.AutoNumber("select max(Number) from Book"); if (db.ExeInfochange("insert into Book values(" + number + ",'" + txtBookID.Text.Trim() + "','" + txtBookCode.Text.Trim() + "','" + txtSlassificationID.Text.Trim() + "','" + txtBookName.Text.Trim() + "','" + cmbBookType.Text.Trim() + "','" + txtBookAhour.Text.Trim() + "','" + txtTranslator.Text.Trim() + "','" + txtISBN.Text.Trim() + "','" + cmbBookPublisher.Text.Trim() + "','" + cmbRevision.Text.Trim() + "','" + cmbFormat.Text.Trim() + "','" + txtBookWord.Text.Trim() + "','" + txtBookPage.Text.Trim() + "','" + txtBookPrice.Text.Trim() + "','" + dateTimePicker1.Text.Trim() + "','" + txtQty.Text.Trim() + "','" + txtBookExtant.Text.Trim() + "','" + cmbCirculate.Text.Trim() + "')") == 1) { this.Close(); } else { MessageBox.Show("此图书已存在或数据不合法,添加失败!", "提示"); } } } } catch (Exception) { ; } } }
private void tsbAdd_Click(object sender, EventArgs e) { string AutoNumber = Convert.ToString(dbl.AutoNumber("select Max(PulNumber) from Publishing")); frmPubChange fpc = new frmPubChange(AutoNumber); fpc.Text = "出版社信息(增加)"; fpc.ShowDialog(); }
private void butOk_Click(object sender, EventArgs e) { string time; time = dateTimePicker1.Text.ToString() + " " + dateTimePicker2.Text.ToString(); if (HandleType == "添加") { int Number = dbl.AutoNumber("select max(Number) from Remind"); if (checkBox2.Checked == true) { dbc.ExeInfochange("insert into Remind values(" + Number + ",'尚未提示','" + time + "','" + txtRemind.Text.Trim() + "','是','" + cmbRemindWay.Text + "','" + txtReaderName.Text.Trim() + "','" + dbl.GetTime(3) + "')"); } if (checkBox2.Checked == false) { dbc.ExeInfochange("insert into Remind values(" + Number + ",'尚未提示','" + time + "','" + txtRemind.Text.Trim() + "','否 ','" + cmbRemindWay.Text + "','" + txtReaderName.Text.Trim() + "','" + dbl.GetTime(3) + "')"); } MessageBox.Show("添加成功!", "提示"); butOk.Enabled = false; butExit.Enabled = false; tsbAdd.Enabled = true; tsbChange.Enabled = true; } if (HandleType == "修改") { if (checkBox2.Checked == true) { dbc.ExeInfochange("update Remind set Statue='尚未提示',RemindTime='" + time + "',Content='" + txtRemind.Text.Trim() + "',IsRemind='是',Type='" + cmbRemindWay.Text + "',IsToReader='" + txtReaderName.Text.Trim() + "'where Number='" + txtRemorandum.Text.Trim() + "'"); } if (checkBox2.Checked == false) { dbc.ExeInfochange("update Remind set Statue='尚未提示',RemindTime='" + time + "',Content='" + txtRemind.Text.Trim() + "',IsRemind='否',Type='" + cmbRemindWay.Text + "',IsToReader='" + txtReaderName.Text.Trim() + "' where Number='" + txtRemorandum.Text.Trim() + "'"); } MessageBox.Show("修改成功!", "提示"); butOk.Enabled = false; butExit.Enabled = false; tsbAdd.Enabled = true; tsbChange.Enabled = true; } txtRemorandum.Clear(); txtReaderName.Clear(); txtRemind.Clear(); Reflseh(); }
private void frmMain_Load(object sender, EventArgs e) { if (frmlogin.type == "普通用户") { 用户管理UToolStripMenuItem.Enabled = false; } //设置时间和日期 tssl1.Text = "今天日期:" + System.DateTime.Now.ToLongDateString(); tssl2.Text = "登录时间:" + System.DateTime.Now.ToLongTimeString(); tsslLoginUser.Text = "当前用户:" + " " + frmlogin.userName; //系统启动时导航栏的状态 listView1.Clear(); listView1.LargeImageList = imageList1; listView1.Items.Add("借阅管理", " 借阅管理", 0); listView1.Items.Add("借阅查询", " 借阅查询", 1); listView1.Items.Add("操作流水", " 操作流水", 2); listView1.Items.Add("预借详情", " 预借详情", 3); listView1.Items.Add("帐务管理", " 帐务管理", 4); listView1.Items.Add("备忘管理", " 备忘管理", 5); //起始窗口布局 层叠窗口CToolStripMenuItem.Checked = true; this.LayoutMdi(MdiLayout.Cascade); 竖排窗口VToolStripMenuItem.Checked = false; 横排窗口HToolStripMenuItem.Checked = false; toolStrip1.AutoSize = false; this.notifyIcon1 = new System.Windows.Forms.NotifyIcon(this.components); notifyIcon1.Visible = false; this.SizeChanged += new System.EventHandler(this.frmMain_SizeChanged); //Rectangle rect = System.Windows.Forms.SystemInformation.VirtualScreen; //获得屏幕宽度 tssl1.Width = this.Width / 5; tssl2.Width = this.Width / 5; tssl3.Width = this.Width / 5; tsslLoginUser.Width = this.Width / 5; //插入登录记录 string time = dbl.GetTime(3); int Number = dbl.AutoNumber("select Max(Number) from Journal"); db.ExeInfochange("insert into Journal values (" + Number + ",'" + frmlogin.userName + "','" + frmlogin.type + "','" + time + "')"); }
private void butAdd_Click(object sender, EventArgs e) { if (txtNumber.Text.Length == 0 || txtName.Text.Length == 0) { MessageBox.Show("借书证号和读者姓名为必填项!", "提示"); //借书证号和姓名为必填项 txtNumber.Focus(); txtNumber.SelectAll(); } else { if (MessageBox.Show("您将添加一位读者,是否继续?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { try { Dbconnection db = new Dbconnection(); Dblink dbl = new Dblink(); int Number = dbl.AutoNumber("select Max(Number) from Reader"); // 添加读者的信息 string sql = "insert into Reader values (" + Number + ",'" + txtNumber.Text.Trim() + "','" + txtName.Text.Trim() + "','0','" + txtBarcode.Text.Trim() + "','" + cmbReadertype.Text.Trim() + "','" + cmbStatu.Text.Trim() + "','" + dateTimePicker1.Text + "','" + dateTimePicker2.Text + "','" + cmbSex.Text + "','" + txtWorkshop.Text.Trim() + "','" + txtPhoneNumber.Text + "')"; if (db.ExeInfochange(sql) == 1) { MessageBox.Show("读者信息添加成功!", "提示"); //ShowAll(); } else { MessageBox.Show("数据长度不符合要求,读者信息添加失败!", "提示"); } } catch (Exception) { ; } } } }
private void butOk_Click(object sender, EventArgs e) { if (cmbDataType.Text == "数据库备份") { try { SqlConnection con = new SqlConnection(); con.ConnectionString = "server=.;database =51asp.net_Library;uid=sa;pwd=51asp.net"; con.Open(); SqlCommand com = new SqlCommand(); //实现数据库备份 com.CommandText = "BACKUP DATABASE " + "Library" + " TO DISK = '" + waybackup + "'"; com.Connection = con; int number = com.ExecuteNonQuery(); if (number == -1) { MessageBox.Show("数据库备份成功!", "提示"); string time = dbl.GetTime(3); int Number1 = dbl.AutoNumber("select Max(Number) from Backupinfo"); string strSql = "insert into Backupinfo values (" + Number1 + ",'" + frmlogin.userName + "','" + time + "','" + cmbDataType.Text + "','" + txtBackupWay.Text + "')"; InserInfo(strSql); } con.Close(); con.Dispose(); } catch (Exception) { MessageBox.Show("数据库备份失败!", "提示"); } } else { if (cmbDataType.Text == "数据库还原") { try { //实现数据库还原 string SqlStr1 = "server=.;database =51asp.net_Library;uid=sa;pwd=51asp.net"; SqlConnection con = new SqlConnection(SqlStr1); con.Open(); string SqlStr2 = "use master restore database " + "Library" + " from disk='" + txtBackupWay.Text + "'"; //string SqlStr2 = "insert into Backupinfo values ('123','2008-12-5','D:')"; SqlCommand cmd = new SqlCommand(SqlStr2, con); cmd.Connection = con; int number = cmd.ExecuteNonQuery(); if (number == -1) { MessageBox.Show("还原数据库成功!", "提示"); string time = dbl.GetTime(3); int Number2 = dbl.AutoNumber("select Max(Number) from Backupinfo"); string strSql1 = "insert into Backupinfo values (," + Number2 + "," + frmlogin.userName + "','" + time + "','" + cmbDataType.Text + "','" + txtBackupWay.Text + "')"; InserInfo(strSql1); } con.Close(); con.Dispose(); } catch (Exception) { //throw new Exception(ce.Message); MessageBox.Show("数据库还原失败!", "提示"); } } } }
private void Borrow(int Txtnumber) { Dbconnection db = new Dbconnection(); try { string time = System.DateTime.Now.ToShortDateString(); //获得今天的时间 string time1 = dbl.GetTime(3); //获得系统参数中的数据 DataSet ds = new DataSet(); ds = dbl.GetDataset("select * from Reader where CardID='" + labCardId.Text.Trim() + "'"); int BroNumber = Convert.ToInt32(ds.Tables[0].Rows[0][3]); //获得读者表中已借的数量 ds = dbl.GetDataset("select * from Book where BookID='" + labBookID.Text.Trim() + "'"); int BookStore = Convert.ToInt32(ds.Tables[0].Rows[0][17]); //获得图书表中的可借出数量 int ReBookQty = BookStore - 1; //更新图书表中的可出借数量 int ReReaderQty = BroNumber + 1; //更新读者已借阅图书的数量 if (labSatue.Text.Trim() == "有效") { if (BroNumber < Txtnumber) { if (BookStore > 1) { string sql = "select * from ReserBroInfo where r_bookid='" + labBookID.Text + "' and r_readerid='" + labCardId.Text + "'"; if (Convert.ToInt32(db.ExecuteSelect(sql)) > 0) { frb.MaximizeBox = false; frb.MinimizeBox = false; frb.Location = new Point(150, 150); frb.ShowDialog(); } else { //向借阅表中添加一条记录 int Number1 = dbl.AutoNumber("select Max(Number) from Borrow"); dbc.ExeInfochange("insert into Borrow values (" + Number1 + ",'" + labCardId.Text.Trim() + "','" + labReaderName.Text.Trim() + "','" + labBookID.Text.Trim() + "','" + labBookName.Text.Trim() + "','" + labAuthor.Text.Trim() + "','" + labPublisher.Text.Trim() + "','" + labPrice.Text.Trim() + "','" + time1 + "','" + dupBookNumber.Text.Trim() + "','" + frmlogin.userName.Trim() + "','" + dupBroTime.Text.Trim() + "','否')"); //向借阅流水表中添加一条记录 int Number2 = dbl.AutoNumber("select Max(HandleNumber) from HandleNote"); dbc.ExeInfochange("insert into HandleNote values (" + Number2 + ",'" + this.Text.Trim() + "','" + frmlogin.userName.Trim() + "','" + labBookName.Text.Trim() + "','" + labBookID.Text.Trim() + "','" + labCardId.Text.Trim() + "','" + labReaderName.Text.Trim() + "','" + labSex.Text.Trim() + "','" + dupBookNumber.Text.Trim() + "','" + labPrice.Text.Trim() + "','" + time1 + "')"); //更新图书表中图书的可借数量 dbc.ExeInfochange("update Book set Extant=" + ReBookQty + " where BookID='" + labBookID.Text.Trim() + "'"); //更新读者表中已借图书的数量 dbc.ExeInfochange("update Reader set BorrowNumber=" + ReReaderQty + " where CardID='" + labCardId.Text.Trim() + "'"); //更新读者已借的图书数量和图书馆藏数量 labBroNumber.Text = Convert.ToString(ReReaderQty); labQty.Text = Convert.ToString(ReBookQty); MessageBox.Show("借书成功!", "提示"); } } else { MessageBox.Show("最后样书,不能出借!", "提示"); } } else { MessageBox.Show("已达到最大借书数量,无法继续借阅!", "提示"); } } else { MessageBox.Show("借书证处于无效状态,无法出借图书!", "提示"); } } catch (Exception) { ; } }