433 lines
20 KiB
C#
433 lines
20 KiB
C#
using FastReport;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Drawing.Imaging;
|
|
using System.IO;
|
|
using System.Speech.Synthesis;
|
|
using System.Net;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Windows.Forms;
|
|
|
|
namespace dccdc.Selfhelp
|
|
{
|
|
public partial class frm_zyddy_1 : Form
|
|
{
|
|
public frm_zyddy_1()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
public static FastReport.EnvironmentSettings eSet = new EnvironmentSettings();
|
|
private SpeechSynthesizer speaker;
|
|
ICollection<string> setting = extend.Config.AppSettings.Settings.AllKeys as ICollection<string>;
|
|
|
|
private void frm_zyddy_1_Load(object sender, EventArgs e)
|
|
{
|
|
/*
|
|
speaker.SelectVoice(cbb_yyk.Text);
|
|
speaker.Rate = (int)nud_ys.Value;
|
|
speaker.Volume = (int)nud_yd.Value;
|
|
*/
|
|
speaker = new SpeechSynthesizer();
|
|
if (setting.Contains("yyk"))
|
|
{
|
|
speaker.SelectVoice( extend.Config.AppSettings.Settings["yyk"].Value);
|
|
}
|
|
if (setting.Contains("yd"))
|
|
{
|
|
speaker.Volume = int.Parse(extend.Config.AppSettings.Settings["yd"].Value);
|
|
}
|
|
if (setting.Contains("ys"))
|
|
{
|
|
speaker.Rate = int.Parse(extend.Config.AppSettings.Settings["ys"].Value);
|
|
}
|
|
eSet.ReportSettings.ShowProgress = false;
|
|
//int a = extend.test(1, 2);
|
|
this.TopLevel = true;
|
|
//t_readCard.Enabled = true;
|
|
|
|
int port = 0;
|
|
string sport = System.Configuration.ConfigurationManager.AppSettings["commPort"];
|
|
if (!int.TryParse(sport, out port))
|
|
{
|
|
port = 1;
|
|
}
|
|
try
|
|
{
|
|
extend.close_comm();
|
|
extend.open_comm(port);
|
|
extend.send_comm(13);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Status s = new Status(ex.Message);
|
|
s.ShowDialog();
|
|
this.Close();
|
|
}
|
|
|
|
|
|
}
|
|
|
|
private void frm_zyddy_1_MouseMove(object sender, MouseEventArgs e)
|
|
{
|
|
Rectangle rect = new Rectangle(30, 30, 170, 56);
|
|
if (rect.Contains(e.Location))
|
|
{
|
|
Cursor = Cursors.Hand;
|
|
}
|
|
else
|
|
{
|
|
Cursor = Cursors.Default;
|
|
}
|
|
}
|
|
|
|
private void frm_zyddy_1_MouseClick(object sender, MouseEventArgs e)
|
|
{
|
|
Rectangle rect = new Rectangle(30, 30, 170, 56);
|
|
if (rect.Contains(e.Location))
|
|
{
|
|
this.Close();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 没有读到卡
|
|
/// </summary>
|
|
int readcard = 0;
|
|
/// <summary>
|
|
/// 身份证信息
|
|
/// </summary>
|
|
IDCardInfo info = new IDCardInfo();
|
|
int returncode = 0;
|
|
int messagecode = 0;
|
|
string errmsg = "";
|
|
|
|
private void t_readcard()
|
|
{
|
|
//MessageBox.Show("1");
|
|
IDCardData CardMsg = new IDCardData();
|
|
//extend.Init();
|
|
int code = 0;
|
|
byte[] photoPath = new byte[260];
|
|
int r = extend.Read_IDCard(ref CardMsg, ref photoPath[0], ref code);
|
|
if (r == 0 || r == 1)
|
|
{
|
|
|
|
info.Name = CardMsg.Name;
|
|
info.Nation = CardMsg.Nation;
|
|
info.IDCardNo = CardMsg.IDCardNo;
|
|
info.GrantDept = CardMsg.GrantDept;
|
|
info.Born = CardMsg.Born;
|
|
info.Address = CardMsg.Address;
|
|
info.UserLifeEnd = CardMsg.UserLifeEnd;
|
|
info.UserLifeBegin = CardMsg.UserLifeBegin;
|
|
info.Sex = CardMsg.Sex;
|
|
info.reserved = CardMsg.reserved;
|
|
info.PhotoFileName = CardMsg.PhotoFileName;
|
|
info.FPInfo = System.Text.Encoding.ASCII.GetString(photoPath);
|
|
info.FPInfo = info.FPInfo.Replace("\0", "");
|
|
if (!string.IsNullOrEmpty(info.PhotoFileName) && System.IO.File.Exists(info.PhotoFileName))
|
|
{
|
|
FileStream fs = new FileStream(info.PhotoFileName, FileMode.Open);
|
|
byte[] bs = new byte[fs.Length];
|
|
fs.Read(bs, 0, bs.Length);
|
|
fs.Close();
|
|
info.Photo = System.Drawing.Image.FromStream(new MemoryStream(bs));
|
|
File.Delete(info.PhotoFileName);
|
|
}
|
|
extend.Close_IDCard();
|
|
readcard = 1;
|
|
}
|
|
else
|
|
{
|
|
extend.send_comm(14);
|
|
readcard = 1;
|
|
returncode = r;
|
|
messagecode = code;
|
|
}
|
|
}
|
|
private void t_readCard_Tick(object sender, EventArgs e)
|
|
{
|
|
t_readCard.Enabled = false;
|
|
try
|
|
{
|
|
readcard = 0;
|
|
Thread t = new Thread(t_readcard);
|
|
t.Start();
|
|
for(int i=0;i<=10*100;i++)
|
|
{
|
|
Thread.CurrentThread.Join(10);
|
|
Application.DoEvents();
|
|
if(readcard==1)
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
t.Abort();
|
|
if(readcard!=1)
|
|
{
|
|
extend.Close_IDCard();
|
|
Status s = new Status("没有检测到身份证");
|
|
s.ShowDialog();
|
|
s.Close();
|
|
this.Close();
|
|
return;
|
|
}
|
|
int r = returncode;
|
|
// int r = extend.Read_IDCard(ref CardMsg, ref photoPath[0], ref code);
|
|
if (r == 0 || r == 1)
|
|
{
|
|
/*
|
|
info.Name = CardMsg.Name;
|
|
info.Nation = CardMsg.Nation;
|
|
info.IDCardNo = CardMsg.IDCardNo;
|
|
info.GrantDept = CardMsg.GrantDept;
|
|
info.Born = CardMsg.Born;
|
|
info.Address = CardMsg.Address;
|
|
info.UserLifeEnd = CardMsg.UserLifeEnd;
|
|
info.UserLifeBegin = CardMsg.UserLifeBegin;
|
|
info.Sex = CardMsg.Sex;
|
|
info.reserved = CardMsg.reserved;
|
|
info.PhotoFileName = CardMsg.PhotoFileName;
|
|
info.FPInfo = System.Text.Encoding.ASCII.GetString(photoPath);
|
|
info.FPInfo = info.FPInfo.Replace("\0", "");
|
|
if (!string.IsNullOrEmpty(info.PhotoFileName) && System.IO.File.Exists(info.PhotoFileName))
|
|
{
|
|
FileStream fs = new FileStream(info.PhotoFileName, FileMode.Open);
|
|
byte[] bs = new byte[fs.Length];
|
|
fs.Read(bs, 0, bs.Length);
|
|
fs.Close();
|
|
info.Photo = System.Drawing.Image.FromStream(new MemoryStream(bs));
|
|
File.Delete(info.PhotoFileName);
|
|
}
|
|
extend.Close_IDCard();*/
|
|
Status s = new Status("正在查询您的预约信息请稍后");
|
|
s.Show();
|
|
Application.DoEvents();
|
|
WebClient wc = new WebClient();
|
|
wc.Encoding = Encoding.UTF8;
|
|
string data = wc.DownloadString(extend.URL + "zzj/getYYXX?id=" + info.IDCardNo);
|
|
List<dccdc.Models.MedicalAppointment> list = Newtonsoft.Json.JsonConvert.DeserializeObject<List<dccdc.Models.MedicalAppointment>>(data);
|
|
if (list.Count > 0)
|
|
{
|
|
foreach (var ma in list)
|
|
{
|
|
MemoryStream ms = new MemoryStream();
|
|
info.Photo.Save(ms, ImageFormat.Jpeg);
|
|
//调用后台进行注册
|
|
wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
|
|
byte[] udata = System.Text.Encoding.UTF8.GetBytes("xm=" + info.Name + "&csrq=" + info.Born + "&idcard=" + info.IDCardNo + "&img=" + System.Web.HttpUtility.UrlEncode(Convert.ToBase64String(ms.ToArray())) + "&jtzz=" + info.Address);
|
|
byte[] bs = wc.UploadData(extend.URL + "zzj/register?id=" + ma.id, udata);
|
|
data = System.Text.Encoding.UTF8.GetString(bs);
|
|
|
|
var or = Newtonsoft.Json.JsonConvert.DeserializeObject<Models.OperationResult>(data);
|
|
if (or.State == 1)
|
|
{
|
|
string pos_dyj = System.Configuration.ConfigurationManager.AppSettings["pos_dyj"];
|
|
string jsonData = "";
|
|
DataTable dt;
|
|
//打印指引单
|
|
|
|
|
|
wc.Encoding = System.Text.Encoding.UTF8;
|
|
try
|
|
{
|
|
jsonData = wc.DownloadString(extend.URL + "Registration/GetRegisteModel?tm=" + or.Message);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
dt = Newtonsoft.Json.JsonConvert.DeserializeObject<DataTable>(jsonData);
|
|
FastReport.Report re = new FastReport.Report();
|
|
re.Load(Application.StartupPath + "\\report\\zyd.frx");
|
|
re.RegisterData(dt, "professionalExam_register");
|
|
DataTable tjlctop = new DataTable();
|
|
tjlctop.Columns.Add("lc");
|
|
DataTable tjlcbom = new DataTable();
|
|
tjlcbom.Columns.Add("lc");
|
|
DataTable zydtop = new DataTable();
|
|
zydtop.Columns.Add("zyd");
|
|
DataTable imagedt = new DataTable();
|
|
imagedt.Columns.Add("image", typeof(byte[]));
|
|
DataRow d = imagedt.NewRow();
|
|
d["image"] = Convert.FromBase64String(dt.Rows[0]["phone_path"].ToString());
|
|
imagedt.Rows.Add(d);
|
|
|
|
DataRow dr;
|
|
switch (dt.Rows[0]["physical_category"].ToString())
|
|
{
|
|
case "公共场所":
|
|
dr = zydtop.NewRow();
|
|
dr["zyd"] = "公共场所从业人员健康检查指引单";
|
|
zydtop.Rows.Add(dr);
|
|
DataRow dr1 = tjlctop.NewRow();
|
|
dr1["lc"] = "3. “内科(216)室”检查内科项目;";
|
|
DataRow dr2 = tjlctop.NewRow();
|
|
dr2["lc"] = "4. “皮肤科(209)室”检查皮肤;";
|
|
//DataRow dr3 = tjlctop.NewRow();
|
|
//dr3["lc"] = "5. “培训(201)室”卫生知识培训。";
|
|
tjlctop.Rows.Add(dr1); tjlctop.Rows.Add(dr2); //tjlctop.Rows.Add(dr3);
|
|
//DataRow dr10 = tjlcbom.NewRow();
|
|
//dr10["lc"] = "指引单到“办证室”领取健康证。";
|
|
//tjlcbom.Rows.Add(dr10);
|
|
break;
|
|
case "食品从业":
|
|
dr = zydtop.NewRow();
|
|
dr["zyd"] = "食品从业人员健康检查指引单";
|
|
zydtop.Rows.Add(dr);
|
|
DataRow dr4 = tjlctop.NewRow();
|
|
dr4["lc"] = "3. “皮肤科(209)室”检查皮肤;";
|
|
//DataRow dr5 = tjlctop.NewRow();
|
|
//dr5["lc"] = "4. “培训(201)室”卫生知识培训。";
|
|
tjlctop.Rows.Add(dr4);// tjlctop.Rows.Add(dr5);
|
|
//DataRow dr9 = tjlcbom.NewRow();
|
|
//dr9["lc"] = "指引单到“办证室”领取健康证。";
|
|
//tjlcbom.Rows.Add(dr9);
|
|
break;
|
|
case "药品从业":
|
|
dr = zydtop.NewRow();
|
|
dr["zyd"] = "药品从业人员健康检查指引单";
|
|
zydtop.Rows.Add(dr);
|
|
DataRow dr6 = tjlctop.NewRow();
|
|
dr6["lc"] = "3. “内科(216)室”检查内科项目;";
|
|
DataRow dr7 = tjlctop.NewRow();
|
|
dr7["lc"] = "4. “皮肤科(209)室”检查皮肤及辨色力;";
|
|
tjlctop.Rows.Add(dr6); tjlctop.Rows.Add(dr7);
|
|
|
|
DataRow dr8 = tjlctop.NewRow();
|
|
DataRow dr9 = tjlctop.NewRow();
|
|
dr8["lc"] = "5. “一楼院内X光室”检查胸透;";
|
|
// tjlctop.Rows.Add(dr6); tjlctop.Rows.Add(dr7);
|
|
dr9["lc"] = "6. “心电图(208)室”检查心电图;";
|
|
tjlctop.Rows.Add(dr8); tjlctop.Rows.Add(dr9);
|
|
//DataRow dr8 = tjlcbom.NewRow();
|
|
//dr8["lc"] = "指引单到“职业卫生科(206)室”领取检查表。";
|
|
//tjlcbom.Rows.Add(dr8);
|
|
break;
|
|
default:
|
|
dr = zydtop.NewRow();
|
|
dr["zyd"] = "从业人员健康检查指引单";
|
|
zydtop.Rows.Add(dr);
|
|
break;
|
|
}
|
|
re.RegisterData(tjlcbom, "tjlcbom");
|
|
re.RegisterData(tjlctop, "tjlctop");
|
|
re.RegisterData(zydtop, "zydtop");
|
|
re.RegisterData(imagedt, "imagedt");
|
|
re.SetParameterValue("agreement_money", dt.Rows[0]["agreement_money"]);
|
|
re.PrintSettings.ShowDialog = false;
|
|
if (!string.IsNullOrEmpty(pos_dyj))
|
|
re.PrintSettings.Printer = pos_dyj;
|
|
re.Print();
|
|
var loger = log4net.LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
try
|
|
{
|
|
|
|
string msg = "";
|
|
int mc= extend.open_printer(13, 0, ref msg);
|
|
loger.Info("打印小票打印机:" + mc + "\t" + msg);
|
|
mc= extend.get_printerStatus();
|
|
loger.Info("小票打印机状态:" + mc);
|
|
mc= extend.close_printer();
|
|
loger.Info("关闭小票打印机:" + mc);
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
loger.Info("小票打印机异常:" + ex.Message);
|
|
}
|
|
//打印条码
|
|
string tmprint = System.Configuration.ConfigurationManager.AppSettings["tmprint"];
|
|
jsonData = "";
|
|
//wc.Encoding = System.Text.Encoding.UTF8;
|
|
try
|
|
{
|
|
jsonData = wc.DownloadString(extend.URL + "professional/getTMByphysical_num/" + or.Message);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
|
|
dt = Newtonsoft.Json.JsonConvert.DeserializeObject<DataTable>(jsonData);
|
|
if (dt.Rows.Count == 0)
|
|
return;
|
|
re = new FastReport.Report();
|
|
re.Load(Application.StartupPath + "\\report\\barcode.frx");
|
|
re.RegisterData(dt, "barcode");
|
|
re.PrintSettings.ShowDialog = false;
|
|
if (!string.IsNullOrEmpty(tmprint))
|
|
re.PrintSettings.Printer = tmprint;
|
|
re.Print();
|
|
}
|
|
else
|
|
{
|
|
s.update(or.Message);
|
|
}
|
|
|
|
|
|
|
|
}
|
|
s.update("登记成功!");
|
|
Application.DoEvents();
|
|
Thread.Sleep(2000);
|
|
s.Close();
|
|
this.Close();
|
|
|
|
}
|
|
else
|
|
{
|
|
s.update("没有找到您的预约信息!");
|
|
Application.DoEvents();
|
|
Thread.Sleep(2000);
|
|
s.Close();
|
|
this.Close();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (r != -1)
|
|
{
|
|
Status s = new Status("读取身份证失败:" + messagecode + "_" + r);
|
|
extend.Close_IDCard();
|
|
s.ShowDialog();
|
|
}
|
|
this.Close();
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Status s = new Status(ex.Message);
|
|
s.ShowDialog();
|
|
this.Close();
|
|
}
|
|
finally
|
|
{
|
|
//extend.send_comm(14);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
private void frm_zyddy_1_FormClosing(object sender, FormClosingEventArgs e)
|
|
{
|
|
extend.send_comm(14);
|
|
extend.close_comm();
|
|
extend.Close_IDCard();
|
|
}
|
|
|
|
// private SpeechSynthesizer speaker;
|
|
|
|
private void timer1_Tick(object sender, EventArgs e)
|
|
{
|
|
|
|
//speaker.SpeakAsync(extend.Config.AppSettings.Settings["dktext"].Value);
|
|
}
|
|
}
|
|
}
|