📄 form_publisher_bookmanagement.cs
字号:
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();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -