//读取身份证 private void button3_Click(object sender, EventArgs e) { textBox5.Text = ""; textBox6.Text = ""; try { if ((iRetCOM == 1) || (iRetUSB == 1)) { int authenticate = CVRSDK.CVR_Authenticate(); if (authenticate == 1) { int readContent = CVRSDK.CVR_Read_Content(4); if (readContent == 1) { FillData(); } else { this.label41.Text = "读卡操作失败!"; } } else { MessageBox.Show("未放卡或卡片放置不正确"); } } else { //MessageBox.Show("初始化失败!"); loginLogBean lb = new loginLogBean(); lb.name = frmLogin.name; lb.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); lb.eventInfo = "身份证读卡初始化失败!"; lb.type = "3"; logservice.addCheckLog(lb); } } catch (Exception ex) { loginLogBean lb = new loginLogBean(); lb.name = frmLogin.name; lb.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); lb.eventInfo = "身份证读卡失败!"; lb.type = "3"; logservice.addCheckLog(lb); jkjcheckdao.updateShDevice(0, -1, -1, -1, -1, -1, -1, -1, -1, -1); //MessageBox.Show("读卡错误,请重试!"); } }
//打印条码 public void OnPrintSampleBarcode(string barcode, int pageCount, string nameCode) { bool addjkbool = false; DataTable dt = null; if (grjdxx != null) { string cardcode = grjdxx.Cardcode; if (!"".Equals(cardcode)) { dt = grjddao.judgeRepeat(textBox3.Text); } else { dt = grjddao.judgeRepeatBync(textBox1.Text, textBox8.Text); } if (dt.Rows.Count < 1) { if (!"".Equals(cardcode)) { grjdxx.archive_no = cardcode; } grjdxx.doctor_id = basicInfoSettings.zeren_doctorId; grjddao.addgrjdInfo(grjdxx); //添加个人信息档案 registrationRecordCheck(); //右侧统计 } else { grjdxx.archive_no = dt.Rows[0]["archive_no"].ToString(); grjddao.updategejdInfonew(grjdxx, 0); //grjdxx.archive_no = dt.Rows[0]["archive_no"].ToString(); //grjdxx.doctor_id= dt.Rows[0]["doctor_id"].ToString(); //grjddao.updateGrjdInfo(grjdxx.archive_no, grjdxx.photo_code); //grjddao.updategejdInfo(grjdxx); } grjddao.addPhysicalExaminationInfo(grjdxx, barcode);//添加健康体检表信息 jkBean jk = new jkBean(); jk.aichive_no = grjdxx.archive_no; jk.id_number = grjdxx.Cardcode; jk.bar_code = barcode; jk.Pic1 = grjdxx.CardPic; jk.Pic2 = grjdxx.Cardcode + ".jpg"; jk.village_code = basicInfoSettings.xcuncode; jk.address = grjdxx.Zhuzhi; jk.name = grjdxx.name; jk.sex = grjdxx.Sex; jk.age = grjdxx.age; jk.JddwName = basicInfoSettings.organ_name; jk.JdrName = basicInfoSettings.input_name; jk.ZrysName = basicInfoSettings.zeren_doctor; jk.XzjdName = basicInfoSettings.xzName; jk.CjwhName = basicInfoSettings.xcName; addjkbool = grjddao.addJkInfo(jk); textBox5.Text = jk.aichive_no; textBox6.Text = barcode; if (addjkbool) { //体检信息统计表 grjddao.addBgdcInfo(grjdxx, barcode, basicInfoSettings.xcuncode); } } try { if (addjkbool) { //调用Bartender btApp = new BarTender.Application(); //获取打印模板,指定打印机 btFormat = btApp.Formats.Open(@str + "\\cs1.btw", false, ""); // 同样标签的份数 btFormat.PrintSetup.IdenticalCopiesOfLabel = pageCount; // 序列标签数 btFormat.PrintSetup.NumberSerializedLabels = 1; //设置参数 code btFormat.SetNamedSubStringValue("code", barcode); btFormat.SetNamedSubStringValue("nameCode", nameCode); //打印开始 第2个参数是 是否显示打印机属性的。可以设置打印机路径 btFormat.PrintOut(false, false); //关闭摸板文件,并且关闭文件流 btFormat.Close(BarTender.BtSaveOptions.btDoNotSaveChanges); //打印完毕 btApp.Quit(BarTender.BtSaveOptions.btDoNotSaveChanges); jkjcheckdao.updateShDevice(-1, -1, 1, -1, -1, -1, -1, -1, -1, -1); } } catch (Exception e) { loginLogBean lb = new loginLogBean(); lb.name = frmLogin.name; lb.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); lb.eventInfo = "打印机设备连接不正确!"; lb.type = "3"; logservice.addCheckLog(lb); MessageBox.Show(e.Message + "---" + e.StackTrace); MessageBox.Show("打印机设备连接不正确,请重新连接或重启!"); jkjcheckdao.updateShDevice(-1, -1, 0, -1, -1, -1, -1, -1, -1, -1); } Common.SetComboBoxInfo(comboBox7, ltdorganizationDao.GetShengInfo());//默认区域 DataTable dtbasic = bsdao.checkBasicsettingInfo(); if (dtbasic.Rows.Count > 0) { xcuncode = dtbasic.Rows[0]["cun_code"].ToString(); shengcode = dtbasic.Rows[0]["sheng_code"].ToString(); Common.SetComboBoxInfo(comboBox6, ltdorganizationDao.GetCityInfo(shengcode)); shicode = dtbasic.Rows[0]["shi_code"].ToString(); Common.SetComboBoxInfo(comboBox3, ltdorganizationDao.GetCountyInfo(shicode)); qxcode = dtbasic.Rows[0]["qx_code"].ToString(); Common.SetComboBoxInfo(comboBox4, areadao.zhenInfo(qxcode)); xzcode = dtbasic.Rows[0]["xz_code"].ToString(); Common.SetComboBoxInfo(comboBox5, areadao.cunInfo(xzcode)); //因为名称有可能对应不上那么就用code对应 Common.SetComboBoxSelectIndex(comboBox7, shengcode); Common.SetComboBoxSelectIndex(comboBox6, shicode); Common.SetComboBoxSelectIndex(comboBox3, qxcode); Common.SetComboBoxSelectIndex(comboBox4, xzcode); Common.SetComboBoxSelectIndex(comboBox5, xcuncode); } }
private void personRegist_Load(object sender, EventArgs e) { this.label1.Text = "居民健康档案登记"; this.label1.ForeColor = Color.SkyBlue; label1.Font = new Font("微软雅黑", 20F, System.Drawing.FontStyle.Bold, GraphicsUnit.Point, ((byte)(134))); label1.Left = (this.panel1.Width - this.label1.Width) / 2; label1.BringToFront(); this.label13.Text = "登记记录"; this.label13.ForeColor = Color.SkyBlue; label13.Font = new Font("微软雅黑", 20F, System.Drawing.FontStyle.Bold, GraphicsUnit.Point, ((byte)(134))); label13.Left = (this.panel4.Width - this.label13.Width) / 2; label13.BringToFront(); BindNation(); Common.SetComboBoxInfo(comboBox7, ltdorganizationDao.GetShengInfo());//区域 DataTable dtbasic = bsdao.checkBasicsettingInfo(); if (dtbasic.Rows.Count > 0) { xcuncode = dtbasic.Rows[0]["cun_code"].ToString(); shengcode = dtbasic.Rows[0]["sheng_code"].ToString(); Common.SetComboBoxInfo(comboBox6, ltdorganizationDao.GetCityInfo(shengcode)); shicode = dtbasic.Rows[0]["shi_code"].ToString(); Common.SetComboBoxInfo(comboBox3, ltdorganizationDao.GetCountyInfo(shicode)); qxcode = dtbasic.Rows[0]["qx_code"].ToString(); Common.SetComboBoxInfo(comboBox4, areadao.zhenInfo(qxcode)); xzcode = dtbasic.Rows[0]["xz_code"].ToString(); Common.SetComboBoxInfo(comboBox5, areadao.cunInfo(xzcode)); //因为名称有可能对应不上那么就用code对应 Common.SetComboBoxSelectIndex(comboBox7, shengcode); Common.SetComboBoxSelectIndex(comboBox6, shicode); Common.SetComboBoxSelectIndex(comboBox3, qxcode); Common.SetComboBoxSelectIndex(comboBox4, xzcode); Common.SetComboBoxSelectIndex(comboBox5, xcuncode); } label14.Text = DateTime.Now.Year.ToString() + "年" + DateTime.Now.Month.ToString() + "月" + DateTime.Now.Day.ToString() + "日"; registrationRecordCheck();//右侧统计信息 //身份证读卡初始化 try { int iPort; for (iPort = 1001; iPort <= 1016; iPort++) { iRetUSB = CVRSDK.CVR_InitComm(iPort); if (iRetUSB == 1) { break; } } if (iRetUSB != 1) { for (iPort = 1; iPort <= 4; iPort++) { iRetCOM = CVRSDK.CVR_InitComm(iPort); if (iRetCOM == 1) { break; } } } if ((iRetCOM == 1) || (iRetUSB == 1)) { this.label42.Text = "初始化成功!"; jkjcheckdao.updateShDevice(1, -1, -1, -1, -1, -1, -1, -1, -1, -1); } else { this.label42.Text = "初始化失败!"; loginLogBean lb = new loginLogBean(); lb.name = frmLogin.name; lb.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); lb.eventInfo = "身份证读卡初始化失败!"; lb.type = "3"; logservice.addCheckLog(lb); jkjcheckdao.updateShDevice(0, -1, -1, -1, -1, -1, -1, -1, -1, -1); } } catch (Exception ex) { loginLogBean lb = new loginLogBean(); lb.name = frmLogin.name; lb.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); lb.eventInfo = "身份证读卡初始化失败!"; lb.type = "3"; logservice.addCheckLog(lb); jkjcheckdao.updateShDevice(0, -1, -1, -1, -1, -1, -1, -1, -1, -1); } //摄像头初始化 try { // 枚举所有视频输入设备 videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice); if (videoDevices.Count == 0) { throw new ApplicationException(); } //foreach (FilterInfo device in videoDevices) //{ // tscbxCameras.Items.Add(device.Name); //} //tscbxCameras.SelectedIndex = 0; VideoCaptureDevice videoSource = new VideoCaptureDevice(videoDevices[0].MonikerString); videoSource.DesiredFrameSize = new System.Drawing.Size(320, 240); videoSource.DesiredFrameRate = 1; videoSourcePlayer1.VideoSource = videoSource; videoSourcePlayer1.Start(); } catch (ApplicationException) { videoDevices = null; loginLogBean lb = new loginLogBean(); lb.name = frmLogin.name; lb.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); lb.eventInfo = "摄像头初始化失败!"; lb.type = "3"; logservice.addCheckLog(lb); jkjcheckdao.updateShDevice(-1, 0, -1, -1, -1, -1, -1, -1, -1, -1); } //读取默认的打印条数 ReadPrintBarCodeNumber(); }
//摄像头拍照 private void button4_Click(object sender, EventArgs e) { try { if (videoSourcePlayer1.IsRunning) { BitmapSource bitmapSource = Imaging.CreateBitmapSourceFromHBitmap( videoSourcePlayer1.GetCurrentVideoFrame().GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); PngBitmapEncoder pE = new PngBitmapEncoder(); pE.Frames.Add(BitmapFrame.Create(bitmapSource)); if (textBox1.Text != null && !"".Equals(textBox1.Text) && textBox8.Text != null && !"".Equals(textBox8.Text)) { if (textBox3.Text != null && !"".Equals(textBox3.Text)) { if (File.Exists(Application.StartupPath + "\\photoImg\\" + textBox3.Text + ".jpg")) { File.Delete(Application.StartupPath + "\\photoImg\\" + textBox3.Text + ".jpg"); } string picName = Application.StartupPath + "\\photoImg" + "\\" + textBox3.Text + ".jpg"; if (File.Exists(picName)) { File.Delete(picName); } using (Stream stream = File.Create(picName)) { pE.Save(stream); this.pictureBox2.ImageLocation = picName; } } else { if (File.Exists(Application.StartupPath + "\\photoImg\\" + textBox1.Text + textBox8.Text + ".jpg")) { File.Delete(Application.StartupPath + "\\photoImg\\" + textBox1.Text + textBox8.Text + ".jpg"); } string picName = Application.StartupPath + "\\photoImg" + "\\" + textBox1.Text + textBox8.Text + ".jpg"; if (File.Exists(picName)) { File.Delete(picName); } using (Stream stream = File.Create(picName)) { pE.Save(stream); this.pictureBox2.ImageLocation = picName; } } } else { string picName = Application.StartupPath + "\\photoImg" + "\\123.jpg"; if (File.Exists(picName)) { File.Delete(picName); } using (Stream stream = File.Create(picName)) { pE.Save(stream); this.pictureBox2.ImageLocation = picName; } } } jkjcheckdao.updateShDevice(-1, -1, 1, -1, -1, -1, -1, -1, -1, -1); } catch (Exception ex) { //MessageBox.Show("摄像头异常:" + ex.Message + "\n" + ex.StackTrace); loginLogBean lb = new loginLogBean(); lb.name = frmLogin.name; lb.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); lb.eventInfo = "摄像头拍照失败!"; lb.type = "3"; logservice.addCheckLog(lb); jkjcheckdao.updateShDevice(-1, 0, -1, -1, -1, -1, -1, -1, -1, -1); } }
public void FillData() { try { byte[] name = new byte[30]; int length = 30; CVRSDK.GetPeopleName(ref name[0], ref length); byte[] number = new byte[30]; length = 36; CVRSDK.GetPeopleIDCode(ref number[0], ref length); byte[] people = new byte[30]; length = 3; CVRSDK.GetPeopleNation(ref people[0], ref length); byte[] validtermOfStart = new byte[30]; length = 16; CVRSDK.GetStartDate(ref validtermOfStart[0], ref length); byte[] birthday = new byte[30]; length = 16; CVRSDK.GetPeopleBirthday(ref birthday[0], ref length); byte[] address = new byte[50]; length = 100;//40 80 CVRSDK.GetPeopleAddress(ref address[0], ref length); byte[] validtermOfEnd = new byte[30]; length = 16; CVRSDK.GetEndDate(ref validtermOfEnd[0], ref length); byte[] signdate = new byte[30]; length = 30; CVRSDK.GetDepartment(ref signdate[0], ref length); byte[] sex = new byte[30]; length = 3; CVRSDK.GetPeopleSex(ref sex[0], ref length); //byte[] samid = new byte[32]; //CVRSDK.CVR_GetSAMID(ref samid[0]); richTextBox1.Text = Encoding.GetEncoding("GB2312").GetString(address).Replace("\0", "").Trim(); //textBox9.Text = Encoding.GetEncoding("GB2312").GetString(sex).Replace("\0", "").Trim(); this.comboBox1.Text = Encoding.GetEncoding("GB2312").GetString(sex).Replace("\0", "").Trim(); textBox8.Text = Encoding.GetEncoding("GB2312").GetString(birthday).Replace("\0", "").Trim(); textBox4.Text = Encoding.GetEncoding("GB2312").GetString(signdate).Replace("\0", "").Trim(); textBox3.Text = Encoding.GetEncoding("GB2312").GetString(number).Replace("\0", "").Trim(); textBox1.Text = Encoding.GetEncoding("GB2312").GetString(name).Replace("\0", "").Trim(); //textBox2.Text = Encoding.GetEncoding("GB2312").GetString(people).Replace("\0", "").Trim(); string tmp = Encoding.GetEncoding("GB2312").GetString(people).Replace("\0", "").Trim(); if (tmp.IndexOf("族") < 0) { tmp = tmp + "族"; } comboBox2.Text = tmp; //label11.Text = "安全模块号:" + System.Text.Encoding.GetEncoding("GB2312").GetString(samid).Replace("\0", "").Trim(); //textBox8.Text = Encoding.GetEncoding("GB2312").GetString(validtermOfStart).Replace("\0", "").Trim() + "-" + Encoding.GetEncoding("GB2312").GetString(validtermOfEnd).Replace("\0", "").Trim(); richTextBox1.Text = richTextBox1.Text.Replace("?", "号"); //把身份证图片名称zp.bpm 修改为对应的名称 string pName = Application.StartupPath + "\\zp.bmp"; FileInfo inf = new FileInfo(pName); if (textBox1.Text != null && !"".Equals(textBox1.Text) && textBox8.Text != null && !"".Equals(textBox8.Text)) { if (textBox3.Text != null && !"".Equals(textBox3.Text)) { if (File.Exists(Application.StartupPath + "\\cardImg\\" + textBox3.Text + ".jpg")) { File.Delete(Application.StartupPath + "\\cardImg\\" + textBox3.Text + ".jpg"); } inf.MoveTo(Application.StartupPath + "\\cardImg\\" + textBox3.Text + ".jpg"); pictureBox1.ImageLocation = Application.StartupPath + "\\cardImg\\" + textBox3.Text + ".jpg"; DataTable dt = grjddao.judgeRepeat(textBox3.Text); if (dt.Rows.Count > 0) { textBox1.Text = dt.Rows[0][0].ToString(); //textBox9.Text = dt.Rows[0][1].ToString(); string sexflag = dt.Rows[0][1].ToString(); if (sexflag == "1") { this.comboBox1.Text = "男"; } else if (sexflag == "2") { this.comboBox1.Text = "女"; } textBox8.Text = dt.Rows[0][2].ToString(); textBox3.Text = dt.Rows[0][3].ToString(); pictureBox1.ImageLocation = Application.StartupPath + "\\cardImg\\" + dt.Rows[0][4].ToString(); textBox5.Text = dt.Rows[0][5].ToString(); } ; this.label41.Text = "读卡成功!"; checkPerson();//判断居民一周内是否做过体检 } else { if (File.Exists(Application.StartupPath + "\\cardImg\\" + textBox1.Text + textBox8.Text + ".jpg")) { File.Delete(Application.StartupPath + "\\cardImg\\" + textBox1.Text + textBox8.Text + ".jpg"); } inf.MoveTo(Application.StartupPath + "\\cardImg\\" + textBox1.Text + textBox8.Text + ".jpg"); pictureBox1.ImageLocation = Application.StartupPath + "\\cardImg\\" + textBox1.Text + textBox8.Text + ".jpg"; DataTable dt = grjddao.judgeRepeatBync(textBox1.Text, textBox8.Text); if (dt.Rows.Count > 0) { textBox1.Text = dt.Rows[0][0].ToString(); //textBox9.Text = dt.Rows[0][1].ToString(); string sexflag = dt.Rows[0][1].ToString(); if (sexflag == "1") { this.comboBox1.Text = "男"; } else if (sexflag == "2") { this.comboBox1.Text = "女"; } textBox8.Text = dt.Rows[0][2].ToString(); textBox3.Text = dt.Rows[0][3].ToString(); pictureBox1.ImageLocation = Application.StartupPath + "\\cardImg\\" + dt.Rows[0][4].ToString(); richTextBox1.Text = dt.Rows[0][5].ToString(); tmp = dt.Rows[0][6].ToString(); if (tmp == "") { tmp = "1"; } DataRow[] drw = dtno.Select("id='" + tmp + "'"); if (drw != null) { comboBox2.Text = drw[0]["Name"].ToString(); } textBox5.Text = dt.Rows[0][7].ToString(); } ; } if (File.Exists(pName)) { File.Delete(pName); } } else { inf.MoveTo(Application.StartupPath + "\\cardImg\\123.jpg"); if (File.Exists(pName)) { File.Delete(pName); } pictureBox1.ImageLocation = Application.StartupPath + "\\cardImg\\123.jpg"; } jkjcheckdao.updateShDevice(1, -1, -1, -1, -1, -1, -1, -1, -1, -1); } catch (Exception ex) { loginLogBean lb = new loginLogBean(); lb.name = frmLogin.name; lb.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); lb.eventInfo = "身份证读卡失败!"; lb.type = "3"; logservice.addCheckLog(lb); } }