📄 frmmain.cs
字号:
//Copyright (C) 2002 Microsoft Corporation
//All rights reserved.
//THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
//EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
//MERCHANTIBILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
//Requires the Trial or Release version of Visual Studio .NET Professional (or greater).
using System;
using System.Windows.Forms;
using System.Threading;
using System.Data;
public class frmMain: System.Windows.Forms.Form {
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new frmMain());
}
#region " Windows Form Designer generated code "
public frmMain()
{
//This call is required by the Windows Form Designer.
InitializeComponent();
//Add any initialization after the InitializeComponent() call
// So that we only need to set the title of the application once,
// we use the AssemblyInfo class (defined in the AssemblyInfo.cs file)
// to read the AssemblyTitle attribute.
AssemblyInfo ainfo = new AssemblyInfo();
this.Text = ainfo.Title;
this.mnuAbout.Text = string.Format("&About {0} ...", ainfo.Title);
}
//Form overrides dispose to clean up the component list.
protected override void Dispose(bool disposing) {
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
//Required by the Windows Form Designer
private System.ComponentModel.IContainer components = null;
//NOTE: The following procedure is required by the Windows Form Designer
//It can be modified using the Windows Form Designer.
//Do not modify it using the code editor.
private System.Windows.Forms.MainMenu mnuMain;
private System.Windows.Forms.MenuItem mnuFile;
private System.Windows.Forms.MenuItem mnuExit;
private System.Windows.Forms.MenuItem mnuHelp;
private System.Windows.Forms.MenuItem mnuAbout;
private System.Windows.Forms.DataGrid dgUsers;
private System.Windows.Forms.Label Label1;
private void InitializeComponent() {
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMain));
this.mnuMain = new System.Windows.Forms.MainMenu(this.components);
this.mnuFile = new System.Windows.Forms.MenuItem();
this.mnuExit = new System.Windows.Forms.MenuItem();
this.mnuHelp = new System.Windows.Forms.MenuItem();
this.mnuAbout = new System.Windows.Forms.MenuItem();
this.dgUsers = new System.Windows.Forms.DataGrid();
this.Label1 = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.dgUsers)).BeginInit();
this.SuspendLayout();
//
// mnuMain
//
this.mnuMain.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mnuFile,
this.mnuHelp});
//
// mnuFile
//
this.mnuFile.Index = 0;
this.mnuFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mnuExit});
resources.ApplyResources(this.mnuFile, "mnuFile");
//
// mnuExit
//
this.mnuExit.Index = 0;
resources.ApplyResources(this.mnuExit, "mnuExit");
this.mnuExit.Click += new System.EventHandler(this.mnuExit_Click);
//
// mnuHelp
//
this.mnuHelp.Index = 1;
this.mnuHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.mnuAbout});
resources.ApplyResources(this.mnuHelp, "mnuHelp");
//
// mnuAbout
//
this.mnuAbout.Index = 0;
resources.ApplyResources(this.mnuAbout, "mnuAbout");
this.mnuAbout.Click += new System.EventHandler(this.mnuAbout_Click);
//
// dgUsers
//
resources.ApplyResources(this.dgUsers, "dgUsers");
this.dgUsers.DataMember = "";
this.dgUsers.HeaderForeColor = System.Drawing.SystemColors.ControlText;
this.dgUsers.Name = "dgUsers";
//
// Label1
//
resources.ApplyResources(this.Label1, "Label1");
this.Label1.Name = "Label1";
//
// frmMain
//
resources.ApplyResources(this, "$this");
this.Controls.Add(this.Label1);
this.Controls.Add(this.dgUsers);
this.MaximizeBox = false;
this.Menu = this.mnuMain;
this.Name = "frmMain";
this.Load += new System.EventHandler(this.frmMain_Load);
((System.ComponentModel.ISupportInitialize)(this.dgUsers)).EndInit();
this.ResumeLayout(false);
}
#endregion
#region " Standard Menu Code "
// This code simply shows the About form.
private void mnuAbout_Click(object sender, System.EventArgs e) {
// Open the About form in Dialog Mode
frmAbout frm = new frmAbout();
frm.ShowDialog(this);
frm.Dispose();
}
// This code will close the form.
private void mnuExit_Click(object sender, System.EventArgs e) {
// Close the current form
this.Close();
}
#endregion
private void frmMain_Load(object sender, System.EventArgs e) {
if ((Thread.CurrentPrincipal.IsInRole("Teacher")) ||
(Thread.CurrentPrincipal.IsInRole(@"BuiltIn\Administrators")))
{
DataSet dsUsers = new DataSet();
dsUsers.ReadXml(@"..\..\users.xml");
dgUsers.CaptionText = "用户账号";
dgUsers.DataSource = dsUsers.Tables[0];
}
else
{
MessageBox.Show("您必须是老师或本地管理员账户" +
"查看后台账户数据", "权限不够!",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -