public ExamForm(int chetype, bool isExam) { InitializeComponent(); form_mdata = new CMonData(); _isExam = isExam; settings = ModuleConfig.GetSettings(); //tempBmpDir = Environment.CurrentDirectory + @"\Temp\"; //if (!Directory.Exists(tempBmpDir)) // Directory.CreateDirectory(tempBmpDir); //显示牌初始化 displaycomm = new zhuangkao.Displaycomm.CDisplaycomm(settings); displaycomm.Setdisplaytype = Displaycomm.DisplayType.Zhidisp; pictureBox_photo.ImageLocation = "img\\photonull.bmp"; if (isExam) { displaycomm.ShowText("准备考试"); if (settings.IsNetwork) { try { Client = new CNetClient(settings.ServerIP, settings.Devnum); Client.Connect(); Client.Event_Devnetdata += new CNetClient.D_DEVNETDATA(netclient_Event_Devnetdata); } catch { MessageBox.Show("不能与点名中心建立网络连接", settings.Devnum.ToString() + "号库"); } } else { ButtonStart.Text = "开始考试"; TextBox_Input.Enabled = true; } //-------------身份证识别------------------------- idcardinfo = new CIDCardInfo(); idcardinfo.InitIDcardDev(); idcardinfo.Start(); idcardinfo.OnIDCardReceived += new CIDCardInfo.IDCardRequest(idcardinfo_OnIDCardReceived); //---------------------------------------------------------------- student = new CStudent(settings);//增加后台数据库连接时间所以将初始化学员信息前置 //pictureBox2.Visible = false ; if (chetype == 0) { this.Text = "小型车考试"; } else { this.Text = "大型车考试"; } ToolTip toolTip1 = new ToolTip(); //--------------鼠标悬停提示------------------------ toolTip1.AutoPopDelay = 5000; toolTip1.InitialDelay = 1000; toolTip1.ReshowDelay = 500; toolTip1.ShowAlways = true; toolTip1.SetToolTip(this.showLinkState1, "本地数据库连接"); toolTip1.SetToolTip(this.showLinkState2, "远端数据库连接"); //-----------初始化考试信息文本框------------------- //StudentText = new TextBox[7]; //for (int i = 0; i < 7; i++) //{ // StudentText[i] = new System.Windows.Forms.TextBox(); // this.navigationPanePanel1.Controls.Add(this.StudentText[i]); // this.StudentText[i].Location = new System.Drawing.Point(65, 13 + i * 20); // this.StudentText[i].Size = new System.Drawing.Size(115, 21); // this.StudentText[i].TabIndex = i; // this.StudentText[i].KeyPress += new KeyPressEventHandler(this.StudentText_KeyPress); //} //this.StudentText[0].Leave += new System.EventHandler(this.StudentText_Leave); //-----------数据库连接状态灯---------------------- showLinkState1.init(); showLinkState2.init(); //-------------综合初始化----------------------------- //-------考验员信息---------- //string tmpconnstr = "Data Source="+ settings.Ipaddress +";Initial Catalog=zhuangkao;Persist Security Info=True;User ID=sa;Password=cgcsxb";//mssql数据库链接 //CDatabase tmpdb = new CMsSqlDatabase(tmpconnstr); ////if (!tmpdb.OpenConnect()) ////{ //// MessageBox.Show("数据库连接故障!"); //// this.Close(); //// return; ////} //while (!tmpdb.OpenConnect()) ; //IDataReader dr = tmpdb.executeReader("select name from kyy"); //while (dr.Read()) //{ //comboBox1.Items.Add(dr["name"]); //comboBox2.Items.Add(dr["name"]); //} //dr.Close(); //tmpdb.CloseConnect(); comboBox1.Text = CMyGlobal.G_Loging_Username.Trim(); // comboBox2.Text = comboBox2.Items[0].ToString(); // --------学员信息----------- // student = new CStudent(settings); //Thread.Sleep(500); student.GetKsNumber(); label_pass.Text = "合格:" + student.PassNumber.ToString() + "人"; label_nopass.Text = "不合格:" + student.NoPassNumber.ToString() + "人"; label_sum.Text = "共计:" + Convert.ToString(student.PassNumber + student.NoPassNumber) + "人"; showLinkState1.LinkState = student.LinkState1; //显示连接状态 showLinkState2.LinkState = student.LinkState2; myprint = new CPrintContent(); //初始化打印 ButtonStart.Text = "申请考试"; //初始化排队考生列表 StudentlistView.GridLines = true; StudentlistView.FullRowSelect = true; //要选择就是一行 StudentlistView.View = View.Details; //定义列表显示的方式 StudentlistView.Scrollable = true; //需要时候显示滚动条 StudentlistView.HeaderStyle = ColumnHeaderStyle.Nonclickable; StudentlistView.Columns.Add("序号", StudentlistView.Width * 1 / 6 + 2, HorizontalAlignment.Left); StudentlistView.Columns.Add("姓名", StudentlistView.Width * 2 / 6 - 4, HorizontalAlignment.Left); StudentlistView.Columns.Add("证号", StudentlistView.Width * 3 / 6 - 3, HorizontalAlignment.Left); } else { if (chetype == 0) { this.Text = "小型车练习"; } else { this.Text = "大型车练习"; } displaycomm.ShowText("准备练习"); ButtonStart.Text = "开始考试"; } myinit(chetype); }
private void netclient_Event_Devnetdata(CNetData data) { switch (data.cmdCommand) { case Command.Zkzhm: if (label_xm.InvokeRequired || label_lsh.InvokeRequired || label_zkzhm.InvokeRequired) { label_xm.BeginInvoke(new Labelinvoke(netclient_Event_Devnetdata), data); } else { if (student.GetStudentInfo(data.strZjbh)) { label_xm.Text = "姓名:" + student.Xm; label_lsh.Text = "流水号:" + student.Lsh; label_zkzhm.Text = "准考证:" + student.Zkzmbh; label_sfzhm.Text = "身份证:" + student.Sfzmhm; label_kscx.Text = "考试车型:" + student.Kscx; label_kscs.Text = "考试次数:" + student.Kscs.ToString(); label_jbr.Text = "经办人:" + student.Jbr; student.Ksy1 = comboBox1.Text; student.Ksy2 = comboBox2.Text; ButtonStart.Text = "开始考试"; displaycomm.ShowText(student.Xm); buttonX2.Enabled = true; ButtonStart.Focus(); } } break; case Command.AddStudent: if (StudentlistView.InvokeRequired) { StudentlistView.BeginInvoke(new Labelinvoke(netclient_Event_Devnetdata), data); } else { AddStudentforlistview(data.strZjbh, data.Xm); } break; case Command.DeleteStudent: if (StudentlistView.InvokeRequired) { StudentlistView.BeginInvoke(new Labelinvoke(netclient_Event_Devnetdata), data); } else { DeleteStudentforlistview(data.strZjbh); } break; case Command.ClearStudent: if (StudentlistView.InvokeRequired) { StudentlistView.BeginInvoke(new Labelinvoke(netclient_Event_Devnetdata), data); } else { ClearStudentlistview(); } break; } }