




已閱讀5頁,還剩13頁未讀, 繼續(xù)免費閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領(lǐng)
文檔簡介
namespace BookManage public partial class frmLogin : Form public frmLogin() InitializeComponent(); private void btnLogin_Click(object sender, EventArgs e) /驗證通過 if (Validate() string state = this.cboUserType.Text; int num; if (state.Equals(管理員)/判斷用戶角色 num = 1; else if (state.Equals(后臺管理) num = 2; else num = 3; /定義查詢語句 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(用戶名或密碼錯誤); private void frmLogin_Load(object sender, EventArgs e) this.cboUserType.SelectedIndex = 0; /驗證方法 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) /檢測該窗口是否處于打開狀態(tài) if (this.checkchildfrm(frmLogin) = true) return; /窗口已經(jīng)打開,返回 frmLogin user = new frmLogin();/實例化登錄窗體 user.ShowDialog(); /登錄窗體以模式對話框的方式的打開 /判斷是否登錄成功,登錄成功則啟用相應(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(); /圖書入庫菜單Click事件處理 private void 圖書入庫ToolStripMenuItem1_Click(object sender, EventArgs e) frmBookInStore bookinstore = new frmBookInStore(); bookinstore.ShowDialog(); /圖書入庫按鈕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(); /窗體載入時事件處理 private void FrmMain_Load(object sender, EventArgs e) /this.tsbtnAddBook.Enabled = false; /this.mnuAddBook.Enabled = false; /this.mnuUpdateBook.Enabled = false; /在關(guān)閉主窗體的同時,關(guān)閉整個系統(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 注冊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);/庫存 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();/圖書編號 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();/庫存 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ù)據(jù)庫中嗎?,操作提示,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();/借閱編號 this.textBox14.Text = this.dataGridView1.Rowsindex.Cells1.Value.ToString().Trim();/借書證號 this.textBox13.Text = this.dataGridView1.Rowsindex.Cells2.Value.ToString().Trim();/用戶名 this.textBox12.Text = this.dataGridView1.Rowsindex.Cells3.Value.ToString().Trim();/圖書編號 this.textBox11.Text = this.dataGridView1.Rowsindex.Cells4.Value.ToString().Trim();/圖書名 this.textBox10.Text = this.dataGridView1.Rowsindex.Cells5.Value.ToString().Trim();/借閱時間 this.textBox9.Text = this.dataGridView1.Rowsindex.Cells6.Value.ToString().Trim();/歸還時間 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. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 襯砌施工方法及模板裝置
- 健康科技在運動與健身領(lǐng)域的應(yīng)用考核試卷
- 印刷設(shè)備自動化技術(shù)培訓與教育體系研究考核試卷
- 庫存風險管理與企業(yè)信用風險管理整合考核試卷
- 渠道銷售團隊的銷售技能培訓方法考核試卷
- 藍色星球測試題及答案
- 禮儀生活考試題及答案
- 合成氣制備過程中的噪聲控制技術(shù)考核試卷
- 勘查技術(shù)更新與淘汰機制研究考核試卷
- 飛行法規(guī)試題及答案
- 2025呼倫貝爾農(nóng)墾集團有限公司校園招聘44人筆試參考題庫附帶答案詳解析集合
- 2025年數(shù)智供應(yīng)鏈案例集-商務(wù)部
- 護林員考試題及答案
- T/CAPA 008-2022紅光類美容儀器在皮膚健康管理中的應(yīng)用規(guī)范
- 2025屆遼寧省大連市高新園區(qū)七年級數(shù)學第二學期期末考試試題含解析
- 山東省濱州市名校2025屆物理八下期末綜合測試模擬試題含解析
- 醫(yī)療領(lǐng)域AI人才薪酬市場現(xiàn)狀及趨勢
- 金融行業(yè)信息安全培訓
- 醫(yī)療廢物管理
- 山東詠坤新材料科技有限公司年產(chǎn)4000噸鋰鈉電池負極材料生產(chǎn)項目報告書
- 中老年人健康教育宣講
評論
0/150
提交評論