⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 returnfrm.cs

📁 C#的图书管理系统,用ASP自己开发的系统
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data.OleDb;
using System.Data;
namespace bookmanager
{
	/// <summary>
	/// Summary description for returnFrm.
	/// </summary>
	public class returnFrm : System.Windows.Forms.Form
	{
		private System.Windows.Forms.GroupBox groupBox2;
		private System.Windows.Forms.Label label15;
		private System.Windows.Forms.Label label14;
		private System.Windows.Forms.Label label13;
		private System.Windows.Forms.Label label12;
		private System.Windows.Forms.Label label11;
		private System.Windows.Forms.TextBox textBox12;
		private System.Windows.Forms.TextBox textBox11;
		public System.Windows.Forms.TextBox textBox10;
		public System.Windows.Forms.TextBox textBox9;
		public System.Windows.Forms.TextBox textBox8;
		public System.Windows.Forms.TextBox textBox7;
		private System.Windows.Forms.Button button2;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.DataGrid dataGrid1;
		private System.Windows.Forms.Button button1;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
        public static string [] readerDataArray = new string [] {"","","",""};
		public static string autoId=null;
		private System.Windows.Forms.Button button3;
		private System.Windows.Forms.Label label2;
		public static string whereStr=null;
		public returnFrm()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.groupBox2 = new System.Windows.Forms.GroupBox();
			this.label15 = new System.Windows.Forms.Label();
			this.label14 = new System.Windows.Forms.Label();
			this.label13 = new System.Windows.Forms.Label();
			this.label12 = new System.Windows.Forms.Label();
			this.label11 = new System.Windows.Forms.Label();
			this.textBox12 = new System.Windows.Forms.TextBox();
			this.textBox11 = new System.Windows.Forms.TextBox();
			this.textBox10 = new System.Windows.Forms.TextBox();
			this.textBox9 = new System.Windows.Forms.TextBox();
			this.textBox8 = new System.Windows.Forms.TextBox();
			this.textBox7 = new System.Windows.Forms.TextBox();
			this.button2 = new System.Windows.Forms.Button();
			this.label1 = new System.Windows.Forms.Label();
			this.dataGrid1 = new System.Windows.Forms.DataGrid();
			this.button1 = new System.Windows.Forms.Button();
			this.button3 = new System.Windows.Forms.Button();
			this.label2 = new System.Windows.Forms.Label();
			this.groupBox2.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).BeginInit();
			this.SuspendLayout();
			// 
			// groupBox2
			// 
			this.groupBox2.Controls.Add(this.label15);
			this.groupBox2.Controls.Add(this.label14);
			this.groupBox2.Controls.Add(this.label13);
			this.groupBox2.Controls.Add(this.label12);
			this.groupBox2.Controls.Add(this.label11);
			this.groupBox2.Controls.Add(this.textBox12);
			this.groupBox2.Controls.Add(this.textBox11);
			this.groupBox2.Controls.Add(this.textBox10);
			this.groupBox2.Controls.Add(this.textBox9);
			this.groupBox2.Controls.Add(this.textBox8);
			this.groupBox2.Location = new System.Drawing.Point(8, 96);
			this.groupBox2.Name = "groupBox2";
			this.groupBox2.Size = new System.Drawing.Size(640, 80);
			this.groupBox2.TabIndex = 11;
			this.groupBox2.TabStop = false;
			this.groupBox2.Text = "阅读者信息";
			// 
			// label15
			// 
			this.label15.Location = new System.Drawing.Point(16, 56);
			this.label15.Name = "label15";
			this.label15.Size = new System.Drawing.Size(48, 16);
			this.label15.TabIndex = 10;
			this.label15.Text = "共借书";
			// 
			// label14
			// 
			this.label14.Location = new System.Drawing.Point(160, 56);
			this.label14.Name = "label14";
			this.label14.Size = new System.Drawing.Size(48, 16);
			this.label14.TabIndex = 9;
			this.label14.Text = "未还书";
			// 
			// label13
			// 
			this.label13.Location = new System.Drawing.Point(320, 24);
			this.label13.Name = "label13";
			this.label13.Size = new System.Drawing.Size(56, 16);
			this.label13.TabIndex = 8;
			this.label13.Text = "身份证号";
			// 
			// label12
			// 
			this.label12.Location = new System.Drawing.Point(160, 24);
			this.label12.Name = "label12";
			this.label12.Size = new System.Drawing.Size(48, 16);
			this.label12.TabIndex = 7;
			this.label12.Text = "姓别";
			// 
			// label11
			// 
			this.label11.Location = new System.Drawing.Point(16, 24);
			this.label11.Name = "label11";
			this.label11.Size = new System.Drawing.Size(56, 16);
			this.label11.TabIndex = 6;
			this.label11.Text = "借书证号";
			// 
			// textBox12
			// 
			this.textBox12.Location = new System.Drawing.Point(216, 48);
			this.textBox12.Name = "textBox12";
			this.textBox12.ReadOnly = true;
			this.textBox12.Size = new System.Drawing.Size(72, 21);
			this.textBox12.TabIndex = 4;
			this.textBox12.Text = "";
			// 
			// textBox11
			// 
			this.textBox11.Location = new System.Drawing.Point(72, 48);
			this.textBox11.Name = "textBox11";
			this.textBox11.ReadOnly = true;
			this.textBox11.Size = new System.Drawing.Size(72, 21);
			this.textBox11.TabIndex = 3;
			this.textBox11.Text = "";
			// 
			// textBox10
			// 
			this.textBox10.Location = new System.Drawing.Point(376, 16);
			this.textBox10.Name = "textBox10";
			this.textBox10.ReadOnly = true;
			this.textBox10.Size = new System.Drawing.Size(144, 21);
			this.textBox10.TabIndex = 2;
			this.textBox10.Text = "";
			// 
			// textBox9
			// 
			this.textBox9.Location = new System.Drawing.Point(216, 16);
			this.textBox9.Name = "textBox9";
			this.textBox9.ReadOnly = true;
			this.textBox9.Size = new System.Drawing.Size(72, 21);
			this.textBox9.TabIndex = 1;
			this.textBox9.Text = "";
			// 
			// textBox8
			// 
			this.textBox8.Location = new System.Drawing.Point(72, 16);
			this.textBox8.Name = "textBox8";
			this.textBox8.ReadOnly = true;
			this.textBox8.Size = new System.Drawing.Size(72, 21);
			this.textBox8.TabIndex = 0;
			this.textBox8.Text = "";
			// 
			// textBox7
			// 
			this.textBox7.Location = new System.Drawing.Point(24, 64);
			this.textBox7.Name = "textBox7";
			this.textBox7.Size = new System.Drawing.Size(80, 21);
			this.textBox7.TabIndex = 10;
			this.textBox7.Text = "";
			// 
			// button2
			// 
			this.button2.Location = new System.Drawing.Point(112, 64);
			this.button2.Name = "button2";
			this.button2.Size = new System.Drawing.Size(80, 24);
			this.button2.TabIndex = 9;
			this.button2.Text = "选择还书者";
			this.button2.Click += new System.EventHandler(this.button2_Click);
			// 
			// label1
			// 
			this.label1.Font = new System.Drawing.Font("SimHei", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label1.ForeColor = System.Drawing.SystemColors.ActiveCaption;
			this.label1.Location = new System.Drawing.Point(200, 16);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(256, 24);
			this.label1.TabIndex = 12;
			this.label1.Text = "还  书  单";
			this.label1.TextAlign = System.Drawing.ContentAlignment.TopCenter;
			// 
			// dataGrid1
			// 
			this.dataGrid1.CaptionVisible = false;
			this.dataGrid1.DataMember = "";
			this.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dataGrid1.Location = new System.Drawing.Point(8, 176);
			this.dataGrid1.Name = "dataGrid1";
			this.dataGrid1.Size = new System.Drawing.Size(640, 136);
			this.dataGrid1.TabIndex = 13;
			// 
			// button1
			// 
			this.button1.Location = new System.Drawing.Point(232, 64);
			this.button1.Name = "button1";
			this.button1.Size = new System.Drawing.Size(80, 24);
			this.button1.TabIndex = 14;
			this.button1.Text = "未还书清单";
			this.button1.Click += new System.EventHandler(this.button1_Click);
			// 
			// button3
			// 
			this.button3.Location = new System.Drawing.Point(552, 64);
			this.button3.Name = "button3";
			this.button3.Size = new System.Drawing.Size(96, 24);
			this.button3.TabIndex = 15;
			this.button3.Text = "图书归还";
			this.button3.Click += new System.EventHandler(this.button3_Click);
			// 
			// label2
			// 
			this.label2.ForeColor = System.Drawing.SystemColors.ActiveCaption;
			this.label2.Location = new System.Drawing.Point(8, 320);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(304, 16);
			this.label2.TabIndex = 16;
			this.label2.Text = "选择还书人(阅读者)-->选择要还的书籍-->确认还书";
			// 
			// returnFrm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(656, 342);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.button3);
			this.Controls.Add(this.button1);
			this.Controls.Add(this.dataGrid1);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.groupBox2);
			this.Controls.Add(this.textBox7);
			this.Controls.Add(this.button2);
			this.Name = "returnFrm";
			this.Text = "还书管理";
			this.groupBox2.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.dataGrid1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		private void button1_Click(object sender, System.EventArgs e)
		{
			if(this.textBox12.Text.Trim()!="" && Int32.Parse(textBox12.Text.Trim())!= 0)
			{   string wherestr1 ="";
				whereStr=null;
				FormList listfrm =new FormList(readerDataArray[0],true);
				listfrm.ShowDialog();
				if (whereStr!=null)
				{
					wherestr1=" and a.code in(" + whereStr +")";
					if(this.dataGrid1.DataSource != null) ((DataTable)this.dataGrid1.DataSource).Rows.Clear();
					string sql = "select a.id as 自动编号,a.code as 编号,a.name as 名称,a.author as 作者,a.press as 出版社,a.outdate as 出版日期,a.memotxt as 内容简介,a.cost as 价格,a.lost as 状态,b.name as 图书类别  from book a,orders b  where a.ordercode=b.id   " +wherestr1 +" order by a.code  ";
					DataSet ds = new DataSet();
					OleDbDataAdapter  ad = new OleDbDataAdapter(sql,Public.conn);
					ad.Fill( ds,"book");
					this.dataGrid1.SetDataBinding(ds.Tables[0],""); 
				}
			}
		}

