Exemple #1
0
        //添加
        public int add_role(Role role)
        {
            int result = 0;

            if (checkTable(role.name, "vr_roleid", "name"))
            {
                MessageBox.Show("此名称已存在!", "基于虚拟现实的铁路综合运输训练系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                DBHelper db  = new DBHelper();
                string   sql = "insert into vr_roleid values('" + role.name + "'," + UserInfoForm.getMajorIdByMajor(role.major) + ")";
                try
                {
                    DbCommand cmd = db.GetSqlStringCommand(sql);
                    result = db.ExecuteNonQuery(cmd);
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            return(result);
        }
Exemple #2
0
        //添加
        public int add_video(Video video)
        {
            int result = 0;

            if (checkTable(video.name, "game_questions", "question"))
            {
                MessageBox.Show("此项目已存在!", "基于虚拟现实的铁路综合运输训练系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                DBHelper db  = new DBHelper();
                string   sql = "insert into game_questions values('" + video.name + "',null," + UserInfoForm.getMajorIdByMajor(video.major) + ",2,null,null,null,null,'" + video.url + "'," + video.startTime + "," + video.endTime + ")";
                try
                {
                    DbCommand cmd = db.GetSqlStringCommand(sql);
                    result = db.ExecuteNonQuery(cmd);
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            return(result);
        }
Exemple #3
0
        //更新题目
        public int update_video(Video video)
        {
            int result = 0;

            if (checkTable(video.name, video.id, "game_questions", "question"))
            {
                MessageBox.Show("存在相同项目,请更改!", "基于虚拟现实的铁路综合运输训练系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                DBHelper db  = new DBHelper();
                string   sql = "update game_questions set question='" + video.name + "',startTime='" + video.startTime + "',endTime='" + video.endTime + "',majorId=" + UserInfoForm.getMajorIdByMajor(video.major) + ",fileName='" + video.url + "' where id=" + video.id;
                try
                {
                    DbCommand cmd = db.GetSqlStringCommand(sql);
                    result = db.ExecuteNonQuery(cmd);
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            return(result);
        }
Exemple #4
0
        //添加题目
        public int add_i_Question(Question question)
        {
            int result = 0;

            if (checkTable(question.question, "game_questions", "question"))
            {
                MessageBox.Show("此题目已存在!", "基于虚拟现实的铁路综合运输训练系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                DBHelper db  = new DBHelper();
                string   sql = "insert into game_questions values('" + question.question + "','" + question.answer + "'," + UserInfoForm.getMajorIdByMajor(question.major) + ",1,null,null,null,null," + (question.multiOption == null ? "null" : "'" + list2string(question.multiOption) + "'") + ",null,null)";
                try
                {
                    DbCommand cmd = db.GetSqlStringCommand(sql);
                    result = db.ExecuteNonQuery(cmd);
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            return(result);
        }
Exemple #5
0
        //更新题目
        public int update_i_Question(Question question)
        {
            int result = 0;

            if (checkTable(question.question, question.id, "game_questions", "question"))
            {
                MessageBox.Show("存在相同题目,请更改题目!", "基于虚拟现实的铁路综合运输训练系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                DBHelper db  = new DBHelper();
                string   sql = "update game_questions set question='" + question.question + "',answer='" + question.answer + "',majorId=" + UserInfoForm.getMajorIdByMajor(question.major) + ",type=1,fileName=" + (question.multiOption == null ? "null" : "'" + list2string(question.multiOption) + "'") + " where id=" + question.id;
                try
                {
                    DbCommand cmd = db.GetSqlStringCommand(sql);
                    result = db.ExecuteNonQuery(cmd);
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            return(result);
        }
Exemple #6
0
        //更新
        public int update_role(Role role)
        {
            int result = 0;

            if (checkTable(role.name, role.id, "vr_roleid", "name"))
            {
                MessageBox.Show("存在相同名称,请更改名称!", "基于虚拟现实的铁路综合运输训练系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                DBHelper db  = new DBHelper();
                string   sql = "update vr_roleid set name='" + role.name + "',majorId=" + UserInfoForm.getMajorIdByMajor(role.major) + " where id=" + role.id;
                try
                {
                    DbCommand cmd = db.GetSqlStringCommand(sql);
                    result = db.ExecuteNonQuery(cmd);
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            return(result);
        }
Exemple #7
0
        //添加题目
        public int addQuestion(Question question)
        {
            int result = 0;

            if (checkQuestion(question.question))
            {
                MessageBox.Show("此题目已存在!", "基于虚拟现实的铁路综合运输训练系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                DBHelper db  = new DBHelper();
                string   sql = "insert into questions values('" + question.question + "','" + question.answer + "','" + question.difficulty + "'," + UserInfoForm.getMajorIdByMajor(question.major) + "," + getTypeIdByType(question.type) + "," + (question.optionA == null ? "null" : "'" + question.optionA + "'") + "," + (question.optionB == null ? "null" : "'" + question.optionB + "'") + "," + (question.optionC == null ? "null" : "'" + question.optionC + "'") + "," + (question.optionD == null ? "null" : "'" + question.optionD + "'") + ")";
                try
                {
                    DbCommand cmd = db.GetSqlStringCommand(sql);
                    result = db.ExecuteNonQuery(cmd);
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            return(result);
        }
Exemple #8
0
        //更新题目
        public int updateQuestion(Question question)
        {
            int result = 0;

            if (checkQuestion(question.question, question.id))
            {
                MessageBox.Show("存在相同题目,请更改题目!", "基于虚拟现实的铁路综合运输训练系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                DBHelper db  = new DBHelper();
                string   sql = "update questions set question='" + question.question + "',answer='" + question.answer + "',difficulty='" + question.difficulty + "',majorId=" + UserInfoForm.getMajorIdByMajor(question.major) + ",typeId=" + getTypeIdByType(question.type) + ",OptionA=" + (question.optionA == null ? "null" : "'" + question.optionA + "'") + ",OptionB=" + (question.optionB == null ? "null" : "'" + question.optionB + "'") + ",OptionC=" + (question.optionC == null ? "null" : "'" + question.optionC + "'") + ",OptionD=" + (question.optionD == null ? "null" : "'" + question.optionD + "'") + " where id=" + question.id;
                try
                {
                    DbCommand cmd = db.GetSqlStringCommand(sql);
                    result = db.ExecuteNonQuery(cmd);
                }
                catch (Exception e)
                {
                    throw e;
                }
            }
            return(result);
        }