tijian_jichuang/Code/SaleSettings/frmTuanTiHeTongNeiRong.cs
2025-02-20 11:54:48 +08:00

1093 lines
42 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.Services;
using SOH.BLL;
using SOH.Entities;
using SOH.Common;
using System.Diagnostics;
using xiaoy.Excel;
using WinForm_Test;
using EAS;
using EAS.Data;
using SOH.Data;
using SOH.Entities.DTO;
using System.Configuration;
using SOH.Configuration;
using System.Reflection;
using System.Drawing.Imaging;
using System.IO;
namespace SOH.SaleSettings
{
[ModuleAttribute(ModuleID = "4D7353CF-00BE-47B9-BCB2-DF64A035F225", ModuleName = "团体合同内容")]
public partial class frmTuanTiHeTongNeiRong : SOH.Window.baseChildForm
{
public frmTuanTiHeTongNeiRong()
{
InitializeComponent();
}
private short fddm; //分店代码
//上传参数 false是审核失败不允许导入 true审核成功可以导入
bool upload = false;
int upcounts = 0;
int zt; //分组信息状态 0添加1修改 tag1
int zt1;//分组信息状态 0添加1修改 tag2
private void frmTuanTiHeTongNeiRong_Load(object sender, EventArgs e)
{
for (int i = 1; i <= 100; i++)
{
dudjxzl.Items.Add(i);
}
var service = ServiceContainer.GetService<It_ht>();
thtBindingSource.DataSource = service.GetListByparam("");
var service1 = ServiceContainer.GetService<ITaoCan>();
cbbtc.DataSource = service1.getTaoCanList2("");
var service2 = ServiceContainer.GetService<It_ks>();
cbbks.DataSource = service2.GetAllks("", -1, 0);
//获取分店代码
string fddmstr = LoginUser.yydm;
short fd = 0;
short.TryParse(fddmstr, out fd);
fddm = fd;
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
var service = ServiceContainer.GetService<It_ht>();
thtBindingSource.DataSource = service.GetListByparam(this.textBox1.Text);
}
private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (dataGridView1.CurrentRow.Index < 0)
{
return;
}
var service = ServiceContainer.GetService<It_htfzb>();
t_ht o = dataGridView1.Rows[dataGridView1.CurrentRow.Index].DataBoundItem as t_ht;
thtfzbBindingSource.DataSource = service.GetListByhtbm(o.htbm);
this.cbbfz1.DataSource = service.GetListByhtbm(o.htbm);
this.cbbfz2.DataSource = service.GetListByhtbm(o.htbm);
dataGridView2_CellClick(null, null);
dataGridView5_CellClick(null, null);
dataGridView9.DataSource = "";
}
private void dataGridView2_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (dataGridView2.CurrentRow.Index < 0)
{
return;
}
t_htfzb o = dataGridView2.Rows[dataGridView2.CurrentRow.Index].DataBoundItem as t_htfzb;
this.tbhtfzmc.Text = o.htfzmc;
this.cbbxb.SelectedIndex = o.xb;
this.cbbsfzj.SelectedIndex = o.sfzj;
this.tbfzjg.Text = Math.Round((Convert.ToDecimal(o.fzjg) / 100), 2).ToString();
this.cbbqbfs.SelectedIndex = o.qbfs;
this.tbssjg.Text = Math.Round((Convert.ToDecimal(o.ssjg) / 100), 2).ToString();
this.tbnlsx.Text = o.nlsx.ToString();
this.cbbjxgzfbj.SelectedIndex = o.jxgzfbj;
this.tbfzzl.Text = o.fzzl.ToString();
this.cbbgzfbj.SelectedIndex = o.gzfbj;
//this.dudjxzl.Text = o.jxzl;
this.tbnlxx.Text = o.nlxx.ToString();
this.cbbhyzk.SelectedIndex = o.hyzk;
this.dudjxzl.Text = o.jxzl.ToString();
var service = ServiceContainer.GetService<It_zhxm>();
tzhxmBindingSource.DataSource = service.GetzhxmByhtfzbm(o.htfzbm);
zt = 3;
}
private void cbbtc_SelectedIndexChanged(object sender, EventArgs e)
{
tzhxmBindingSource.DataSource = ServiceContainer.GetService<ITaoCan>().getTCMX(Convert.ToInt16(this.cbbtc.SelectedValue));
}
private void cbbks_SelectedIndexChanged(object sender, EventArgs e)
{
tzhxmBindingSource1.DataSource = ServiceContainer.GetService<It_zhxm>().GetzhxmByks(Convert.ToInt16(this.cbbks.SelectedValue), Convert.ToInt32(LoginUser.yydm));
}
private void button1_Click(object sender, EventArgs e)
{
if (dataGridView1.CurrentRow.Index < 0)
{
MessageBox.Show("请选择需要添加合同的客户!");
return;
}
zt = 0;
tbhtfzmc.Text = "";
tbnlsx.Text = "100";
tbnlxx.Text = "0";
cbbxb.SelectedIndex = 2;
cbbhyzk.SelectedIndex = 2;
cbbsfzj.SelectedIndex = 1;
cbbqbfs.SelectedIndex = 0;
cbbgzfbj.SelectedIndex = 0;
cbbjxgzfbj.SelectedIndex = 1;
tbfzjg.Text = "0";
tbssjg.Text = "0";
tbfzzl.Text = "0";
dudjxzl.Text = "100";
tzhxmBindingSource.DataSource = new List<t_zhxm>();
tzhxmBindingSource1.DataSource = new List<t_zhxm>();
}
private bool check1()
{
if (tbhtfzmc.Text == "")
{
MessageBox.Show("分组名称不能为空!");
return false;
}
if (tbnlsx.Text == "")
{
MessageBox.Show("年龄上限不能为空!");
return false;
}
if (tbnlxx.Text == "")
{
MessageBox.Show("年龄下限不能为空!");
return false;
}
if (tbfzjg.Text == "")
{
MessageBox.Show("合计价格不能为空!");
return false;
}
if (tbssjg.Text == "")
{
MessageBox.Show("实收价格不能为空!");
return false;
}
if (tbfzzl.Text == "")
{
MessageBox.Show("分组折率不能为空!");
return false;
}
if (dudjxzl.Text == "")
{
MessageBox.Show("加项折率不能为空!");
return false;
}
return true;
}
private void button2_Click(object sender, EventArgs e)
{
if (!check1())
{ return; }
if (zt == 0)
{
var service = ServiceContainer.GetService<It_htfzb>();
t_htfzb b = new t_htfzb();
b.fzjg = Convert.ToInt32(Convert.ToDouble(tbfzjg.Text) * 100);
b.fzzl = Convert.ToInt16(tbfzzl.Text);
b.gzfbj = Convert.ToInt16(cbbgzfbj.SelectedIndex);
b.htbm = Convert.ToInt32(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["htbmDataGridViewTextBoxColumn"].Value);
b.htfzbm = ServiceContainer.GetService<IBasic>().GetMax(b.DbTableName, -1);
b.htfzmc = tbhtfzmc.Text;
b.hyzk = Convert.ToInt16(cbbhyzk.SelectedIndex);
b.jxgzfbj = Convert.ToInt16(cbbjxgzfbj.SelectedIndex);
b.jxzl = Convert.ToInt16(dudjxzl.Text);
b.nlsx = Convert.ToInt16(tbnlsx.Text);
b.nlxx = Convert.ToInt16(tbnlxx.Text);
b.qbfs = Convert.ToInt16(cbbqbfs.SelectedIndex);
b.sfzj = Convert.ToInt16(cbbsfzj.SelectedIndex);
b.ssjg = Convert.ToInt32(Convert.ToDouble(tbssjg.Text) * 100);
b.tcbm = (cbbtc.Text == "") ? 0 : Convert.ToInt32(cbbtc.SelectedValue);
b.tjlb = 0;
b.xb = Convert.ToInt16(cbbxb.SelectedIndex);
List<t_htxmb> xmbal = new List<t_htxmb>();
List<t_zhxm> zhxmal = ((System.Windows.Forms.BindingSource)(dataGridView3.DataSource)).List as List<t_zhxm>;
foreach (t_zhxm xm in zhxmal)
{
t_htxmb bb = new t_htxmb();
bb.htfzbm = b.htfzbm;
bb.zhbm = xm.zhbm;
bb.upflag = 1;
xmbal.Add(bb);
}
MessageBox.Show(service.Insert(b, xmbal).Message);
dataGridView1_CellClick(null, null);
}
}
private void textBox8_TextChanged(object sender, EventArgs e)
{
tzhxmBindingSource1.DataSource = ServiceContainer.GetService<It_zhxm>().GetzhxmByzjm(this.textBox8.Text);
}
private void dataGridView3_DoubleClick(object sender, EventArgs e)
{
}
private void dataGridView4_DoubleClick(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
if (zt == 3)
{
if (!check1())
{ return; }
var service = ServiceContainer.GetService<It_htfzb>();
t_htfzb b = new t_htfzb();
b.fzjg = Convert.ToInt32(Convert.ToDouble(tbfzjg.Text) * 100);
b.fzzl = Convert.ToInt16(tbfzzl.Text);
b.gzfbj = Convert.ToInt16(cbbgzfbj.SelectedIndex);
b.htbm = Convert.ToInt32(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["htbmDataGridViewTextBoxColumn"].Value);
b.htfzbm = Convert.ToInt32(dataGridView2.Rows[dataGridView2.CurrentRow.Index].Cells["htfzbmDataGridViewTextBoxColumn"].Value);
b.htfzmc = tbhtfzmc.Text;
b.hyzk = Convert.ToInt16(cbbhyzk.SelectedIndex);
b.jxgzfbj = Convert.ToInt16(cbbjxgzfbj.SelectedIndex);
b.jxzl = Convert.ToInt16(dudjxzl.Text);
b.nlsx = Convert.ToInt16(tbnlsx.Text);
b.nlxx = Convert.ToInt16(tbnlxx.Text);
b.qbfs = Convert.ToInt16(cbbqbfs.SelectedIndex);
b.sfzj = Convert.ToInt16(cbbsfzj.SelectedIndex);
b.ssjg = Convert.ToInt32(Convert.ToDouble(tbssjg.Text) * 100);
b.tcbm = (cbbtc.Text == "") ? 0 : Convert.ToInt32(cbbtc.SelectedValue);
b.tjlb = 0;
b.xb = Convert.ToInt16(cbbxb.SelectedIndex);
List<t_htxmb> xmbal = new List<t_htxmb>();
List<t_zhxm> zhxmal = ((System.Windows.Forms.BindingSource)(dataGridView3.DataSource)).List as List<t_zhxm>;
foreach (t_zhxm xm in zhxmal)
{
t_htxmb bb = new t_htxmb();
bb.htfzbm = b.htfzbm;
bb.zhbm = xm.zhbm;
bb.upflag = 1;
xmbal.Add(bb);
}
MessageBox.Show(service.Update(b, xmbal).Message);
dataGridView1_CellClick(null, null);
}
else
{
MessageBox.Show("请选择要修改的分组信息!");
}
}
private void dataGridView5_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (dataGridView5.CurrentRow.Index < 0)
{
return;
}
t_htfzb o = dataGridView5.Rows[dataGridView5.CurrentRow.Index].DataBoundItem as t_htfzb;
this.tbfzmc1.Text = o.htfzmc;
this.cbbxb1.SelectedIndex = o.xb;
this.cbbsfzj1.SelectedIndex = o.sfzj;
this.tbnlsx1.Text = o.nlsx.ToString();
this.cbbjxfs.SelectedIndex = o.jxgzfbj;
this.cbbjffs.SelectedIndex = o.gzfbj;
this.tbnlxx1.Text = o.nlxx.ToString();
this.cbbhyzk1.SelectedIndex = o.hyzk;
this.tbtcmc.Text = o.tcbianma.ToString();
var service = ServiceContainer.GetService<It_ttgzb>();
String data = service.GetList2(o.htfzbm);
DataTable dt = Newtonsoft.Json.JsonConvert.DeserializeObject(data, typeof(DataTable)) as DataTable;
//tttgzbBindingSource.DataSource = service.GetList(o.htfzbm);
if (dt.Rows.Count != 0)
{
dataGridView6.DataSource = dt;
}
else
{
dataGridView6.DataSource = null;
}
}
private void dataGridView6_CellClick(object sender, DataGridViewCellEventArgs e)
{
if (dataGridView6.CurrentRow.Index < 0)
{
return;
}
//t_ttgzb o = dataGridView6.Rows[dataGridView6.CurrentRow.Index].DataBoundItem as t_ttgzb;
tbhyh.Text = dataGridView6.SelectedRows[0].Cells["hyh"].Value.ToString();
tbsfzh.Text = dataGridView6.SelectedRows[0].Cells["sfzh"].Value.ToString();
tbxm.Text = dataGridView6.SelectedRows[0].Cells["xm"].Value.ToString();
cbbxb2.SelectedIndex = dataGridView6.SelectedRows[0].Cells["xb"].Value.ToString() == "男" ? 0 : 1;
dtpcsrq.Text = dataGridView6.SelectedRows[0].Cells["csrq"].Value.ToString();
tbnl2.Text = dataGridView6.SelectedRows[0].Cells["nl"].Value.ToString();
cbbhyzk2.SelectedIndex = Convert.ToInt32(dataGridView6.SelectedRows[0].Cells["hyzk1"].Value.ToString());
if (dataGridView6.SelectedRows[0].Cells["ssbm"].Value != null)
{
tbssbm.Text = dataGridView6.SelectedRows[0].Cells["ssbm"].Value.ToString();
}
else
{
tbssbm.Text = "";
}
tbygh.Text = dataGridView6.SelectedRows[0].Cells["ygh"].Value.ToString();
if (dataGridView6.SelectedRows[0].Cells["tel"].Value != null)
{
tbtel.Text = dataGridView6.SelectedRows[0].Cells["tel"].Value.ToString();
}
else
{
tbtel.Text = "";
}
tbbeizhu.Text = dataGridView6.SelectedRows[0].Cells["beizhu"].Value.ToString();
zt1 = 3;
}
private void cbbfz1_SelectedIndexChanged(object sender, EventArgs e)
{
var service = ServiceContainer.GetService<It_ttgzb>();
tttgzbBindingSource1.DataSource = service.GetList(Convert.ToInt32(cbbfz1.SelectedValue));
var service1 = ServiceContainer.GetService<It_ttgzb>();
tttgzbBindingSource2.DataSource = service1.GetList(Convert.ToInt32(cbbfz2.SelectedValue));
}
private void cbbfz2_SelectedIndexChanged(object sender, EventArgs e)
{
var service = ServiceContainer.GetService<It_ttgzb>();
tttgzbBindingSource2.DataSource = service.GetList(Convert.ToInt32(cbbfz2.SelectedValue));
var service1 = ServiceContainer.GetService<It_ttgzb>();
tttgzbBindingSource1.DataSource = service1.GetList(Convert.ToInt32(cbbfz1.SelectedValue));
}
private void button10_Click(object sender, EventArgs e)
{
upcounts = 0;
upload = true;
string fddm = LoginUser.yydm;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string excelVersion = ExcelVersion.Excel8;
//确定导入文件的版本
excelVersion = ExcelVersion.Excel3;
//关键语句调用ExcelFile组件执行导入操作。
DataTable showTabe = new DataTable();
frmWaitingBox f = new frmWaitingBox((obj, args) =>
{
DataTable[] dtExcelDatas = ExcelFile.GetData(openFileDialog1.FileName, excelVersion, HDRType.Yes, true);
showTabe = dtExcelDatas[0].Clone();
for (int i = 0; i < dtExcelDatas[0].Rows.Count; i++)
{
showTabe.Rows.Add(dtExcelDatas[0].Rows[i].ItemArray);
}
}, 100000, "请等待...", false, false);
f.ShowDialog();
dataGridView9.DataSource = showTabe;
t_ht o = dataGridView1.Rows[dataGridView1.CurrentRow.Index].DataBoundItem as t_ht;
//List<t_htfzb> bal;
var service = ServiceContainer.GetService<It_htfzb>();
frmWaitingBox f1 = new frmWaitingBox((obj, args) =>
{
//DataTable dt = dataGridView9.DataSource as DataTable;
for (int i = 0; i < dataGridView9.Rows.Count - 1; i++)
{
//判断此合同中是否有此分组编码
//int fzbm = Convert.ToInt32(dataGridView9.Rows[i].Cells["分组编码"].Value);
//bal = service.GetListByhtbm(o.htbm);
//if (!bal.Where(t => t.htfzbm == fzbm).Any())
//{
// dataGridView9.Rows[i].Cells["分组编码"].Style.BackColor = Color.Red;
// MessageBox.Show("请审核分组编码!");
// upload = false;
// break;
//}
//else upload = true;
//判断该合同是否有该名称分组
string sfzh = dataGridView9.Rows[i].Cells["身份证号"].Value.ToString();
if (sfzh.ToString().Length != 18)
{
if (Convert.ToInt16(LoginUser.yydm) == 1)
{
dataGridView9.Rows[i].Cells["身份证号"].Style.BackColor = Color.Red;
//MessageBox.Show("身份证号不合法!");
upload = false;
upcounts = upcounts + 1;
return;
}
}
else upload = true;
string fzmc = dataGridView9.Rows[i].Cells["分组名称"].Value.ToString();
t_htfzb b = service.GethtfzbmByhtbmAndhtfzmc(o.htbm, fzmc);
if (b == null)
{
dataGridView9.Rows[i].Cells["分组名称"].Style.BackColor = Color.Red;
upload = false;
upcounts = upcounts + 1;
return;
}
else upload = true;
//判断只存在已婚未婚未知值
t_htfzb bmodel = service.GetModelByfzbm(b.htfzbm);
string hyzk = dataGridView9.Rows[i].Cells["婚姻状况"].Value.ToString();
if (hyzk == "未婚" || hyzk == "已婚" || hyzk == "不限" || hyzk != "")
{
upload = true;
}
if ((bmodel.hyzk == 0 && hyzk == "未婚") || (bmodel.hyzk == 1 && hyzk == "已婚") || (bmodel.hyzk == 2 && hyzk == "不限") || (bmodel.hyzk == 2 && hyzk == "未婚") || (bmodel.hyzk == 2 && hyzk == "已婚"))
{
upload = true;
}
else
{
dataGridView9.Rows[i].Cells["婚姻状况"].Style.BackColor = Color.Red;
upload = false;
upcounts = upcounts + 1;
}
//判断姓名是否为空
string xm = dataGridView9.Rows[i].Cells["姓名"].Value.ToString();
if (xm == "")
{
dataGridView9.Rows[i].Cells["姓名"].Style.BackColor = Color.Red;
upload = false;
upcounts = upcounts + 1;
}
else upload = true;
//判断年龄是否为空
string nl = dataGridView9.Rows[i].Cells["年龄"].Value.ToString();
if (nl == "")
{
dataGridView9.Rows[i].Cells["年龄"].Style.BackColor = Color.Red;
upload = false;
upcounts = upcounts + 1;
}
else upload = true;
//判断该分组适用的性别
string xb = dataGridView9.Rows[i].Cells["性别"].Value.ToString();
if (xb == "男" || xb == "女" || xb == "不限" || xb != "")
{
upload = true;
}
if ((bmodel.xb == 0 && xb == "男") || (bmodel.xb == 1 && xb == "女") || (bmodel.xb == 2 && xb == "不限"))
{
upload = true;
}
else
{
dataGridView9.Rows[i].Cells["性别"].Style.BackColor = Color.Red; upload = false;
upcounts = upcounts + 1;
}
//淄博新增业务判断是否有VIP字段
if (fddm == "2")
{
string sfVip = dataGridView9.Rows[i].Cells["VIP"].Value.ToString();
if (!"是".Equals(sfVip) && !"否".Equals(sfVip))
{
dataGridView9.Rows[i].Cells["VIP"].Style.BackColor = Color.Red;
//MessageBox.Show("身份证号不合法!");
upload = false;
upcounts = upcounts + 1;
return;
}
}
}
}, 100000, "审核数据中请稍后...", false, false);
f1.ShowDialog();
}
}
private void dataGridView7_DoubleClick(object sender, EventArgs e)
{
if (cbbfz1.SelectedValue.ToString() == cbbfz2.SelectedValue.ToString())
{
return;
}
if ((cbbfz1.SelectedItem as t_htfzb).xb != (cbbfz2.SelectedItem as t_htfzb).xb)
{
MessageBox.Show("目的分组对性别的要求不允许对该人员作出调整!");
return;
}
if ((cbbfz1.SelectedItem as t_htfzb).hyzk != (cbbfz2.SelectedItem as t_htfzb).hyzk)
{
MessageBox.Show("目的分组对婚姻状况的要求不允许对该人员作出调整!");
return;
}
t_ttgzb o = dataGridView7.Rows[dataGridView7.CurrentRow.Index].DataBoundItem as t_ttgzb;
o.htfzbm = Convert.ToInt32(cbbfz2.SelectedValue);
tttgzbBindingSource2.Add(o);
tttgzbBindingSource1.Remove(o);
}
private void dataGridView8_DoubleClick(object sender, EventArgs e)
{
if (cbbfz1.SelectedValue.ToString() == cbbfz2.SelectedValue.ToString())
{
return;
}
t_ttgzb o = dataGridView8.Rows[dataGridView8.CurrentRow.Index].DataBoundItem as t_ttgzb;
o.htfzbm = Convert.ToInt32(cbbfz1.SelectedValue);
tttgzbBindingSource1.Add(o);
tttgzbBindingSource2.Remove(o);
}
private void button9_Click(object sender, EventArgs e)
{
var service = ServiceContainer.GetService<It_ttgzb>();
MessageBox.Show(service.Updatefz(((System.Windows.Forms.BindingSource)(dataGridView7.DataSource)).List as List<t_ttgzb>, ((System.Windows.Forms.BindingSource)(dataGridView8.DataSource)).List as List<t_ttgzb>).Message);
}
private void button7_Click(object sender, EventArgs e)
{
if (zt1 == 3)
{
if (!check2())
{
return;
}
if (dataGridView6.CurrentRow.Index < 0)
{
return;
}
object oo = dataGridView6.Rows[dataGridView6.CurrentRow.Index].DataBoundItem;
string ztztj = dataGridView6.SelectedRows[0].Cells["tjzt"].Value.ToString();
string tmsh = dataGridView6.SelectedRows[0].Cells["tm"].Value.ToString();
t_ttgzb o = dataGridView6.Rows[dataGridView6.CurrentRow.Index].DataBoundItem as t_ttgzb;
/*if (o.tmztz >= 2)
{
MessageBox.Show("正在体检人员信息不可以修改!");
return;
}*/
if (ztztj == "正在体检")
{
MessageBox.Show("正在体检人员信息不可以修改!");
return;
}
var service = ServiceContainer.GetService<It_ttgzb>();
t_ttgzb o1 = service.GetModelBytm(Convert.ToInt32(tmsh));
o1.hyh = Convert.ToInt32(tbhyh.Text);
o1.sfzh = tbsfzh.Text;
o1.xm = tbxm.Text;
o1.xb = Convert.ToInt16(cbbxb2.SelectedIndex);
o1.csrq = Convert.ToDateTime(dtpcsrq.Text);
o1.nl = Convert.ToInt16(tbnl2.Text);
o1.hyzk = Convert.ToInt16(cbbhyzk2.SelectedIndex);
o1.ssbm = tbssbm.Text;
o1.ygh = tbygh.Text;
o1.tel = tbtel.Text;
o1.beizhu = tbbeizhu.Text;
MessageBox.Show(service.UpdateModel(o1).Message);
dataGridView5_CellClick(null, null);
}
}
private void button5_Click(object sender, EventArgs e)
{
tbhyh.Text = "";
tbsfzh.Text = "";
tbxm.Text = "";
cbbxb2.SelectedIndex = 2;
tbnl2.Text = "0";
cbbhyzk2.SelectedIndex = 2;
tbssbm.Text = "";
tbygh.Text = "";
tbtel.Text = "";
tbbeizhu.Text = "";
zt1 = 1;
}
private void button6_Click(object sender, EventArgs e)
{
if (zt1 == 1)
{
if (!check2())
{
return;
}
if (cbbxb1.SelectedIndex != cbbxb2.SelectedIndex)
{
MessageBox.Show("该套餐不适合该性别。");
return;
}
var service = ServiceContainer.GetService<It_ttgzb>();
t_ttgzb o1 = new t_ttgzb();
//o1.hyh = ServiceContainer.GetService<IBasic>().gethyh(Convert.ToInt32(LoginUser.yydm), 1);
o1.htbm = (dataGridView1.Rows[dataGridView1.CurrentRow.Index].DataBoundItem as t_ht).htbm;
o1.htfzbm = (dataGridView5.Rows[dataGridView5.CurrentRow.Index].DataBoundItem as t_htfzb).htfzbm;
o1.sfzh = tbsfzh.Text;
o1.tm = ServiceContainer.GetService<IBasic>().gettmh(Convert.ToInt32(LoginUser.yydm), 1, 1);
o1.xm = tbxm.Text;
o1.xb = Convert.ToInt16(cbbxb2.SelectedIndex);
o1.csrq = Convert.ToDateTime(dtpcsrq.Text);
o1.nl = Convert.ToInt16(tbnl2.Text);
o1.hyzk = Convert.ToInt16(cbbhyzk2.SelectedIndex);
o1.ssbm = tbssbm.Text;
o1.ygh = tbygh.Text;
o1.tel = tbtel.Text;
o1.tmztz = 0;
o1.czjjxbj = 0;
o1.lrczy = LoginUser.username;
o1.dybz = 0;
o1.tjzje = (dataGridView5.Rows[dataGridView5.CurrentRow.Index].DataBoundItem as t_htfzb).ssjg;
o1.xh = service.GetMaxxh(o1.htbm) + 1;
o1.fddm = Convert.ToInt16(LoginUser.yydm);
o1.barcode = "";
o1.bz = "";
o1.djczy = "";
o1.dyczy = "";
o1.dyrq = Convert.ToDateTime("1900-1-1");
o1.dysj = "";
o1.image = null;
o1.printczy = "";
o1.sbczy = "";
o1.yysj = "";
o1.tjrq = DateTime.Now;
o1.zjm = StrToPinyin.GetChineseFirstSpell(o1.xm);
o1.khlx = (dataGridView5.Rows[dataGridView5.CurrentRow.Index].DataBoundItem as t_htfzb).tjlb == 0 ? 2 : 1;
o1.beizhu = tbbeizhu.Text;
List<t_ttgzb> bb = new List<t_ttgzb>();
bb.Add(o1);
MessageBox.Show(service.InsertModel(bb, short.Parse(LoginUser.yydm)).Message);
dataGridView5_CellClick(null, null);
tbsfzh.Text = ""; tbxm.Text = ""; tbssbm.Text = ""; tbygh.Text = ""; tbtel.Text = ""; tbnl2.Text = ""; tbbeizhu.Text = "";
}
}
private bool check2()
{
if (tbxm.Text == "")
{
MessageBox.Show("团检人员名称不能为空!");
return false;
}
if (tbnl2.Text == "")
{
MessageBox.Show("团检人员年龄不能为空!");
return false;
}
if (tbtel.Text == "")
{
MessageBox.Show("团检人员电话不能为空!");
return false;
}
return true;
}
private void button4_Click(object sender, EventArgs e)
{
t_htfzb o = dataGridView2.Rows[dataGridView2.CurrentRow.Index].DataBoundItem as t_htfzb;
var service = ServiceContainer.GetService<It_htfzb>();
MessageBox.Show(service.Delete(o).Message);
dataGridView1_CellClick(null, null);
}
private void button8_Click(object sender, EventArgs e)
{
//t_ttgzb o = dataGridView6.Rows[dataGridView6.CurrentRow.Index].DataBoundItem as t_ttgzb;
int state = 0;
for (int i = 0; i < dataGridView6.Rows.Count; i++)
{
if ((bool)dataGridView6.Rows[i].Cells["checkbox44"].EditedFormattedValue)
{
String tm = dataGridView6.Rows[i].Cells["tm"].Value.ToString();
int tmztz = Convert.ToInt32(dataGridView6.Rows[i].Cells["tmztz"].Value.ToString());
if (tmztz >= 2)
{
MessageBox.Show("体检人员信息不可以修改!");
return;
}
/*var service = ServiceContainer.GetService<It_ttgzb>();
service.Delete(Convert.ToInt32(tm));*/
OperationResult or = ServiceContainer.GetService<It_ttgzb>().Del(Convert.ToInt32(tm));
state = or.State;
if (state == 1)
{
OperationResult or1 = ServiceContainer.GetService<It_grgzb>().GrgzbCzrzDel(LoginUser.username, tmztz, Convert.ToInt32(tm));
}
}
}
dataGridView5_CellClick(null, null);
/* string tm = dataGridView6.SelectedRows[0].Cells["tm"].Value.ToString();
int tmztz = Convert.ToInt32(dataGridView6.SelectedRows[0].Cells["tmztz"].Value.ToString());
if (tmztz >= 2)
{
MessageBox.Show("体检人员信息不可以修改!");
return;
}
var service = ServiceContainer.GetService<It_ttgzb>();
MessageBox.Show(service.Delete(Convert.ToInt32(tm)).Message);
dataGridView5_CellClick(null, null);*/
}
private void button11_Click(object sender, EventArgs e)
{
if (upcounts > 0 || upload == false)
{
MessageBox.Show("导入数据不符合要求!请调整后再导入!");
return;
}
upcounts = 0;
upload = true;
DataTable dt = dataGridView9.DataSource as DataTable;
var service = ServiceContainer.GetService<It_ttgzb>();
List<t_ttgzb> gzbal = new List<t_ttgzb>();
for (int i = 0; i < dt.Rows.Count; i++)
{
t_ttgzb b = new t_ttgzb();
t_ht o = dataGridView1.Rows[dataGridView1.CurrentRow.Index].DataBoundItem as t_ht;
var service1 = ServiceContainer.GetService<It_htfzb>();
string fzmc = dataGridView9.Rows[i].Cells["分组名称"].Value.ToString();
t_htfzb b1 = service1.GethtfzbmByhtbmAndhtfzmc(o.htbm, fzmc);
b.htfzbm = b1.htfzbm;
b.htbm = (dataGridView1.Rows[dataGridView1.CurrentRow.Index].DataBoundItem as t_ht).htbm;
b.xm = dt.Rows[i]["姓名"].ToString();
//淄博新加业务
if (LoginUser.yydm=="2")
{
if ("是".Equals(dt.Rows[i]["VIP"].ToString()))
{
b.khlx = 1;
}
else
{
b.khlx = 2;
}
}
else
{
b.khlx = b1.tjlb == 0 ? 2 : 1;
}
switch (dt.Rows[i]["性别"].ToString())
{
case "男":
b.xb = 0;
break;
case "女":
b.xb = 1;
break;
case "不限":
b.xb = 2;
break;
}
b.nl = Convert.ToInt16(dt.Rows[i]["年龄"]);
switch (dt.Rows[i]["婚姻状况"].ToString())
{
case "已婚":
b.hyzk = 1;
break;
case "未婚":
b.hyzk = 0;
break;
case "未知":
b.hyzk = 2;
break;
}
b.sfzh = dt.Rows[i]["身份证号"].ToString();
b.ssbm = dt.Rows[i]["所属部门"].ToString();
b.ygh = dt.Rows[i]["员工号"].ToString();
try
{
b.tel = dt.Rows[i]["联系方式"].ToString();
}
catch { }
//b.hyh = ServiceContainer.GetService<IBasic>().GetMax("hyh", 1);
b.tm = ServiceContainer.GetService<IBasic>().gettmh(Convert.ToInt32(LoginUser.yydm), 1, 1);
string csrq = Common.PubFunc.GetCsrqBySfz(dt.Rows[i]["身份证号"].ToString());
DateTime det;
if (DateTime.TryParse(string.IsNullOrEmpty(csrq) ? "" : csrq, out det))
{
b.csrq = det;
}
else
{
b.csrq = DateTime.Now.AddYears(-b.nl);
}
//b.tel = tbtel.Text;
b.tmztz = 0;
b.czjjxbj = 0;
b.lrczy = LoginUser.username;
b.dybz = 0;
b.tjzje = ServiceContainer.GetService<It_htfzb>().GetModelByfzbm(b.htfzbm).ssjg;//(dataGridView5.Rows[dataGridView5.CurrentRow.Index].DataBoundItem as t_htfzb).ssjg;
b.xh = service.GetMaxxh(b.htbm) + 1;
b.fddm = Convert.ToInt16(LoginUser.yydm);
b.bz = "";
b.djczy = "";
b.dyczy = "";
b.dyrq = Convert.ToDateTime("1900-1-1");
b.dcdjrq = Convert.ToDateTime("1900-1-1");
b.dcrq = Convert.ToDateTime("1900-1-1");
b.hsrq = Convert.ToDateTime("1900-1-1");
b.dysj = "";
b.image = null;
b.printczy = "";
b.sbczy = "";
b.yysj = "";
b.tjrq = DateTime.Now;
b.zjm = StrToPinyin.GetChineseFirstSpell(b.xm);
gzbal.Add(b);
}
var service11 = ServiceContainer.GetService<It_ttgzb>();
MessageBox.Show(service11.InsertModel(gzbal, short.Parse(LoginUser.yydm)).Message);
}
private void tbsfzh_KeyDown(object sender, KeyEventArgs e)
{
if (tbsfzh.Text.Length == 18)
{
tbnl2.Text = Common.PubFunc.GetNlBySfz(tbsfzh.Text).ToString();
dtpcsrq.Text = Common.PubFunc.GetCsrqBySfz(tbsfzh.Text);
cbbxb2.SelectedText = Common.PubFunc.GetsexBysfz(tbsfzh.Text);
}
}
private void tbnl2_KeyPress(object sender, KeyPressEventArgs e)
{
}
private void tbnl2_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode != Keys.Enter)
{
return;
}
if (tbnl2.Text.ToString().Trim() != "")
{
try
{
int nl = Convert.ToInt32(tbnl2.Text.ToString().Trim());
if (nl > 0)
{
dtpcsrq.Value = DateTime.Now.AddYears(-nl);
}
}
catch
{ }
}
}
private void button12_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;
}
//System.Configuration.Configuration conf = System.Configuration.ConfigurationManager.OpenExeConfiguration(System.Windows.Forms.Application.StartupPath + "\\local.ext");
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;
tbsfzh_Leave(null, null);
string xm = idcard.xm;
tbxm.Text = xm;
idcard.exit();
jysfzh();
}
private void jysfzh()
{
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.IfExistGJBySFZH(sfzh, fddm);
if (or.State == 0)
{
MessageBox.Show(or.Message);
this.tbsfzh.Select();
return;
}
//根据身份证号计算出生日期和年龄
int nl = Common.PubFunc.GetNlBySfz(sfzh);
string csrq = Common.PubFunc.GetCsrqBySfz(sfzh);
dtpcsrq.Text = csrq;
tbnl2.Text = nl.ToString();
short xb_short = Common.PubFunc.GetSexShortBysfz(sfzh);
this.cbbxb2.SelectedIndex = xb_short;
if (string.IsNullOrEmpty(csrq) || nl == -1)
{
//this.tbJKGW.Focus();
MessageBox.Show("请输入正确的身份证号");
this.tbsfzh.Select();
this.tbsfzh.SelectAll();
return;
}
var vs = ServiceContainer.GetService<IQianTai2>();
t_hyb thyb = vs.GetHyBySfzh(sfzh);
if (thyb != null)
{
tbhyh.Text = thyb.hyh.ToString();
tbxm.Text = thyb.xm.ToString();
}
}
private void tbsfzh_Leave(object sender, EventArgs e)
{
jysfzh();
}
private void button13_Click(object sender, EventArgs e)
{
new ExcelDC().ExportExcel("体检人员信息表", this.dataGridView6);
}
private void button14_Click(object sender, EventArgs e)
{
if (String.IsNullOrEmpty(this.txtNameSearch.Text))
{
MessageBox.Show("请输入查询的姓名");
this.txtNameSearch.Focus();
return;
}
if (dataGridView6.Rows.Count != 0)
{
for (int i = 0; i < dataGridView6.Rows.Count; i++)
{
String xm = dataGridView6.Rows[i].Cells["xm"].Value.ToString();
if (this.txtNameSearch.Text.Trim().Equals(xm))
{
this.dataGridView6.Rows[i].Selected = true;
dataGridView6.CurrentCell = this.dataGridView6[0, i];
break;
}
}
}
}
private void dataGridView6_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.ColumnIndex == 0)
{
if ((bool)dataGridView6.Rows[e.RowIndex].Cells["checkbox44"].EditedFormattedValue == true)
{
this.dataGridView6.Rows[e.RowIndex].Cells["checkbox44"].Value = false;
}
else
{
this.dataGridView6.Rows[e.RowIndex].Cells["checkbox44"].Value = true;
}
}
this.dataGridView6.RefreshEdit();
}
}
}