📄 form1.cs
字号:
//
// MenuItem4
//
this.MenuItem4.Index = 2;
this.MenuItem4.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.MenuItem8,
this.MenuItem9});
this.MenuItem4.Text = "帮助(&H)";
//
// MenuItem8
//
this.MenuItem8.Index = 0;
this.MenuItem8.Text = "关于";
this.MenuItem8.Click += new System.EventHandler(this.MenuItem8_Click);
//
// MenuItem9
//
this.MenuItem9.Index = 1;
this.MenuItem9.Text = "帮助";
//
// BtEdit
//
this.BtEdit.BackColor = System.Drawing.Color.Plum;
this.BtEdit.Location = new System.Drawing.Point(208, 216);
this.BtEdit.Name = "BtEdit";
this.BtEdit.Size = new System.Drawing.Size(64, 24);
this.BtEdit.TabIndex = 6;
this.BtEdit.Text = "编辑&E";
this.BtEdit.Click += new System.EventHandler(this.BtEdit_Click);
//
// BtDelete
//
this.BtDelete.BackColor = System.Drawing.Color.Plum;
this.BtDelete.Location = new System.Drawing.Point(208, 184);
this.BtDelete.Name = "BtDelete";
this.BtDelete.Size = new System.Drawing.Size(64, 24);
this.BtDelete.TabIndex = 5;
this.BtDelete.Text = "删除&D";
this.BtDelete.Click += new System.EventHandler(this.BtDelete_Click);
//
// BtAdd
//
this.BtAdd.BackColor = System.Drawing.Color.Plum;
this.BtAdd.Location = new System.Drawing.Point(208, 152);
this.BtAdd.Name = "BtAdd";
this.BtAdd.Size = new System.Drawing.Size(64, 24);
this.BtAdd.TabIndex = 4;
this.BtAdd.Text = "添加&A";
this.BtAdd.Click += new System.EventHandler(this.BtAdd_Click);
//
// BtLast
//
this.BtLast.BackColor = System.Drawing.Color.Plum;
this.BtLast.Location = new System.Drawing.Point(208, 120);
this.BtLast.Name = "BtLast";
this.BtLast.Size = new System.Drawing.Size(64, 24);
this.BtLast.TabIndex = 3;
this.BtLast.Text = "最后一条&L";
this.BtLast.Click += new System.EventHandler(this.BtLast_Click);
//
// BtFirst
//
this.BtFirst.BackColor = System.Drawing.Color.Plum;
this.BtFirst.Location = new System.Drawing.Point(208, 88);
this.BtFirst.Name = "BtFirst";
this.BtFirst.Size = new System.Drawing.Size(64, 24);
this.BtFirst.TabIndex = 2;
this.BtFirst.Text = "第一条&F";
this.BtFirst.Click += new System.EventHandler(this.BtFirst_Click);
//
// BtNext
//
this.BtNext.BackColor = System.Drawing.Color.Plum;
this.BtNext.Location = new System.Drawing.Point(208, 56);
this.BtNext.Name = "BtNext";
this.BtNext.Size = new System.Drawing.Size(64, 24);
this.BtNext.TabIndex = 1;
this.BtNext.Text = "下一条&N";
this.BtNext.Click += new System.EventHandler(this.BtNext_Click);
//
// BtPre
//
this.BtPre.BackColor = System.Drawing.Color.Plum;
this.BtPre.Location = new System.Drawing.Point(208, 24);
this.BtPre.Name = "BtPre";
this.BtPre.Size = new System.Drawing.Size(64, 24);
this.BtPre.TabIndex = 0;
this.BtPre.Text = "上一条&P";
this.BtPre.Click += new System.EventHandler(this.BtPre_Click);
//
// NotifyIcon1
//
this.NotifyIcon1.ContextMenu = this.myIconMenu;
this.NotifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("NotifyIcon1.Icon")));
this.NotifyIcon1.Text = "学生名册管理系统";
this.NotifyIcon1.Visible = true;
this.NotifyIcon1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.NotifyIcon1_MouseDown);
//
// myIconMenu
//
this.myIconMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.MenuItem2,
this.MenuItem12});
this.myIconMenu.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
this.myIconMenu.Popup += new System.EventHandler(this.myIconMenu_Popup);
//
// MenuItem2
//
this.MenuItem2.Index = 0;
this.MenuItem2.Text = "关于学生名册管理系统";
this.MenuItem2.Click += new System.EventHandler(this.MenuItem2_Click);
//
// MenuItem12
//
this.MenuItem12.Index = 1;
this.MenuItem12.Text = "退出";
this.MenuItem12.Click += new System.EventHandler(this.MenuItem12_Click);
//
// MonthCalendar1
//
this.MonthCalendar1.Cursor = System.Windows.Forms.Cursors.Hand;
this.MonthCalendar1.Location = new System.Drawing.Point(184, 120);
this.MonthCalendar1.Name = "MonthCalendar1";
this.MonthCalendar1.TabIndex = 22;
this.MonthCalendar1.Visible = false;
this.MonthCalendar1.DateSelected += new System.Windows.Forms.DateRangeEventHandler(this.MonthCalendar1_DateSelected);
//
// Cal
//
this.Cal.Location = new System.Drawing.Point(184, 120);
this.Cal.Name = "Cal";
this.Cal.Size = new System.Drawing.Size(16, 16);
this.Cal.TabIndex = 23;
this.Cal.Text = "Button1";
this.Cal.Click += new System.EventHandler(this.Cal_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.BackColor = System.Drawing.Color.Plum;
this.ClientSize = new System.Drawing.Size(456, 265);
this.Controls.AddRange(new System.Windows.Forms.Control[] {
this.Cal,
this.MonthCalendar1,
this.Label6,
this.txtSearch,
this.CmbSearch,
this.Label5,
this.TxtTel,
this.label4,
this.TxtDate,
this.label3,
this.TxtName,
this.label2,
this.txtNumber,
this.label1,
this.BtExit,
this.BtFind,
this.BtEdit,
this.BtDelete,
this.BtAdd,
this.BtLast,
this.BtFirst,
this.BtNext,
this.BtPre});
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Menu = this.MainMenu1;
this.Name = "Form1";
this.Text = "Form1";
this.TopMost = true;
this.Load += new System.EventHandler(this.Form1_Load);
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}
//----------------------------------------------
//以下定义了一些DAO对象
//和一些SQL打开数据库字符串
//设计了一个OPenDB()函数
//用DAO对象打开了数据库
//----------------------------------------------
DAO.Database Mydb;
//定义一个DAO.Database数据库对象
DAO.Workspace MyWs;
//定义一个工作空间DAO.Workspace
String MySql ;
//定义一个字符串用来存放SQL查询语言
DAO.Recordset Myrec;
//定义一个数据项DAO.Recordset
DAO.DBEngine de=new DAO.DBEngineClass();
//定义一个数据引擎DAO.DBEngine()
public bool OpenDb()
{
//定义一个数据打开函数
String dbstr;
//定义一个字符串来存放数据库所在目录
dbstr =Application.StartupPath +"\\STUDENT.MDB";
//取得数据库所在目录
MyWs = de.Workspaces[0];
//建立一个工作空间
Mydb = MyWs.OpenDatabase(dbstr,null,null,null);
//打开数据库存放于Mydb
MySql = "select * from 学生名册";
//设置SQL打开方式
Myrec = Mydb.OpenRecordset(MySql,
DAO.RecordsetTypeEnum.dbOpenDynaset,
DAO.RecordsetOptionEnum.dbDenyWrite,
DAO.LockTypeEnum.dbOptimistic);
//打开数据项
return true;
}
private void Form1_Load(object sender, System.EventArgs e)
{
txtNumber.Text = Myrec.Fields[0].Value.ToString();
//给 txtnumber.Text赋值为数据项的0单员中的内容
TxtName.Text = Myrec.Fields[1].Value.ToString();
//给 txtname.Text赋值为数据项的1单员中的内容
TxtDate.Text = Myrec.Fields[3].Value.ToString().Substring(0,9);
//用.Substring(0, 9)方法取得时间字符串的前10位
//在这里进行了修改
//给 txtdate.Text赋值为数据项的3单员中的内容
TxtTel.Text = Myrec.Fields[2].Value.ToString();
//给 txttel.Text赋值为数据项的2单员中的内容
}
private void BtNext_Click(object sender, System.EventArgs e)
{
//当点击下一条按钮时产生的操作
Myrec.MoveNext();
//数据项先后移动一项
if(Myrec.EOF)
{
//判断是否移动到了末尾
MessageBox.Show("已经是最后一条");
//如果到了末尾则不向下移动数据项
}
else
{
txtNumber.Text = Myrec.Fields[0].Value.ToString();
//给 txtnumber.Text赋值为数据项的0单员中的内容
TxtName.Text = Myrec.Fields[1].Value.ToString();
//给 txtname.Text赋值为数据项的1单员中的内容
TxtDate.Text = Myrec.Fields[3].Value.ToString().Substring(0, 9);
//用.Substring(0, 9)方法取得时间字符串的前10位
//给 txtdate.Text赋值为数据项的3单员中的内容
TxtTel.Text = Myrec.Fields[2].Value.ToString();
//给 txttel.Text赋值为数据项的2单员中的内容
}
}
private void BtPre_Click(object sender, System.EventArgs e)
{
//点击上一条时产生的操作
Myrec.MovePrevious();
//如果没到则向前移动数据项
if(Myrec.BOF)
{
//判断是否移动到了末尾
MessageBox.Show("已经是第一条");
//如果到了末尾则不向上移动数据项
}
else
{
txtNumber.Text = Myrec.Fields[0].Value.ToString();
//给 txtnumber.Text赋值为数据项的0单员中的内容
TxtName.Text = Myrec.Fields[1].Value.ToString();
//给 txtname.Text赋值为数据项的1单员中的内容
TxtDate.Text = Myrec.Fields[3].Value.ToString().Substring(0, 9);
//用.Substring(0, 9)方法取得时间字符串的前10位
//给 txtdate.Text赋值为数据项的3单员中的内容
TxtTel.Text = Myrec.Fields[2].Value.ToString();
//给 txttel.Text赋值为数据项的2单员中的内容
}
}
private void BtFirst_Click(object sender, System.EventArgs e)
{
Myrec.MoveFirst();
//将记录移动到第一条
txtNumber.Text = Myrec.Fields[0].Value.ToString();
//给 txtnumber.Text赋值为数据项的0单员中的内容
TxtName.Text = Myrec.Fields[1].Value.ToString();
//给 txtname.Text赋值为数据项的1单员中的内容
TxtDate.Text = Myrec.Fields[3].Value.ToString().Substring(0, 9);
//用.Substring(0, 9)方法取得时间字符串的前10位
//给 txtdate.Text赋值为数据项的3单员中的内容
TxtTel.Text = Myrec.Fields[2].Value.ToString();
//给 txttel.Text赋值为数据项的2单员中的内容
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -