513 lines
17 KiB
C#
513 lines
17 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.ComponentModel;
|
||
using System.Data;
|
||
using System.Drawing;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Windows.Forms;
|
||
using SOH.Kernel;
|
||
using EAS;
|
||
using EAS.Services;
|
||
using SOH.BLL;
|
||
using SOH.Entities;
|
||
using SOH.Entities.DTO;
|
||
using SOH.Data;
|
||
using SOH.Configuration;
|
||
using System.Reflection;
|
||
using System.Drawing.Imaging;
|
||
using System.IO;
|
||
|
||
|
||
namespace SOH.QianTai
|
||
{
|
||
[ModuleAttribute(ModuleID = "D4B408A4-5642-470A-97B4-19749C3A1ACC", ModuleName = "团检条码批量打印")]
|
||
public partial class frmTuanJianTiaoMa : SOH.Window.baseChildForm
|
||
{
|
||
private short fddm; //分店代码
|
||
private List<t_ttgzb> ltgzb; //
|
||
|
||
public frmTuanJianTiaoMa()
|
||
{
|
||
InitializeComponent();
|
||
string yydm = LoginUser.yydm;
|
||
short fddmtemp = 0;
|
||
short.TryParse(yydm, out fddmtemp);
|
||
fddm = fddmtemp;
|
||
this.gvTJDW.AutoGenerateColumns = false;
|
||
this.gvHTFZ.AutoGenerateColumns = false;
|
||
this.gvDY1.AutoGenerateColumns = false;
|
||
this.gvDY2.AutoGenerateColumns = false;
|
||
}
|
||
|
||
private void frmTuanJianTiaoMa_Load(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void btnMH_Click(object sender, EventArgs e)
|
||
{
|
||
string dwmcstr = this.tbTJDW.Text.Trim();
|
||
BindTJDW(fddm, dwmcstr);
|
||
}
|
||
|
||
private void btnQB_Click(object sender, EventArgs e)
|
||
{
|
||
this.tbTJDW.Text = "";
|
||
BindTJDW(fddm, "");
|
||
}
|
||
|
||
//根据fddm和dwmc(单位名称)查询符合条件的体检单位
|
||
private void BindTJDW(short tfddm, string dwmc)
|
||
{
|
||
var vs = ServiceContainer.GetService<ITjtmdy>();
|
||
List<dto_tjkhht> ldt = vs.GetTjdwForTmdy(tfddm, dwmc);
|
||
this.gvTJDW.DataSource = null;
|
||
if (ldt != null && ldt.Count > 0)
|
||
{
|
||
this.gvTJDW.DataSource = ldt;
|
||
}
|
||
}
|
||
|
||
//体检单位选择事件
|
||
private void gvTJDW_SelectionChanged(object sender, EventArgs e)
|
||
{
|
||
if (this.gvTJDW.SelectedRows.Count > 0)
|
||
{
|
||
this.gvDY1.DataSource = null;
|
||
this.tbXJ1.Text = "0";
|
||
this.gvDY2.DataSource = null;
|
||
this.tbXJ2.Text = "0";
|
||
int rindex = this.gvTJDW.SelectedRows[0].Index;
|
||
dto_tjkhht dt = this.gvTJDW.Rows[rindex].DataBoundItem as dto_tjkhht;
|
||
|
||
//根据合同编码获取所有合同分组
|
||
var vs = ServiceContainer.GetService<It_htfzb>();
|
||
List<Entities.t_htfzb> let = vs.GetListByhtbm(dt.htbm);
|
||
this.gvHTFZ.DataSource = null;
|
||
//筛选出公费的以供打印 gzfbj=0
|
||
var data = let.Where(t => t.gzfbj == 0);
|
||
if (data.Any())
|
||
{
|
||
List<Entities.t_htfzb> lth = data.ToList();
|
||
this.gvHTFZ.DataSource = lth;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return;
|
||
}
|
||
}
|
||
|
||
//合同分组列表选中事件
|
||
private void gvHTFZ_SelectionChanged(object sender, EventArgs e)
|
||
{
|
||
if (this.gvHTFZ.SelectedRows.Count > 0)
|
||
{
|
||
this.gvDY1.DataSource = null;
|
||
this.tbXJ1.Text = "0";
|
||
this.gvDY2.DataSource = null;
|
||
this.tbXJ2.Text = "0";
|
||
int rindex = this.gvHTFZ.SelectedRows[0].Index;
|
||
t_htfzb th = this.gvHTFZ.Rows[rindex].DataBoundItem as t_htfzb;
|
||
int htfzbm = th.htfzbm;
|
||
ltgzb = null; //
|
||
var vs = ServiceContainer.GetService<It_ttgzb>();
|
||
List<t_ttgzb> lttt = vs.GetList(htfzbm);
|
||
//var data = lttt.Where(t => t.tmztz == 0 || t.tmztz == -1);
|
||
var data = lttt.Where(t => t.tmztz != 9);
|
||
if (data.Any())
|
||
{
|
||
List<t_ttgzb> lt = data.ToList();
|
||
ltgzb = lt;
|
||
this.gvDY1.DataSource = lt;
|
||
|
||
for (int i = 0; i < lt.Count; i++)
|
||
{
|
||
if (!string.IsNullOrEmpty(lt[i]["printczy"].ToString()))
|
||
{
|
||
gvDY1.Rows[i].DefaultCellStyle.BackColor = Color.LightGreen;
|
||
}
|
||
}
|
||
|
||
this.tbXJ1.Text = lt.Count.ToString();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return;
|
||
}
|
||
}
|
||
|
||
//助记符筛选
|
||
private void tbZJM_TextChanged(object sender, EventArgs e)
|
||
{
|
||
string zjm = this.tbZJM.Text.Trim().ToUpper();
|
||
if (ltgzb == null || ltgzb.Count == 0)
|
||
{
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
this.gvDY1.DataSource = null;
|
||
var data = ltgzb.Where(t => t.zjm.Contains(zjm.ToLower()));
|
||
if (data.Any())
|
||
{
|
||
List<t_ttgzb> lttt = data.ToList();
|
||
this.gvDY1.DataSource = lttt;
|
||
this.tbXJ1.Text = lttt.Count.ToString();
|
||
}
|
||
}
|
||
}
|
||
|
||
//打印
|
||
private void btnPrint_Click(object sender, EventArgs e)
|
||
{
|
||
if (this.gvDY2.DataSource == null)
|
||
{
|
||
return;
|
||
}
|
||
List<t_ttgzb> lttt = this.gvDY2.DataSource as List<t_ttgzb>;
|
||
if (lttt == null || lttt.Count == 0)
|
||
{
|
||
return;
|
||
}
|
||
int dylx = 0; //全部:条码和导检单
|
||
if (this.radioButton2.Checked)
|
||
{
|
||
dylx = 1; //条码
|
||
}
|
||
if (this.radioButton3.Checked)
|
||
{
|
||
dylx = 2; //导检单
|
||
}
|
||
if (dylx == 0 || dylx == 1)
|
||
{
|
||
PrintTm(lttt);
|
||
}
|
||
if (dylx == 0 || dylx == 2)
|
||
{
|
||
PrintDJD(lttt);
|
||
}
|
||
|
||
}
|
||
//打印条码
|
||
private void PrintTm(List<t_ttgzb> lttt)
|
||
{
|
||
if (lttt == null || lttt.Count == 0)
|
||
{
|
||
//MessageBox.Show
|
||
return;
|
||
}
|
||
foreach (t_ttgzb tt in lttt)
|
||
{
|
||
SOH.ShouFei.frmprinttm ptm = new SOH.ShouFei.frmprinttm();
|
||
ptm.init(tt.tm, 0, 0, null);
|
||
ptm.print();
|
||
}
|
||
}
|
||
//打印导检单
|
||
private void PrintDJD(List<t_ttgzb> lttt)
|
||
{
|
||
if (lttt == null || lttt.Count == 0)
|
||
{
|
||
//MessageBox.Show
|
||
return;
|
||
}
|
||
foreach (t_ttgzb tt in lttt)
|
||
{
|
||
SOH.ShouFei.frmPrintDaoJianDan pdjd = new SOH.ShouFei.frmPrintDaoJianDan();
|
||
pdjd.init(tt.tm);
|
||
pdjd.print();
|
||
var vs = ServiceContainer.GetService<IZongJian>();
|
||
OperationResult or = vs.UpdatePrintDjd(tt.tm,LoginUser.username);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
private void btnJia_Click(object sender, EventArgs e)
|
||
{
|
||
if (this.gvDY1.SelectedRows.Count > 0)
|
||
{
|
||
int rindex = this.gvDY1.SelectedRows[0].Index;
|
||
t_ttgzb tt = this.gvDY1.Rows[rindex].DataBoundItem as t_ttgzb;
|
||
//移除
|
||
ltgzb.Remove(tt);
|
||
List<t_ttgzb> lt1 = this.gvDY1.DataSource as List<t_ttgzb>;
|
||
lt1.Remove(tt);
|
||
this.gvDY1.DataSource = null;
|
||
this.tbXJ1.Text = "0";
|
||
if (lt1 != null && lt1.Count > 0)
|
||
{
|
||
this.gvDY1.DataSource = lt1;
|
||
this.tbXJ1.Text = lt1.Count.ToString();
|
||
}
|
||
//增加
|
||
List<t_ttgzb> lt2 = new List<t_ttgzb>();
|
||
if (this.gvDY2.DataSource == null)
|
||
{
|
||
}
|
||
else
|
||
{
|
||
lt2 = this.gvDY2.DataSource as List<t_ttgzb>;
|
||
}
|
||
lt2.Add(tt);
|
||
this.gvDY2.DataSource = null;
|
||
this.tbXJ2.Text = "0";
|
||
if (lt2 != null && lt2.Count > 0)
|
||
{
|
||
this.gvDY2.DataSource = lt2;
|
||
this.tbXJ2.Text = lt2.Count.ToString();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return;
|
||
}
|
||
}
|
||
|
||
private void btnJian_Click(object sender, EventArgs e)
|
||
{
|
||
if (this.gvDY2.SelectedRows.Count > 0)
|
||
{
|
||
int rindex = this.gvDY2.SelectedRows[0].Index;
|
||
t_ttgzb tt = this.gvDY2.Rows[rindex].DataBoundItem as t_ttgzb;
|
||
//增加
|
||
ltgzb.Add(tt);
|
||
List<t_ttgzb> lt1 = this.gvDY1.DataSource as List<t_ttgzb>;
|
||
if (lt1 == null || lt1.Count == 0)
|
||
{
|
||
lt1 = new List<t_ttgzb>();
|
||
}
|
||
lt1.Add(tt);
|
||
this.gvDY1.DataSource = null;
|
||
this.tbXJ1.Text = "0";
|
||
if (lt1 != null && lt1.Count > 0)
|
||
{
|
||
this.gvDY1.DataSource = lt1;
|
||
this.tbXJ1.Text = lt1.Count.ToString();
|
||
}
|
||
|
||
//移除
|
||
List<t_ttgzb> lt2 = this.gvDY2.DataSource as List<t_ttgzb>;
|
||
lt2.Remove(tt);
|
||
this.gvDY2.DataSource = null;
|
||
this.tbXJ2.Text = "0";
|
||
if (lt2 != null && lt2.Count > 0)
|
||
{
|
||
this.gvDY2.DataSource = lt2;
|
||
this.tbXJ2.Text = lt2.Count.ToString();
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return;
|
||
}
|
||
}
|
||
|
||
private void btnCX1_Click(object sender, EventArgs e)
|
||
{
|
||
System.Configuration.Configuration conf = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Windows.Forms.Application.StartupPath + "\\local.ext");
|
||
// string sfzdkq = "";
|
||
if (conf.AppSettings.Settings.AllKeys.Contains("QYSFZDKQ"))
|
||
{
|
||
if (conf.AppSettings.Settings["QYSFZDKQ"].Value != "1")
|
||
{
|
||
MessageBox.Show("系统没有配置读卡器相关配置,请联系管理员设置!");
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("系统没有配置读卡器相关配置,请联系管理员设置!");
|
||
return;
|
||
}
|
||
|
||
var group = conf.SectionGroups["object"];
|
||
if (group == null)
|
||
{
|
||
//group = new ConfigurationSectionGroup();
|
||
//conf.SectionGroups.Add("object", group);
|
||
MessageBox.Show("系统没有配置读卡器相关配置,请联系管理员设置!");
|
||
return;
|
||
}
|
||
|
||
|
||
// ConfigurationSection section = new ConfigurationSection();
|
||
// group.Sections.Add("IDCard",)
|
||
|
||
|
||
MyAssemblySection section = group.Sections["ass"] as MyAssemblySection;
|
||
MyAssemblyElement myelement = null;
|
||
foreach (MyAssemblyElement element in section.MyAssemblyElements)
|
||
{
|
||
if (element.name == "IDCard")
|
||
{
|
||
myelement = element;
|
||
break;
|
||
}
|
||
}
|
||
if (myelement == null)
|
||
{
|
||
MessageBox.Show("系统没有配置读卡器相关配置,请联系管理员设置!");
|
||
return;
|
||
}
|
||
var ass = Assembly.Load(myelement.assembly);
|
||
SOH.Interface.IIDCardRead idcard = ass.CreateInstance(myelement.type) as SOH.Interface.IIDCardRead;
|
||
int result = idcard.init();
|
||
if (result != 0)
|
||
{
|
||
MessageBox.Show("初始化读卡器失败!");
|
||
return;
|
||
|
||
}
|
||
result = idcard.read();
|
||
if (result != 0)
|
||
{
|
||
MessageBox.Show("读卡失败!");
|
||
return;
|
||
|
||
}
|
||
tbSFZH.Text = idcard.sfzh;
|
||
//idcard.
|
||
cxhy();
|
||
string xm = idcard.xm;
|
||
//tb3_SFZH_Leave(null, null);
|
||
//tbXM.Text = xm;
|
||
//if (tbTXDZ.Text == "")
|
||
// tbTXDZ.Text = idcard.dz;
|
||
idcard.exit();
|
||
}
|
||
private void cxhy()
|
||
{
|
||
#region 根据身份证号查询是否是已登记会员
|
||
//if (e.KeyCode == Keys.Enter)
|
||
string sfzh = this.tbSFZH.Text.Trim();
|
||
//验证身份证号的长度
|
||
//if (sfzh.Length != 18 && sfzh.Length != 15)
|
||
if (string.IsNullOrEmpty(sfzh))
|
||
{
|
||
//this.tbJKGW.Focus();
|
||
MessageBox.Show("身份证号长度不符");
|
||
this.tbSFZH.Select();
|
||
return;
|
||
}
|
||
|
||
//根据身份证号获取此人是否已经有体检信息
|
||
var vsqt = ServiceContainer.GetService<IQianTai>();
|
||
OperationResult or = vsqt.IfExistTJBySFZH2(sfzh, fddm);
|
||
if (or.State == 0)
|
||
{
|
||
MessageBox.Show(or.Message);
|
||
this.tbSFZH.Select();
|
||
return;
|
||
}
|
||
|
||
string tms = or.Message;
|
||
int tm = 0;
|
||
if (Int32.TryParse(tms, out tm))
|
||
{
|
||
var vs = ServiceContainer.GetService<IQianTai2>();
|
||
string json = vs.GetTTDJInfo(tm);
|
||
DataTable dt = new DataTable();
|
||
dt = Newtonsoft.Json.JsonConvert.DeserializeObject<DataTable>(json);
|
||
|
||
//进行判断
|
||
string fdstr = dt.Rows[0]["fddm"].ToString(); //合同所在分店
|
||
string htzt = dt.Rows[0]["htzt"].ToString(); //体检合同状态
|
||
string tmztz = dt.Rows[0]["tmztz"].ToString(); //体检条码状态
|
||
string tjlb = dt.Rows[0]["tjlb"].ToString();
|
||
DateTime dts = DateTime.Now;
|
||
|
||
DateTime dts2 = Convert.ToDateTime(dt.Rows[0]["htjzrq"].ToString());
|
||
|
||
if(DateTime.Compare(dts, dts2) > 0)
|
||
{
|
||
MessageBox.Show("对应单位的合同已过期");
|
||
return;
|
||
}
|
||
|
||
if (htzt == "1") //htzt=1是正常的合同
|
||
{
|
||
//过
|
||
}
|
||
else if (htzt == "0")
|
||
{
|
||
MessageBox.Show("对应单位的合同还未生效");
|
||
return;
|
||
}
|
||
else if (htzt == "2")
|
||
{
|
||
MessageBox.Show("对应单位的合同已经失效");
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("对应单位的合同不明确");
|
||
return;
|
||
}
|
||
//看当前人的体检状态 tmztz
|
||
if (tmztz == "0")
|
||
{
|
||
//等于0的 为可以进行登记的
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("该客人已经进行体检,不能登记");
|
||
return;
|
||
}
|
||
|
||
//看体检合同是公费还是自费
|
||
string gzfbj = dt.Rows[0]["gzfbj"].ToString();
|
||
if (gzfbj == "1") //自费不能在此登记
|
||
{
|
||
MessageBox.Show("团检自费合同不能在此登记,请到团检现场登记");
|
||
return;
|
||
}
|
||
|
||
//填充团检单位
|
||
BindTJDW(fddm, dt.Rows[0]["khmc"].ToString());
|
||
|
||
//填充合同分组
|
||
var vs1 = ServiceContainer.GetService<It_htfzb>();
|
||
List<t_htfzb> let = vs1.GetModelListByfzbm(Convert.ToInt32(dt.Rows[0]["htfzbm"].ToString()));
|
||
this.gvHTFZ.DataSource = null;
|
||
this.gvHTFZ.DataSource = let;
|
||
|
||
//填充团检人员
|
||
var vs2 = ServiceContainer.GetService<It_ttgzb>();
|
||
List<t_ttgzb> lttt = vs2.GetModelListBytm(tm);
|
||
this.gvDY1.DataSource = lttt;
|
||
|
||
this.tbSFZH.Text = "";
|
||
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show("请输入正确格式的条码");
|
||
return;
|
||
}
|
||
|
||
#endregion
|
||
}
|
||
|
||
private void tbSFZH_KeyDown(object sender, KeyEventArgs e)
|
||
{
|
||
if (e.KeyCode == Keys.Enter)
|
||
{
|
||
cxhy();
|
||
}
|
||
}
|
||
|
||
private void tbSFZH_Leave(object sender, EventArgs e)
|
||
{
|
||
}
|
||
|
||
}
|
||
}
|