		private void button2_Click(object sender, System.EventArgs e)
		{
			
			reader readerFrm =new reader(true,"returnFrm");
			readerFrm.ShowDialog();
			setWareData();
			string sql = "select * from lend  where readerid = '" + autoId +"'";
			OleDbDataAdapter ad = new OleDbDataAdapter(sql,Public.conn);
			DataSet ds = new DataSet();
			ad.Fill(ds,"list");
			this.textBox11.Text =ds.Tables[0].Rows.Count.ToString() ;
			sql = "select * from lend  where readerid = '" + autoId  +"' and bakdate is null";
			ad = new OleDbDataAdapter(sql,Public.conn);
		    ds.Clear();
			ad.Fill(ds,"list");
			this.textBox12.Text =ds.Tables[0].Rows.Count.ToString() ;
			if(this.dataGrid1.DataSource != null) ((DataTable)this.dataGrid1.DataSource).Rows.Clear();
			whereStr=null;
		}
		public void setWareData()
		{
			this.textBox7.Text  = readerDataArray[1];
			this.textBox8.Text = readerDataArray[0];
			this.textBox9.Text = readerDataArray[2];
			this.textBox10.Text = readerDataArray[3];
		}

		private void button3_Click(object sender, System.EventArgs e)
		{
		  try
		  {
			   if (whereStr == null ){ MessageBox.Show("没有选择书籍");}
			  if(MessageBox.Show("真的确认归还吗?","提示",MessageBoxButtons.YesNo)==DialogResult.Yes )
			  {
			      string sql=" update lend set bakDate ='" + System.DateTime.Now +"'where code in(" + whereStr + ") and readerid ='" + readerDataArray[0] +"'";
			      Public.ExeSql(sql);
				  MessageBox.Show ("还书成功!");
			  }
			  if(this.dataGrid1.DataSource != null) ((DataTable)this.dataGrid1.DataSource).Rows.Clear();
		   }
		   catch(Exception ex)
		   {
			   MessageBox.Show(ex.Message.ToString());
		   }
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -