Form_Publisher.cs
上传用户:chinapurv
上传日期:2014-03-12
资源大小:4870k
文件大小:18k
- using System;
- using System.Drawing;
- using System.Collections;
- using System.ComponentModel;
- using System.Windows.Forms;
- namespace 图书管理系统
- {
- /// <summary>
- /// Form_Publisher 的摘要说明。
- /// </summary>
- public class Form_Publisher : System.Windows.Forms.Form
- {
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.Label label4;
- private System.Windows.Forms.TextBox pressname;
- private System.Windows.Forms.TextBox presslinkman;
- private System.Windows.Forms.TextBox pressaddress;
- private System.Windows.Forms.TextBox presstelephone;
- private System.Windows.Forms.Button butPrev;
- private System.Windows.Forms.Button butNext;
- private System.Windows.Forms.Button butLast;
- private System.Windows.Forms.Button butFirst;
- private System.Windows.Forms.Button butShowAll;
- private System.Windows.Forms.Label label5;
- private System.Windows.Forms.ComboBox comboBox1;
- private System.Windows.Forms.ComboBox comboBox2;
- private System.Windows.Forms.Button butSearch;
- private System.Windows.Forms.Button butDelete;
- private System.Windows.Forms.Button butAdd;
- private System.Windows.Forms.Button butAlter;
- private System.Windows.Forms.Button butBookManagement;
- private System.Windows.Forms.TextBox textForSearch;
- /// <summary>
- /// 必需的设计器变量。
- /// </summary>
- private System.ComponentModel.Container components = null;
- public Form_Publisher()
- {
- //
- // 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));
- this.label1 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.label3 = new System.Windows.Forms.Label();
- this.label4 = new System.Windows.Forms.Label();
- this.pressname = new System.Windows.Forms.TextBox();
- this.presslinkman = new System.Windows.Forms.TextBox();
- this.pressaddress = new System.Windows.Forms.TextBox();
- this.presstelephone = new System.Windows.Forms.TextBox();
- this.butBookManagement = new System.Windows.Forms.Button();
- this.butPrev = new System.Windows.Forms.Button();
- this.butNext = new System.Windows.Forms.Button();
- this.butLast = new System.Windows.Forms.Button();
- this.butFirst = new System.Windows.Forms.Button();
- this.butShowAll = new System.Windows.Forms.Button();
- this.label5 = new System.Windows.Forms.Label();
- this.comboBox1 = new System.Windows.Forms.ComboBox();
- this.butSearch = new System.Windows.Forms.Button();
- this.textForSearch = new System.Windows.Forms.TextBox();
- this.comboBox2 = new System.Windows.Forms.ComboBox();
- this.butDelete = new System.Windows.Forms.Button();
- this.butAdd = new System.Windows.Forms.Button();
- this.butAlter = new System.Windows.Forms.Button();
- this.SuspendLayout();
- //
- // label1
- //
- this.label1.BackColor = System.Drawing.Color.Transparent;
- this.label1.Location = new System.Drawing.Point(72, 48);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(112, 24);
- this.label1.TabIndex = 0;
- this.label1.Text = "出版社名称";
- //
- // label2
- //
- this.label2.BackColor = System.Drawing.Color.Transparent;
- this.label2.Location = new System.Drawing.Point(72, 96);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(112, 24);
- this.label2.TabIndex = 1;
- this.label2.Text = "联系人姓名";
- //
- // label3
- //
- this.label3.BackColor = System.Drawing.Color.Transparent;
- this.label3.Location = new System.Drawing.Point(72, 144);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(112, 24);
- this.label3.TabIndex = 2;
- this.label3.Text = "出版社地址";
- //
- // label4
- //
- this.label4.BackColor = System.Drawing.Color.Transparent;
- this.label4.Location = new System.Drawing.Point(72, 192);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(112, 24);
- this.label4.TabIndex = 3;
- this.label4.Text = "联系电话";
- //
- // pressname
- //
- this.pressname.Location = new System.Drawing.Point(200, 48);
- this.pressname.Name = "pressname";
- this.pressname.ReadOnly = true;
- this.pressname.Size = new System.Drawing.Size(200, 21);
- this.pressname.TabIndex = 4;
- this.pressname.Text = "pressname";
- //
- // presslinkman
- //
- this.presslinkman.Location = new System.Drawing.Point(200, 96);
- this.presslinkman.Name = "presslinkman";
- this.presslinkman.ReadOnly = true;
- this.presslinkman.Size = new System.Drawing.Size(200, 21);
- this.presslinkman.TabIndex = 5;
- this.presslinkman.Text = "presslinkman";
- //
- // pressaddress
- //
- this.pressaddress.Location = new System.Drawing.Point(200, 136);
- this.pressaddress.Name = "pressaddress";
- this.pressaddress.ReadOnly = true;
- this.pressaddress.Size = new System.Drawing.Size(200, 21);
- this.pressaddress.TabIndex = 6;
- this.pressaddress.Text = "pressaddress";
- //
- // presstelephone
- //
- this.presstelephone.Location = new System.Drawing.Point(200, 192);
- this.presstelephone.Name = "presstelephone";
- this.presstelephone.ReadOnly = true;
- this.presstelephone.Size = new System.Drawing.Size(200, 21);
- this.presstelephone.TabIndex = 7;
- this.presstelephone.Text = "presstelephone";
- //
- // butBookManagement
- //
- this.butBookManagement.BackColor = System.Drawing.Color.Transparent;
- this.butBookManagement.Location = new System.Drawing.Point(312, 256);
- this.butBookManagement.Name = "butBookManagement";
- this.butBookManagement.Size = new System.Drawing.Size(104, 24);
- this.butBookManagement.TabIndex = 8;
- this.butBookManagement.Text = "书目信息管理";
- this.butBookManagement.Click += new System.EventHandler(this.butBookManagement_Click);
- //
- // butPrev
- //
- this.butPrev.BackColor = System.Drawing.Color.Transparent;
- this.butPrev.Location = new System.Drawing.Point(180, 344);
- this.butPrev.Name = "butPrev";
- this.butPrev.Size = new System.Drawing.Size(56, 24);
- this.butPrev.TabIndex = 9;
- this.butPrev.Text = "<";
- this.butPrev.Click += new System.EventHandler(this.butPrev_Click);
- //
- // butNext
- //
- this.butNext.BackColor = System.Drawing.Color.Transparent;
- this.butNext.Location = new System.Drawing.Point(236, 344);
- this.butNext.Name = "butNext";
- this.butNext.Size = new System.Drawing.Size(56, 24);
- this.butNext.TabIndex = 10;
- this.butNext.Text = ">";
- this.butNext.Click += new System.EventHandler(this.butNext_Click);
- //
- // butLast
- //
- this.butLast.BackColor = System.Drawing.Color.Transparent;
- this.butLast.Location = new System.Drawing.Point(292, 344);
- this.butLast.Name = "butLast";
- this.butLast.Size = new System.Drawing.Size(56, 24);
- this.butLast.TabIndex = 12;
- 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(124, 344);
- this.butFirst.Name = "butFirst";
- this.butFirst.Size = new System.Drawing.Size(56, 24);
- this.butFirst.TabIndex = 11;
- this.butFirst.Text = "|<";
- this.butFirst.Click += new System.EventHandler(this.butFirst_Click);
- //
- // butShowAll
- //
- this.butShowAll.BackColor = System.Drawing.Color.Transparent;
- this.butShowAll.Location = new System.Drawing.Point(224, 256);
- this.butShowAll.Name = "butShowAll";
- this.butShowAll.Size = new System.Drawing.Size(88, 24);
- this.butShowAll.TabIndex = 13;
- this.butShowAll.Text = "查看全部";
- this.butShowAll.Click += new System.EventHandler(this.butShowAll_Click);
- //
- // label5
- //
- this.label5.BackColor = System.Drawing.Color.Transparent;
- this.label5.Location = new System.Drawing.Point(36, 304);
- this.label5.Name = "label5";
- this.label5.Size = new System.Drawing.Size(56, 16);
- this.label5.TabIndex = 14;
- this.label5.Text = "查找方式";
- //
- // comboBox1
- //
- this.comboBox1.Items.AddRange(new object[] {
- "出版社名称",
- "联系电话"});
- this.comboBox1.Location = new System.Drawing.Point(108, 304);
- this.comboBox1.MaxDropDownItems = 2;
- this.comboBox1.Name = "comboBox1";
- this.comboBox1.Size = new System.Drawing.Size(88, 20);
- this.comboBox1.TabIndex = 15;
- this.comboBox1.Text = "出版社名称";
- //
- // butSearch
- //
- this.butSearch.BackColor = System.Drawing.Color.Transparent;
- this.butSearch.Location = new System.Drawing.Point(372, 304);
- this.butSearch.Name = "butSearch";
- this.butSearch.Size = new System.Drawing.Size(64, 24);
- this.butSearch.TabIndex = 16;
- this.butSearch.Text = "查找";
- this.butSearch.Click += new System.EventHandler(this.butSearch_Click);
- //
- // textForSearch
- //
- this.textForSearch.Location = new System.Drawing.Point(268, 304);
- this.textForSearch.Name = "textForSearch";
- this.textForSearch.Size = new System.Drawing.Size(96, 21);
- this.textForSearch.TabIndex = 17;
- this.textForSearch.Text = "";
- //
- // comboBox2
- //
- this.comboBox2.Items.AddRange(new object[] {
- "模糊",
- "精确"});
- this.comboBox2.Location = new System.Drawing.Point(212, 304);
- this.comboBox2.MaxDropDownItems = 2;
- this.comboBox2.Name = "comboBox2";
- this.comboBox2.Size = new System.Drawing.Size(48, 20);
- this.comboBox2.TabIndex = 18;
- this.comboBox2.Text = "模糊";
- //
- // butDelete
- //
- this.butDelete.BackColor = System.Drawing.Color.Transparent;
- this.butDelete.Location = new System.Drawing.Point(168, 256);
- this.butDelete.Name = "butDelete";
- this.butDelete.Size = new System.Drawing.Size(56, 24);
- this.butDelete.TabIndex = 48;
- this.butDelete.Text = "删除";
- this.butDelete.Click += new System.EventHandler(this.butDelete_Click);
- //
- // butAdd
- //
- this.butAdd.BackColor = System.Drawing.Color.Transparent;
- this.butAdd.Location = new System.Drawing.Point(112, 256);
- this.butAdd.Name = "butAdd";
- this.butAdd.Size = new System.Drawing.Size(56, 24);
- this.butAdd.TabIndex = 47;
- 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(56, 256);
- this.butAlter.Name = "butAlter";
- this.butAlter.Size = new System.Drawing.Size(56, 24);
- this.butAlter.TabIndex = 46;
- this.butAlter.Text = "修改";
- this.butAlter.Click += new System.EventHandler(this.butAlter_Click);
- //
- // Form_Publisher
- //
- this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
- this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
- this.ClientSize = new System.Drawing.Size(472, 382);
- this.ControlBox = false;
- this.Controls.Add(this.butDelete);
- this.Controls.Add(this.butAdd);
- this.Controls.Add(this.butAlter);
- this.Controls.Add(this.comboBox2);
- this.Controls.Add(this.textForSearch);
- this.Controls.Add(this.presstelephone);
- this.Controls.Add(this.pressaddress);
- this.Controls.Add(this.presslinkman);
- this.Controls.Add(this.pressname);
- this.Controls.Add(this.butSearch);
- this.Controls.Add(this.comboBox1);
- this.Controls.Add(this.label5);
- this.Controls.Add(this.butShowAll);
- this.Controls.Add(this.butLast);
- this.Controls.Add(this.butFirst);
- this.Controls.Add(this.butNext);
- this.Controls.Add(this.butPrev);
- this.Controls.Add(this.butBookManagement);
- 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.None;
- this.Name = "Form_Publisher";
- this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
- this.Text = "Form_Publisher";
- this.Load += new System.EventHandler(this.Form_Publisher_Load);
- this.ResumeLayout(false);
- }
- #endregion
- private void butBookManagement_Click(object sender, System.EventArgs e)
- {
- if(Pressname!="")
- {
- Form_Publisher_BookManagement child=new Form_Publisher_BookManagement();
- child.ShowDialog();
- }
- else
- {
- MessageBox.Show("还没有选择出版社!","提示");
- }
- }
- SQL sql;
- public static string Pressname;
- private void Form_Publisher_Load(object sender, System.EventArgs e)
- {
- sql=new SQL("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=图书管理系统数据库.mdb");
- sql.ExecuteSQL("select * from 出版社信息表 order by pressname");
- show();
- }
- public void show()
- {
- if(sql.rows.GetLength(0)!=0)
- {
- pressname.Text=sql.rows[sql.getPos(),0].ToString();
- presslinkman.Text=sql.rows[sql.getPos(),1].ToString();
- pressaddress.Text=sql.rows[sql.getPos(),2].ToString();
- presstelephone.Text=sql.rows[sql.getPos(),3].ToString();
- }
- else
- {
- pressname.Text="";
- presslinkman.Text="";
- pressaddress.Text="";
- presstelephone.Text="";
- MessageBox.Show("无符合查询条件的结果!","提示");
- }
- Pressname=pressname.Text;
- }
- 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 butFirst_Click(object sender, System.EventArgs e)
- {
- sql.pointToFirst();
- show();
- }
- private void butLast_Click(object sender, System.EventArgs e)
- {
- sql.pointToLast();
- show();
- }
- string oldpressname;
- private void butAlter_Click(object sender, System.EventArgs e)
- {
- if(butAlter.Text=="修改")
- {
- butAlter.Text="更新";
- oldpressname=pressname.Text;
- pressname.ReadOnly =false;
- presslinkman.ReadOnly =false;
- pressaddress.ReadOnly =false;
- presstelephone.ReadOnly =false;
- butAdd.Enabled=false;
- butDelete.Enabled=false;
- butFirst.Enabled=false;
- butPrev.Enabled=false;
- butNext.Enabled=false;
- butLast.Enabled=false;
- butShowAll.Enabled=false;
- butSearch.Enabled=false;
- butBookManagement.Enabled=false;
- }
- else
- {
- if(sql.ExecuteSQL("update 出版社信息表 set pressname='"+pressname.Text+"',presslinkman='"+presslinkman.Text+"',pressaddress='"+pressaddress.Text+"',presstelephone='"+presstelephone.Text+"' where pressname='"+oldpressname+"'")
- ==false)
- {
- show();
- }
- else
- {
- Pressname=pressname.Text;
- sql.ExecuteSQL("update 出版社图书信息表 set pressname='"+pressname.Text+"' where pressname='"+oldpressname+"'");
- }
- pressname.ReadOnly =true;
- presslinkman.ReadOnly =true;
- pressaddress.ReadOnly =true;
- presstelephone.ReadOnly =true;
- butAlter.Text="修改";
- butAdd.Enabled=true;
- butDelete.Enabled=true;
- butFirst.Enabled=true;
- butPrev.Enabled=true;
- butNext.Enabled=true;
- butLast.Enabled=true;
- butShowAll.Enabled=true;
- butSearch.Enabled=true;
- butBookManagement.Enabled=true;
- }
- }
- private void butAdd_Click(object sender, System.EventArgs e)
- {
- if(butAdd.Text=="添加")
- {
- butAdd.Text="提交";
- pressname.Text="";
- presslinkman.Text="";
- pressaddress.Text="";
- presstelephone.Text="";
- pressname.ReadOnly =false;
- presslinkman.ReadOnly =false;
- pressaddress.ReadOnly =false;
- presstelephone.ReadOnly =false;
- butAlter.Enabled=false;
- butDelete.Enabled=false;
- butFirst.Enabled=false;
- butPrev.Enabled=false;
- butNext.Enabled=false;
- butLast.Enabled=false;
- butShowAll.Enabled=false;
- butSearch.Enabled=false;
- butBookManagement.Enabled=false;
- }
- else
- {
- if(sql.ExecuteSQL("insert into 出版社信息表 values('"+pressname.Text+"','"+presslinkman.Text+"','"+pressaddress.Text+"','"+presstelephone.Text+"')")
- ==false)
- {
- show();
- }
- else
- {
- Pressname=pressname.Text;
- }
- pressname.ReadOnly =true;
- presslinkman.ReadOnly =true;
- pressaddress.ReadOnly =true;
- presstelephone.ReadOnly =true;
- butAdd.Text="添加";
- butAlter.Enabled=true;
- butDelete.Enabled=true;
- butFirst.Enabled=true;
- butPrev.Enabled=true;
- butNext.Enabled=true;
- butLast.Enabled=true;
- butShowAll.Enabled=true;
- butSearch.Enabled=true;
- butBookManagement.Enabled=true;
- }
- }
- private void butDelete_Click(object sender, System.EventArgs e)
- {
- sql.ExecuteSQL("delete from 出版社信息表 where pressname='"+pressname.Text+"'");
- sql.ExecuteSQL("delete from 出版社图书信息表 where pressname='"+pressname.Text+"'");
- sql.pointToFirst();
- show();
- }
- private void butSearch_Click(object sender, System.EventArgs e)
- {
- if(comboBox1.Text=="出版社名称")
- {
- if(comboBox2.Text=="精确")
- {
- sql.ExecuteSQL("select * from 出版社信息表 where pressname='"+textForSearch.Text+"'");
- show();
- }
- else
- {
- sql.ExecuteSQL("select * from 出版社信息表 where pressname like '%"+textForSearch.Text+"%'");
- show();
- }
- }
- else
- {
- if(comboBox2.Text=="精确")
- {
- sql.ExecuteSQL("select * from 出版社信息表 where presstelephone='"+textForSearch.Text+"'");
- show();
- }
- else
- {
- sql.ExecuteSQL("select * from 出版社信息表 where presstelephone like '%"+textForSearch.Text+"%'");
- show();
- }
- }
- }
- private void butShowAll_Click(object sender, System.EventArgs e)
- {
- sql.ExecuteSQL("select * from 出版社信息表 order by pressname");
- show();
- }
- }
- }