private void AfterUserCheck(IAsyncResult result) { #region DLUserCheck dl_do = (DLUserCheck)result.AsyncState; if (!this.InvokeRequired) { return; } if (dl_do.EndInvoke(result)) { this.Invoke(new MethodInvoker(() => { _iconStatus._systemNotifyIcon.Text += "\r\nNO:" + _User.userid; this.Hide(); UserMainWindow mainwindow = new UserMainWindow(); mainwindow._IconController = new icon.IconController(); mainwindow._IconController.Bind(_iconStatus); mainwindow.Show(); _iconStatus.BindToWindow(mainwindow); })); } else { this.Invoke(new MethodInvoker(() => { ExtMessage.Show("帐号异常!"); })); } #endregion }
/// <summary> /// 提交考题内容 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void submitQuestionContent(object sender , RoutedEventArgs e) { #region if (this.cbQuestiontype.SelectedValue != null) { questiontype = this.cbQuestiontype.SelectedValue.ToString(); } switch (questiontype) { case "1": this.tbQuestionSelect.Text = this.tbQuestion.Text; this.showSelectTab(); break; case "2": this.showEstimateTab(); if (_frmState == ExamQuestionState.NormalEdit) { this.initEstimate(); } break; case "3": this.tbQuestionEssay.Text = this.tbQuestion.Text; this.showEssayTab(); break; default: ExtMessage.Show("请选择考题类型!"); break; } #endregion }
private void resetConnectDB(object sender , RoutedEventArgs e) { #region if (isTestConnectDBing) { ExtMessage.Show("正在尝试连接数据库……"); } else { if (IsConnectingDB) { ExtMessage.Show("已连接上数据库,软件可以正常使用!"); } else { if (ExtMessage.ShowConfirm("您确认要重新连接数据库吗?") == System.Windows.Forms.DialogResult.OK) { this.getDBDataToUI(); } } } #endregion }
/// <summary> /// (linkbutton)查询试题 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void queryQuestion(object sender, RoutedEventArgs e) { #region this.AddDBCheck(() => { this.tcMainWindowTab.SelectedIndex = 1; ExtMessage.Show("在列表顶端的查询区域输入关键字或按照试题类型、试题领域进行组合查询!"); }); #endregion }
/// <summary> /// 进行数据库检测 /// </summary> /// <param name="businessProcess"></param> private void AddDBCheck(DLBusinessProcess businessProcess) { #region if (IsConnectingDB) { businessProcess(); } else { ExtMessage.Show("数据库连接失败!"); } #endregion }
private void saveDbConnectParams(object sender , RoutedEventArgs e) { #region if (!_isTestSuccessfull) { ExtMessage.Show(@"请先测试连接成功后再进行保存!"); } else { string newConnectString = "Data Source={0};Initial Catalog={1};Persist Security Info=True;User ID={2};Password={3};"; string[] cStrArr = new string[4]; cStrArr[0] = this.tbDataSource.Text.Trim(); cStrArr[1] = this.tbDataBase.Text.Trim(); cStrArr[2] = this.tbUsername.Text.Trim(); cStrArr[3] = this.tbPassword.Text.Trim(); newConnectString = String.Format(newConnectString, cStrArr); XmlDocument doc = new XmlDocument(); doc.Load(_cfgFileName); //找出名称为“add”的所有元素 XmlNodeList nodes = doc.GetElementsByTagName("add"); for (int i = 0; i < nodes.Count; i++) { //获得将当前元素的key属性 XmlAttribute att = nodes[i].Attributes["name"]; //根据元素的第一个属性来判断当前的元素是不是目标元素 if (att.Value == "ConnectString") { //对目标元素中的第二个属性赋值 att = nodes[i].Attributes["connectionString"]; att.Value = newConnectString; break; } } doc.Save(_cfgFileName); System.Diagnostics.Process.Start("RestartApplication.exe", "ExamSystemConfig.exe"); System.Environment.Exit(0); this.Close(); } #endregion }
private void ConnectDB(string connectString) { #region try { DateTime dt = CustomTime.GetDBServerTime(connectString); ExtMessage.Show(@"连接成功,返回服务器时间" + dt.ToString() + "\r\n现在可以点击“保存数据库参数”确保下次程序开启后能正确连接数据库!"); this._isTestSuccessfull = true; } catch { ExtMessage.ShowError("连接不成功!"); } finally { this.Dispatcher.BeginInvoke( new DLControlProgress(() => { this.ctlprogress.IsActive = false; }), null); } #endregion }
/// <summary> /// 编辑选中考题 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void showEditQuestion(object sender, RoutedEventArgs e) { #region this.AddDBCheck(() => { DataRowView drvquestion = null; if (this.dgQuestion.SelectedItem != null) { drvquestion = this.dgQuestion.SelectedItem as DataRowView; } else { ExtMessage.Show("请选中要编辑的数据!"); return; } NewQuestion frmquestion = new NewQuestion(ExamQuestionState.NormalEdit); frmquestion.QuestionRow = QuestionController.QuestionData.Tables[0] .Rows.Find(drvquestion[ExamQuestionData.questionId]); frmquestion.InitUI(); frmquestion.ShowDialog(); }); #endregion }
/// <summary> /// /// </summary> private void initEstimate() { #region this.tbQuestionEstimate.Text = this.tbQuestion.Text; int totalcount = 0; ExamAnswerEstimateBusiness answerestimatebusiness = new ExamAnswerEstimateBusiness(); _entityAnswerEstimate = new EntityExamAnswerEstimate(); _entityAnswerEstimate.questionId = QuestionRow[ExamQuestionData.questionId].ToString(); this._answerEstimateData = answerestimatebusiness.GetData(_entityAnswerEstimate, null, out totalcount); if (totalcount == 1) { this.cbAnswerEstimate.IsChecked = Convert .ToBoolean(this._answerEstimateData.Tables[0] .Rows[0][ExamAnswerEstimateData.answer]); } else { ExtMessage.Show("数据错误,请将此项数据进行删除!"); } #endregion }
/// <summary> /// 保存考题 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void saveQuestion(object sender , RoutedEventArgs e) { #region switch (questiontype) { case "2": if (_frmState == ExamQuestionState.NormalAdd) { addEstimateQuestion(); } else { updateEstimateQuestion(); } break; default: break; } ExtMessage.Show("已成功提交考题!"); this.Close(); #endregion }