📄 frmsourchresult.cs
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using ExamSystem.BusinessFacade.TopicsFacade;
using System.Data;
using ExamSystem.Common;
namespace StudentsClient
{
/// <summary>
/// FrmSourchResult 的摘要说明。
/// </summary>
public class FrmSourchResult : System.Windows.Forms.Form
{
private System.Windows.Forms.Button btnSourch;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.ComboBox cmbExam;
private System.Windows.Forms.Label lblExam;
private System.Windows.Forms.GroupBox groupBox1;
private ExamSystem.Common.DataListView dlvResult;
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
DataSet dsResult;
private void fillExam()
{
ExamFac examFac=new ExamFac();
DataSet dsExam=examFac.getExam(-1,"",CommVal.CurrentStu.StuClass,-1,"",SearchBooleans.NULL);
DataRow dr=dsExam.Tables[0].NewRow();
dr["ExamID"]=-1;
dr["ExamName"]="所有考试";
dsExam.Tables[0].Rows.InsertAt(dr,0);
cmbExam.DataSource=dsExam.Tables[0];
cmbExam.DisplayMember="ExamName";
cmbExam.ValueMember="ExamID";
}
private void fillResult()
{
int stuID=CommVal.CurrentStu.StuID;
int examID=(int)this.cmbExam.SelectedValue;
ResultFac resFac=new ResultFac();
dsResult=resFac.getResult(-1,stuID,examID,-1,"");
filldlv(dsResult.Tables[0]);
}
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;
}
}
}
public FrmSourchResult()
{
//
// 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.cmbExam = new System.Windows.Forms.ComboBox();
this.lblExam = new System.Windows.Forms.Label();
this.btnSourch = new System.Windows.Forms.Button();
this.panel1 = new System.Windows.Forms.Panel();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.dlvResult = new ExamSystem.Common.DataListView();
this.panel1.SuspendLayout();
this.groupBox1.SuspendLayout();
this.SuspendLayout();
//
// cmbExam
//
this.cmbExam.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cmbExam.Location = new System.Drawing.Point(68, 20);
this.cmbExam.Name = "cmbExam";
this.cmbExam.Size = new System.Drawing.Size(114, 20);
this.cmbExam.TabIndex = 25;
//
// lblExam
//
this.lblExam.Location = new System.Drawing.Point(14, 24);
this.lblExam.Name = "lblExam";
this.lblExam.Size = new System.Drawing.Size(60, 16);
this.lblExam.TabIndex = 24;
this.lblExam.Text = "考试名称";
//
// btnSourch
//
this.btnSourch.Location = new System.Drawing.Point(186, 20);
this.btnSourch.Name = "btnSourch";
this.btnSourch.Size = new System.Drawing.Size(64, 22);
this.btnSourch.TabIndex = 26;
this.btnSourch.Text = "查询";
this.btnSourch.Click += new System.EventHandler(this.btnSourch_Click);
//
// panel1
//
this.panel1.Controls.Add(this.cmbExam);
this.panel1.Controls.Add(this.btnSourch);
this.panel1.Controls.Add(this.lblExam);
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(536, 56);
this.panel1.TabIndex = 29;
//
// groupBox1
//
this.groupBox1.Controls.Add(this.dlvResult);
this.groupBox1.Dock = System.Windows.Forms.DockStyle.Fill;
this.groupBox1.Location = new System.Drawing.Point(0, 56);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(536, 309);
this.groupBox1.TabIndex = 30;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "成绩查询";
//
// dlvResult
//
this.dlvResult.AutoColumnsWidth = false;
this.dlvResult.BindTable = null;
this.dlvResult.ColumnsWidth = 100;
this.dlvResult.Dock = System.Windows.Forms.DockStyle.Fill;
this.dlvResult.FullRowSelect = true;
this.dlvResult.LineNumWidth = 50;
this.dlvResult.Location = new System.Drawing.Point(3, 17);
this.dlvResult.MultiSelect = false;
this.dlvResult.Name = "dlvResult";
this.dlvResult.SelectedColor = System.Drawing.Color.Transparent;
this.dlvResult.Size = new System.Drawing.Size(530, 289);
this.dlvResult.TabIndex = 31;
this.dlvResult.View = System.Windows.Forms.View.Details;
this.dlvResult.DoubleClick += new System.EventHandler(this.dlvResult_DoubleClick);
//
// FrmSourchResult
//
this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
this.ClientSize = new System.Drawing.Size(536, 365);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.panel1);
this.Name = "FrmSourchResult";
this.Text = "分数查询";
this.Load += new System.EventHandler(this.FrmSourchResult_Load);
this.panel1.ResumeLayout(false);
this.groupBox1.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private void btnSourch_Click(object sender, System.EventArgs e)
{
fillResult();
}
private void FrmSourchResult_Load(object sender, System.EventArgs e)
{
fillExam();
}
private void dlvResult_DoubleClick(object sender, System.EventArgs e)
{
if(dlvResult.SelectedIndices.Count<=0)
{
return;
}
int index=dlvResult.SelectedIndices[0];
if(index<0)
{
return;
}
ResultFac resFac=new ResultFac();
int resID=Convert.ToInt32(dsResult.Tables[0].Rows[index][0]);
DataSet ds=resFac.getResultDetile(resID,-1,-1,-1,"");
if(ds.Tables[0].Rows.Count<=0)
{
MessageBox.Show("找不到成绩","错误",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
string res=ds.Tables[0].Rows[0][0].ToString();
if(res.Length<=0)
{
MessageBox.Show("找不到成绩","错误",MessageBoxButtons.OK,MessageBoxIcon.Information);
return;
}
string root=Application.StartupPath+@"\bak\bak.htm";
ResultCreater.saveResult(res,root);
FrmView frmView=new FrmView();
frmView.MdiParent=this.MdiParent;
frmView.Show();
frmView.linkFile(root);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -