




已閱讀5頁(yè),還剩13頁(yè)未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
namespace BookManage public partial class frmLogin : Form public frmLogin() InitializeComponent(); private void btnLogin_Click(object sender, EventArgs e) /驗(yàn)證通過(guò) if (Validate() string state = this.cboUserType.Text; int num; if (state.Equals(管理員)/判斷用戶角色 num = 1; else if (state.Equals(后臺(tái)管理) num = 2; else num = 3; /定義查詢語(yǔ)句 string sql = string.Format(select * from userinfo where uname=0and upwd=1 and ustate=2, this.txName.Text.Trim(),this.txtPwd.Text.Trim(),num); DataSet ds = DataAccess.GetDataSetBySql(sql); if (ds.Tables0.Rows.Count 0) MessageBox.Show(登錄成功); Constans.UserBookID = ds.Tables0.Rows0UBookID.ToString(); Constans.UserName = ds.Tables0.Rows0UName.ToString(); Constans.UserState = ds.Tables0.Rows0UState.ToString(); if(num=1) frmMain.result = DialogResult.OK; this.Hide(); frmMain main = new frmMain(); main.ShowDialog(); else if (num = 2) frmBookInStore store = new frmBookInStore(); store.ShowDialog(); else frmBookJY jy = new frmBookJY(); jy.ShowDialog(); else MessageBox.Show(用戶名或密碼錯(cuò)誤); private void frmLogin_Load(object sender, EventArgs e) this.cboUserType.SelectedIndex = 0; /驗(yàn)證方法 private bool Vaildate() if (this.txName.Text != string.Empty & this.txtPwd.Text != string.Empty) return true; else MessageBox.Show(用戶名或密碼不能為空); return false; private void btnCancle_Click(object sender, EventArgs e) this.Close(); namespace BookManage public partial class frmMain : Form public static DialogResult result; public frmMain() InitializeComponent(); /查詢子窗體是否存在 public bool checkchildfrm(string childfrmname) foreach (Form childFrm in this.MdiChildren) if (childFrm.Name = childfrmname) if (childFrm.WindowState = FormWindowState.Minimized) childFrm.WindowState = FormWindowState.Normal; childFrm.Activate(); return true; return false; /用戶登錄菜單的事件處理 private void 用戶登錄ToolStripMenuItem_Click(object sender, EventArgs e) /檢測(cè)該窗口是否處于打開狀態(tài) if (this.checkchildfrm(frmLogin) = true) return; /窗口已經(jīng)打開,返回 frmLogin user = new frmLogin();/實(shí)例化登錄窗體 user.ShowDialog(); /登錄窗體以模式對(duì)話框的方式的打開 /判斷是否登錄成功,登錄成功則啟用相應(yīng)的菜單和按鈕 if (result = DialogResult.OK) this.tsbtnAddBook.Enabled = true; this.mnuUpdateBook.Enabled = true; this.mnuAddBook.Enabled = true; /登錄按鈕事件處理 private void tsbtnLogin_Click(object sender, EventArgs e) if (this.checkchildfrm(frmLogin) = true) return; frmLogin user = new frmLogin(); user.ShowDialog(); if (result = DialogResult.OK) this.tsbtnAddBook.Enabled = true; this.mnuUpdateBook.Enabled = true; this.mnuAddBook.Enabled = true; /圖書查詢按鈕Click事件處理 private void tsbtnSearch_Click(object sender, EventArgs e) frmBookSearch frmbs = new frmBookSearch(); frmbs.ShowDialog(); /圖書檢索菜單Click事件處理 private void 圖書檢索ToolStripMenuItem_Click(object sender, EventArgs e) frmBookSearch frmbs = new frmBookSearch(); frmbs.ShowDialog(); /圖書入庫(kù)菜單Click事件處理 private void 圖書入庫(kù)ToolStripMenuItem1_Click(object sender, EventArgs e) frmBookInStore bookinstore = new frmBookInStore(); bookinstore.ShowDialog(); /圖書入庫(kù)按鈕Click事件處理 private void tsbtnAddBook_Click(object sender, EventArgs e) frmTsgx tsgx = new frmTsgx(); tsgx.ShowDialog(); /圖書更新菜單Click事件處理 private void 圖書修改ToolStripMenuItem_Click(object sender, EventArgs e) frmTsgx tsgx = new frmTsgx(); tsgx.ShowDialog(); /圖書借閱按鈕事件處理 private void tsbtnIssue_Click(object sender, EventArgs e) frmBookJY bookjy = new frmBookJY(); bookjy.ShowDialog(); private void tsbtnExit_Click(object sender, EventArgs e) Application.Exit(); private void 退出ToolStripMenuItem1_Click(object sender, EventArgs e) Application.Exit(); private void 退出ToolStripMenuItem_Click(object sender, EventArgs e) Application.Exit(); /窗體載入時(shí)事件處理 private void FrmMain_Load(object sender, EventArgs e) /this.tsbtnAddBook.Enabled = false; /this.mnuAddBook.Enabled = false; /this.mnuUpdateBook.Enabled = false; /在關(guān)閉主窗體的同時(shí),關(guān)閉整個(gè)系統(tǒng) private void frmMain_FormClosed(object sender, FormClosedEventArgs e) Application.Exit(); private void 圖書借閱ToolStripMenuItem_Click(object sender, EventArgs e) frmBookJY bookJy = new frmBookJY(); bookJy.ShowDialog(); private void 圖書歸還ToolStripMenuItem_Click(object sender, EventArgs e) frmBookReturn frmreturn = new frmBookReturn(); frmreturn.ShowDialog(); private void 注冊(cè)ToolStripMenuItem_Click(object sender, EventArgs e) frmUserZC zc = new frmUserZC(); zc.ShowDialog(); namespace BookManage public partial class frmBookInStore : Form public frmBookInStore() InitializeComponent(); private void BookInStore_Load(object sender, EventArgs e) DataSet Myds = DataAccess.GetDataSetBySql(select * from BookInfo); DataTable table = Myds.Tables0; this.dataGridView1.DataSource = table; private void btnExit_Click(object sender, EventArgs e) this.Close(); private void btnInsert_Click(object sender, EventArgs e) string bookname = this.txtBookName.Text; string booktype = this.txtBookType.Text; string author = this.txtAuthor.Text; string cbs = this.txtCBS.Text;/出版商 int kc =Convert.ToInt32( this.txtKC.Text);/庫(kù)存 int kjysl =Convert.ToInt32( this.txtKJY.Text);/可借閱數(shù)量 string sql = string.Format(insert into BookInfo values(0,1,2,3,4,5), booktype,bookname, author, cbs, kc, kjysl); if (DataAccess.UpdateDataTable(sql) MessageBox.Show(添加成功!, 提示); else MessageBox.Show(添加失??!,提示,MessageBoxButtons.OK); DataSet Myds = DataAccess.GetDataSetBySql(select * from BookInfo); DataTable table=Myds.Tables0; this.dataGridView1.DataSource = table; public bool Validate() return true; namespace BookManage public partial class frmTsgx : Form public frmTsgx() InitializeComponent(); private void btnClose_Click(object sender, EventArgs e) this.Close(); private void frmTsgx_Load(object sender, EventArgs e) DataSet Myds = DataAccess.GetDataSetBySql(select * from BookInfo); DataTable table = Myds.Tables0; dataGridView1.DataSource = table; private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e) int index = dataGridView1.CurrentCell.RowIndex; this.textBox1.Text = this.dataGridView1.Rowsindex.Cells0.Value.ToString().Trim();/圖書編號(hào) this.textBox2.Text = this.dataGridView1.Rowsindex.Cells2.Value.ToString().Trim();/圖書名稱 this.textBox3.Text = this.dataGridView1.Rowsindex.Cells1.Value.ToString().Trim();/圖書類型 this.textBox4.Text = this.dataGridView1.Rowsindex.Cells3.Value.ToString().Trim();/圖書作者 this.textBox5.Text = this.dataGridView1.Rowsindex.Cells4.Value.ToString().Trim();/出版商 this.textBox6.Text = this.dataGridView1.Rowsindex.Cells5.Value.ToString().Trim();/庫(kù)存 this.textBox7.Text = this.dataGridView1.Rowsindex.Cells6.Value.ToString().Trim();/可借閱的數(shù)量 private void btnUpdate_Click(object sender, EventArgs e) string bookname = textBox2.Text.ToString().Trim(); string booktype = textBox3.Text.ToString().Trim(); string bookauthor = textBox4.Text.ToString().Trim(); string bookpublish = textBox5.Text.ToString().Trim(); int bookkc = Convert.ToInt32(textBox6.Text.Trim(); int bookjysl = Convert.ToInt32(textBox7.Text.Trim(); string sql = string.Format(update BookInfo set BookName=0,BookType=1,BookAuthor=2,BookPublish=3,BookKC=4,BookJYSL=5 where BookID=6,bookname,booktype,bookauthor,bookpublish,bookkc,bookjysl,Convert.ToInt32(textBox1.Text); if (DataAccess.UpdateDataTable(sql) MessageBox.Show(更新成功!, 提示, MessageBoxButtons.OK); else MessageBox.Show(更新失敗!,提示,MessageBoxButtons.OK); private void btnSaveEdit_Click(object sender, EventArgs e) string sql = select * from BookInfo; DataSet ds = DataAccess.GetDataSetBySql(sql); DialogResult result = MessageBox.Show(您確實(shí)要將修改保存到數(shù)據(jù)庫(kù)中嗎?,操作提示,MessageBoxButtons.OKCancel,MessageBoxIcon.Question); if(result=DialogResult.OK) DataAccess.UpdateDataSet(ds,sql); MessageBox.Show(保存成功!); dataGridView1.DataSource = DataAccess.GetDataSetBySql(sql).Tables0; namespace BookManage public partial class frmBookSearch : Form public frmBookSearch() InitializeComponent(); private void btnClose_Click(object sender, EventArgs e) this.Close(); private void btnSearch_Click(object sender, EventArgs e) /string cbo1 = this.cboBookType.Text; string booktype = this.cboType2.Text; string bookname = this.txtBookName.Text; string sql=select * from BookInfo where BookType=+booktype+and BookName like %+bookname+%; DataSet Myds = DataAccess.GetDataSetBySql(sql); DataTable table = Myds.Tables0; this.dataGridView1.DataSource = table; private void frmBookSearch_Load(object sender, EventArgs e) DataSet Myds = DataAccess.GetDataSetBySql(select distinct BookType from BookInfo); DataTable table = Myds.Tables0; for (int i = 0; i table.Rows.Count; i+) /this.cboBookType.Items.Add(table.Rowsi0.ToString().Trim(); this.cboType2.Items.Add(table.Rowsi0.ToString().Trim(); / this.cboBookType.SelectedIndex = 0; this.cboType2.SelectedIndex = 0; namespace BookManage public partial class frmBookReturn : Form public frmBookReturn() InitializeComponent(); private void button2_Click(object sender, EventArgs e) this.Close(); private void btnSearch_Click(object sender, EventArgs e) string userbookid = textBox1.Text; string sql=string.Format(select * from IssueInfo where UserBookID=0,userbookid); DataSet Myds = DataAccess.GetDataSetBySql(sql); DataTable table = Myds.Tables0; dataGridView1.DataSource = table; private void button1_Click(object sender, EventArgs e) DateTime time = Convert.ToDateTime(this.textBox9.Text); string bo = boBox2.Text.ToString(); string sql =string.Format( update IssueInfo set ghDateTime=0,Bool=1 where IssID=2,time,bo,Convert.ToInt32(textBox15.Text); if (DataAccess.UpdateDataTable(sql) MessageBox.Show(還書成功!, 提示, MessageBoxButtons.OK); string sql2 = string.Format(update BookInfo set BookKC=BookKC+1 where BookID=0,Convert.ToInt32( this.textBox14.Text.ToString().Trim(); string sq = string.Format(update UserIssue set BookKC=BookKC-1 where UserBookID=0, this.textBox15.Text.ToString(); DataAccess.UpdateDataTable(sql2); DataAccess.UpdateDataTable(sq); else MessageBox.Show(還書失??!,提示,MessageBoxButtons.OK); private void dataGridView1_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) int index = dataGridView1.CurrentCell.RowIndex; this.textBox15.Text = this.dataGridView1.Rowsindex.Cells0.Value.ToString().Trim();/借閱編號(hào) this.textBox14.Text = this.dataGridView1.Rowsindex.Cells1.Value.ToString().Trim();/借書證號(hào) this.textBox13.Text = this.dataGridView1.Rowsindex.Cells2.Value.ToString().Trim();/用戶名 this.textBox12.Text = this.dataGridView1.Rowsindex.Cells3.Value.ToString().Trim();/圖書編號(hào) this.textBox11.Text = this.dataGridView1.Rowsindex.Cells4.Value.ToString().Trim();/圖書名 this.textBox10.Text = this.dataGridView1.Rowsindex.Cells5.Value.ToString().Trim();/借閱時(shí)間 this.textBox9.Text = this.dataGridView1.Rowsindex.Cells6.Value.ToString().Trim();/歸還時(shí)間 private void frmBookReturn_Load(object sender, EventArgs e) boBox2.SelectedIndex = 0; namespace BookManage public partial class frmBookJY : Form DataSet da = new DataSet(); public frmBookJY() InitializeComponent(); private void btnExit_Click(object sender, EventArgs e) this.Close(); private void frmBookJY_Load(object sender, EventArgs e) textBox1.Text = Constans.UserBookID; textBox2.Text = Constans.UserName; DataSet Myds = DataAccess.GetDataSetBySql(select * from IssueInfo); DataTable table = Myds.Tables0; dataGridView1.DataSource = table; da = DataAccess.GetDataSetBySql(select * from BookInfo); boBox1.DataSource = da.Tables0; boBox1.DisplayMember = BookName; boBox1.ValueMember = BookID; boBox2.DataSource = da.Tables0; boBox2.DisplayMember = BookID; boBox2.ValueMember = BookID; private void btnJY_Click(object sender, EventArgs e) string userbookid = textBox1.Text.ToString(); string username = textBox2.Text.ToString(); string bookname = comboBox1.Text.ToString(); string
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 公司演講感悟活動(dòng)方案
- 公司新年大掃除活動(dòng)方案
- 公司朗讀活動(dòng)方案
- 2025年藥劑師執(zhí)業(yè)資格考試試卷及答案
- 2025年新媒體與網(wǎng)絡(luò)傳播課程核心知識(shí)考試試題及答案
- 2025年現(xiàn)代經(jīng)濟(jì)學(xué)與區(qū)域發(fā)展考試試卷及答案
- 2025年數(shù)字圖書館建設(shè)與管理專業(yè)模擬考試卷及答案
- 2025年人際關(guān)系與溝通能力考試試題及答案
- 2025年數(shù)字版權(quán)管理師考試試卷及答案
- 2025年去中心化金融領(lǐng)域職業(yè)資格測(cè)試題及答案
- 02565+24273中醫(yī)藥學(xué)概論
- 電力鐵塔灌注樁施工方案
- 荒山綠化工程建設(shè)項(xiàng)目可行性研究報(bào)告
- 北京理工大學(xué)《數(shù)據(jù)結(jié)構(gòu)與算法設(shè)計(jì)》2022-2023學(xué)年第一學(xué)期期末試卷
- 高速公路運(yùn)營(yíng)公司安全管理
- 【MOOC】電動(dòng)力學(xué)-同濟(jì)大學(xué) 中國(guó)大學(xué)慕課MOOC答案
- 礦井通風(fēng)機(jī)停電停風(fēng)事故專項(xiàng)應(yīng)急預(yù)案樣本(2篇)
- 醫(yī)療新技術(shù)匯報(bào)
- 光伏項(xiàng)目合伙投資協(xié)議書
- 運(yùn)營(yíng)崗位轉(zhuǎn)正述職報(bào)告
- 員工離職協(xié)議書模板
評(píng)論
0/150
提交評(píng)論