?? 主窗口.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>
/// 必需的設(shè)計器變量。
/// </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 窗體設(shè)計器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 調(diào)用后添加任何構(gòu)造函數(shù)代碼
//
}
/// <summary>
/// 清理所有正在使用的資源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗體設(shè)計器生成的代碼
/// <summary>
/// 設(shè)計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內(nèi)容。
/// </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 = "續(xù)借";
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();
公共數(shù)據(jù)dll.Store.cn.Open();
公共數(shù)據(jù)dll.Store.sqlStr="exec lendbook '"+公共數(shù)據(jù)dll.Store.str_temp+"','"+bookid+"'";
公共數(shù)據(jù)dll.Store.cmd=new SqlCommand(公共數(shù)據(jù)dll.Store.sqlStr,公共數(shù)據(jù)dll.Store.cn);
object n=公共數(shù)據(jù)dll.Store.cmd.ExecuteNonQuery();
if(int.Parse(n.ToString())!=-1)
{
MessageBox.Show("借書成功!");
公共數(shù)據(jù)dll.Store.ds.Tables["currentrecord"].Clear();
公共數(shù)據(jù)dll.Store.sqlStr="select record.條碼號,題名,館藏地,借閱日期,應(yīng)歸還日期,操作='續(xù)借該書' from record,bookinfoview where record.條碼號=bookinfoview.條碼號 and 證件號='"+公共數(shù)據(jù)dll.Store.str_temp+"' and record.狀態(tài)='未還' or record.狀態(tài)='超期'";
公共數(shù)據(jù)dll.Store.myDataAdapter=new System.Data.SqlClient.SqlDataAdapter(公共數(shù)據(jù)dll.Store.sqlStr,公共數(shù)據(jù)dll.Store.cn);
公共數(shù)據(jù)dll.Store.cb =new System.Data.SqlClient.SqlCommandBuilder(公共數(shù)據(jù)dll.Store.myDataAdapter);
公共數(shù)據(jù)dll.Store.myDataAdapter.Fill(公共數(shù)據(jù)dll.Store.ds,"currentrecord");
this.userControl11.dataGrid1.SetDataBinding(公共數(shù)據(jù)dll.Store.ds,"currentrecord");
}
}
catch(Exception E)
{
MessageBox.Show(E.Message);
}
公共數(shù)據(jù)dll.Store.cn.Close();
}
private void menuItem5_Click(object sender, System.EventArgs e)//續(xù)借
{
try
{
書條碼號 p=new 書條碼號();
p.ShowDialog();
if(p.bookid=="null")return;
bookid=p.bookid;//用來查看書的借閱情況,
p.Close();
公共數(shù)據(jù)dll.Store.cn.Open();
公共數(shù)據(jù)dll.Store.sqlStr="exec renew '"+公共數(shù)據(jù)dll.Store.str_temp+"','"+bookid+"','"+this.singlelibrary+"'";
公共數(shù)據(jù)dll.Store.cmd=new SqlCommand(公共數(shù)據(jù)dll.Store.sqlStr,公共數(shù)據(jù)dll.Store.cn);
object n=公共數(shù)據(jù)dll.Store.cmd.ExecuteNonQuery();
if(int.Parse(n.ToString())!=-1)
{
MessageBox.Show("續(xù)借成功!");
公共數(shù)據(jù)dll.Store.ds.Tables["currentrecord"].Clear();
公共數(shù)據(jù)dll.Store.sqlStr="select record.條碼號,題名,館藏地,借閱日期,應(yīng)歸還日期,操作='續(xù)借該書' from record,bookinfoview where record.條碼號=bookinfoview.條碼號 and 證件號='"+公共數(shù)據(jù)dll.Store.str_temp+"' and record.狀態(tài)='未還' or record.狀態(tài)='超期'";
公共數(shù)據(jù)dll.Store.myDataAdapter=new System.Data.SqlClient.SqlDataAdapter(公共數(shù)據(jù)dll.Store.sqlStr,公共數(shù)據(jù)dll.Store.cn);
公共數(shù)據(jù)dll.Store.cb =new System.Data.SqlClient.SqlCommandBuilder(公共數(shù)據(jù)dll.Store.myDataAdapter);
公共數(shù)據(jù)dll.Store.myDataAdapter.Fill(公共數(shù)據(jù)dll.Store.ds,"currentrecord");
this.userControl11.dataGrid1.SetDataBinding(公共數(shù)據(jù)dll.Store.ds,"currentrecord");
}
}
catch(Exception E)
{
MessageBox.Show(E.Message);
}
公共數(shù)據(jù)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();
公共數(shù)據(jù)dll.Store.cn.Open();
公共數(shù)據(jù)dll.Store.sqlStr="exec giveback '"+bookid+"','"+this.singlelibrary+"'";
公共數(shù)據(jù)dll.Store.cmd=new SqlCommand(公共數(shù)據(jù)dll.Store.sqlStr,公共數(shù)據(jù)dll.Store.cn);
object n=公共數(shù)據(jù)dll.Store.cmd.ExecuteNonQuery();
if(int.Parse(n.ToString())!=-1)
{
MessageBox.Show("還書成功!");
公共數(shù)據(jù)dll.Store.ds.Tables["currentrecord"].Clear();
公共數(shù)據(jù)dll.Store.sqlStr="select record.條碼號,題名,館藏地,借閱日期,應(yīng)歸還日期,操作='續(xù)借該書' from record,bookinfoview where record.條碼號=bookinfoview.條碼號 and 證件號='"+公共數(shù)據(jù)dll.Store.str_temp+"' and record.狀態(tài)='未還' or record.狀態(tài)='超期'";
公共數(shù)據(jù)dll.Store.myDataAdapter=new System.Data.SqlClient.SqlDataAdapter(公共數(shù)據(jù)dll.Store.sqlStr,公共數(shù)據(jù)dll.Store.cn);
公共數(shù)據(jù)dll.Store.cb =new System.Data.SqlClient.SqlCommandBuilder(公共數(shù)據(jù)dll.Store.myDataAdapter);
公共數(shù)據(jù)dll.Store.myDataAdapter.Fill(公共數(shù)據(jù)dll.Store.ds,"currentrecord");
this.userControl11.dataGrid1.SetDataBinding(公共數(shù)據(jù)dll.Store.ds,"currentrecord");
}
}
catch(Exception E)
{
MessageBox.Show(E.Message);
}
公共數(shù)據(jù)dll.Store.cn.Close();
}
private void menuItem1_Popup(object sender, System.EventArgs e)//驗證證件號的正確性
{
公共數(shù)據(jù)dll.Store.cn.Open();
公共數(shù)據(jù)dll.Store.sqlStr="select count(*) from readerinfo where 證件號='"+公共數(shù)據(jù)dll.Store.str_temp+"'";
公共數(shù)據(jù)dll.Store.cmd=new SqlCommand(公共數(shù)據(jù)dll.Store.sqlStr,公共數(shù)據(jù)dll.Store.cn);
object n=公共數(shù)據(jù)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;
}
公共數(shù)據(jù)dll.Store.cn.Close();
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -