?? frmmain.cs
字號:
// mainMenu1
//
this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem1,
this.menuItem2,
this.menuItem3});
//
// menuItem1
//
this.menuItem1.Index = 0;
this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
this.menuItem4,
this.menuItem5,
this.menuItem6,
this.menuItem7,
this.menuItem8});
this.menuItem1.Text = "文件";
//
// menuItem4
//
this.menuItem4.Index = 0;
this.menuItem4.Text = "新建班級(&c)";
this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click);
//
// menuItem5
//
this.menuItem5.Index = 1;
this.menuItem5.Text = "新建學生檔案(&s)";
this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click);
//
// menuItem6
//
this.menuItem6.Index = 2;
this.menuItem6.Text = "科目管理(&k)";
this.menuItem6.Click += new System.EventHandler(this.menuItem6_Click);
//
// menuItem7
//
this.menuItem7.Index = 3;
this.menuItem7.Text = "新建課程(&l)";
this.menuItem7.Click += new System.EventHandler(this.menuItem7_Click);
//
// menuItem8
//
this.menuItem8.Index = 4;
this.menuItem8.Text = "退出(&e)";
//
// menuItem2
//
this.menuItem2.Index = 1;
this.menuItem2.Text = "視圖";
//
// menuItem3
//
this.menuItem3.Index = 2;
this.menuItem3.Text = "幫助";
//
// frmMain
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(624, 349);
this.Controls.Add(this.panel2);
this.Controls.Add(this.panel1);
this.Menu = this.mainMenu1;
this.Name = "frmMain";
this.Text = "主窗體";
this.Load += new System.EventHandler(this.frmMain_Load);
this.panel1.ResumeLayout(false);
this.panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dgScore)).EndInit();
this.ResumeLayout(false);
}
#endregion
/// <summary>
/// 應用程序的主入口點。
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new frmMain());
}
//顯示班級的方法
public void ShowClass()
{
Classs classes=new Classs ();
dsClass=classes.SelectClass(-1,"");
this.tvClass .Nodes .Clear ();
foreach(System.Data.DataRow row in dsClass.Tables [0].Rows)
{
System.Windows.Forms .TreeNode node=new TreeNode (row[1].ToString(),0,0);
this.tvClass.Nodes.Add (node);
}
}
//在listview中顯示學生信息的方法
public void ShowStudent(int iStudentId,string sStudentName,string sStudentNo, int iClassId)
{
Students student=new Students ();
dsStudent =student.SelectStudent(iStudentId, sStudentName, sStudentNo, iClassId);
this.lvStudent .Items .Clear ();
foreach(System.Data.DataRow row in dsStudent.Tables [0].Rows)
{
string sex="";
if((int)row[3]==0)
{
sex="男";
}
else
{
sex="女";
}
ListViewItem i=new ListViewItem(new string[]{ row[2].ToString (),
row[1].ToString (),sex,row[4].ToString (),row[8].ToString (),
row[7].ToString ()},1);
this.lvStudent .Items .Add (i);
}
}
//顯示課程的方法
public void ShowCourse(int iCourseId,int iClassId,int iSubjectId)
{
Aptech.Student.DataAccess.Courses courses=new Courses ();
dsCourses=courses.SelectCourse(iCourseId,iClassId,iSubjectId);
this.lvCourse .Items .Clear ();
foreach(System.Data.DataRow row in dsCourses.Tables [0].Rows)
{
ListViewItem i=new ListViewItem(row[7].ToString(),2);
this.lvCourse.Items .Add (i);
}
}
//顯示成績的方法
public void ShowScores(int iStudentId,int iCourseId,int iClassId)
{
Aptech.Student.DataAccess.Scores scores=new Scores ();
dsScores=scores.SelectScore(iStudentId,iCourseId,iClassId);
this.dgScore .DataSource =dsScores.Tables[0];
}
private void frmMain_Load(object sender, System.EventArgs e)//窗體加載
{
//在treeview中顯示所有的班級
this.ShowClass ();
//在listview中顯示所有的學生的信息
this.ShowStudent(-1,"","",-1);
//在datagrid中顯示所有的學生的成績信息
this.ShowScores(-1,-1,-1);
}
private void tvClass_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e)
{//雙擊班級
string className=e.Node .Text.ToString() ;//得到所選的班級名
Classs classes=new Classs ();
dsClass=classes.SelectClass(-1,className);//根據班級名得到dsClass
int classId=(int)dsClass.Tables[0].Rows [0][0];//取得班級id
this.ShowStudent (-1,"","",classId);//顯示該班學生信息
this.ShowCourse(-1,classId,-1);//顯示該班課程信息
this.ShowScores(-1,-1,classId);//顯示該班成績信息
}
private void menuItem4_Click(object sender, System.EventArgs e)
{//新建班級
frmAddClass fac=new frmAddClass (this);
fac.ShowDialog (this);
}
private void menuItem5_Click(object sender, System.EventArgs e)
{//新建學生檔案
frmAddStudent fas=new frmAddStudent (this);
fas.ShowDialog (this);
}
private void menuItem7_Click(object sender, System.EventArgs e)
{//新建課程
frmAddCourse facour=new frmAddCourse (this);
facour.ShowDialog (this);
}
private void menuItem6_Click(object sender, System.EventArgs e)
{//科目管理
frmMangeSubject fms=new frmMangeSubject (this);
fms.ShowDialog (this);
}
private void tvClass_DoubleClick(object sender, System.EventArgs e)
{//雙擊班級
string name=this.tvClass .SelectedNode.Text ;
frmUpdateClass fuc=new frmUpdateClass (this,name);
fuc.ShowDialog (this);
}
private void lvStudent_DoubleClick(object sender, System.EventArgs e)
{//雙擊學生
string studentNo;
if(this.lvStudent .SelectedItems.Count!=0)
{
studentNo=this.lvStudent.SelectedItems[0].SubItems[1].Text ;
frmUpdateStudent fus=new frmUpdateStudent (this,studentNo);
fus.ShowDialog (this);
}
}
private void lvCourse_DoubleClick(object sender, System.EventArgs e)
{//雙擊課程
string courseName;
if(this.lvCourse .SelectedItems.Count !=0)
{
courseName=this.lvCourse .SelectedItems[0].Text;
frmUpdateCourse fuc=new frmUpdateCourse (courseName,this);
fuc.ShowDialog (this);
}
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -