Form_Publisher_BookManagement.cs
上传用户:chinapurv
上传日期:2014-03-12
资源大小:4870k
文件大小:21k
源码类别:
教育系统应用
开发平台:
C#
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- namespace 图书管理系统
- {
- /// <summary>
- /// Form_Publisher_BookManagemant 的摘要说明。
- /// </summary>
- public class Form_Publisher_BookManagement : System.Windows.Forms.Form
- {
- private System.Windows.Forms.Label label4;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.TextBox bookpublishdate;
- private System.Windows.Forms.TextBox bookinfo;
- private System.Windows.Forms.TextBox bookname;
- private System.Windows.Forms.TextBox bookISBN;
- private System.Windows.Forms.Label label6;
- private System.Windows.Forms.Button butLast;
- private System.Windows.Forms.Button butFirst;
- private System.Windows.Forms.Button butNext;
- private System.Windows.Forms.Button butPrev;
- private System.Windows.Forms.Label label5;
- private System.Windows.Forms.Button butSearch;
- private System.Windows.Forms.Button butAll;
- private System.Windows.Forms.Button butThisYear;
- private System.Windows.Forms.Button butThisQuarter;
- private System.Windows.Forms.Button butBuy;
- private System.Windows.Forms.Button butAdd;
- private System.Windows.Forms.Button butAlter;
- private System.Windows.Forms.Button butDelete;
- private System.Windows.Forms.TextBox pressname;
- private System.Windows.Forms.Label label7;
- private System.Windows.Forms.TextBox bookinprice;
- private System.Windows.Forms.TextBox textForSearch;
- /// <summary>
- /// 必需的设计器变量。
- /// </summary>
- private System.ComponentModel.Container components = null;
- public Form_Publisher_BookManagement()
- {
- //
- // Windows 窗体设计器支持所必需的
- //
- InitializeComponent();
- //
- // TODO: 在 InitializeComponent 调用后添加任何构造函数代码
- //
- }
- /// <summary>
- /// 清理所有正在使用的资源。
- /// </summary>
- protected override void Dispose( bool disposing )
- {
- if( disposing )
- {
- if(components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
- #region Windows 窗体设计器生成的代码
- /// <summary>
- /// 设计器支持所需的方法 - 不要使用代码编辑器修改
- /// 此方法的内容。
- /// </summary>
- private void InitializeComponent()
- {
- System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form_Publisher_BookManagement));
- this.bookpublishdate = new System.Windows.Forms.TextBox();
- this.bookinfo = new System.Windows.Forms.TextBox();
- this.bookname = new System.Windows.Forms.TextBox();
- this.bookISBN = new System.Windows.Forms.TextBox();
- this.label4 = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.label1 = new System.Windows.Forms.Label();
- this.bookinprice = new System.Windows.Forms.TextBox();
- this.label6 = new System.Windows.Forms.Label();
- this.butAll = new System.Windows.Forms.Button();
- this.butThisYear = new System.Windows.Forms.Button();
- this.butThisQuarter = new System.Windows.Forms.Button();
- this.butBuy = new System.Windows.Forms.Button();
- this.butLast = new System.Windows.Forms.Button();
- this.butFirst = new System.Windows.Forms.Button();
- this.butNext = new System.Windows.Forms.Button();
- this.butPrev = new System.Windows.Forms.Button();
- this.textForSearch = new System.Windows.Forms.TextBox();
- this.label5 = new System.Windows.Forms.Label();
- this.butSearch = new System.Windows.Forms.Button();
- this.butAdd = new System.Windows.Forms.Button();
- this.butAlter = new System.Windows.Forms.Button();
- this.butDelete = new System.Windows.Forms.Button();
- this.pressname = new System.Windows.Forms.TextBox();
- this.label7 = new System.Windows.Forms.Label();
- this.SuspendLayout();
- //
- // bookpublishdate
- //
- this.bookpublishdate.Location = new System.Drawing.Point(196, 152);
- this.bookpublishdate.Name = "bookpublishdate";
- this.bookpublishdate.ReadOnly = true;
- this.bookpublishdate.Size = new System.Drawing.Size(200, 21);
- this.bookpublishdate.TabIndex = 15;
- this.bookpublishdate.Text = "bookpublishdate";
- //
- // bookinfo
- //
- this.bookinfo.Location = new System.Drawing.Point(196, 120);
- this.bookinfo.Name = "bookinfo";
- this.bookinfo.ReadOnly = true;
- this.bookinfo.Size = new System.Drawing.Size(200, 21);
- this.bookinfo.TabIndex = 14;
- this.bookinfo.Text = "bookinfo";
- //
- // bookname
- //
- this.bookname.Location = new System.Drawing.Point(196, 88);
- this.bookname.Name = "bookname";
- this.bookname.ReadOnly = true;
- this.bookname.Size = new System.Drawing.Size(200, 21);
- this.bookname.TabIndex = 13;
- this.bookname.Text = "bookname";
- //
- // bookISBN
- //
- this.bookISBN.Location = new System.Drawing.Point(196, 56);
- this.bookISBN.Name = "bookISBN";
- this.bookISBN.ReadOnly = true;
- this.bookISBN.Size = new System.Drawing.Size(200, 21);
- this.bookISBN.TabIndex = 12;
- this.bookISBN.Text = "bookISBN";
- //
- // label4
- //
- this.label4.BackColor = System.Drawing.Color.Transparent;
- this.label4.Location = new System.Drawing.Point(68, 152);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(112, 16);
- this.label4.TabIndex = 11;
- this.label4.Text = "出版日期";
- //
- // label3
- //
- this.label3.BackColor = System.Drawing.Color.Transparent;
- this.label3.Location = new System.Drawing.Point(68, 120);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(112, 16);
- this.label3.TabIndex = 10;
- this.label3.Text = "图书简介";
- //
- // label2
- //
- this.label2.BackColor = System.Drawing.Color.Transparent;
- this.label2.Location = new System.Drawing.Point(68, 88);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(112, 16);
- this.label2.TabIndex = 9;
- this.label2.Text = "图书名称";
- //
- // label1
- //
- this.label1.BackColor = System.Drawing.Color.Transparent;
- this.label1.Location = new System.Drawing.Point(68, 56);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(112, 16);
- this.label1.TabIndex = 8;
- this.label1.Text = "ISBN号";
- //
- // bookinprice
- //
- this.bookinprice.Location = new System.Drawing.Point(196, 184);
- this.bookinprice.Name = "bookinprice";
- this.bookinprice.ReadOnly = true;
- this.bookinprice.Size = new System.Drawing.Size(200, 21);
- this.bookinprice.TabIndex = 18;
- this.bookinprice.Text = "bookinprice";
- //
- // label6
- //
- this.label6.BackColor = System.Drawing.Color.Transparent;
- this.label6.Location = new System.Drawing.Point(68, 184);
- this.label6.Name = "label6";
- this.label6.Size = new System.Drawing.Size(112, 16);
- this.label6.TabIndex = 16;
- this.label6.Text = "图书售价";
- //
- // butAll
- //
- this.butAll.BackColor = System.Drawing.Color.Transparent;
- this.butAll.Location = new System.Drawing.Point(360, 240);
- this.butAll.Name = "butAll";
- this.butAll.Size = new System.Drawing.Size(56, 24);
- this.butAll.TabIndex = 35;
- this.butAll.Text = "全部";
- this.butAll.Click += new System.EventHandler(this.butAll_Click);
- //
- // butThisYear
- //
- this.butThisYear.BackColor = System.Drawing.Color.Transparent;
- this.butThisYear.Location = new System.Drawing.Point(304, 240);
- this.butThisYear.Name = "butThisYear";
- this.butThisYear.Size = new System.Drawing.Size(56, 24);
- this.butThisYear.TabIndex = 32;
- this.butThisYear.Text = "今年";
- this.butThisYear.Click += new System.EventHandler(this.butThisYear_Click);
- //
- // butThisQuarter
- //
- this.butThisQuarter.BackColor = System.Drawing.Color.Transparent;
- this.butThisQuarter.Location = new System.Drawing.Point(248, 240);
- this.butThisQuarter.Name = "butThisQuarter";
- this.butThisQuarter.Size = new System.Drawing.Size(56, 24);
- this.butThisQuarter.TabIndex = 31;
- this.butThisQuarter.Text = "本季度";
- this.butThisQuarter.Click += new System.EventHandler(this.butThisQuarter_Click);
- //
- // butBuy
- //
- this.butBuy.BackColor = System.Drawing.Color.Transparent;
- this.butBuy.Location = new System.Drawing.Point(40, 240);
- this.butBuy.Name = "butBuy";
- this.butBuy.Size = new System.Drawing.Size(64, 24);
- this.butBuy.TabIndex = 30;
- this.butBuy.Text = "购入图书";
- this.butBuy.Click += new System.EventHandler(this.butBuy_Click);
- //
- // butLast
- //
- this.butLast.BackColor = System.Drawing.Color.Transparent;
- this.butLast.Location = new System.Drawing.Point(280, 312);
- this.butLast.Name = "butLast";
- this.butLast.Size = new System.Drawing.Size(48, 24);
- this.butLast.TabIndex = 39;
- this.butLast.Text = ">|";
- this.butLast.Click += new System.EventHandler(this.butLast_Click);
- //
- // butFirst
- //
- this.butFirst.BackColor = System.Drawing.Color.Transparent;
- this.butFirst.Location = new System.Drawing.Point(136, 312);
- this.butFirst.Name = "butFirst";
- this.butFirst.Size = new System.Drawing.Size(48, 24);
- this.butFirst.TabIndex = 38;
- this.butFirst.Text = "|<";
- this.butFirst.Click += new System.EventHandler(this.butFirst_Click);
- //
- // butNext
- //
- this.butNext.BackColor = System.Drawing.Color.Transparent;
- this.butNext.Location = new System.Drawing.Point(232, 312);
- this.butNext.Name = "butNext";
- this.butNext.Size = new System.Drawing.Size(48, 24);
- this.butNext.TabIndex = 37;
- this.butNext.Text = ">";
- this.butNext.Click += new System.EventHandler(this.butNext_Click);
- //
- // butPrev
- //
- this.butPrev.BackColor = System.Drawing.Color.Transparent;
- this.butPrev.Location = new System.Drawing.Point(184, 312);
- this.butPrev.Name = "butPrev";
- this.butPrev.Size = new System.Drawing.Size(48, 24);
- this.butPrev.TabIndex = 36;
- this.butPrev.Text = "<";
- this.butPrev.Click += new System.EventHandler(this.butPrev_Click);
- //
- // textForSearch
- //
- this.textForSearch.Location = new System.Drawing.Point(176, 280);
- this.textForSearch.Name = "textForSearch";
- this.textForSearch.Size = new System.Drawing.Size(152, 21);
- this.textForSearch.TabIndex = 40;
- this.textForSearch.Text = "在此输入图书名称";
- //
- // label5
- //
- this.label5.BackColor = System.Drawing.Color.Transparent;
- this.label5.Location = new System.Drawing.Point(72, 280);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(96, 16);
- this.label5.TabIndex = 41;
- this.label5.Text = "按图书名称查找";
- //
- // butSearch
- //
- this.butSearch.BackColor = System.Drawing.Color.Transparent;
- this.butSearch.Location = new System.Drawing.Point(336, 280);
- this.butSearch.Name = "butSearch";
- this.butSearch.Size = new System.Drawing.Size(48, 24);
- this.butSearch.TabIndex = 42;
- this.butSearch.Text = "查找图书";
- this.butSearch.Click += new System.EventHandler(this.butSearch_Click);
- //
- // butAdd
- //
- this.butAdd.BackColor = System.Drawing.Color.Transparent;
- this.butAdd.Location = new System.Drawing.Point(152, 240);
- this.butAdd.Name = "butAdd";
- this.butAdd.Size = new System.Drawing.Size(48, 24);
- this.butAdd.TabIndex = 44;
- this.butAdd.Text = "添加";
- this.butAdd.Click += new System.EventHandler(this.butAdd_Click);
- //
- // butAlter
- //
- this.butAlter.BackColor = System.Drawing.Color.Transparent;
- this.butAlter.Location = new System.Drawing.Point(104, 240);
- this.butAlter.Name = "butAlter";
- this.butAlter.Size = new System.Drawing.Size(48, 24);
- this.butAlter.TabIndex = 43;
- this.butAlter.Text = "修改";
- this.butAlter.Click += new System.EventHandler(this.butAlter_Click);
- //
- // butDelete
- //
- this.butDelete.BackColor = System.Drawing.Color.Transparent;
- this.butDelete.Location = new System.Drawing.Point(200, 240);
- this.butDelete.Name = "butDelete";
- this.butDelete.Size = new System.Drawing.Size(48, 24);
- this.butDelete.TabIndex = 45;
- this.butDelete.Text = "删除";
- this.butDelete.Click += new System.EventHandler(this.butDelete_Click);
- //
- // pressname
- //
- this.pressname.Location = new System.Drawing.Point(196, 24);
- this.pressname.Name = "pressname";
- this.pressname.ReadOnly = true;
- this.pressname.Size = new System.Drawing.Size(200, 21);
- this.pressname.TabIndex = 47;
- this.pressname.Text = "pressname";
- //
- // label7
- //
- this.label7.BackColor = System.Drawing.Color.Transparent;
- this.label7.Location = new System.Drawing.Point(68, 24);
- this.label7.Name = "label7";
- this.label7.Size = new System.Drawing.Size(112, 16);
- this.label7.TabIndex = 46;
- this.label7.Text = "出版社";
- //
- // Form_Publisher_BookManagement
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
- this.ClientSize = new System.Drawing.Size(464, 348);
- this.Controls.Add(this.pressname);
- this.Controls.Add(this.textForSearch);
- this.Controls.Add(this.bookinprice);
- this.Controls.Add(this.bookpublishdate);
- this.Controls.Add(this.bookinfo);
- this.Controls.Add(this.bookname);
- this.Controls.Add(this.bookISBN);
- this.Controls.Add(this.label7);
- this.Controls.Add(this.butDelete);
- this.Controls.Add(this.butAdd);
- this.Controls.Add(this.butAlter);
- this.Controls.Add(this.butSearch);
- this.Controls.Add(this.label5);
- this.Controls.Add(this.butLast);
- this.Controls.Add(this.butFirst);
- this.Controls.Add(this.butNext);
- this.Controls.Add(this.butPrev);
- this.Controls.Add(this.butAll);
- this.Controls.Add(this.butThisYear);
- this.Controls.Add(this.butThisQuarter);
- this.Controls.Add(this.butBuy);
- this.Controls.Add(this.label6);
- this.Controls.Add(this.label4);
- this.Controls.Add(this.label3);
- this.Controls.Add(this.label2);
- this.Controls.Add(this.label1);
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
- this.Name = "Form_Publisher_BookManagement";
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
- this.Text = "出版社书目信息管理";
- this.Load += new System.EventHandler(this.Form_Publisher_BookManagement_Load);
- this.ResumeLayout(false);
- }
- #endregion
- private void butBuy_Click(object sender, System.EventArgs e)
- {
- if(bookISBN.Text!="")
- {
- Form_Publisher_BookManagement_Buy child=new Form_Publisher_BookManagement_Buy();
- child.ShowDialog();
- }
- else
- {
- MessageBox.Show("请先选择一本图书!","提示");
- }
- }
- SQL sql;
- string oldbookISBN="";
- public static string BOOKISBN="";
- public static string PRESSNAME="";
- public static string BOOKNAME="";
- public static string BOOKINFO="";
- public static string BOOKPUBLISHDATE="";
- public static string BOOKINPRICE="";
- private string oldbookpublishdate;
- public void show()
- {
- if(sql.rows.GetLength(0)!=0)
- {
- bookISBN.Text=sql.rows[sql.getPos(),0].ToString();
- bookname.Text=sql.rows[sql.getPos(),2].ToString();
- bookinfo.Text=sql.rows[sql.getPos(),3].ToString();
- bookpublishdate.Text=sql.rows[sql.getPos(),4].ToString();
- bookinprice.Text=sql.rows[sql.getPos(),5].ToString();
- }
- else
- {
- bookISBN.Text="";
- bookname.Text="";
- bookinfo.Text="";
- bookpublishdate.Text="";
- bookinprice.Text="";
- MessageBox.Show("无符合查询条件的结果!","提示");
- }
- BOOKISBN=bookISBN.Text;
- PRESSNAME=pressname.Text;
- BOOKNAME=bookname.Text;
- BOOKINFO=bookinfo.Text;
- BOOKPUBLISHDATE=bookpublishdate.Text;
- BOOKINPRICE=bookinprice.Text;
- }
- private void Form_Publisher_BookManagement_Load(object sender, System.EventArgs e)
- {
- pressname.Text=Form_Publisher.Pressname;
- sql=new SQL("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=图书管理系统数据库.mdb");
- sql.ExecuteSQL("select * from 出版社图书信息表 where pressname='"+pressname.Text+"'");
- show();
- }
- private void butFirst_Click(object sender, System.EventArgs e)
- {
- sql.pointToFirst();
- show();
- }
- private void butPrev_Click(object sender, System.EventArgs e)
- {
- sql.pointToPrev();
- show();
- }
- private void butNext_Click(object sender, System.EventArgs e)
- {
- sql.pointToNext();
- show();
- }
- private void butLast_Click(object sender, System.EventArgs e)
- {
- sql.pointToLast();
- show();
- }
- private void butAlter_Click(object sender, System.EventArgs e)
- {
- if(butAlter.Text=="修改")
- {
- butAlter.Text="更新";
- oldbookISBN=bookISBN.Text;
- oldbookpublishdate=bookpublishdate.Text;
- bookISBN.ReadOnly =false;
- bookname.ReadOnly =false;
- bookinfo.ReadOnly =false;
- bookpublishdate.ReadOnly =false;
- bookinprice.ReadOnly =false;
- butAdd.Enabled=false;
- butDelete.Enabled=false;
- butFirst.Enabled=false;
- butPrev.Enabled=false;
- butNext.Enabled=false;
- butLast.Enabled=false;
- butSearch.Enabled=false;
- butBuy.Enabled=false;
- butThisQuarter.Enabled=false;
- butThisYear.Enabled=false;
- butAll.Enabled=false;
- }
- else
- {
- if(STR.IsDate(bookpublishdate.Text)==true)
- {
- if(sql.ExecuteSQL("update 出版社图书信息表 set bookISBN='"+bookISBN.Text+"',pressname='"+pressname.Text+"',bookname='"+bookname.Text+"',bookinfo='"+bookinfo.Text+"',bookpublishdate='"+bookpublishdate.Text+"',bookinprice='"+bookinprice.Text+"' where bookISBN='"+oldbookISBN+"'")
- ==false)
- {
- show();
- }
- }
- else
- {
- MessageBox.Show("时间格式错误!","提示");
- bookpublishdate.Text=oldbookpublishdate;
- }
- bookISBN.ReadOnly =true;
- bookname.ReadOnly =true;
- bookinfo.ReadOnly =true;
- bookpublishdate.ReadOnly =true;
- bookinprice.ReadOnly =true;
- butAlter.Text="修改";
- butAdd.Enabled=true;
- butDelete.Enabled=true;
- butFirst.Enabled=true;
- butPrev.Enabled=true;
- butNext.Enabled=true;
- butLast.Enabled=true;
- butSearch.Enabled=true;
- butBuy.Enabled=true;
- butThisQuarter.Enabled=true;
- butThisYear.Enabled=true;
- butAll.Enabled=true;
- }
- }
- private void butAdd_Click(object sender, System.EventArgs e)
- {
- if(butAdd.Text=="添加")
- {
- butAdd.Text="提交";
- bookISBN.Text="";
- bookname.Text="";
- bookinfo.Text="";
- bookpublishdate.Text="";
- bookinprice.Text="";
- bookISBN.ReadOnly =false;
- bookname.ReadOnly =false;
- bookinfo.ReadOnly =false;
- bookpublishdate.ReadOnly =false;
- bookinprice.ReadOnly =false;
- butAlter.Enabled=false;
- butDelete.Enabled=false;
- butFirst.Enabled=false;
- butPrev.Enabled=false;
- butNext.Enabled=false;
- butLast.Enabled=false;
- butSearch.Enabled=false;
- butBuy.Enabled=false;
- butThisQuarter.Enabled=false;
- butThisYear.Enabled=false;
- butAll.Enabled=false;
- }
- else
- {
- if(STR.IsDate(bookpublishdate.Text)==true)
- {
- if(sql.ExecuteSQL("insert into 出版社图书信息表 values('"+bookISBN.Text+"','"+pressname.Text+"','"+bookname.Text+"','"+bookinfo.Text+"','"+bookpublishdate.Text+"','"+bookinprice.Text+"')")
- ==false)
- {
- show();
- }
- }
- else
- {
- MessageBox.Show("时间格式错误!","提示");
- show();
- }
- bookISBN.ReadOnly =true;
- bookname.ReadOnly =true;
- bookinfo.ReadOnly =true;
- bookpublishdate.ReadOnly =true;
- bookinprice.ReadOnly =true;
- butAdd.Text="添加";
- butAlter.Enabled=true;
- butDelete.Enabled=true;
- butFirst.Enabled=true;
- butPrev.Enabled=true;
- butNext.Enabled=true;
- butLast.Enabled=true;
- butSearch.Enabled=true;
- butBuy.Enabled=true;
- butThisQuarter.Enabled=true;
- butThisYear.Enabled=true;
- butAll.Enabled=true;
- }
- }
- private void butDelete_Click(object sender, System.EventArgs e)
- {
- sql.ExecuteSQL("delete from 出版社图书信息表 where bookISBN='"+bookISBN.Text+"'");
- show();
- }
- private void butThisQuarter_Click(object sender, System.EventArgs e)
- {
- int month=System.DateTime.Now.Month;
- int space=(3-month%3)%3;
- string min=System.DateTime.Now.Year.ToString()+STR.add0(Convert.ToString(month+space-2))+"00";
- string max=System.DateTime.Now.Year.ToString()+STR.add0(Convert.ToString(month+space))+"99";
- sql.ExecuteSQL("select * from 出版社图书信息表 where bookpublishdate>'"+min+"' and bookpublishdate<'"+max+"'");
- show();
- }
- private void butThisYear_Click(object sender, System.EventArgs e)
- {
- string min=System.DateTime.Now.Year.ToString()+"0000";
- string max=System.DateTime.Now.Year.ToString()+"9999";
- sql.ExecuteSQL("select * from 出版社图书信息表 where bookpublishdate>'"+min+"' and bookpublishdate<'"+max+"'");
- show();
- }
- private void butAll_Click(object sender, System.EventArgs e)
- {
- sql.ExecuteSQL("select * from 出版社图书信息表 where pressname='"+pressname.Text+"'");
- show();
- }
- private void butSearch_Click(object sender, System.EventArgs e)
- {
- sql.ExecuteSQL("select * from 出版社图书信息表 where bookname='"+textForSearch.Text+"'");
- show();
- }
- }
- }