using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Model;
namespace View
{
public partial class ctlJudge : UserControl
{
private tb_question_answer ModelJudge = new tb_question_answer();
private List<tb_question_answer> lstQA = new List<tb_question_answer>();
public ctlJudge()
{
InitializeComponent();
}
public ctlJudge(tb_question_answer model) : this()
{
ModelJudge = model;
this.memoEditQuestion.Text = ModelJudge.Question;
}
private void btnRelease_Click(object sender, EventArgs e)
{
ModelJudge.UserAnswer = "TRUE";
JudgeMent();
}
private void btnHold_Click(object sender, EventArgs e)
{
ModelJudge.UserAnswer = "FALSE";
JudgeMent();
}
private void JudgeMent()
{
ctlJudgeResult ctl;
if (ModelJudge.UserAnswer.Trim().ToUpper() == ModelJudge.Answer.Trim().ToUpper())
{
ctl = new ctlJudgeResult("快去抽取您的大奖吧!", 1);
}
else
{
ctl = new ctlJudgeResult("谢谢参与,请至工作人员处领取纪念品哦!", 2);
}
DevExpress.XtraEditors.XtraForm frm = new DevExpress.XtraEditors.XtraForm();
frm.StartPosition = FormStartPosition.CenterParent;
ctl.Dock = DockStyle.Fill;
frm.Text = "判题结果";
frm.FormBorderStyle = FormBorderStyle.None;
frm.ShowInTaskbar = false;
frm.BackColor = Color.Transparent;
frm.Height = 629;
frm.Width = 468;
frm.MaximizeBox = false;
frm.MinimumSize = new Size(629, 468);
frm.MaximumSize = new Size(629, 468);
frm.Icon = this.ParentForm.Icon;
frm.Controls.Add(ctl);
frm.ShowDialog();
this.FindForm().Visible = false;
if (frm.DialogResult == DialogResult.OK)
{
this.FindForm().DialogResult = DialogResult.OK;
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ViewController;
using Model;
using DevExpress.XtraEditors;
using log4net;
namespace View
{
public partial class ctlJudgeMain : UserControl
{
private SimpleButton btn;
private ctlQASelectController _ctlQaSelectController = new ctlQASelectController();
private ctlQAlogController _ctlQAlogController = new ctlQAlogController();
private List<tb_question_answer> lstQA = new List<tb_question_answer>();
private static readonly ILog logger = LogManager.GetLogger(typeof(ctlJudgeMain));
public ctlJudgeMain()
{
InitializeComponent();
}
private void ctlJudgeMain_Load(object sender, EventArgs e)
{
pnlQuestion.Visible = false;
picGif.Image = global::View.Properties.Resources.timg; ;
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
timer1.Stop();
this.textEditID.Focus();
this.textEditID.Text = "";
// simpleButtonbtnjudge_Click(null,null);
}
private void simpleButtonStop_Click(object sender, EventArgs e)
{
timer1.Stop();
}
private void simpleButtonStop_DoubleClick(object sender, EventArgs e)
{
timer1_Tick(null,null);
}
private void simpleButtonStop_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode==Keys.Enter)
{
timer1.Stop();
}
}
private void simpleButtonStop_KeyPress(object sender, KeyPressEventArgs e)
{
}
private void simpleButtonbtnjudge_Click(object sender, EventArgs e)
{
}
private void textEditJudgeId_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
judgeStart_Click(null,null);
}
}
private void labelControlNameJ_Click(object sender, EventArgs e)
{
}
private void judgeStart_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrWhiteSpace(textEditID.Text.Trim()))//判断textID内的值是否为空
{
XtraMessageBox.Show("工号不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
ctlSignController _ctlSignController = new ctlSignController();
string name = _ctlSignController.QueryUserCardInfoByEmpId(textEditID.Text.Trim()).NAME;//查找数据库中是否存在此name
if (string.IsNullOrWhiteSpace(name))
{
XtraMessageBox.Show("用户不存在!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
else
{
lblName.Text = name;
}
if (_ctlQAlogController.QueryQALog(textEditID.Text.Trim()) > 0)
{
XtraMessageBox.Show("很抱歉您已参加过答题,请下次再来!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
textEditID.Text = "";
textEditID.Focus();
return;
}
picGif.Image = null;
pnlQuestion.Visible = false;
ctlHRActionJudgeController judgeHelper = new ctlHRActionJudgeController();
tb_question_answer model = judgeHelper.QuestionInfo();
if (model.QType == "JUDGE")
{
DevExpress.XtraEditors.XtraForm frm = new DevExpress.XtraEditors.XtraForm();
frm.StartPosition = FormStartPosition.CenterParent;
ctlJudge ctl = new ctlJudge(model);
ctl.Dock = DockStyle.Fill;
frm.Text = "判案结果";
frm.FormBorderStyle = FormBorderStyle.None;
frm.ShowInTaskbar = false;
frm.BackColor = Color.Transparent;
frm.Height = 667;
frm.Width = 625;
frm.MaximizeBox = false;
frm.MinimumSize = new Size(667, 625);
frm.MaximumSize = new Size(667, 625);
frm.Icon = this.ParentForm.Icon;
frm.Controls.Add(ctl);
frm.ShowDialog();
if (frm.DialogResult == DialogResult.OK)
{
ctlJudgeMain_Load(null, null);
lblName.Text = " ";
}
}
else
if (model.QType == "SELECT1")
{
DevExpress.XtraEditors.XtraForm frm = new DevExpress.XtraEditors.XtraForm();
frm.StartPosition = FormStartPosition.CenterParent;
ctlJudgeSelect ctl = new ctlJudgeSelect(model);
ctl.Dock = DockStyle.Fill;
frm.Text = "审案结果";
frm.FormBorderStyle = FormBorderStyle.None;
frm.ShowInTaskbar = false;
frm.BackColor = Color.Transparent;
frm.Height = 668;
frm.Width = 626;
frm.MaximizeBox = false;
frm.MinimumSize = new Size(668, 626);
frm.MaximumSize = new Size(668, 626);
frm.Icon = this.ParentForm.Icon;
frm.Controls.Add(ctl);
frm.ShowDialog();
if (frm.DialogResult == DialogResult.OK)
{
ctlJudgeMain_Load(null, null);
lblName.Text = " ";
}
}
timer1_Tick(null, null);
}
catch (Exception ex)
{
XtraMessageBox.Show(ex.Message, "出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
XtraForm.ActiveForm.Focus();
}
}
private void textEditID_KeyDown(object sender, KeyEventArgs e)
{
// if (e.KeyCode == Keys.Space )空格键触发事件
if (e.KeyCode==Keys.Enter)
{
judgeStart_Click(null, null);
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ViewController;
using DevExpress.XtraEditors;
namespace View
{
public partial class ctlJudgeResult : UserControl
{
private ctlQAlogController _ctlQAlogController = new ctlQAlogController();
public ctlJudgeResult()
{
InitializeComponent();
}
public ctlJudgeResult(string lblInfo, int picNo) : this()
{
lblResultInfo.Text = lblInfo;
switch (picNo)
{
case 1:
{
pictureEditResult.Image = global::View.Properties.Resources.Judgetrue;
break;
}
case 2:
{
pictureEditResult.Image = global::View.Properties.Resources.judgefalse;
break;
}
case 3:
{
pictureEditResult.Image = global::View.Properties.Resources.Selecttrue;
break;
}
case 4:
{
pictureEditResult.Image = global::View.Properties.Resources.selectF1;
break;
}
case 5:
{
pictureEditResult.Image = global::View.Properties.Resources.selectF2;
break;
}
default:
break;
}
}
private void txtEditCardNo_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
if (_ctlQAlogController.QueryREMARK(txtEditCardNo.Text.Trim()) > 0)
{
this.FindForm().DialogResult = DialogResult.OK;
}
else
{
XtraMessageBox.Show("你没有这个权限,请联系系统管理员!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
private void txtEditCardNo_KeyDown_1(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
if (_ctlQAlogController.QueryREMARK(txtEditCardNo.Text.Trim()) > 0)
{
this.FindForm().DialogResult = DialogResult.OK;
}
else
{
XtraMessageBox.Show("你没有这个权限,请联系系统管理员!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Model;
using DevExpress.XtraEditors;
namespace View
{
public partial class ctlJudgeSelect: UserControl
{
private tb_question_answer ModelJudge = new tb_question_answer();
public ctlJudgeSelect()
{
InitializeComponent();
}
public ctlJudgeSelect(tb_question_answer model):this()
{
ModelJudge = model;
this.memoEditQuestion.Text = ModelJudge.Question;
}
private void btnHigh_Click(object sender, EventArgs e)
{
ModelJudge.UserAnswer = "B";
SelectMent();
}
private void btnMid_Click(object sender, EventArgs e)
{
ModelJudge.UserAnswer = "C";
SelectMent();
}
private void btnLight_Click(object sender, EventArgs e)
{
ModelJudge.UserAnswer = "A";
SelectMent();
}
private void SelectMent()
{
ctlJudgeResult ctl;
if (ModelJudge.UserAnswer.Trim().ToUpper()==ModelJudge.Answer.Trim().ToUpper())
{
ctl = new ctlJudgeResult("快去抽取您的大奖吧!", 3);
}
else if(ModelJudge.UserAnswer.Trim().ToUpper() == ModelJudge.Answer.Trim().ToUpper())
{
ctl = new ctlJudgeResult("谢谢参与,请至工作人员处领取纪念品哦!", 4);
}else{
ctl = new ctlJudgeResult("谢谢参与,请至工作人员处领取纪念品哦!", 5);
}
InsertLog(ModelJudge.UserAnswer,ModelJudge.Question,ModelJudge.Answer);
DevExpress.XtraEditors.XtraForm frm = new DevExpress.XtraEditors.XtraForm();
frm.StartPosition = FormStartPosition.CenterParent;
ctl.Dock = DockStyle.Fill;
frm.Text = "判案结果";
frm.FormBorderStyle = FormBorderStyle.None;
frm.ShowInTaskbar = false;
frm.BackColor = Color.Transparent;
frm.Height = 630;
frm.Width = 469;
frm.MaximizeBox = false;
frm.MinimumSize = new Size(630, 469);
frm.MaximumSize = new Size(630, 469);
frm.Icon = this.ParentForm.Icon;
frm.Controls.Add(ctl);
frm.ShowDialog();
this.FindForm().Visible = false;
if (frm.DialogResult == DialogResult.OK)
{
this.FindForm().DialogResult = DialogResult.OK;
}
}
private void InsertLog(string empId, string UserAnswer, string trueAnswer)
{
try
{
string A = "N";
if (UserAnswer == trueAnswer)
A = "Y";
else
A = "N";
string sql = $"Insert into tb_QaLog (EmpId,QType,UserAnswer,TrueAnswer,ResultA,QAtime) values('{empId}','SELECT','{UserAnswer}','{trueAnswer}','{A}',datetime('now'))";
int r = SQLiteHelper.SQLiteHelper.ExecuteNonQuery(sql);
}
catch (Exception ex)
{
XtraMessageBox.Show(ex.Message, "出错", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}