📄 frmresult.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using ExamSystem.BusinessFacade.TopicsFacade;
using ExamSystem.Common;
using ExamSystem.BusinessFacade.TeacherFac;
namespace TeachersClient
{
/// <summary>
/// FrmResult 的摘要说明。
/// </summary>
public class FrmResult : System.Windows.Forms.Form
{
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Panel panel3;
private System.Windows.Forms.Panel panel5;
private System.Windows.Forms.Panel panel4;
private System.Windows.Forms.Panel pan1;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.ComboBox cmbExam;
private System.Windows.Forms.Panel panel10;
private System.Windows.Forms.Button button2;
private System.Windows.Forms.Panel panel11;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.TreeView tvClass;
private ExamSystem.Common.DataListView dlvResult;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
DataView dvClass;//班级的记录
DataTable dtResult;
private System.Windows.Forms.Panel pan5;
private System.Windows.Forms.Panel pan4;
private System.Windows.Forms.Panel pan3;
private System.Windows.Forms.Panel pan2;
private System.Windows.Forms.Label labTotle;
private System.Windows.Forms.Label labExam;
private System.Windows.Forms.Label labScor5;
private System.Windows.Forms.Label labScor4;
private System.Windows.Forms.Label labScor3;
private System.Windows.Forms.Label labScor2;
private System.Windows.Forms.Label labScor1;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label1;//成绩的记录
Panel[] pans=new Panel[5];
private System.Windows.Forms.Panel panDetile;
private System.Windows.Forms.Button btnDetile;
Label[] labs=new Label[5];
/// <summary>
/// 初始化Panel数组
/// </summary>
private void initPansArray()
{
pans[0]=pan1;
pans[1]=pan2;
pans[2]=pan3;
pans[3]=pan4;
pans[4]=pan5;
labs[0]=labScor1;
labs[1]=labScor2;
labs[2]=labScor3;
labs[3]=labScor4;
labs[4]=labScor5;
}
/// <summary>
/// 填充考试统计
/// </summary>
private void fillScoreDetile()
{
this.labExam.Text=this.cmbExam.Text;
DataView dvRes=dtResult.DefaultView;
int totle=dvRes.Count;//总人数
this.labTotle.Text="考试人数:"+totle.ToString();
int[] scoreNumbers=new int[5];
//算出60以下的人数
dvRes.RowFilter="Result<60";
scoreNumbers[0]=dvRes.Count;
//算出60-70的人数
dvRes.RowFilter="Result>=60 and Result<70";
scoreNumbers[1]=dvRes.Count;
//算出70-80的人数
dvRes.RowFilter="Result>=70 and Result<80";
scoreNumbers[2]=dvRes.Count;
//算出80-90的人数
dvRes.RowFilter="Result>=80 and Result<90";
scoreNumbers[3]=dvRes.Count;
//算出90以上的人数
dvRes.RowFilter="Result>90";
scoreNumbers[4]=dvRes.Count;
for(int i=0;i<pans.Length;i++)
{
setHeight(scoreNumbers[i],totle,pans[i],labs[i]);
}
dvRes.RowFilter="1=1";//把筛选器重置
}
/// <summary>
/// 根据人数设置控件的高度
/// </summary>
/// <param name="scNum">当前人数</param>
/// <param name="totle">总人数</param>
/// <param name="pan">Panel控件</param>
/// <param name="lab">显示人数的控件</param>
private void setHeight(int scNum,int totle,Panel pan,Label lab)
{
int maxTop=220;//最大的顶边距
int maxHeight=190;//最大高度
double ratio=(double)scNum/(double)totle;//现有人数跟总人数的比率
int height=(int)(maxHeight*ratio);//算出这控件的高度
int top=maxTop-height;//算出这控件的顶边距
pan.Top=top;
pan.Height=height;
lab.Text=scNum.ToString();
}
/// <summary>
/// 清空考试信息
/// </summary>
private void clearScoreDetile()
{
int maxTop=220;//最大的顶边距
this.labExam.Text="";
this.labTotle.Text="";
for(int i=0;i<pans.Length;i++)
{
pans[i].Height=0;
pans[i].Top=maxTop;
labs[i].Text="";
}
}
/// <summary>
/// 填充班级选择的TreeView
/// </summary>
private void fillClass()
{
tvClass.Nodes.Clear();
GradeFac grdFac=new GradeFac();
DataSet dsGrade=grdFac.getGrade(-1,"");
ClassFac clsFac=new ClassFac();
DataSet dsClass=clsFac.getClass(-1,"",-1);
dvClass=dsClass.Tables[0].DefaultView;
for(int i=0;i<dsGrade.Tables[0].Rows.Count;i++)//穷举所有年级
{
TreeNode nodeGrade=new TreeNode(dsGrade.Tables[0].Rows[i][1].ToString());
tvClass.Nodes.Add(nodeGrade);
dvClass.RowFilter="Grade="+dsGrade.Tables[0].Rows[i][0].ToString();//过滤年级所属的班级
for(int k=0;k<dvClass.Count;k++)//把班级加到所属的年级下
{
TreeNode nodeClass=new TreeNode(dvClass[k][1].ToString());
nodeGrade.Nodes.Add(nodeClass);
}
}
}
/// <summary>
/// 填充学生信息
/// </summary>
/// <param name="className">班级名</param>
private void fillResult(string className)
{
ResultFac resFac=new ResultFac();
dvClass.RowFilter="ClassName='"+className+"'";
int classID=Convert.ToInt32(dvClass[0][0]);
ExamFac examFac=new ExamFac();
DataSet ds=examFac.getExam(-1,"",classID,-1,"",SearchBooleans.NULL);
cmbExam.DataSource=ds.Tables[0];
cmbExam.DisplayMember="ExamName";
cmbExam.ValueMember="ExamID";
}
/// <summary>
/// 根据DataTable填充ListView
/// </summary>
/// <param name="dt"></param>
private void filldlv(DataTable dt)
{
DataTable dtTmp=dt.Copy();
dtTmp.Columns.RemoveAt(4);
dtTmp.Columns.RemoveAt(3);
dtTmp.Columns.RemoveAt(0);
dlvResult.BindTable=dtTmp;
dlvResult.Columns[1].Text="学生姓名";
dlvResult.Columns[2].Text="考试名称";
dlvResult.Columns[3].Text="成绩";
for(int i=0;i<dlvResult.Items.Count;i++)
{
if(Convert.ToDouble(dlvResult.Items[i].SubItems[3].Text)<60)
{
dlvResult.Items[i].ForeColor=Color.Red;
}
else
{
dlvResult.Items[i].ForeColor=Color.Black;
}
}
dtTmp.Dispose();
}
public FrmResult()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();
//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.panDetile = new System.Windows.Forms.Panel();
this.panel5 = new System.Windows.Forms.Panel();
this.panel11 = new System.Windows.Forms.Panel();
this.labTotle = new System.Windows.Forms.Label();
this.labExam = new System.Windows.Forms.Label();
this.panel4 = new System.Windows.Forms.Panel();
this.labScor5 = new System.Windows.Forms.Label();
this.labScor4 = new System.Windows.Forms.Label();
this.labScor3 = new System.Windows.Forms.Label();
this.labScor2 = new System.Windows.Forms.Label();
this.labScor1 = new System.Windows.Forms.Label();
this.pan5 = new System.Windows.Forms.Panel();
this.pan4 = new System.Windows.Forms.Panel();
this.pan3 = new System.Windows.Forms.Panel();
this.pan2 = new System.Windows.Forms.Panel();
this.pan1 = new System.Windows.Forms.Panel();
this.label5 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label1 = new System.Windows.Forms.Label();
this.btnDetile = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.dlvResult = new ExamSystem.Common.DataListView();
this.panel3 = new System.Windows.Forms.Panel();
this.button2 = new System.Windows.Forms.Button();
this.cmbExam = new System.Windows.Forms.ComboBox();
this.label10 = new System.Windows.Forms.Label();
this.panel10 = new System.Windows.Forms.Panel();
this.tvClass = new System.Windows.Forms.TreeView();
this.label13 = new System.Windows.Forms.Label();
this.panDetile.SuspendLayout();
this.panel5.SuspendLayout();
this.panel11.SuspendLayout();
this.panel4.SuspendLayout();
this.panel1.SuspendLayout();
this.panel3.SuspendLayout();
this.panel10.SuspendLayout();
this.SuspendLayout();
//
// panDetile
//
this.panDetile.Controls.Add(this.panel5);
this.panDetile.Controls.Add(this.panel4);
this.panDetile.Dock = System.Windows.Forms.DockStyle.Right;
this.panDetile.Location = new System.Drawing.Point(428, 0);
this.panDetile.Name = "panDetile";
this.panDetile.Size = new System.Drawing.Size(316, 381);
this.panDetile.TabIndex = 1;
//
// panel5
//
this.panel5.Controls.Add(this.panel11);
this.panel5.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel5.Location = new System.Drawing.Point(0, 0);
this.panel5.Name = "panel5";
this.panel5.Size = new System.Drawing.Size(316, 141);
this.panel5.TabIndex = 6;
//
// panel11
//
this.panel11.Controls.Add(this.labTotle);
this.panel11.Controls.Add(this.labExam);
this.panel11.Dock = System.Windows.Forms.DockStyle.Top;
this.panel11.Location = new System.Drawing.Point(0, 0);
this.panel11.Name = "panel11";
this.panel11.Size = new System.Drawing.Size(316, 106);
this.panel11.TabIndex = 0;
//
// labTotle
//
this.labTotle.Dock = System.Windows.Forms.DockStyle.Bottom;
this.labTotle.Location = new System.Drawing.Point(0, 62);
this.labTotle.Name = "labTotle";
this.labTotle.Size = new System.Drawing.Size(316, 44);
this.labTotle.TabIndex = 3;
this.labTotle.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
//
// labExam
//
this.labExam.Dock = System.Windows.Forms.DockStyle.Top;
this.labExam.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(134)));
this.labExam.ForeColor = System.Drawing.Color.Red;
this.labExam.Location = new System.Drawing.Point(0, 0);
this.labExam.Name = "labExam";
this.labExam.Size = new System.Drawing.Size(316, 46);
this.labExam.TabIndex = 2;
this.labExam.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
//
// panel4
//
this.panel4.Controls.Add(this.labScor5);
this.panel4.Controls.Add(this.labScor4);
this.panel4.Controls.Add(this.labScor3);
this.panel4.Controls.Add(this.labScor2);
this.panel4.Controls.Add(this.labScor1);
this.panel4.Controls.Add(this.pan5);
this.panel4.Controls.Add(this.pan4);
this.panel4.Controls.Add(this.pan3);
this.panel4.Controls.Add(this.pan2);
this.panel4.Controls.Add(this.pan1);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -