⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmexamreports.cs

📁 本论文叙述了联机考试系统的现状以及C#语言的概况。重点介绍了联机考试系统的实现过程:包括系统分析、 系统调查、 数据流程分析、功能设计、 数据库设计、 系统物理配置方案、 系统实现、 系统测试和调试。
💻 CS
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Data.OleDb;
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;

namespace OES
{
	/// <summary>
	/// Summary description for frmExamReports.
	/// </summary>
	public class frmExamReports : System.Windows.Forms.Form
	{
		internal System.Windows.Forms.Button btnSearch;
		internal System.Windows.Forms.Button btnClose;
		private System.Windows.Forms.Label lblExamReports;
		private System.Windows.Forms.Button btnHelp;
		private System.Windows.Forms.Label lblScheduledDate;
		private System.Windows.Forms.Label lblSubject;
		private System.Windows.Forms.DateTimePicker dtpSchedule;
		public System.Windows.Forms.ComboBox cboSubject;
		private System.Windows.Forms.DataGrid dbgExamDetails;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
		
		private string[] searchValue;
		private Exam objExam ;
		private DataTable dtReports;
		public ReportDocument repDoc;
        OES.TestReport tr=new TestReport ();
		public static bool boolReportStaus;
		
		

		//private int attended=0;//, passed=0, failed=0;
		public frmExamReports()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
			searchValue = new string[4];
			//
			// 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()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(frmExamReports));
			this.btnSearch = new System.Windows.Forms.Button();
			this.btnClose = new System.Windows.Forms.Button();
			this.lblExamReports = new System.Windows.Forms.Label();
			this.btnHelp = new System.Windows.Forms.Button();
			this.lblScheduledDate = new System.Windows.Forms.Label();
			this.lblSubject = new System.Windows.Forms.Label();
			this.dtpSchedule = new System.Windows.Forms.DateTimePicker();
			this.cboSubject = new System.Windows.Forms.ComboBox();
			this.dbgExamDetails = new System.Windows.Forms.DataGrid();
			((System.ComponentModel.ISupportInitialize)(this.dbgExamDetails)).BeginInit();
			this.SuspendLayout();
			// 
			// btnSearch
			// 
			this.btnSearch.BackColor = System.Drawing.Color.Transparent;
			this.btnSearch.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btnSearch.Font = new System.Drawing.Font("Verdana", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.btnSearch.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
			this.btnSearch.Location = new System.Drawing.Point(671, 92);
			this.btnSearch.Name = "btnSearch";
			this.btnSearch.Size = new System.Drawing.Size(96, 25);
			this.btnSearch.TabIndex = 46;
			this.btnSearch.Text = "搜索(&S)";
			this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
			// 
			// btnClose
			// 
			this.btnClose.BackColor = System.Drawing.Color.Transparent;
			this.btnClose.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btnClose.Font = new System.Drawing.Font("Verdana", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.btnClose.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
			this.btnClose.Location = new System.Drawing.Point(672, 482);
			this.btnClose.Name = "btnClose";
			this.btnClose.Size = new System.Drawing.Size(96, 26);
			this.btnClose.TabIndex = 49;
			this.btnClose.Text = "关闭(&C)";
			this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
			// 
			// lblExamReports
			// 
			this.lblExamReports.AutoSize = true;
			this.lblExamReports.BackColor = System.Drawing.Color.Transparent;
			this.lblExamReports.Font = new System.Drawing.Font("Century Gothic", 21.75F);
			this.lblExamReports.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(192)), ((System.Byte)(255)));
			this.lblExamReports.Location = new System.Drawing.Point(154, 17);
			this.lblExamReports.Name = "lblExamReports";
			this.lblExamReports.Size = new System.Drawing.Size(191, 39);
			this.lblExamReports.TabIndex = 53;
			this.lblExamReports.Text = "考  试  报  告";
			// 
			// btnHelp
			// 
			this.btnHelp.BackColor = System.Drawing.Color.Transparent;
			this.btnHelp.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
			this.btnHelp.Font = new System.Drawing.Font("Verdana", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.btnHelp.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
			this.btnHelp.Location = new System.Drawing.Point(696, 34);
			this.btnHelp.Name = "btnHelp";
			this.btnHelp.Size = new System.Drawing.Size(72, 26);
			this.btnHelp.TabIndex = 54;
			this.btnHelp.Text = "帮助(&H)";
			this.btnHelp.Click += new System.EventHandler(this.btnHelp_Click);
			// 
			// lblScheduledDate
			// 
			this.lblScheduledDate.AutoSize = true;
			this.lblScheduledDate.BackColor = System.Drawing.Color.Transparent;
			this.lblScheduledDate.Font = new System.Drawing.Font("Century Gothic", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.lblScheduledDate.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
			this.lblScheduledDate.Location = new System.Drawing.Point(176, 96);
			this.lblScheduledDate.Name = "lblScheduledDate";
			this.lblScheduledDate.Size = new System.Drawing.Size(74, 18);
			this.lblScheduledDate.TabIndex = 55;
			this.lblScheduledDate.Text = "预定日期>=";
			// 
			// lblSubject
			// 
			this.lblSubject.AutoSize = true;
			this.lblSubject.BackColor = System.Drawing.Color.Transparent;
			this.lblSubject.Font = new System.Drawing.Font("Century Gothic", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.lblSubject.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
			this.lblSubject.Location = new System.Drawing.Point(439, 95);
			this.lblSubject.Name = "lblSubject";
			this.lblSubject.Size = new System.Drawing.Size(32, 18);
			this.lblSubject.TabIndex = 56;
			this.lblSubject.Text = "科目";
			// 
			// dtpSchedule
			// 
			this.dtpSchedule.AllowDrop = true;
			this.dtpSchedule.CalendarTitleForeColor = System.Drawing.SystemColors.Info;
			this.dtpSchedule.CustomFormat = "dd\'/\'MM\'/\'yyyy";
			this.dtpSchedule.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
			this.dtpSchedule.Location = new System.Drawing.Point(295, 94);
			this.dtpSchedule.Name = "dtpSchedule";
			this.dtpSchedule.Size = new System.Drawing.Size(125, 21);
			this.dtpSchedule.TabIndex = 57;
			// 
			// cboSubject
			// 
			this.cboSubject.BackColor = System.Drawing.SystemColors.Info;
			this.cboSubject.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cboSubject.Location = new System.Drawing.Point(517, 94);
			this.cboSubject.Name = "cboSubject";
			this.cboSubject.Size = new System.Drawing.Size(135, 20);
			this.cboSubject.TabIndex = 58;
			// 
			// dbgExamDetails
			// 
			this.dbgExamDetails.BackgroundColor = System.Drawing.Color.LightSteelBlue;
			this.dbgExamDetails.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.dbgExamDetails.DataMember = "";
			this.dbgExamDetails.HeaderForeColor = System.Drawing.SystemColors.ControlText;
			this.dbgExamDetails.Location = new System.Drawing.Point(154, 129);
			this.dbgExamDetails.Name = "dbgExamDetails";
			this.dbgExamDetails.ReadOnly = true;
			this.dbgExamDetails.Size = new System.Drawing.Size(614, 345);
			this.dbgExamDetails.TabIndex = 59;
			this.dbgExamDetails.DoubleClick += new System.EventHandler(this.dbgExamDetails_DoubleClick);
			this.dbgExamDetails.Navigate += new System.Windows.Forms.NavigateEventHandler(this.dbgExamDetails_Navigate);
			// 
			// frmExamReports
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
			this.ClientSize = new System.Drawing.Size(783, 520);
			this.Controls.Add(this.dbgExamDetails);
			this.Controls.Add(this.cboSubject);
			this.Controls.Add(this.dtpSchedule);
			this.Controls.Add(this.lblSubject);
			this.Controls.Add(this.lblScheduledDate);
			this.Controls.Add(this.lblExamReports);
			this.Controls.Add(this.btnHelp);
			this.Controls.Add(this.btnClose);
			this.Controls.Add(this.btnSearch);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
			this.Location = new System.Drawing.Point(146, 115);
			this.Name = "frmExamReports";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
			this.Text = "frmExamReports";
			this.Load += new System.EventHandler(this.frmExamReports_Load);
			((System.ComponentModel.ISupportInitialize)(this.dbgExamDetails)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

		

		private void btnClose_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}
		
		/// <summary>
		/// //修改情况:部门:ACCP产品开发培训部   修改人:王文  时间:2004-12-26
		/// 所添加的CODES
		/// </summary>
		void emptySearchValue()
		{
			for (int i = 0; i<searchValue.Length; i++)
				searchValue.SetValue(string.Empty, i);
		}
		///修改情况:部门:ACCP产品开发培训部   修改人:王文  时间:2004-12-26
		private void btnSearch_Click(object sender, System.EventArgs e)
		{
			try
			{
				emptySearchValue(); /// 所添加的CODES

				searchValue[0] = this.cboSubject.Text;

				searchValue[1] = this.dtpSchedule.Value.ToString("dd/MM/yyyy");
				
				 //除去DataAccess objDA=DataAccess.GetInstance();
				
				objExam = new Exam();

                DataTable dtExamReport = objExam.FetchExamReports(searchValue);
				
				if (dtExamReport.Rows.Count == 0)
				{
					this.dbgExamDetails.DataSource = null; //除去dtExamReport;
					// //除去MessageBox.Show("No Records found");
					return ;
				}
				else
				{
					//emptySearchValue(); /// 所添加的CODES

					searchValue[0]=this.cboSubject.Text;
					searchValue[3]="Score";
					DataTable dtResults = objExam.FetchExamDetails(searchValue);			
					this.dbgExamDetails.DataSource=dtResults;

					CreateTable();				
				}
			}
			catch(Exception myException)
			{
				Console.WriteLine(myException.StackTrace);
				MessageBox.Show(myException.StackTrace);
			}
		}

		private void frmExamReports_Load(object sender, System.EventArgs e)
		{
			this.cboSubject.Items.AddRange(new object[] {"Java", "C#", "SQL Server", "Html"});
			this.cboSubject.Text = "Java";
		}

		
		public void CreateTable()
		{
			dtReports = new DataTable("Reports");			
			dtReports.Columns.Add("ExamCode",    typeof(String));
			dtReports.Columns.Add("ExamTitle",   typeof(String));
			dtReports.Columns.Add("NoOfAttended",typeof(System.Int32));
			dtReports.Columns.Add("NoOfPassed",  typeof(System.Int32));
			dtReports.Columns.Add("NoOfFailed",  typeof(System.Int32));
		}

		private void btnHelp_Click(object sender, System.EventArgs e)
		{
			Help.ShowHelp(this,Environment.CurrentDirectory +@"\\OES_Help\OES_Help.chm");
		}	
		
		
		private void initialLoad(string str)
	   {

			try{
				OES.Exam exam=new OES.Exam ();
				

				DataTable tbCurrentTabel=(DataTable)this.dbgExamDetails .DataSource; 
				tr.Tables [0].Clear ();
				DataTable tbExResult=exam.ExamResult(tbCurrentTabel.Rows [this.dbgExamDetails .CurrentCell .RowNumber ][0].ToString ());
				
				for(int i=0 ;i<tbExResult.Rows.Count ;i++)
				{
					DataRow dr=tr.Tables [0].NewRow ();
					dr[0]=tbExResult.Rows [i][0].ToString ();
					dr[1]=tbExResult.Rows [i][1].ToString ();
					dr[2]=tbExResult.Rows [i][2].ToString ();
					dr[3]=tbExResult.Rows [i][3].ToString ();
					dr[8]=tbExResult.Rows [i][5].ToString ();
					tr.Tables[0].Rows .Add (dr);
				}
					
				//给考试及格人数赋值
				tr.Tables [0].Rows[0][4] =exam.ExamPass  (tbCurrentTabel.Rows [this.dbgExamDetails .CurrentCell .RowNumber ][0].ToString () );

				//给考试不及格人数赋值
				tr.Tables [0].Rows[0][5] =exam.ExamFlunk  (tbCurrentTabel.Rows [this.dbgExamDetails .CurrentCell .RowNumber ][0].ToString () );

				//给考试人数字段赋值
				tr.Tables [0].Rows[0][6] =exam.ExamTotal (tbCurrentTabel.Rows [this.dbgExamDetails .CurrentCell .RowNumber ][0].ToString () );

				//给考试代码字段赋值
				tr.Tables [0].Rows[0][7] =tbCurrentTabel.Rows [this.dbgExamDetails .CurrentCell .RowNumber ][1].ToString () ;

				TableLogOnInfo tliCurrent = new CrystalDecisions.Shared.TableLogOnInfo();
			repDoc=new ReportDocument(); 
			
				repDoc.Load(str);
				repDoc.SetDataSource (tr);

			}
			catch(OleDbException excep)
			{
              Console.WriteLine ("Exception occured"+excep.Message);   
			}
		}

		private void dbgExamDetails_DoubleClick(object sender, System.EventArgs e)
		{	
			frmDetailedReport rpt = new frmDetailedReport();
			
			if(!boolReportStaus )
			{
				initialLoad(Environment.CurrentDirectory +@"\Reports\DetailedReport.rpt");			
				rpt.crvExamReports.ReportSource = repDoc;
				boolReportStaus=true;
				rpt.Show();	
				
			}
			
		}

		private void dbgExamDetails_Navigate(object sender, System.Windows.Forms.NavigateEventArgs ne)
		{
		
		}

		
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -