Example #1
0
        private void btn_v_update_Click(object sender, EventArgs e)
        {
            //没有在DataGridView中选中项目
            if (dgvvideo.SelectedRows.Count <= 0)
            {
                MessageBox.Show("当前没有选择项目,请选择一个项目进行更新!", "基于虚拟现实的铁路综合运输训练系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            //在DataGridView中选中两个或两个以上题目
            if (dgvvideo.SelectedRows.Count > 1)
            {
                MessageBox.Show("无法同时对多个项目进行更新操作,请选择一个项目进行更新!", "基于虚拟现实的铁路综合运输训练系统", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            //根据DataGridView选中项,生成一个Video类的实例
            Video           video      = new Video();
            DataGridViewRow currentRow = dgvvideo.Rows[dgvvideo.SelectedRows[0].Index];

            video.id    = Convert.ToInt32(currentRow.Cells[0].Value);
            video.name  = currentRow.Cells[1].Value.ToString();
            video.major = currentRow.Cells[5].Value.ToString();
            DBHelper db  = new DBHelper();
            string   sql = "select startTime,endTime,fileName from game_questions where id=" + video.id;

            try
            {
                DbCommand cmd = db.GetSqlStringCommand(sql);
                using (DbDataReader reader = db.ExecuteReader(cmd))
                {
                    if (reader.Read())
                    {
                        video.startTime = float.Parse(reader["startTime"].ToString());
                        video.endTime   = float.Parse(reader["endTime"].ToString());
                        video.url       = reader["fileName"].ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            v_dialog = new VideoEditedFrom();
            //设置对话框的题目数据
            v_dialog.video = video;

            //显示对话框
            if (v_dialog.ShowDialog() == DialogResult.OK)
            {
                //更新题目信息
                if (update_video(v_dialog.video) <= 0)
                {
                    return;
                }
                show_video();
            }
        }
Example #2
0
 private void btn_v_Add_Click(object sender, EventArgs e)
 {
     v_dialog = new VideoEditedFrom();
     //清空题目信息对话框的数据
     v_dialog.video = null;
     //如果在对话框中选择了“确定”,则根据输入信息添加
     if (v_dialog.ShowDialog() == DialogResult.OK)
     {
         if (add_video(v_dialog.video) <= 0)
         {
             return;
         }
         show_video();
     }
 }
Example #3
0
        private void loadVideoEditedFrom()
        {
            VideoEditedFrom video = new VideoEditedFrom();

            video.ShowDialog();
        }