private void labelAdd_Click(object sender, EventArgs e) { ChapterInfo model = new ChapterInfo(); FormChapterAdd formChapterAdd = new FormChapterAdd(); formChapterAdd.SetType(_Type); if (DialogResult.OK == formChapterAdd.ShowDialog()) { RefreshGroups(); } }
private void UpdateBankList() { //List<ModelChapter> lst = null; //将列表取进来 Dictionary <int, ChapterInfo> lst = ModelManager.m_DicIntensifyList; foreach (var data in lst) { ChapterInfo model = data.Value; AddItem(model.ID, model.Name, model.IsEnable, model.Classification, model.Count); } }
private void FormQuestionManage_Shown(object sender, EventArgs e) { ChapterInfo modelNull = new ChapterInfo(); modelNull.ID = 0; modelNull.Name = "全部"; ChapterInfo modelNotSplit = new ChapterInfo(); modelNotSplit.ID = -1; modelNotSplit.Name = "未分类"; comboBoxChapter.Items.Add(modelNull); foreach (var model in ModelManager.m_DicMoudleList) { comboBoxChapter.Items.Add(model); } comboBoxSkill.Items.Add(modelNull); foreach (var model in ModelManager.m_DicSkillList) { comboBoxSkill.Items.Add(model.Value); } comboBoxSkill.Items.Add(modelNotSplit); comboBoxBank.Items.Add(modelNull); foreach (var model in ModelManager.m_DicBankList) { comboBoxBank.Items.Add(model.Value); } comboBoxBank.Items.Add(modelNotSplit); comboBoxBank.SelectedIndex = 0; comboBoxSkill.SelectedIndex = 0; comboBoxChapter.SelectedIndex = 1; foreach (var classification in Question._ModelClassificationInfo) { comboBoxClassification.Items.Add(classification); } comboBoxClassification.SelectedIndex = 0; foreach (var typeInfo in Question._TypeInfo) { comboBoxType.Items.Add(typeInfo); } comboBoxType.SelectedIndex = 0; RefreshQuestions(); }
private void UpdateBankList() { //List<ModelChapter> lst = null; Dictionary <int, ChapterInfo> lst = ModelManager.m_DicBankList; foreach (var data in lst) { ChapterInfo model = data.Value; AddItem(model.ID, model.Name, model.IsEnable, model.Classification, model.Count); #if _SaveToSqliteGroups AddChaperOrSkill(model, 2); #endif } }
public FormChapterAdd() { InitializeComponent(); chapterManager = new ChapterManager(); m_chapter = new ChapterInfo(); chapterManager.GetChapterTypeList(out List <ChapterType> chapterTypeList); cboxChapterType.Items.Clear(); foreach (ChapterType chapterTypeInfo in chapterTypeList) { cboxChapterType.Items.Add(chapterTypeInfo); } }
public bool SetChapter(ChapterInfo chapter) { if (null != chapter) { m_chapter = chapter; } lblInfo.Text = "修改分组:" + chapter.Name; richTextBoxTittle.Text = chapter.Name; cboxType.SelectedIndex = chapter.Classification - 1; cboxChapterType.SelectedIndex = chapter.ChapterType; cboxStatus.SelectedIndex = chapter.IsEnable ? 1 : 0; txtSql.Text = chapter.ChapterSqlString; txtParamerter.Text = chapter.SqlParamter; return(true); }
private void cboxChaperType_SelectedIndexChanged(object sender, EventArgs e) { if (cboxChaperType.SelectedIndex < 0) { return; } isLoadSuccess = false; ChapterType chapterType = (ChapterType)cboxChaperType.SelectedItem; ChapterManager.GetChapterList(chapterType.ID, out List <ChapterInfo> chapterInfoList); comboBoxChapter.Items.Clear(); ChapterInfo modelNull = new ChapterInfo(); modelNull.ID = 0; modelNull.Name = "全部"; comboBoxChapter.Items.Add(modelNull); ChapterInfo modelNotSplit = new ChapterInfo(); modelNotSplit.ID = -1; modelNotSplit.Name = "未分类"; comboBoxChapter.Items.Add(modelNotSplit); foreach (ChapterInfo chapterInfo in chapterInfoList) { comboBoxChapter.Items.Add(chapterInfo); } comboBoxChapter.SelectedIndex = 0; cboxClassification.SelectedIndex = 0; comboBoxType.SelectedIndex = 0; textBoxFilterTittle.Text = ""; isLoadSuccess = true; RefreshQuestions(); //textBoxFilterOptions.Text = ""; }
/// <summary> /// 更新添加或更新的章节信息到列表中 /// </summary> /// <param name="model"></param> /// <param name="modelList"></param> /// <param name="isReplace"></param> /// <returns></returns> public static bool AddModelToList(ChapterInfo model, Dictionary <int, ChapterInfo> modelList, out bool isReplace) { isReplace = false; foreach (var tmp in modelList) { if (tmp.Key == model.ID) { isReplace = true; tmp.Value.Name = model.Name; tmp.Value.IsEnable = model.IsEnable; tmp.Value.Classification = model.Classification; return(true); } } modelList.Add(model.ID, model); return(true); }
public void RefreshDatas(int pageNumber, int currentPage) { ChapterInfo chapterInfo = (ChapterInfo)comboBoxChapter.SelectedItem; ChapterType chapterType = (ChapterType)cboxChaperType.SelectedItem; DataTable data = ChpaterQuestionManager.GetChapterQuestions(chapterType.ID, chapterInfo.ID, cboxClassification.SelectedIndex, comboBoxType.SelectedIndex, "%" + textBoxFilterTittle.Text + "%", pageNumber, currentPage); dataGridView1.Rows.Clear(); if (null == data) { MessageBox.Show("获取题目数据失败"); return; } Console.WriteLine(data.Rows.Count); foreach (DataRow row in data.Rows) { AddItem(row); } }
public bool SendBack(ChapterInfo model, bool Replace) { if (true == Replace) { //List<ModelChapter> list = null; Dictionary <int, ChapterInfo> list = null; string path = ""; list = ModelManager.m_DicBankList; path = ModelManager._PathBank; bool isReplace = false; if (true == ModelManager.AddModelToList(model, list, out isReplace)) { if (true == ModelManager.SetListToFile(list, path)) { this.panelModelList.BringToFront(); this.panelModelInfo.SendToBack(); if (isReplace != true) { SystemConfig._maxBankId = model.ID; SystemConfig.SaveModelId(); } AddItem(model.ID, model.Name, model.IsEnable, model.Classification, model.Count); return(true); } } return(false); } else { this.panelModelList.BringToFront(); this.panelModelInfo.SendToBack(); return(true); } }
/// <summary> /// 从数据库获取列表 /// </summary> /// <param name="type"></param> /// <returns></returns> public static Dictionary <int, ChapterInfo> GetChapterListFromDB(int type) { Dictionary <int, ChapterInfo> m_List = new Dictionary <int, ChapterInfo>(); string sql = @"select g.id,g.name, g.type, g.classification, g.status, count(gq.question_id) as count from groups as g left join group_questions as gq on gq.group_id=g.id and gq.type=g.type where g.type=@type group by g.id,g.name,g.type, g.classification, g.status"; DataTable data = SQLiteHelper.SQLiteHelper.GetDataTable(sql, new SQLiteParameter[] { new SQLiteParameter("@type", type) }); foreach (DataRow row in data.Rows) { ChapterInfo modelChapter = new ChapterInfo(); modelChapter.ID = Convert.ToInt32(row["id"].ToString()); modelChapter.Classification = Convert.ToInt32(row["classification"].ToString()); modelChapter.IsEnable = row["status"].ToString() == "1"; modelChapter.Name = row["name"].ToString(); modelChapter.Count = Convert.ToInt32(row["count"].ToString()); m_List.Add(modelChapter.ID, modelChapter); } return(m_List); }
//TODO;更新题目列表 private void RefreshQuestions() { if (false == isLoadSuccess) { return; } ChapterInfo chapterInfo = (ChapterInfo)comboBoxChapter.SelectedItem; ChapterType chapterType = (ChapterType)cboxChaperType.SelectedItem; //ChpaterQuestionManager.GetChapterQuestionsCount(chapterType.ID, chapterInfo.ID, cboxClassification.SelectedIndex, comboBoxType.SelectedIndex); int dataCount = ChpaterQuestionManager.GetChapterQuestionsCount(chapterType.ID, chapterInfo.ID, cboxClassification.SelectedIndex, comboBoxType.SelectedIndex, "%" + textBoxFilterTittle.Text + "%"); labelQuestionCount.Text = dataCount.ToString(); pageControl1.BeginUpdate(); pageControl1.TotalCount = dataCount; RefreshDatas(pageControl1.PerPageNumber, pageControl1.CurrentPage); pageControl1.EndUpdate(); //labelQuestionCount.Text = data.Rows.Count.ToString(); }
private void labelAdd_Click(object sender, EventArgs e) { ChapterInfo model = new ChapterInfo(); switch (_Type) { case 0: model.ID = SystemConfig._maxModuleId + 1; break; case 1: model.ID = SystemConfig._maxSkillId + 1; break; case 2: model.ID = SystemConfig._maxBankId + 1; break; case 3: model.ID = SystemConfig._maxIntensifyId + 1; break; } model.Classification = 1; doShowModelInfo(model); }
/// <summary> /// 获取列表 /// </summary> /// <param name="type"></param> /// <returns></returns> public static bool GetChapterList(int type, out List <ChapterInfo> chapterInfos) { chapterInfos = new List <ChapterInfo>(); try { Dictionary <int, ChapterInfo> m_List = new Dictionary <int, ChapterInfo>(); string sql = @"select g.sql, g.sql_parameter, g.id,g.name, g.type, g.classification as classification_id, g.status, count(gq.question_id) as count, g.name as classification_name, gt.name as group_type from groups as g left join group_questions as gq on gq.group_id=g.id and gq.type=g.type left join classfication as c on g.classification=c.id left join group_type as gt on g.type = gt.id where g.type=@type group by g.id,g.name,g.type, g.classification, g.status order by g.id"; DataTable data = SQLiteHelper.SQLiteHelper.GetDataTable(sql, new SQLiteParameter[] { new SQLiteParameter("@type", type) }); foreach (DataRow row in data.Rows) { ChapterInfo modelChapter = new ChapterInfo(); modelChapter.ID = Convert.ToInt32(row["id"].ToString()); modelChapter.Classification = Convert.ToInt32(row["classification_id"].ToString()); modelChapter.IsEnable = row["status"].ToString() == "1"; modelChapter.Name = row["name"].ToString(); modelChapter.Count = Convert.ToInt32(row["count"].ToString()); modelChapter.ChapterType = Convert.ToInt32(row["type"].ToString()); modelChapter.ChapterSqlString = row["sql"].ToString(); modelChapter.SqlParamter = row["sql_parameter"].ToString(); string classficationName = row["classification_name"].ToString(); chapterInfos.Add(modelChapter); } return(true); } catch (Exception ex) { return(false); } }
public static Dictionary <int, ChapterInfo> GetListFromFile(string filePath) { Dictionary <int, ChapterInfo> m_List = new Dictionary <int, ChapterInfo>(); var file = File.Open(filePath, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite); using (var stream = new StreamReader(file, Encoding.UTF8)) { while (!stream.EndOfStream) { string txtLine = stream.ReadLine(); if (string.IsNullOrEmpty(txtLine)) { continue; } if (txtLine.IndexOf("====&&====") != -1) { continue; } ChapterInfo model = new ChapterInfo(); string[] splitStr = Regex.Split(txtLine, "==>"); model.ID = Convert.ToInt32(splitStr[0]); model.Name = splitStr[1]; model.IsEnable = "1" == splitStr[2] ? true : false; model.Classification = Convert.ToInt32(splitStr[3]); model.Count = Convert.ToInt32(splitStr[4]); m_List.Add(model.ID, model); } } file.Close(); return(m_List); }
private void buttonSave_Click(object sender, EventArgs e) { if (false == CheckQuestionInfo()) { return; } if (DialogResult.No == MessageBox.Show("确认要保存此题目信息吗?", "确认信息", MessageBoxButtons.YesNo)) { return; } BindUIToQuestion(out Question question); if (true == QuestionManagerSql.UpdateQuestion(question, m_question)) { //MessageBox.Show("保存题目信息成功,题目id:" + m_question.Id.ToString() + ".", "提示信息", MessageBoxButtons.OK); } else { MessageBox.Show("保存题目信息失败,题目id:" + m_question.Id.ToString() + "请检查题目信息!", "提示信息", MessageBoxButtons.OK); return; } ChapterInfo chapterSkill = (ChapterInfo)comboBoxSkill.SelectedItem; bool result = false; if (chapterSkill.ID != m_skillId) { if (chapterSkill.ID == 0) { result = QuestionManagerSql.DeleteQuestionGroup(m_question.Id, m_skillId); } else { result = QuestionManagerSql.UpdateQuestionGroup(m_question.Id, chapterSkill.ID, m_skillId, 1); } if (result) { //MessageBox.Show("保存技巧信息成功,题目id:" + m_question.Id.ToString() + ".", "提示信息", MessageBoxButtons.OK); } else { MessageBox.Show("保存技巧信息失败,题目id:" + m_question.Id.ToString() + "技巧ID:" + m_skillId + "新的技巧ID:" + chapterSkill.ID + "请检查题目信息!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } result = false; ChapterInfo chapterBank = (ChapterInfo)cboxBank.SelectedItem; if (chapterBank.ID != m_bankId) { if (chapterBank.ID == 0) { result = QuestionManagerSql.DeleteQuestionGroup(m_question.Id, m_bankId); } else { result = QuestionManagerSql.UpdateQuestionGroup(m_question.Id, chapterBank.ID, m_bankId, 2); } if (result) { //MessageBox.Show("保存强化信息成功,题目id:" + m_question.Id.ToString() + ".", "提示信息", MessageBoxButtons.OK); } else { MessageBox.Show("保存强化信息失败,题目id:" + m_question.Id.ToString() + "强化ID:" + m_skillId + "新的强化ID:" + chapterSkill.ID + "请检查题目信息!", "提示信息", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } DialogResult = DialogResult.Yes; }
void AddItem(AnswerQuestion answer) { DataGridViewRow row = new DataGridViewRow(); DataGridViewTextBoxCell txtBox1 = new DataGridViewTextBoxCell(); txtBox1.Value = answer.seq.ToString(); txtBox1.ToolTipText = "ID=" + answer.question.Id.ToString(); row.Cells.Add(txtBox1); txtBox1.ReadOnly = true; DataGridViewTextBoxCell txtBox2 = new DataGridViewTextBoxCell(); txtBox2.Value = answer.question.Tittle; txtBox2.ToolTipText = answer.question.Tittle; row.Cells.Add(txtBox2); txtBox2.ReadOnly = true; DataGridViewTextBoxCell txtBox4 = new DataGridViewTextBoxCell(); txtBox4.Value = Question._TypeInfo[answer.question.Type]; txtBox4.ToolTipText = "题目类型"; row.Cells.Add((DataGridViewTextBoxCell)txtBox4); txtBox4.ReadOnly = true; DataGridViewTextBoxCell txtBox5 = new DataGridViewTextBoxCell(); ChapterInfo model = new ChapterInfo(); txtBox5.Value = answer.AnswerString; txtBox5.ToolTipText = "您的答案"; row.Cells.Add((DataGridViewTextBoxCell)txtBox5); txtBox5.ReadOnly = true; DataGridViewTextBoxCell txtBox6 = new DataGridViewTextBoxCell(); txtBox6.Value = answer.CorrectString; txtBox6.ToolTipText = "正确答案"; row.Cells.Add((DataGridViewTextBoxCell)txtBox6); txtBox6.ReadOnly = true; DataGridViewTextBoxCell txtBox7 = new DataGridViewTextBoxCell(); if (0 == answer.RightStatus) { txtBox7.Value = "未回答"; } if (1 == answer.RightStatus) { txtBox7.Value = "回答正确"; } if (2 == answer.RightStatus) { txtBox7.Value = "回答错误"; } txtBox7.ToolTipText = answer.question.SkillNotice; row.Cells.Add((DataGridViewTextBoxCell)txtBox7); txtBox7.ReadOnly = true; row.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGridView1.Rows.Add(row); }
public bool SendBack(ChapterInfo model, bool Replace) { if (true == Replace) { //List<ModelChapter> list = null; Dictionary<int, ChapterInfo> list = null; string path = ""; switch(_Type) { case 0: list = ModelManager.m_DicMoudleList; break; case 1: list = ModelManager.m_DicSkillList; break; case 2: list = ModelManager.m_DicBankList; break; case 3: list = ModelManager.m_DicIntensifyList; break; } //if (_Type == 0) //{ // list = ModelManager.m_DicSkillList; // path = ModelManager._PathSkill; //} //else //{ // list = ModelManager.m_DicMoudleList; // path = ModelManager._PathModule; //} bool isReplace = false; if (true == ModelManager.AddModelToList(model, list, out isReplace)) { //TODO:保存章節信息到數據庫 if (!isReplace) { if (false == this.AddChapterToDB(model)) return false; } else { if (false == this.UpdateChapterToDB(model)) return false; } //if (true == ModelManager.SetListToFile(list, path)) { this.panelModelList.BringToFront(); this.panelModelInfo.SendToBack(); if(isReplace != true) { switch(_Type) { case 0: SystemConfig._maxModuleId = model.ID; break; case 1: SystemConfig._maxSkillId = model.ID; break; case 2: SystemConfig._maxBankId = model.ID; break; case 3: SystemConfig._maxIntensifyId = model.ID; break; } //if (_Type == 0) //{ // SystemConfig._maxSkillId = model.Id; //} //else //{ // SystemConfig._maxModuleId = model.Id; //} SystemConfig.SaveModelId(); } AddItem(model.ID, model.Name, model.IsEnable, model.Classification, model.Count); return true; } } return false; } else { this.panelModelList.BringToFront(); this.panelModelInfo.SendToBack(); return true; } }
//TODO;更新题目列表 private void RefreshQuestions() { try { dataGridView1.Rows.Clear(); foreach (var question in QuestionManager.m_QuestionsList) { if (question == null) { continue; } if (0 != comboBoxChapter.SelectedIndex) { if (question.Module != comboBoxChapter.SelectedIndex) { continue; } } ChapterInfo modelSkill = (ChapterInfo)comboBoxSkill.SelectedItem; if (modelSkill.ID == -1) { //未分类 if (question.Skill != 0) { continue; } } else if (modelSkill.ID != 0) { if (question.Skill != modelSkill.ID) { continue; } } ChapterInfo modelBank = (ChapterInfo)comboBoxBank.SelectedItem; if (modelBank.ID == -1) { //未分类 if (question.BankId != 0) { continue; } } else if (modelBank.ID != 0) { if (question.BankId != modelBank.ID) { continue; } } //if (0 != comboBoxSkill.SelectedIndex) //{ // if (question.Skill != comboBoxSkill.SelectedIndex) // continue; //} if (0 != comboBoxType.SelectedIndex) { if (question.Type != comboBoxType.SelectedIndex) { continue; } } if (0 != comboBoxClassification.SelectedIndex) { if (question.Classification != comboBoxClassification.SelectedIndex) { continue; } } AddItem(question); } labelQuestionCount.Text = dataGridView1.Rows.Count.ToString(); } catch (Exception ex) { MessageBox.Show("题目未完全加载,请稍候打开!" + ex.Message); } }
/// <summary> /// 更新技巧和章节信息 /// </summary> private void UpdateModel(int SkillId, int ChapterId, int bankId) { comboBoxChapter.Items.Clear(); comboBoxChapter.BeginUpdate(); int i = 0; foreach (var modelInfo in ModelManager.m_DicMoudleList) { //if (modelInfo.Value.Classification != comboBoxClassification.SelectedIndex + 1) // continue; comboBoxChapter.Items.Add(modelInfo); if (modelInfo.Value.ID == ChapterId) { comboBoxChapter.SelectedIndex = i; } i++; } comboBoxChapter.EndUpdate(); if (comboBoxChapter.SelectedIndex == -1) { comboBoxChapter.SelectedIndex = 0; } comboBoxSkill.Items.Clear(); comboBoxSkill.BeginUpdate(); ChapterInfo model = new ChapterInfo(); model.ID = 0; model.Name = "未分类"; KeyValuePair <int, ChapterInfo> pair = new KeyValuePair <int, ChapterInfo>(0, model); comboBoxSkill.Items.Add(pair); i = 1; foreach (var modelInfo in ModelManager.m_DicSkillList) { //if (modelInfo.Value.Classification != comboBoxClassification.SelectedIndex + 1) // continue; comboBoxSkill.Items.Add(modelInfo); if (modelInfo.Value.ID == SkillId) { comboBoxSkill.SelectedIndex = i; } i++; } comboBoxSkill.EndUpdate(); if (comboBoxSkill.SelectedIndex == -1) { comboBoxSkill.SelectedIndex = 0; } cboxBank.Items.Clear(); cboxBank.BeginUpdate(); ChapterInfo modelBank = new ChapterInfo(); modelBank.ID = 0; modelBank.Name = "未分类"; KeyValuePair <int, ChapterInfo> pairBank = new KeyValuePair <int, ChapterInfo>(0, modelBank); cboxBank.Items.Add(pair); i = 1; foreach (var modelInfo in ModelManager.m_DicBankList) { //if (modelInfo.Value.Classification != comboBoxClassification.SelectedIndex + 1) // continue; cboxBank.Items.Add(modelInfo); if (modelInfo.Value.ID == bankId) { cboxBank.SelectedIndex = i; } i++; } cboxBank.EndUpdate(); if (cboxBank.SelectedIndex == -1) { cboxBank.SelectedIndex = 0; } }
private void BindUIToQuestion() { Question question = m_question; question.Tittle = richTextBoxTittle.Text; question.Classification = comboBoxClassification.SelectedIndex + 1; ChapterInfo modelSkill = ((KeyValuePair <int, ChapterInfo>)comboBoxSkill.SelectedItem).Value; if (null == modelSkill) { question.Skill = 0; } else { question.Skill = modelSkill.ID; } ChapterInfo modelBank = ((KeyValuePair <int, ChapterInfo>)cboxBank.SelectedItem).Value; if (null == modelBank) { question.BankId = 0; } else { question.BankId = modelBank.ID; } ChapterInfo modelChapter = ((KeyValuePair <int, ChapterInfo>)comboBoxChapter.SelectedItem).Value; question.Module = modelChapter.ID; question.TittleEmphasize = string.IsNullOrEmpty(textBoxEmphasize.Text)?"" : textBoxEmphasize.Text; question.SkillNotice = string.IsNullOrEmpty(richTextBoxSkillNotice.Text) ? "" : richTextBoxSkillNotice.Text; question.SkillNotice = question.SkillNotice.Replace("\n", "&"); if (!string.IsNullOrEmpty(textBoxTittleImage.Text)) { string extension = Path.GetExtension(_pathImage); if (!string.IsNullOrEmpty(_pathImage)) { question.ImagePath = question.Id.ToString() + Path.GetExtension(_pathImage); } if (!string.IsNullOrEmpty(_pathFlash)) { question.FlashPath = question.Id.ToString() + Path.GetExtension(_pathFlash); } } if (radioButtonType1.Checked == true) { question.Type = 1; } else { question.Type = 2; } int answerCount = 0; if (checkBoxA.Checked == true) { answerCount++; } if (checkBoxB.Checked == true) { answerCount++; } if (checkBoxC.Checked == true) { answerCount++; } if (checkBoxD.Checked == true) { answerCount++; } if (answerCount > 1) { question.Type = 3; } question.Options.Clear(); question.Options.Add(textBoxOptionA.Text); question.Options.Add(textBoxOptionB.Text); question.Options.Add(textBoxOptionC.Text); question.Options.Add(textBoxOptionD.Text); question.OptionsEmphasize.Clear(); question.OptionsEmphasize.Add(textBoxEmphasizeA.Text); question.OptionsEmphasize.Add(textBoxEmphasizeB.Text); question.OptionsEmphasize.Add(textBoxEmphasizeC.Text); question.OptionsEmphasize.Add(textBoxEmphasizeD.Text); question.CorrectAnswer.Clear(); if (checkBoxA.Checked) { question.CorrectAnswer.Add(1); } if (checkBoxB.Checked) { question.CorrectAnswer.Add(2); } if (checkBoxC.Checked) { question.CorrectAnswer.Add(3); } if (checkBoxD.Checked) { question.CorrectAnswer.Add(4); } }
private bool BindUIToQuestion(out Question question) { question = new Question(); question.Tittle = richTextBoxTittle.Text; question.Classification = comboBoxClassification.SelectedIndex + 1; question.TittleEmphasize = string.IsNullOrEmpty(textBoxEmphasize.Text)?"" : textBoxEmphasize.Text; question.SkillNotice = string.IsNullOrEmpty(richTextBoxSkillNotice.Text) ? "" : richTextBoxSkillNotice.Text; question.SkillNotice = question.SkillNotice.Replace("\n", "&"); if (comboBoxChapter.SelectedItem != null) { ChapterInfo chapterInfo = (ChapterInfo)comboBoxChapter.SelectedItem; question.Module = chapterInfo.ID; } else { question.Module = 0; } if (!string.IsNullOrEmpty(textBoxTittleImage.Text)) { string extension = Path.GetExtension(_pathImage); if (!string.IsNullOrEmpty(_pathImage)) { question.ImagePath = question.Id.ToString() + Path.GetExtension(_pathImage); } if (!string.IsNullOrEmpty(_pathFlash)) { question.FlashPath = question.Id.ToString() + Path.GetExtension(_pathFlash); } } else { question.ImagePath = ""; question.FlashPath = ""; } if (radioButtonType1.Checked == true) { question.Type = 1; } else { question.Type = 2; } int answerCount = 0; if (checkBoxA.Checked == true) { answerCount++; } if (checkBoxB.Checked == true) { answerCount++; } if (checkBoxC.Checked == true) { answerCount++; } if (checkBoxD.Checked == true) { answerCount++; } if (answerCount > 1) { question.Type = 3; } question.Options = new List <string>(); question.Options.Clear(); question.Options.Add(textBoxOptionA.Text); question.Options.Add(textBoxOptionB.Text); question.Options.Add(textBoxOptionC.Text); question.Options.Add(textBoxOptionD.Text); question.OptionsEmphasize = new List <string>(); question.OptionsEmphasize.Clear(); question.OptionsEmphasize.Add(textBoxEmphasizeA.Text); question.OptionsEmphasize.Add(textBoxEmphasizeB.Text); question.OptionsEmphasize.Add(textBoxEmphasizeC.Text); question.OptionsEmphasize.Add(textBoxEmphasizeD.Text); question.CorrectAnswer = new List <int>(); question.CorrectAnswer.Clear(); if (checkBoxA.Checked) { question.CorrectAnswer.Add(1); } if (checkBoxB.Checked) { question.CorrectAnswer.Add(2); } if (checkBoxC.Checked) { question.CorrectAnswer.Add(3); } if (checkBoxD.Checked) { question.CorrectAnswer.Add(4); } question.Answers = new List <int>(); question.Answers.Add(checkBoxA.Checked ? 1 : 0); question.Answers.Add(checkBoxB.Checked ? 1 : 0); question.Answers.Add(checkBoxC.Checked ? 1 : 0); question.Answers.Add(checkBoxD.Checked ? 1 : 0); return(true); }
private void AddItem(ChapterInfo chapter, string classficationName) { DataGridViewRow row = new DataGridViewRow(); row.Tag = chapter; DataGridViewCheckBoxCell chkBoxCell = new DataGridViewCheckBoxCell(); chkBoxCell.Value = false; row.Cells.Add(chkBoxCell); DataGridViewTextBoxCell txtBox1 = new DataGridViewTextBoxCell(); //txtBox1.Value = (dataGridView1.Rows.Count + 1).ToString(); txtBox1.Value = chapter.ID.ToString(); txtBox1.Tag = chapter.ID.ToString(); row.Cells.Add(txtBox1); txtBox1.ReadOnly = true; DataGridViewTextBoxCell txtBox2 = new DataGridViewTextBoxCell(); txtBox2.Value = chapter.Name; txtBox2.ToolTipText = chapter.Name; row.Cells.Add(txtBox2); txtBox2.ReadOnly = true; DataGridViewTextBoxCell txtBox3 = new DataGridViewTextBoxCell(); txtBox3.Value = Question._ModelClassificationInfo[chapter.Classification]; txtBox3.ToolTipText = "分组所属类型"; row.Cells.Add((DataGridViewTextBoxCell)txtBox3); txtBox3.ReadOnly = true; txtBox3.Tag = classficationName; DataGridViewTextBoxCell txtBox5 = new DataGridViewTextBoxCell(); txtBox5.Value = chapter.Count.ToString(); txtBox5.ToolTipText = "此分组下面的题目数"; row.Cells.Add((DataGridViewTextBoxCell)txtBox5); txtBox5.ReadOnly = true; txtBox5.Tag = chapter.Count; DataGridViewTextBoxCell txtBox4 = new DataGridViewTextBoxCell(); txtBox4.Value = chapter.IsEnable ? "启用" : "停用"; txtBox4.ToolTipText = "是否启用"; txtBox4.Tag = chapter.IsEnable; row.Cells.Add((DataGridViewTextBoxCell)txtBox4); txtBox4.ReadOnly = true; DataGridViewButtonCell button = new DataGridViewButtonCell(); button.Value = "编辑"; button.ToolTipText = "编辑此分组"; row.Cells.Add(button); button = new DataGridViewButtonCell(); button.Value = "删除"; button.ToolTipText = "删除此分组"; row.Cells.Add(button); row.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGridView1.Rows.Add(row); }
private void radioButtonTemplate_CheckedChanged(object sender, EventArgs e) { g_ChapterInfo = (ChapterInfo)(((RadioButton)sender).Tag); }
private void AddItem(Question question) { if (!string.IsNullOrEmpty(textBoxFilterTittle.Text)) { if (question.Tittle.IndexOf(textBoxFilterTittle.Text) == -1) { return; } } if (!string.IsNullOrEmpty(textBoxFilterOptions.Text)) { bool isFind = false; foreach (var info in question.Options) { if (info.IndexOf(textBoxFilterOptions.Text) != -1) { isFind = true; } } if (isFind == false) { return; } } DataGridViewRow row = new DataGridViewRow(); DataGridViewCheckBoxCell chkBoxCell = new DataGridViewCheckBoxCell(); chkBoxCell.Value = false; chkBoxCell.Tag = question; row.Cells.Add(chkBoxCell); DataGridViewTextBoxCell txtBox1 = new DataGridViewTextBoxCell(); txtBox1.Value = Convert.ToInt32(dataGridView1.Rows.Count + 1); //txtBox1.Tag = question.Id.ToString(); txtBox1.ToolTipText = "ID=" + question.Id.ToString(); row.Cells.Add(txtBox1); txtBox1.ReadOnly = true; DataGridViewTextBoxCell txtBox2 = new DataGridViewTextBoxCell(); txtBox2.Value = question.Tittle; txtBox2.ToolTipText = question.Tittle; row.Cells.Add(txtBox2); txtBox2.ReadOnly = true; //这个类别不正确 DataGridViewTextBoxCell txtBox3 = new DataGridViewTextBoxCell(); if (question.Classification == 0) { txtBox3.Value = "未分类"; } else { txtBox3.Value = Question._ModelClassificationInfo[question.Classification]; } txtBox3.ToolTipText = "题目类别"; row.Cells.Add((DataGridViewTextBoxCell)txtBox3); txtBox3.ReadOnly = true; //txtBox3.Tag = question.Type; DataGridViewTextBoxCell txtBox4 = new DataGridViewTextBoxCell(); txtBox4.Value = Question._TypeInfo[question.Type]; if (question.Type == 1) { txtBox4.ToolTipText = "题目类型"; } else { string questionOptions = ""; for (int i = 1; i <= question.Options.Count; i++) { var option = question.Options[i - 1]; questionOptions += i.ToString() + "." + option + " "; } txtBox4.ToolTipText = questionOptions; } row.Cells.Add((DataGridViewTextBoxCell)txtBox4); //txtBox4.Tag = question.Type; txtBox4.ReadOnly = true; DataGridViewTextBoxCell txtBox5 = new DataGridViewTextBoxCell(); ChapterInfo model = new ChapterInfo(); ModelManager.m_DicMoudleList.TryGetValue(question.Module, out model); if (model == null) { txtBox5.Value = "未分类"; txtBox5.ToolTipText = "未分类"; } else { txtBox5.Value = model.Name; txtBox5.ToolTipText = model.Name; } row.Cells.Add((DataGridViewTextBoxCell)txtBox5); txtBox5.ReadOnly = true; DataGridViewTextBoxCell txtBox6 = new DataGridViewTextBoxCell(); // txtBox6.Tag = question.Skill; ChapterInfo modelSkill = null; ModelManager.m_DicSkillList.TryGetValue(question.Skill, out modelSkill); if (modelSkill == null) { txtBox6.Value = "未分类"; txtBox6.ToolTipText = "未分类"; } else { txtBox6.Value = modelSkill.Name; txtBox6.ToolTipText = modelSkill.Name; } row.Cells.Add((DataGridViewTextBoxCell)txtBox6); txtBox6.ReadOnly = true; DataGridViewTextBoxCell txtBox7 = new DataGridViewTextBoxCell(); // txtBox6.Tag = question.Skill; ChapterInfo modelBank = null; ModelManager.m_DicBankList.TryGetValue(question.BankId, out modelBank); if (modelBank == null) { txtBox7.Value = "未分类"; txtBox7.ToolTipText = "未分类"; } else { txtBox7.Value = modelBank.Name; txtBox7.ToolTipText = modelBank.Name; } row.Cells.Add((DataGridViewTextBoxCell)txtBox7); txtBox7.ReadOnly = true; DataGridViewButtonCell button = new DataGridViewButtonCell(); button.Value = "编辑"; row.Cells.Add(button); button = new DataGridViewButtonCell(); button.Value = "删除"; row.Cells.Add(button); row.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; dataGridView1.Rows.Add(row); }
/// <summary> /// 更新技巧和章节信息 /// </summary> private void UpdateGroups(int ChapterId, int SkillId, int bankId) { comboBoxChapter.Items.Clear(); comboBoxChapter.BeginUpdate(); int index = 0; ChapterInfo chapterNull = new ChapterInfo(); chapterNull.ID = 0; chapterNull.Name = "未分类"; comboBoxChapter.Items.Add(chapterNull); ChapterManager.GetChapterList(0, out List <ChapterInfo> chapterInfos); int i = 0; foreach (var chapterInfo in chapterInfos) { i++; comboBoxChapter.Items.Add(chapterInfo); if (chapterInfo.ID == ChapterId) { index = i; } } comboBoxChapter.SelectedIndex = index; comboBoxChapter.EndUpdate(); comboBoxSkill.Items.Clear(); comboBoxSkill.BeginUpdate(); index = 0; ChapterInfo skillNull = new ChapterInfo(); skillNull.ID = 0; skillNull.Name = "未分类"; comboBoxSkill.Items.Add(skillNull); ChapterManager.GetChapterList(1, out List <ChapterInfo> chapterSkills); i = 0; foreach (var chapterInfo in chapterSkills) { i++; comboBoxSkill.Items.Add(chapterInfo); if (chapterInfo.ID == SkillId) { index = i; } } comboBoxSkill.SelectedIndex = index; comboBoxSkill.EndUpdate(); cboxBank.Items.Clear(); cboxBank.BeginUpdate(); index = 0; ChapterInfo bankNull = new ChapterInfo(); bankNull.ID = 0; bankNull.Name = "未分类"; cboxBank.Items.Add(bankNull); ChapterManager.GetChapterList(2, out List <ChapterInfo> chapterBanks); i = 0; foreach (var chapterInfo in chapterBanks) { i++; cboxBank.Items.Add(chapterInfo); if (chapterInfo.ID == bankId) { index = i; } } cboxBank.SelectedIndex = index; cboxBank.EndUpdate(); }