📄 mainform.cs
字号:
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;
namespace SourceManager
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class MainForm : System.Windows.Forms.Form
{
private System.Windows.Forms.MainMenu mainMenu1;
private System.Windows.Forms.MenuItem menuItem1;
private System.Windows.Forms.MenuItem menuItem3;
private System.Windows.Forms.MenuItem menuItem4;
private System.Windows.Forms.MenuItem menuItem5;
private System.Windows.Forms.MenuItem menuItem6;
private System.Windows.Forms.MenuItem menuItem8;
private System.Windows.Forms.MenuItem menuItem9;
private System.Windows.Forms.ToolBar MaintoolBar;
private System.Windows.Forms.MenuItem menuItem10;
private System.Windows.Forms.ToolBarButton toolBarButton2;
private System.Windows.Forms.MenuItem menuItem_usrload;
private System.Windows.Forms.ToolBarButton toolBarButton_USRLOAD;
private System.Windows.Forms.ImageList imageList1;
private System.Windows.Forms.MenuItem menuItem_usrmana;
private System.Data.OleDb.OleDbCommand zl_oleDbCommand;
private System.Windows.Forms.MenuItem menuItem2;
private System.Windows.Forms.MenuItem menuItem7;
private System.Windows.Forms.MenuItem menuItem11;
private System.Windows.Forms.StatusBar statusBar1;
private System.Data.OleDb.OleDbConnection zl_oleDbConnection;
private System.ComponentModel.IContainer components;
public MainForm()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();
m_currentUsr=null;
//
// TODO: Add any constructor code after InitializeComponent call
//
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.mainMenu1 = new System.Windows.Forms.MainMenu();
this.menuItem1 = new System.Windows.Forms.MenuItem();
this.menuItem_usrload = new System.Windows.Forms.MenuItem();
this.menuItem_usrmana = new System.Windows.Forms.MenuItem();
this.menuItem3 = new System.Windows.Forms.MenuItem();
this.menuItem4 = new System.Windows.Forms.MenuItem();
this.menuItem5 = new System.Windows.Forms.MenuItem();
this.menuItem6 = new System.Windows.Forms.MenuItem();
this.menuItem8 = new System.Windows.Forms.MenuItem();
this.menuItem9 = new System.Windows.Forms.MenuItem();
this.menuItem11 = new System.Windows.Forms.MenuItem();
this.menuItem10 = new System.Windows.Forms.MenuItem();
this.menuItem2 = new System.Windows.Forms.MenuItem();
this.menuItem7 = new System.Windows.Forms.MenuItem();
this.MaintoolBar = new System.Windows.Forms.ToolBar();
this.toolBarButton_USRLOAD = new System.Windows.Forms.ToolBarButton();
this.toolBarButton2 = new System.Windows.Forms.ToolBarButton();
this.imageList1 = new System.Windows.Forms.ImageList(this.components);
this.zl_oleDbCommand = new System.Data.OleDb.OleDbCommand();
this.statusBar1 = new System.Windows.Forms.StatusBar();
this.zl_oleDbConnection = new System.Data.OleDb.OleDbConnection();
this.SuspendLayout();
//
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1,
this.menuItem5,
this.menuItem2});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem_usrload,
this.menuItem_usrmana,
this.menuItem3,
this.menuItem4});
this.menuItem1.Text = "基本操作";
//
// menuItem_usrload
//
this.menuItem_usrload.Enabled = false;
this.menuItem_usrload.Index = 0;
this.menuItem_usrload.Text = "用户登录...";
this.menuItem_usrload.Click += new System.EventHandler(this.menuItem_usrload_Click);
//
// menuItem_usrmana
//
this.menuItem_usrmana.Index = 1;
this.menuItem_usrmana.Text = "用户管理...";
this.menuItem_usrmana.Click += new System.EventHandler(this.menuItem_usrmana_Click);
//
// menuItem3
//
this.menuItem3.Index = 2;
this.menuItem3.Text = "-";
//
// menuItem4
//
this.menuItem4.Index = 3;
this.menuItem4.Text = "退出";
this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
//
// menuItem5
//
this.menuItem5.Index = 1;
this.menuItem5.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem6,
this.menuItem8,
this.menuItem9,
this.menuItem11,
this.menuItem10});
this.menuItem5.Text = "代码管理";
//
// menuItem6
//
this.menuItem6.Index = 0;
this.menuItem6.Text = "添加代码...";
this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
//
// menuItem8
//
this.menuItem8.Index = 1;
this.menuItem8.Text = "寻找查询...";
this.menuItem8.Click += new System.EventHandler(this.menuItem8_Click);
//
// menuItem9
//
this.menuItem9.Index = 2;
this.menuItem9.Text = "代码属性管理...";
this.menuItem9.Click += new System.EventHandler(this.menuItem9_Click);
//
// menuItem11
//
this.menuItem11.Index = 3;
this.menuItem11.Text = "源文件数据库一致性检查...";
this.menuItem11.Click += new System.EventHandler(this.menuItem11_Click);
//
// menuItem10
//
this.menuItem10.Index = 4;
this.menuItem10.Text = "代码打印";
//
// menuItem2
//
this.menuItem2.Index = 2;
this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem7});
this.menuItem2.Text = "帮助";
//
// menuItem7
//
this.menuItem7.Index = 0;
this.menuItem7.Text = "关于我们...";
//
// MaintoolBar
//
this.MaintoolBar.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
this.toolBarButton_USRLOAD,
this.toolBarButton2});
this.MaintoolBar.ButtonSize = new System.Drawing.Size(16, 16);
this.MaintoolBar.DropDownArrows = true;
this.MaintoolBar.Location = new System.Drawing.Point(0, 0);
this.MaintoolBar.Name = "MaintoolBar";
this.MaintoolBar.ShowToolTips = true;
this.MaintoolBar.Size = new System.Drawing.Size(336, 28);
this.MaintoolBar.TabIndex = 1;
this.MaintoolBar.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.MaintoolBar_ButtonClick);
//
// imageList1
//
this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
//
// zl_oleDbCommand
//
this.zl_oleDbCommand.Connection = this.zl_oleDbConnection;
//
// statusBar1
//
this.statusBar1.Location = new System.Drawing.Point(0, 263);
this.statusBar1.Name = "statusBar1";
this.statusBar1.Size = new System.Drawing.Size(336, 22);
this.statusBar1.TabIndex = 3;
//
// zl_oleDbConnection
//
this.zl_oleDbConnection.ConnectionString = @"Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database Locking Mode=1;Data Source=""SourceManager.mdb"";Mode=Share Deny None;Jet OLEDB:Engine Type=5;Provider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB:SFP=False;persist security info=False;Extended Properties=;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;User ID=Admin;Jet OLEDB:Global Bulk Transactions=1";
//
// MainForm
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(336, 285);
this.Controls.Add(this.statusBar1);
this.Controls.Add(this.MaintoolBar);
this.IsMdiContainer = true;
this.Menu = this.mainMenu1;
this.Name = "MainForm";
this.Text = "源代码管理器v1.0";
this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
this.Load += new System.EventHandler(this.MainForm_Load);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
//执行初始化
Application.Run(new MainForm());
}
private void menuItem_usrload_Click(object sender, System.EventArgs e)
{
}
private void menuItem_usrmana_Click(object sender, System.EventArgs e)
{
}
private void MaintoolBar_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
{
}
private void MainForm_Load(object sender, System.EventArgs e)
{
string password;
//初始化数据库联接
zl_oleDbConnection.Open();
///////////////////
#region 登录
LoadForm logfrm=new LoadForm() ;
//logfrm.MdiParent=this;
if (logfrm.ShowDialog(this)== DialogResult.OK)
{
}
else
{
}
////////验证
m_currentUsr=logfrm.usrname;
password=logfrm.password;
string sqlstr;
sqlstr="select * from userinfo where userid='"+m_currentUsr+"' and password='"+password+"'";
zl_oleDbCommand.CommandText=sqlstr;
try
{
DataReader=zl_oleDbCommand.ExecuteReader();
if(!DataReader.HasRows)
{
MessageBox.Show("用户名密码有误!","错误",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
this.Close();
}
}
catch(OleDbException ee)
{
MessageBox.Show (ee.Message,"错误!");
}
finally
{
DataReader.Close();
zl_oleDbConnection.Close();
}
/////////
#endregion
/////////////////
#region 检查目录一致性
#endregion
}
private string m_currentUsr;
private OleDbDataReader DataReader;
private void menuItem4_Click(object sender, System.EventArgs e)
{
this.Close();
}
private void menuItem9_Click(object sender, System.EventArgs e)
{
ParamForm parafrm=new ParamForm();
parafrm.SetConnection(zl_oleDbConnection);
parafrm.MdiParent=this;
parafrm.Show();
}
private void menuItem6_Click(object sender, System.EventArgs e)
{
AddForm frm=new AddForm();
frm.SetConnection(zl_oleDbConnection);
frm.MdiParent=this;
frm.Show();
}
private void menuItem8_Click(object sender, System.EventArgs e)
{
SearchForm frm=new SearchForm();
frm.SetConnection(zl_oleDbConnection);
frm.MdiParent=this;
frm.Show();
}
private void menuItem11_Click(object sender, System.EventArgs e)
{
//代码文件系统一致性检查
CheckForm frm=new CheckForm();
frm.MdiParent=this;
frm.SetConnection(zl_oleDbConnection);
frm.Show();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -