?? librarymanager.cs
字號:
#region Using
using System;
using System.Drawing;
//using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.IO;
using Library.Class;
using DataBaseOperation;
#endregion
namespace Library
{
/// <summary>
/// Global 的摘要說明。
/// </summary>
public class Global : System.Windows.Forms.Form
{
#region 控件變量
private System.Windows.Forms.MainMenu mnuMain;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem mnuBuyBooks;
private System.Windows.Forms.MenuItem menuItem10;
private System.Windows.Forms.MenuItem menuItem11;
private System.Windows.Forms.MenuItem mnuAddNewCard;
private System.Windows.Forms.MenuItem menuItem19;
private System.Windows.Forms.MenuItem menuItem20;
private System.Windows.Forms.MenuItem mnuSystem;
private System.Windows.Forms.MenuItem mnuExitSystem;
private System.Windows.Forms.MenuItem mnuHelp;
private System.Windows.Forms.MenuItem mnuWindows;
private System.Windows.Forms.ImageList iltToolBar;
private System.Windows.Forms.ToolBar tbMain;
private System.Windows.Forms.ToolBarButton toolBarButton1;
private System.Windows.Forms.ToolBarButton toolBarButton2;
private System.Windows.Forms.ToolBarButton toolBarButton6;
private System.Windows.Forms.MenuItem mnuAboutLibraryManageSystem;
private System.Windows.Forms.MenuItem mnuReturnBooks;
private System.Windows.Forms.MenuItem mnuCancelReader;
private System.Windows.Forms.MenuItem mnuProvisionalLeave;
private System.Windows.Forms.MenuItem mnuStatistics;
private System.Windows.Forms.MenuItem mnuBooksStatistics;
private System.Windows.Forms.MenuItem mnuReaderStatistics;
private System.Windows.Forms.MenuItem mnuRegisterLoss;
private System.Windows.Forms.MenuItem mnuLiftLossRegister;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem mnuBooksSetting;
private System.Windows.Forms.MenuItem mnuBooksManage;
private System.Windows.Forms.MenuItem mnuReaderManage;
private System.Windows.Forms.MenuItem mnuSystemSearch;
private System.Windows.Forms.MenuItem menuItem5;
private System.Windows.Forms.MenuItem menuItem6;
private System.Windows.Forms.MenuItem menuItem18;
private System.Windows.Forms.MenuItem menuItem21;
private System.Windows.Forms.MenuItem menuItem22;
private System.Windows.Forms.MenuItem menuItem23;
private System.Windows.Forms.MenuItem menuItem25;
private System.Windows.Forms.MenuItem menuItem27;
private System.Windows.Forms.MenuItem menuItem32;
private System.Windows.Forms.MenuItem menuItem33;
private System.Windows.Forms.MenuItem menuItem34;
private System.Windows.Forms.MenuItem menuItem35;
private System.Windows.Forms.MenuItem menuItem36;
private System.Windows.Forms.MenuItem menuItem37;
private System.Windows.Forms.MenuItem menuItem38;
private System.Windows.Forms.MenuItem menuItem39;
private System.Windows.Forms.MenuItem menuItem40;
private System.Windows.Forms.MenuItem menuItem41;
private System.Windows.Forms.MenuItem menuItem42;
private System.Windows.Forms.MenuItem menuItem43;
private System.Windows.Forms.MenuItem menuItem44;
private System.Windows.Forms.ToolBarButton toolBarButton3;
private System.Windows.Forms.ToolBarButton toolBarButton4;
private System.Windows.Forms.ToolBarButton toolBarButton5;
private System.Windows.Forms.ToolBarButton toolBarButton7;
private System.Windows.Forms.MenuItem menuItem48;
private System.Drawing.Printing.PrintDocument prtDocument;
private System.Windows.Forms.PageSetupDialog dlgPageSetup;
private System.Windows.Forms.PrintDialog dlgPrint;
private System.Windows.Forms.MenuItem mnuPressSetting;
private System.Windows.Forms.MenuItem mnuUserSetting;
private System.Windows.Forms.MenuItem mnuLibraryInfo;
private System.Windows.Forms.MenuItem mnuBorrowBooks;
private System.Windows.Forms.MenuItem mnuBooksInfo;
private System.ComponentModel.IContainer components;
#endregion
#region 靜態變量
/// <summary>
/// 狀態欄sbrGlobal
/// </summary>
public static System.Windows.Forms.StatusBar sbrGlobal;
/// <summary>
/// 狀態欄Panel sbpGlobal
/// </summary>
public static System.Windows.Forms.StatusBarPanel sbpGlobal;
/// <summary>
/// 狀態欄Panel sbpOther
/// </summary>
public static System.Windows.Forms.StatusBarPanel sbpOther;
/// <summary>
/// SqlConnection
/// </summary>
public static SqlConnection conn;
/// <summary>
/// SqlConnection.ConnectionString
/// </summary>
public static string ConnectionString = @"data source = localhost;
initial catalog = Library;
integrated security = SSPI;
persist security info = False;
packet size= 4096";
/// <summary>
/// 激活狀態的子窗體
/// </summary>
public static string ActiveChild = "null";
/// <summary>
/// BooksInfo窗口打開標志
/// </summary>
public static bool BooksInfo = false;
/// <summary>
/// BorrowBooks窗口打開標志
/// </summary>
public static bool BorrowBooks = false;
/// <summary>
/// 續借圖書窗口打開標志
/// </summary>
public static bool ReborrowBooks = false;
/// <summary>
/// 歸還圖書窗口打開標志
/// </summary>
public static bool ReturnBooks = false;
/// <summary>
/// 圖書借閱排名窗口打開標志
/// </summary>
public static bool BooksStatistics = false;
/// <summary>
/// 讀者借閱排名窗口打開標志
/// </summary>
public static bool ReaderStatistics = false;
/// <summary>
/// 登陸的用戶名
/// </summary>
public static string UserName;
/// <summary>
/// 登陸窗體
/// </summary>
public static Library.LoginSystem m_LoginSystem ;
/// <summary>
/// 權限設置_ 系統設置
/// </summary>
public static bool b_SystemSetting = false;
/// <summary>
/// 權限設置_圖書設置
/// </summary>
public static bool b_BooksSetting = false;
/// <summary>
/// 權限設置_圖書管理
/// </summary>
public static bool b_BooksManage = false;
/// <summary>
/// 權限設置_讀者管理
/// </summary>
public static bool b_ReaderManage = false;
/// <summary>
/// 權限設置_系統查詢
/// </summary>
public static bool b_SystemSearch = false;
/// <summary>
/// 權限設置_統計排名
/// </summary>
public static bool b_Statistics = false;
#endregion
#region 其他變量
/// <summary>
/// MDI窗體中的客戶區,獲取此客戶區可以實現MDI窗體中顯示圖形等
/// </summary>
private System.Windows.Forms.MdiClient mdiClient;
private System.Windows.Forms.MenuItem mnuReaderManager;
private System.Windows.Forms.MenuItem menuItem2;
/// <summary>
/// 配置
/// </summary>
public static DBConfig db = new DBConfig();
#endregion
#region 程序初始化與關閉時銷毀
/// <summary>
/// 生成字符串
/// </summary>
/// <returns></returns>
public void createConnectionString()
{
if(db.Exists())
{
db = DBConfig.Load();
ConnectionString = "server=" + db.DbSource + ";database=" + db.DbName + ";uid="+db.UID + ";pwd="+db.PWD;
//數據庫聯接字符串
conn.ConnectionString = ConnectionString;
try
{
conn.Open();
}
catch(Exception ex)
{
conn.Close();
MessageBox.Show("數據庫連接錯誤!系統將轉到數據庫配置向導!\n錯誤信息:\n\t" + ex.ToString(),"錯誤",MessageBoxButtons.OK,MessageBoxIcon.Error);
Library.DataBaseSetting dbs = new DataBaseSetting();
dbs.ShowDialog();
}
}
else
{
Library.DataBaseSetting dbs = new DataBaseSetting();
dbs.ShowDialog();
}
}
public Global()
{
//Library.Class.HashMethod hm = new HashMethod();
//Console.WriteLine(hm.Encrypto("admin"));
Library.SplashForm sf = new SplashForm();
sf.Show();
//數據庫聯接
conn = new SqlConnection();
createConnectionString();
sf.Close();
//
//登陸
//
m_LoginSystem = new LoginSystem(true);
m_LoginSystem.ShowDialog();
//
//
// Windows 窗體設計器支持所必需的
//
InitializeComponent();
//狀態欄
sbrGlobal = new System.Windows.Forms.StatusBar();
sbpGlobal = new System.Windows.Forms.StatusBarPanel();
sbpOther = new StatusBarPanel();
((System.ComponentModel.ISupportInitialize)(sbpGlobal)).BeginInit();
//
// sbrGlobal
//
sbrGlobal.Location = new System.Drawing.Point(0, 548);
sbrGlobal.Name = "sbrGlobal";
sbrGlobal.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {sbpGlobal,sbpOther});
sbrGlobal.ShowPanels = true;
sbrGlobal.Size = new System.Drawing.Size(794, 20);
sbrGlobal.SizingGrip = false;
sbrGlobal.TabIndex = 0;
//
//sbpOther
//
sbpOther.Width = 200;
sbpOther.Text = "當前登陸用戶:" + UserName;
//
// sbpGlobal
//
sbpGlobal.Text = "就緒";
sbpGlobal.Width = 594;
this.Controls.Add(sbrGlobal);
((System.ComponentModel.ISupportInitialize)(sbpGlobal)).EndInit();
//
//準備獲取MdiClient
//
int iCnt=this.Controls.Count;
for(int i=0;i<this.Controls.Count;i++)
{
if(this.Controls[i].GetType().ToString()=="System.Windows.Forms.MdiClient")
{
this.mdiClient=(System.Windows.Forms.MdiClient)this.Controls[i];
break;
}
}
string fbImage = Application.StartupPath + "\\Images\\backGround.jpg";
if(File.Exists(fbImage))
{
Bitmap bm = new Bitmap(fbImage);
this.mdiClient.BackgroundImage = bm;
}
}
/// <summary>
/// 清理所有正在使用的資源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
/// <summary>
/// 應用程序的主入口點。
/// </summary>
[STAThread]
static void Main()
{
//采用Windows XP界面
Application.DoEvents();
Application.EnableVisualStyles();
Application.DoEvents();
//系統運行
Application.Run(new Global());
}
#endregion
#region Windows 窗體設計器生成的代碼
/// <summary>
/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內容。
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Global));
this.mnuMain = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.mnuProvisionalLeave = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.mnuExitSystem = new System.Windows.Forms.MenuItem();
this.mnuSystem = new System.Windows.Forms.MenuItem();
this.mnuUserSetting = new System.Windows.Forms.MenuItem();
this.mnuLibraryInfo = new System.Windows.Forms.MenuItem();
this.mnuBooksSetting = new System.Windows.Forms.MenuItem();
this.mnuPressSetting = new System.Windows.Forms.MenuItem();
this.menuItem48 = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.mnuBooksManage = new System.Windows.Forms.MenuItem();
this.mnuBuyBooks = new System.Windows.Forms.MenuItem();
this.mnuBooksInfo = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
this.mnuBorrowBooks = new System.Windows.Forms.MenuItem();
this.menuItem10 = new System.Windows.Forms.MenuItem();
this.menuItem11 = new System.Windows.Forms.MenuItem();
this.mnuReturnBooks = new System.Windows.Forms.MenuItem();
this.menuItem18 = new System.Windows.Forms.MenuItem();
this.menuItem21 = new System.Windows.Forms.MenuItem();
this.menuItem22 = new System.Windows.Forms.MenuItem();
this.mnuReaderManage = new System.Windows.Forms.MenuItem();
this.menuItem23 = new System.Windows.Forms.MenuItem();
this.menuItem25 = new System.Windows.Forms.MenuItem();
this.mnuAddNewCard = new System.Windows.Forms.MenuItem();
this.mnuCancelReader = new System.Windows.Forms.MenuItem();
this.mnuRegisterLoss = new System.Windows.Forms.MenuItem();
this.mnuLiftLossRegister = new System.Windows.Forms.MenuItem();
this.menuItem27 = new System.Windows.Forms.MenuItem();
this.mnuReaderManager = new System.Windows.Forms.MenuItem();
this.mnuSystemSearch = new System.Windows.Forms.MenuItem();
this.menuItem32 = new System.Windows.Forms.MenuItem();
this.menuItem33 = new System.Windows.Forms.MenuItem();
this.menuItem34 = new System.Windows.Forms.MenuItem();
this.menuItem35 = new System.Windows.Forms.MenuItem();
this.menuItem36 = new System.Windows.Forms.MenuItem();
this.menuItem37 = new System.Windows.Forms.MenuItem();
this.menuItem38 = new System.Windows.Forms.MenuItem();
this.menuItem39 = new System.Windows.Forms.MenuItem();
this.menuItem40 = new System.Windows.Forms.MenuItem();
this.menuItem41 = new System.Windows.Forms.MenuItem();
this.menuItem42 = new System.Windows.Forms.MenuItem();
this.menuItem43 = new System.Windows.Forms.MenuItem();
this.menuItem44 = new System.Windows.Forms.MenuItem();
this.mnuStatistics = new System.Windows.Forms.MenuItem();
this.mnuBooksStatistics = new System.Windows.Forms.MenuItem();
this.mnuReaderStatistics = new System.Windows.Forms.MenuItem();
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -