📄 frmreturn.cs
字号:
using System;using System.Collections;using System.ComponentModel;using System.Drawing;using System.Windows.Forms;using System.Data;using System.Data.SqlClient;using Microsoft.VisualBasic;using Microsoft.VisualBasic.CompilerServices;namespace 图书馆管理系统{ public class frmReturn : 图书馆管理系统.frmBase {
internal System.Windows.Forms.GroupBox GroupBox1;
internal System.Windows.Forms.Label Label4;
internal System.Windows.Forms.Button btnSubmit; private System.ComponentModel.IContainer components = null; public frmReturn() { // 该调用是 Windows 窗体设计器所必需的。 InitializeComponent(); // TODO: 在 InitializeComponent 调用后添加任何初始化 } /// <summary> /// 清理所有正在使用的资源。 /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); } #region 设计器生成的代码 /// <summary> /// 设计器支持所需的方法 - 不要使用代码编辑器修改 /// 此方法的内容。 /// </summary> private void InitializeComponent() { this.GroupBox1 = new System.Windows.Forms.GroupBox();
this.Label4 = new System.Windows.Forms.Label();
this.btnSubmit = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dgdList)).BeginInit();
this.GroupBox1.SuspendLayout();
this.SuspendLayout();
//
// dgdList
//
this.dgdList.Location = new System.Drawing.Point(6, 76);
this.dgdList.Name = "dgdList";
this.dgdList.Size = new System.Drawing.Size(498, 84);
//
// GroupBox1
//
this.GroupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.GroupBox1.Controls.Add(this.Label4);
this.GroupBox1.Controls.Add(this.btnSubmit);
this.GroupBox1.Location = new System.Drawing.Point(0, 163);
this.GroupBox1.Name = "GroupBox1";
this.GroupBox1.Size = new System.Drawing.Size(507, 112);
this.GroupBox1.TabIndex = 7;
this.GroupBox1.TabStop = false;
//
// Label4
//
this.Label4.Location = new System.Drawing.Point(187, 22);
this.Label4.Name = "Label4";
this.Label4.Size = new System.Drawing.Size(246, 97);
this.Label4.TabIndex = 1;
this.Label4.Text = "说明:这里是 图书借阅、图书信息、读者信息、三张表关联查询的结果,只显示状态为\"未还\"的记录,选择相应的记录,单击【归还】按钮,先判断选择的记录是否已过期,如果过" +
"期提示输入罚款金额,然后调用\"sf_图书归还\"存储过程,参数是选择记录的借阅编号和超期罚款金额";
//
// btnSubmit
//
this.btnSubmit.Location = new System.Drawing.Point(47, 37);
this.btnSubmit.Name = "btnSubmit";
this.btnSubmit.Size = new System.Drawing.Size(86, 22);
this.btnSubmit.TabIndex = 0;
this.btnSubmit.Text = "归还选择的图书";
this.btnSubmit.Click += new System.EventHandler(this.btnSubmit_Click);
//
// frmReturn
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(506, 294);
this.Controls.Add(this.GroupBox1);
this.Name = "frmReturn";
this.Controls.SetChildIndex(this.dgdList, 0);
this.Controls.SetChildIndex(this.GroupBox1, 0);
((System.ComponentModel.ISupportInitialize)(this.dgdList)).EndInit();
this.GroupBox1.ResumeLayout(false);
this.ResumeLayout(false);
} #endregion
public override void Prepare()
{
this.Text = "图书归还";
Label1.Text = "读书编号";
Label2.Text = "读者条码";
Label3.Text = "图书编号";
ToolBar1.Visible = false;
}
public override void LoadData()
{
string strFilter = "";
if ( txbOne.Text.Trim().Length == 0 )
{
if ( txbTwo.Text.Trim().Length == 0 )
{
if ( txbThree.Text.Trim().Length == 0 )
strFilter = "";
else
{
strFilter = "where 读者条码 like '";
strFilter += txbThree.Text.Trim() + "%'";
}
}
else
{
strFilter = "where 读者条码 like '";
strFilter += txbTwo.Text.Trim() + "%'";
if ( txbThree.Text.Trim().Length != 0 )
strFilter += " and 图书编号 like '" + txbThree.Text.Trim() + "%'";
}
}
else
{
strFilter = "where 读者编号 like '" + txbOne.Text.Trim() + "%'";
if ( txbTwo.Text.Trim().Length != 0 )
{
strFilter += " and 读者条码 like '" + txbTwo.Text.Trim() + "%'";
if ( txbThree.Text.Trim().Length != 0 )
strFilter += " and 图书编号 like '" + txbThree.Text.Trim() + "%'";
}
else
{
if ( txbThree.Text.Trim().Length != 0 )
strFilter += " and 图书编号 like '" + txbThree.Text.Trim() + "%'";
}
}
DataBase db = new DataBase();
string strSQL = "select 借阅编号,c.图书编号,书名 as 图书名称 ,";
strSQL += "借阅时间,应还时间,姓名,c.读者编号,续借次数,";
strSQL += "c.操作员,状态 from 图书信息 as a, 读者信息 as b,";
strSQL += "图书借阅 as c where a.编号 = c.图书编号";
strSQL += " and b.编号 = c.读者编号 ";
strSQL += strFilter + " and 状态='未还'";
DataView dv = db.RunSelectSQL( strSQL );
dtData = dv.Table;
}
public override void SetDataGrid()
{
LoadData();
DataGridTableStyle ts = new DataGridTableStyle();
DataGridTextBoxColumn aCol;
int numCols = dtData.Columns.Count;
for ( int i = 0; i < numCols; i ++ )
{
aCol = new DataGridTextBoxColumn();
aCol.MappingName = dtData.Columns[ i ].ColumnName;
aCol.HeaderText = dtData.Columns[ i ].ColumnName;
aCol.NullText = "";
aCol.Width = 60;
aCol.ReadOnly = true;
ts.GridColumnStyles.Add( aCol );
}
ts.AlternatingBackColor = Color.LightGray;
ts.AllowSorting = false;
ts.MappingName = dtData.TableName;
dgdList.TableStyles.Clear();
dgdList.TableStyles.Add( ts );
DataView dv = dtData.DefaultView;
dv.AllowNew = false;
dv.AllowDelete = false;
dv.AllowEdit = false;
dgdList.DataSource = dv;
lblCount.Text = "记录数:" + dtData.Rows.Count.ToString();
}
private void btnSubmit_Click(object sender, System.EventArgs e)
{
int iRow = dgdList.CurrentCell.RowNumber;
int number = Int32.Parse( dtData.Rows[ iRow ][ "借阅编号" ].ToString() );
string message, title, defaultValue;
object money = null;
message = "归还的图书已经过期,请输入罚款金额,取消";
title = "提示";
defaultValue= "0";
DateTime tmDate = Convert.ToDateTime( dtData.Rows[ iRow ][ "应还时间" ].ToString().Trim() );
// 判断是否过期
if ( DateTime.Now > tmDate )
money = Microsoft.VisualBasic.Interaction.InputBox( message, title, defaultValue ,10,10);
if ( money == null )
money = "0";
DataBase db = new DataBase();
db.RunDelOrInsSQL( "exec sf_图书归还" + number.ToString() + "," + money.ToString().Trim() );
LoadData();
dtData.DefaultView.AllowNew = false;
dtData.DefaultView.AllowEdit = false;
dtData.DefaultView.AllowDelete = false;
dgdList.DataSource = dtData.DefaultView;
} }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -