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

📄 frmexamsearch.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;

namespace OES
{
	/// <summary>
	/// Summary description for frmExamSearch.
	/// </summary>
	public class frmExamSearch : System.Windows.Forms.Form
	{
		
		private System.Windows.Forms.Button btnClose;
		private System.Windows.Forms.Label lblHeading;
		private System.Windows.Forms.Button btnSearch;
		private System.Windows.Forms.Label lblUserName;
		private System.Windows.Forms.GroupBox grpSearch;
		private System.Windows.Forms.ComboBox cboSubject;
		private System.Windows.Forms.Label lblSubject;
		private System.Windows.Forms.Label lblScheduledDate;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.DataGrid dbgExamDetails;
		private System.Windows.Forms.DateTimePicker dtpSchDate;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		private string[] searchValue;
		private System.Windows.Forms.Button btnHelp;
		private Exam objExam;
		public frmExamSearch()
		{
			//
			// 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(frmExamSearch));
			this.btnClose = new System.Windows.Forms.Button();
			this.dbgExamDetails = new System.Windows.Forms.DataGrid();
			this.cboSubject = new System.Windows.Forms.ComboBox();
			this.lblHeading = new System.Windows.Forms.Label();
			this.btnSearch = new System.Windows.Forms.Button();
			this.lblUserName = new System.Windows.Forms.Label();
			this.lblScheduledDate = new System.Windows.Forms.Label();
			this.grpSearch = new System.Windows.Forms.GroupBox();
			this.dtpSchDate = new System.Windows.Forms.DateTimePicker();
			this.lblSubject = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.btnHelp = new System.Windows.Forms.Button();
			((System.ComponentModel.ISupportInitialize)(this.dbgExamDetails)).BeginInit();
			this.grpSearch.SuspendLayout();
			this.SuspendLayout();
			// 
			// 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(370, 431);
			this.btnClose.Name = "btnClose";
			this.btnClose.Size = new System.Drawing.Size(96, 26);
			this.btnClose.TabIndex = 39;
			this.btnClose.Text = "关闭(&O)";
			this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
			// 
			// 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(115, 198);
			this.dbgExamDetails.Name = "dbgExamDetails";
			this.dbgExamDetails.ReadOnly = true;
			this.dbgExamDetails.Size = new System.Drawing.Size(605, 207);
			this.dbgExamDetails.TabIndex = 38;
			// 
			// cboSubject
			// 
			this.cboSubject.BackColor = System.Drawing.SystemColors.Info;
			this.cboSubject.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
			this.cboSubject.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.cboSubject.Location = new System.Drawing.Point(106, 32);
			this.cboSubject.Name = "cboSubject";
			this.cboSubject.Size = new System.Drawing.Size(105, 21);
			this.cboSubject.TabIndex = 36;
			// 
			// lblHeading
			// 
			this.lblHeading.AutoSize = true;
			this.lblHeading.BackColor = System.Drawing.Color.Transparent;
			this.lblHeading.Font = new System.Drawing.Font("Century Gothic", 21.75F);
			this.lblHeading.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(192)), ((System.Byte)(255)));
			this.lblHeading.Location = new System.Drawing.Point(-156, -60);
			this.lblHeading.Name = "lblHeading";
			this.lblHeading.Size = new System.Drawing.Size(262, 39);
			this.lblHeading.TabIndex = 32;
			this.lblHeading.Text = "用  户  搜  索";
			// 
			// 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(490, 34);
			this.btnSearch.Name = "btnSearch";
			this.btnSearch.Size = new System.Drawing.Size(76, 26);
			this.btnSearch.TabIndex = 33;
			this.btnSearch.Text = "搜索(&S)";
			this.btnSearch.Click += new System.EventHandler(this.btnSearch_Click);
			// 
			// lblUserName
			// 
			this.lblUserName.BackColor = System.Drawing.Color.Transparent;
			this.lblUserName.Font = new System.Drawing.Font("Century Gothic", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.lblUserName.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
			this.lblUserName.Location = new System.Drawing.Point(-137, 52);
			this.lblUserName.Name = "lblUserName";
			this.lblUserName.Size = new System.Drawing.Size(118, 24);
			this.lblUserName.TabIndex = 30;
			this.lblUserName.Text = "用户名";
			// 
			// lblScheduledDate
			// 
			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(221, 36);
			this.lblScheduledDate.Name = "lblScheduledDate";
			this.lblScheduledDate.Size = new System.Drawing.Size(125, 24);
			this.lblScheduledDate.TabIndex = 29;
			this.lblScheduledDate.Text = "预定日期>=";
			// 
			// grpSearch
			// 
			this.grpSearch.BackColor = System.Drawing.Color.Transparent;
			this.grpSearch.Controls.Add(this.dtpSchDate);
			this.grpSearch.Controls.Add(this.lblSubject);
			this.grpSearch.Controls.Add(this.cboSubject);
			this.grpSearch.Controls.Add(this.lblScheduledDate);
			this.grpSearch.Controls.Add(this.btnSearch);
			this.grpSearch.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
			this.grpSearch.Font = new System.Drawing.Font("Century Gothic", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.grpSearch.ForeColor = System.Drawing.SystemColors.ActiveCaptionText;
			this.grpSearch.Location = new System.Drawing.Point(115, 78);
			this.grpSearch.Name = "grpSearch";
			this.grpSearch.Size = new System.Drawing.Size(605, 86);
			this.grpSearch.TabIndex = 41;
			this.grpSearch.TabStop = false;
			this.grpSearch.Text = "搜索考试信息";
			// 
			// dtpSchDate
			// 
			this.dtpSchDate.CustomFormat = "dd\'/\'MM\'/\'yyyy";
			this.dtpSchDate.Font = new System.Drawing.Font("Times New Roman", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.dtpSchDate.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
			this.dtpSchDate.Location = new System.Drawing.Point(365, 34);
			this.dtpSchDate.Name = "dtpSchDate";
			this.dtpSchDate.Size = new System.Drawing.Size(96, 21);
			this.dtpSchDate.TabIndex = 45;
			this.dtpSchDate.Value = new System.DateTime(2004, 12, 7, 0, 0, 0, 0);
			// 
			// lblSubject
			// 
			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(29, 36);
			this.lblSubject.Name = "lblSubject";
			this.lblSubject.Size = new System.Drawing.Size(67, 24);
			this.lblSubject.TabIndex = 44;
			this.lblSubject.Text = "科目";
			// 
			// label2
			// 
			this.label2.AutoSize = true;
			this.label2.BackColor = System.Drawing.Color.Transparent;
			this.label2.Font = new System.Drawing.Font("Century Gothic", 21.75F);
			this.label2.ForeColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(192)), ((System.Byte)(255)));
			this.label2.Location = new System.Drawing.Point(115, 17);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(191, 39);
			this.label2.TabIndex = 44;
			this.label2.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(648, 25);
			this.btnHelp.Name = "btnHelp";
			this.btnHelp.Size = new System.Drawing.Size(72, 26);
			this.btnHelp.TabIndex = 45;
			this.btnHelp.Text = "帮助(&H)";
			this.btnHelp.Click += new System.EventHandler(this.btnHelp_Click);
			// 
			// frmExamSearch
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
			this.ClientSize = new System.Drawing.Size(783, 482);
			this.Controls.Add(this.btnHelp);
			this.Controls.Add(this.label2);
			this.Controls.Add(this.lblHeading);
			this.Controls.Add(this.btnClose);
			this.Controls.Add(this.dbgExamDetails);
			this.Controls.Add(this.lblUserName);
			this.Controls.Add(this.grpSearch);
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
			this.Location = new System.Drawing.Point(146, 115);
			this.Name = "frmExamSearch";
			this.ShowInTaskbar = false;
			this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
			this.Text = "frmExamSearch";
			this.Load += new System.EventHandler(this.frmExamSearch_Load);
			((System.ComponentModel.ISupportInitialize)(this.dbgExamDetails)).EndInit();
			this.grpSearch.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion

		private void btnClose_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}

		//修改情况:部门:ACCP产品开发培训部   修改人:王文  时间:2004-12-25
		//所添加的CODES
		private void emptySearchValue()
		{
			for (int i = 0; i<searchValue.Length;i++)
			{
				searchValue[i]=string.Empty;
				
			}
		}
		/// /////
		//修改情况:部门:ACCP产品开发培训部   修改人:王文  时间:2004-12-25
		private void btnSearch_Click(object sender, System.EventArgs e)
		{
			try
			{
				emptySearchValue();
				searchValue[0]=this.dtpSchDate.Value.ToString("dd/MM/yyyy");
				searchValue[1]=this.cboSubject.Text;
			    			
				objExam = new Exam();

				DataTable dtExam = objExam.FetchExamDetails(searchValue);
				if (dtExam.Rows.Count==0)
				{

					//除去/this.dbgExamDetails.DataSource = dtExam;
					//除去 MessageBox.Show("No Records found");
					this.dbgExamDetails.DataSource=null;
					return ;
				}
				else
					this.dbgExamDetails.DataSource = dtExam;
				
			}
			catch(Exception myException)
			{
				//除去Console.WriteLine(myException.Message);
				MessageBox.Show(myException.Message);
			}
		}

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

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

⌨️ 快捷键说明

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