資源簡(jiǎn)介
C#版學(xué)生綜合信息管理系統(tǒng),界面看上去挺不錯(cuò),它可以完成學(xué)生個(gè)人信息管理、考試管理、作業(yè)提交、討論交流、在線答題、成績(jī)查詢等功能,在VS2005下順利編譯,使用MSSQL數(shù)據(jù)庫(kù),運(yùn)行前請(qǐng)先附加數(shù)據(jù)庫(kù)。

代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Text;
using?System.Windows.Forms;
using?System.Data.SqlClient;
//下載自:源碼愛(ài)好者?http://www.codefans.net
namespace?Loginframe
{
????public?partial?class?AddQuestion?:?Form
????{
????????public?AddQuestion()
????????{
????????????InitializeComponent();
????????????
????????}
????????private?void?AddQuestion_Load(object?sender?EventArgs?e)
????????{
????????????string?sql?=?“select?SubjectName?from?Subject“;
????????????try
????????????{
????????????????SqlCommand?command?=?new?SqlCommand(sql?DbHelper.connection);
????????????????DbHelper.connection.Open();
????????????????SqlDataReader?dataReader?=?command.ExecuteReader();
????????????????while?(dataReader.Read())
????????????????{
????????????????????cboSubject.Items.Add(dataReader[“SubjectName“].ToString());
????????????????}
????????????????dataReader.Close();
????????????}
????????????catch?(Exception?ex)
????????????{
????????????????MessageBox.Show(ex.Message);
????????????}
????????????finally?{
????????????????DbHelper.connection.Close();
????????????}
????????}
????????????????
????????private?void?btnAdd_Click(object?sender?EventArgs?e)
????????{
????????????string?question?=?txtQuestion.Text.Trim();
????????????string?optionA?=?txtAnserA.Text.Trim();
????????????string?optionB?=?txtAnserB.Text.Trim();
????????????string?optionC?=?txtAnserC.Text.Trim();
????????????string?optionD?=?txtAnserD.Text.Trim();
????????????string?subject?=?cboSubject.Text;
????????????int?subjectId?=?0;
????????????string?answer?=?““;
????????????int?difficulty?=?0;
????????????if?(!ValidateInput())
????????????{
????????????????MessageBox.Show(“信息填寫不完整!“);
????????????}
????????????else?{
????????????????string?sql?=?string.Format(“select?SubjectId?from?Subject?where?SubjectName=‘{0}‘“subject);
????????????????try
????????????????{
????????????????????SqlCommand?command?=?new?SqlCommand();
????????????????????command.CommandText?=?sql;
????????????????????command.Connection?=?DbHelper.connection;
????????????????????DbHelper.connection.Open();
????????????????????
????????????????????//得到科目編號(hào)
????????????????????subjectId?=?(int)command.ExecuteScalar();
????????????????????//SqlDataReader?dataReader?=?command.ExecuteReader();
????????????????????//if(dataReader.Read()){
????????????????????//????subjectId?=?(int)dataReader[0];
????????????????????//}
????????????????????//dataReader.close();
????????????????????
????????????????????//確定答案
????????????????????if?(rdoA.Checked)?{
????????????????????????answer?=?“A“;
????????????????????}else?if?(rdoB.Checked)?{
????????????????????????answer?=?“B“;
????????????????????}else?if?(rdoC.Checked)?{
????????????????????????answer?=?“C“;
????????????????????}else{
????????????????????????answer?=?“D“;
????????????????????}
????????????????????//確定難
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
-----------?---------??----------?-----??----
?????????????12979519????????????????????120
- 上一篇:C# 抓包封裝類
- 下一篇:C#學(xué)生宿舍管理系統(tǒng)SQL版
評(píng)論
共有 條評(píng)論