📄 主窗口.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Data.SqlClient;
using System.Windows.Forms;
namespace 操作员端
{
/// <summary>
/// 主窗口 的摘要说明。
/// </summary>
public class 主窗口 : System.Windows.Forms.Form
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
private 读者信息dll.UserControl1 userControl11;
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem menuItem4;
private System.Windows.Forms.MenuItem menuItem5;
public Form1 log;
public string bookid;
public string singlelibrary;
public 主窗口()
{
//
// 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()
{
this.userControl11 = new 读者信息dll.UserControl1("operator");
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
this.SuspendLayout();
//
// userControl11
//
this.userControl11.Location = new System.Drawing.Point(0, 16);
this.userControl11.Name = "userControl11";
this.userControl11.Size = new System.Drawing.Size(736, 568);
this.userControl11.TabIndex = 0;
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1,
this.menuItem4});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem2,
this.menuItem5,
this.menuItem3});
this.menuItem1.Text = "操作";
this.menuItem1.Popup += new System.EventHandler(this.menuItem1_Popup);
//
// menuItem2
//
this.menuItem2.Enabled = false;
this.menuItem2.Index = 0;
this.menuItem2.Text = "借书";
this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click);
//
// menuItem5
//
this.menuItem5.Enabled = false;
this.menuItem5.Index = 1;
this.menuItem5.Text = "续借";
this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
//
// menuItem3
//
this.menuItem3.Index = 2;
this.menuItem3.Text = "还书";
this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click);
//
// menuItem4
//
this.menuItem4.Index = 1;
this.menuItem4.Text = "超期处理";
//
// 主窗口
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(744, 573);
this.Controls.Add(this.userControl11);
this.Menu = this.mainMenu1;
this.Name = "主窗口";
this.Text = "主窗口";
this.Closing += new System.ComponentModel.CancelEventHandler(this.主窗口_Closing);
this.Closed += new System.EventHandler(this.主窗口_Closed);
this.ResumeLayout(false);
}
#endregion
private void 主窗口_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
this.Close();
}
private void 主窗口_Closed(object sender, System.EventArgs e)
{
this.log.Close();
}
string addr;
int days=0;
private void menuItem2_Click(object sender, System.EventArgs e)//借书
{
try
{
书条码号 p=new 书条码号();
p.ShowDialog();
if(p.bookid=="null")return;
bookid=p.bookid;//用来查看书的借阅情况,
p.Close();
公共数据dll.Store.cn.Open();
公共数据dll.Store.sqlStr="exec lendbook '"+公共数据dll.Store.str_temp+"','"+bookid+"'";
公共数据dll.Store.cmd=new SqlCommand(公共数据dll.Store.sqlStr,公共数据dll.Store.cn);
object n=公共数据dll.Store.cmd.ExecuteNonQuery();
if(int.Parse(n.ToString())!=-1)
{
MessageBox.Show("借书成功!");
公共数据dll.Store.ds.Tables["currentrecord"].Clear();
公共数据dll.Store.sqlStr="select record.条码号,题名,馆藏地,借阅日期,应归还日期,操作='续借该书' from record,bookinfoview where record.条码号=bookinfoview.条码号 and 证件号='"+公共数据dll.Store.str_temp+"' and record.状态='未还' or record.状态='超期'";
公共数据dll.Store.myDataAdapter=new System.Data.SqlClient.SqlDataAdapter(公共数据dll.Store.sqlStr,公共数据dll.Store.cn);
公共数据dll.Store.cb =new System.Data.SqlClient.SqlCommandBuilder(公共数据dll.Store.myDataAdapter);
公共数据dll.Store.myDataAdapter.Fill(公共数据dll.Store.ds,"currentrecord");
this.userControl11.dataGrid1.SetDataBinding(公共数据dll.Store.ds,"currentrecord");
}
}
catch(Exception E)
{
MessageBox.Show(E.Message);
}
公共数据dll.Store.cn.Close();
}
private void menuItem5_Click(object sender, System.EventArgs e)//续借
{
try
{
书条码号 p=new 书条码号();
p.ShowDialog();
if(p.bookid=="null")return;
bookid=p.bookid;//用来查看书的借阅情况,
p.Close();
公共数据dll.Store.cn.Open();
公共数据dll.Store.sqlStr="exec renew '"+公共数据dll.Store.str_temp+"','"+bookid+"','"+this.singlelibrary+"'";
公共数据dll.Store.cmd=new SqlCommand(公共数据dll.Store.sqlStr,公共数据dll.Store.cn);
object n=公共数据dll.Store.cmd.ExecuteNonQuery();
if(int.Parse(n.ToString())!=-1)
{
MessageBox.Show("续借成功!");
公共数据dll.Store.ds.Tables["currentrecord"].Clear();
公共数据dll.Store.sqlStr="select record.条码号,题名,馆藏地,借阅日期,应归还日期,操作='续借该书' from record,bookinfoview where record.条码号=bookinfoview.条码号 and 证件号='"+公共数据dll.Store.str_temp+"' and record.状态='未还' or record.状态='超期'";
公共数据dll.Store.myDataAdapter=new System.Data.SqlClient.SqlDataAdapter(公共数据dll.Store.sqlStr,公共数据dll.Store.cn);
公共数据dll.Store.cb =new System.Data.SqlClient.SqlCommandBuilder(公共数据dll.Store.myDataAdapter);
公共数据dll.Store.myDataAdapter.Fill(公共数据dll.Store.ds,"currentrecord");
this.userControl11.dataGrid1.SetDataBinding(公共数据dll.Store.ds,"currentrecord");
}
}
catch(Exception E)
{
MessageBox.Show(E.Message);
}
公共数据dll.Store.cn.Close();
}
private void menuItem3_Click(object sender, System.EventArgs e)
{
try
{
书条码号 p=new 书条码号();
p.ShowDialog();
if(p.bookid=="null")return;
bookid=p.bookid;//用来查看书的借阅情况,
p.Close();
公共数据dll.Store.cn.Open();
公共数据dll.Store.sqlStr="exec giveback '"+bookid+"','"+this.singlelibrary+"'";
公共数据dll.Store.cmd=new SqlCommand(公共数据dll.Store.sqlStr,公共数据dll.Store.cn);
object n=公共数据dll.Store.cmd.ExecuteNonQuery();
if(int.Parse(n.ToString())!=-1)
{
MessageBox.Show("还书成功!");
公共数据dll.Store.ds.Tables["currentrecord"].Clear();
公共数据dll.Store.sqlStr="select record.条码号,题名,馆藏地,借阅日期,应归还日期,操作='续借该书' from record,bookinfoview where record.条码号=bookinfoview.条码号 and 证件号='"+公共数据dll.Store.str_temp+"' and record.状态='未还' or record.状态='超期'";
公共数据dll.Store.myDataAdapter=new System.Data.SqlClient.SqlDataAdapter(公共数据dll.Store.sqlStr,公共数据dll.Store.cn);
公共数据dll.Store.cb =new System.Data.SqlClient.SqlCommandBuilder(公共数据dll.Store.myDataAdapter);
公共数据dll.Store.myDataAdapter.Fill(公共数据dll.Store.ds,"currentrecord");
this.userControl11.dataGrid1.SetDataBinding(公共数据dll.Store.ds,"currentrecord");
}
}
catch(Exception E)
{
MessageBox.Show(E.Message);
}
公共数据dll.Store.cn.Close();
}
private void menuItem1_Popup(object sender, System.EventArgs e)//验证证件号的正确性
{
公共数据dll.Store.cn.Open();
公共数据dll.Store.sqlStr="select count(*) from readerinfo where 证件号='"+公共数据dll.Store.str_temp+"'";
公共数据dll.Store.cmd=new SqlCommand(公共数据dll.Store.sqlStr,公共数据dll.Store.cn);
object n=公共数据dll.Store.cmd.ExecuteScalar();
if(int.Parse(n.ToString())==1)
{
this.menuItem2.Enabled=true;
this.menuItem5.Enabled=true;
}
else
{
MessageBox.Show(n.ToString());
this.menuItem2.Enabled=false;
this.menuItem5.Enabled=false;
}
公共数据dll.Store.cn.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -