AddQuestion.cs

(开头部分) 5KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

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;
//下载自:好例子网 http://www.haolizi.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("信息填写不完整!");
            }
后面还有 97 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。