Example #1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (checkTxt() && dgvList.Rows.Count > 1)
            {
                try
                {
                    db_students studentModel = new db_students();
                    DataTable   dt           = studentModel.GetList(" stuName='" + txtStuName.Text.Trim() + "' and idcard='" + txtIdCard.Text.Trim() + "' and examNameID='" + publicModel.examName + "'").Tables[0];
                    if (dt.Rows.Count > 0)
                    {
                        MessageBox.Show("已存在相同的信息!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    else
                    {
                        studentModel.stuName    = txtStuName.Text.Trim();
                        studentModel.IdCard     = txtIdCard.Text.Trim();
                        studentModel.examNameID = publicModel.examName;
                        db_exam modelexam = new db_exam(txtIdCard.Text.Trim(), publicModel.examName);
                        string  kcName    = modelexam == null ? "" : modelexam.kaochangName;
                        studentModel.kaochangName = kcName;
                        studentModel.status       = "异常";

                        studentModel.prushTime       = "";
                        studentModel.sex             = "";
                        studentModel.nation          = "";
                        studentModel.birthday        = "";
                        studentModel.address         = "";
                        studentModel.qianzhengjiguan = "";
                        studentModel.youxiaoqixian   = "";
                        studentModel.applyNo         = "";

                        if (getStuExamRandomNum(kcName))
                        {
                            studentModel.stuNo = printStuNo;
                            studentModel.Add();
                            MessageBox.Show("添加成功!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            //更改导入学生签到状态
                            modelexam.status = "已签到";
                            modelexam.Update();
                            return;
                        }
                        else
                        {
                            MessageBox.Show("添加失败!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    return;
                }
            }
            else
            {
                MessageBox.Show("请输入考生信息,再添加!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }
        }
Example #2
0
        public string printStuNo;       //打印准考证号

        #endregion

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                if ((iRetCOM == 1) || (iRetUSB == 1))
                {
                    int authenticate = CVRSDK.CVR_Authenticate();
                    if (authenticate == 1)
                    {
                        int readContent = CVRSDK.CVR_Read_Content(4);
                        if (readContent == 1)
                        {
                            getFillIdCardData(false);

                            this.label10.Text = "读卡操作成功!";
                            //判断刷卡人是否已录入考试名单
                            string _sql         = "select kaochangName from db_exam where idcard='" + GetCVR_Idcard() + "' and examNameID='" + publicModel.examName + "'";
                            string kaochangName = Convert.ToString(DbHelperOleDb.GetSingle(_sql));
                            if (!string.IsNullOrEmpty(kaochangName))
                            {
                                DataTable dt       = DbHelperOleDb.Query("select * from db_students where IdCard='" + GetCVR_Idcard() + "' and examNameID='" + publicModel.examName + "'").Tables[0];
                                int       selCount = dt.Rows.Count;
                                if (selCount > 0)
                                {
                                    lblExamNo.Visible = true;
                                    lblExamNo.Text    = dt.Rows[0]["stuNo"].ToString();
                                    MessageBox.Show("此身份证已签到!");
                                    newflag = true;
                                }
                                else
                                {
                                    if (getStuExamRandomNum(kaochangName))
                                    {
                                        newflag = false;
                                        FillData(kaochangName);

                                        db_exam modelexam = new db_exam(GetCVR_Idcard(), publicModel.examName);
                                        //更改签到学生的签到状态
                                        modelexam.status = "已签到";
                                        modelexam.Update();
                                    }
                                }
                            }
                            else
                            {
                                MessageBox.Show("“" + publicModel.examName + "” 考试名单中无此人信息!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                                return;
                            }
                        }
                        else
                        {
                            this.label10.Text = "读卡操作失败!";
                        }
                    }
                    else
                    {
                        MessageBox.Show("未放卡或卡片放置不正确", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                else
                {
                    MessageBox.Show("初始化失败!", "系统提示", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }