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

📄 returnbooks.cs

📁 图书馆信息管理系统 Library Information Management System
💻 CS
📖 第 1 页 / 共 2 页
字号:
			this.groupBox6.Controls.Add(this.textBox9);
			this.groupBox6.Controls.Add(this.textBox8);
			this.groupBox6.Controls.Add(this.label13);
			this.groupBox6.Controls.Add(this.label12);
			this.groupBox6.Controls.Add(this.label11);
			this.groupBox6.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.groupBox6.Location = new System.Drawing.Point(352, 128);
			this.groupBox6.Name = "groupBox6";
			this.groupBox6.Size = new System.Drawing.Size(416, 125);
			this.groupBox6.TabIndex = 11;
			this.groupBox6.TabStop = false;
			this.groupBox6.Text = "图书信息";
			// 
			// textBox7
			// 
			this.textBox7.Location = new System.Drawing.Point(112, 22);
			this.textBox7.Name = "textBox7";
			this.textBox7.ReadOnly = true;
			this.textBox7.Size = new System.Drawing.Size(256, 21);
			this.textBox7.TabIndex = 1;
			this.textBox7.Text = "";
			// 
			// textBox9
			// 
			this.textBox9.Location = new System.Drawing.Point(112, 86);
			this.textBox9.Name = "textBox9";
			this.textBox9.ReadOnly = true;
			this.textBox9.Size = new System.Drawing.Size(256, 21);
			this.textBox9.TabIndex = 10;
			this.textBox9.Text = "";
			// 
			// textBox8
			// 
			this.textBox8.Location = new System.Drawing.Point(112, 54);
			this.textBox8.Name = "textBox8";
			this.textBox8.ReadOnly = true;
			this.textBox8.Size = new System.Drawing.Size(256, 21);
			this.textBox8.TabIndex = 9;
			this.textBox8.Text = "";
			// 
			// label13
			// 
			this.label13.AutoSize = true;
			this.label13.Location = new System.Drawing.Point(32, 88);
			this.label13.Name = "label13";
			this.label13.Size = new System.Drawing.Size(42, 17);
			this.label13.TabIndex = 6;
			this.label13.Text = "出版社";
			// 
			// label12
			// 
			this.label12.AutoSize = true;
			this.label12.Location = new System.Drawing.Point(32, 56);
			this.label12.Name = "label12";
			this.label12.Size = new System.Drawing.Size(29, 17);
			this.label12.TabIndex = 5;
			this.label12.Text = "作者";
			// 
			// label11
			// 
			this.label11.AutoSize = true;
			this.label11.Location = new System.Drawing.Point(32, 24);
			this.label11.Name = "label11";
			this.label11.Size = new System.Drawing.Size(29, 17);
			this.label11.TabIndex = 4;
			this.label11.Text = "书名";
			// 
			// groupBox7
			// 
			this.groupBox7.Controls.Add(this.label19);
			this.groupBox7.Controls.Add(this.label18);
			this.groupBox7.Controls.Add(this.label17);
			this.groupBox7.Controls.Add(this.label14);
			this.groupBox7.Controls.Add(this.label2);
			this.groupBox7.Controls.Add(this.label16);
			this.groupBox7.FlatStyle = System.Windows.Forms.FlatStyle.System;
			this.groupBox7.Location = new System.Drawing.Point(576, 256);
			this.groupBox7.Name = "groupBox7";
			this.groupBox7.Size = new System.Drawing.Size(192, 152);
			this.groupBox7.TabIndex = 14;
			this.groupBox7.TabStop = false;
			this.groupBox7.Text = "罚款信息";
			// 
			// label19
			// 
			this.label19.AutoSize = true;
			this.label19.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label19.ForeColor = System.Drawing.SystemColors.ControlText;
			this.label19.Location = new System.Drawing.Point(152, 64);
			this.label19.Name = "label19";
			this.label19.Size = new System.Drawing.Size(17, 17);
			this.label19.TabIndex = 5;
			this.label19.Text = "元";
			this.label19.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// label18
			// 
			this.label18.AutoSize = true;
			this.label18.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label18.ForeColor = System.Drawing.SystemColors.ControlText;
			this.label18.Location = new System.Drawing.Point(152, 24);
			this.label18.Name = "label18";
			this.label18.Size = new System.Drawing.Size(17, 17);
			this.label18.TabIndex = 4;
			this.label18.Text = "天";
			this.label18.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// label17
			// 
			this.label17.AutoSize = true;
			this.label17.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.label17.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label17.ForeColor = System.Drawing.SystemColors.ControlText;
			this.label17.Location = new System.Drawing.Point(88, 64);
			this.label17.Name = "label17";
			this.label17.Size = new System.Drawing.Size(25, 20);
			this.label17.TabIndex = 3;
			this.label17.Text = "...";
			this.label17.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// label14
			// 
			this.label14.AutoSize = true;
			this.label14.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label14.ForeColor = System.Drawing.SystemColors.ControlText;
			this.label14.Location = new System.Drawing.Point(24, 64);
			this.label14.Name = "label14";
			this.label14.Size = new System.Drawing.Size(60, 17);
			this.label14.TabIndex = 2;
			this.label14.Text = "应罚金额:";
			this.label14.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// label2
			// 
			this.label2.AutoSize = true;
			this.label2.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
			this.label2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label2.ForeColor = System.Drawing.SystemColors.ControlText;
			this.label2.Location = new System.Drawing.Point(88, 24);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(25, 20);
			this.label2.TabIndex = 1;
			this.label2.Text = "...";
			this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// label16
			// 
			this.label16.AutoSize = true;
			this.label16.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
			this.label16.ForeColor = System.Drawing.SystemColors.ControlText;
			this.label16.Location = new System.Drawing.Point(24, 25);
			this.label16.Name = "label16";
			this.label16.Size = new System.Drawing.Size(60, 17);
			this.label16.TabIndex = 0;
			this.label16.Text = "超期天数:";
			this.label16.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// ReturnBooks
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(790, 503);
			this.ControlBox = false;
			this.Controls.Add(this.groupBox7);
			this.Controls.Add(this.groupBox3);
			this.Controls.Add(this.groupBox2);
			this.Controls.Add(this.groupBox5);
			this.Controls.Add(this.groupBox4);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.groupBox6);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
			this.Name = "ReturnBooks";
			this.ShowInTaskbar = false;
			this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
			this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
			this.Text = "归还图书";
			this.Load += new System.EventHandler(this.ReturnBooks_Load);
			this.groupBox3.ResumeLayout(false);
			this.groupBox2.ResumeLayout(false);
			this.groupBox5.ResumeLayout(false);
			this.groupBox4.ResumeLayout(false);
			this.groupBox6.ResumeLayout(false);
			this.groupBox7.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion
		/// <summary>
		/// 初始化
		/// </summary>
		private void initializeScreen()
		{
			r_ID = "";
			rc = 0;
			dc = 0;
			book_ID = "";
			btnReturn.Enabled = true;
			btnForfeit.Enabled = false;
			textBox1.Text = "";
			textBox2.Text = "";
			textBox3.Text = "";
			textBox4.Text = "";
			textBox5.Text = "";
			textBox6.Text = "";
			textBox7.Text = "";
			textBox8.Text = "";
			textBox9.Text = "";
			label2.Text = "";
			label17.Text = "";
			listView1.Items.Clear();
			isU=false;
			//ListViewItem item = null;
		}
		/// <summary>
		/// 关闭
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void btnClose_Click(object sender, System.EventArgs e)
		{
			Global.sbpGlobal.Text = "就绪";
			Global.ReturnBooks = false;
			this.Close();
		}
		/// <summary>
		/// 窗体加载代码
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void ReturnBooks_Load(object sender, System.EventArgs e)
		{
			cmd = Global.conn.CreateCommand();
			initializeScreen();
		}
		/// <summary>
		/// 归还图书
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void btnReturn_Click(object sender, System.EventArgs e)
		{
			if(isU)
			{
				MessageBox.Show("此图书已经超期!");
				initializeScreen();
				return;
			}
			else
			{
				string str = "update 流通 set 归还标志=1 where 图书条码号='" + book_ID + "'";
				cmd.CommandText = str;
				try
				{
					cmd.ExecuteNonQuery();
					MessageBox.Show("成功归还图书!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
					initializeScreen();
				}
				catch(Exception ex)
				{
					MessageBox.Show("发生如下错误:\n\n" + ex.ToString(),"错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
					return;
				}
			}
		}
		/// <summary>
		/// 罚款
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void btnForfeit_Click(object sender, System.EventArgs e)
		{
			string str = "insert into 罚款 values('" + book_ID + "'," + Convert.ToDecimal(label17.Text) + ",'"
				+ "图书超期','" + textBox2.Text + "','" + DateTime.Now.ToShortDateString() + "')";
			cmd.CommandText = str;
			//创建事务
			SqlTransaction trans = Global.conn.BeginTransaction();
			cmd.Transaction = trans;
			try
			{
				cmd.CommandText = str;
				cmd.ExecuteNonQuery();
				str = "update 流通 set 归还标志=1 where 图书条码号='" + book_ID + "'";
				cmd.CommandText = str;
				cmd.ExecuteNonQuery();
				trans.Commit();
				MessageBox.Show("此图书成功归还并且缴纳罚金!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
				initializeScreen();
			}
			catch
			{
				try
				{
					trans.Rollback();
				}
				catch (SqlException ex)
				{
					if (trans.Connection != null)
					{
						MessageBox.Show("发生如下错误:\n\t" + ex.ToString(),"错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
					}
				}
				MessageBox.Show("发生错误!图书借阅未成功!");
				initializeScreen();
				return;
			}
		}
		/// <summary>
		/// 
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void textBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if(e.KeyData == Keys.Enter)
			{
				book_ID = textBox1.Text;
				string str = "select * from V_还书 where 图书条码号='" + book_ID + "' and 归还标志=0";
				cmd.CommandText = str;
				try
				{
					dr = cmd.ExecuteReader();
					dr.Read();
					if(dr.HasRows)
					{
						r_ID = dr.GetString(1);
						textBox2.Text = dr.GetString(2);
						textBox3.Text = dr.GetString(3);
						textBox5.Text = dr.GetInt32(7).ToString();
						textBox7.Text = dr.GetString(9);
						textBox8.Text = dr.GetString(11);
						textBox9.Text = dr.GetString(13);
						dc = dr.GetInt32(6);
						rc = dr.GetInt32(7);
						textBox4.Text = rc.ToString();
						if(dr.GetDateTime(17)<DateTime.Now)
						{
							string cd =  Convert.ToString(DateTime.Now.Date-dr.GetDateTime(17).Date).Remove(Convert.ToString(DateTime.Now.Date-dr.GetDateTime(17).Date).IndexOf("."),9);
							label2.Text = cd;
							label17.Text = Convert.ToString(Convert.ToInt32(cd)*Convert.ToDouble(dr.GetDecimal(8)));
							btnReturn.Enabled = false;
							btnForfeit.Enabled = true;
							isU = true;
						}
						else
						{
							btnForfeit.Enabled = false;
							btnReturn.Enabled = true;
							label2.Text = "0";
							label17.Text = "0.00";
							isU= false;
						}
					}
					else
					{
						if(dr!=null)dr.Close();
						MessageBox.Show("此条码对应的图书未被借出或条形码录入错误!请重新检查输入!","错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
						textBox1.SelectAll();
						textBox1.Focus();
						return;
					}
					if(dr!=null)dr.Close();
				}
				catch(Exception ex)
				{
					if(dr!=null)dr.Close();
					MessageBox.Show("发生错误!错误信息如下:\n\t" + ex.ToString(),"错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
					return;
				}
				listView1.Items.Clear();
				ListViewItem item = null;
				str = "select * from V_还书 where 借书证号='" + r_ID + "' and 归还标志=0";
				cmd.CommandText = str;
				try
				{
					int i = 0;
					dr = cmd.ExecuteReader();
					while(dr.Read())
					{
						i++;
						item = new ListViewItem(dr.GetString(0));
						item.SubItems.Add(dr.GetString(9));
						if(dr.GetDateTime(17)<DateTime.Now)
						{
							item.SubItems.Add("是");
						}
						else
						{
							item.SubItems.Add("否");
						}
						item.SubItems.Add(dr.GetString(10));
						item.SubItems.Add(dr.GetString(11));
						item.SubItems.Add(dr.GetDecimal(12).ToString());
						item.SubItems.Add(dr.GetString(13));
						item.SubItems.Add(dr.GetString(14));
						listView1.Items.Add(item);
						textBox6.Text = (rc-i).ToString();
					}
					if(dr!=null)dr.Close();
				}
				catch(Exception ex)
				{
					if(dr!=null)dr.Close();
					MessageBox.Show("发生如下错误:\n\t" + ex.ToString(),"错误",MessageBoxButtons.OK,MessageBoxIcon.Error);
					return;
				}
			}
		}
	}
}

⌨️ 快捷键说明

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