416 lines
15 KiB
C#
416 lines
15 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.DTO;
|
||
using SOH.Data;
|
||
using SOH.Entities;
|
||
|
||
namespace SOH.ShouFei
|
||
{
|
||
public partial class frmTJZXQK : Form
|
||
{
|
||
private int htbm;
|
||
private short fddm;
|
||
public frmTJZXQK()
|
||
{
|
||
InitializeComponent();
|
||
}
|
||
|
||
public frmTJZXQK(int thtbm,short thtzt) :this()
|
||
{
|
||
string dm = LoginUser.yydm;
|
||
short fddmtemp = 0;
|
||
short.TryParse(dm, out fddmtemp);
|
||
fddm = fddmtemp;
|
||
|
||
this.gvHTFZ.AutoGenerateColumns = false;
|
||
this.gvYJF.AutoGenerateColumns = false;
|
||
|
||
htbm = thtbm;
|
||
if (thtzt == 1)
|
||
{
|
||
this.btnHTJZ.Enabled = true;
|
||
this.btnHTFJ.Enabled = false;
|
||
this.btnAdd.Enabled = true;
|
||
this.btnDelete.Enabled = true;
|
||
}
|
||
else if (thtzt == 2) //已经结束的
|
||
{
|
||
this.btnHTJZ.Enabled = false;
|
||
this.btnHTFJ.Enabled = true;
|
||
this.btnAdd.Enabled = false;
|
||
this.btnDelete.Enabled = false;
|
||
}
|
||
else
|
||
{
|
||
//其他状态现在暂时没有,暂时跟1一样
|
||
this.btnHTJZ.Enabled = true;
|
||
this.btnHTFJ.Enabled = false;
|
||
this.btnAdd.Enabled = true;
|
||
this.btnDelete.Enabled = true;
|
||
}
|
||
//根据htbm初始化
|
||
//1.根据htbm获取客户名称和年度
|
||
var vsht = ServiceContainer.GetService<It_ht>();
|
||
string title = vsht.GetTitleByHtbm(htbm);
|
||
this.lbTitle.Text = title;
|
||
|
||
//统计信息
|
||
TongJi();
|
||
|
||
//加载交费人列表
|
||
var vsjfr = ServiceContainer.GetService<It_ygzd>();
|
||
List<t_ygzd> lt= vsjfr.GetListByFddm(fddm);
|
||
this.cbJFR.DataSource = null;
|
||
this.cbJFR.DataSource = lt;
|
||
this.cbJFR.DisplayMember = "xm";
|
||
this.cbJFR.ValueMember = "xm";
|
||
|
||
this.cbJFR.SelectedIndex = 0;
|
||
this.cbJFFS.SelectedIndex = 0;
|
||
|
||
}
|
||
|
||
//统计查询
|
||
private void TongJi()
|
||
{
|
||
if (htbm == null || htbm == 0)
|
||
{
|
||
this.gvHTFZ.DataSource = null;
|
||
}
|
||
else
|
||
{
|
||
//根据合同编码查询合同分组及相关体检人员统计信息
|
||
var vs = ServiceContainer.GetService<It_tjhk>();
|
||
List<dto_tjhtzx> ldt = vs.GetTjqk(htbm);
|
||
//根据ldt计算各种合计
|
||
int fzhj = 0; //分组合计
|
||
int jxhj = 0; //加项合计
|
||
int yshj = 0; //应收合计
|
||
int hkhj = 0; //回款合计
|
||
int zqk = 0; //总欠款
|
||
int yjhj = 0; //原价合计
|
||
if (ldt != null)
|
||
{
|
||
int wdjyjs = 0;
|
||
int djyjs = 0;
|
||
int sjjes = 0;
|
||
int sjrss = 0;
|
||
int wjrss = 0;
|
||
int wjjes = 0;
|
||
int gfjxs = 0;
|
||
int xjs = 0;
|
||
//循环过程中查询出公费加项
|
||
List<dto_tjhtzx> ldtnew = new List<dto_tjhtzx>();
|
||
var vsjjx = ServiceContainer.GetService<It_jjxb>();
|
||
for (int i = 0; i < ldt.Count; i++)
|
||
{
|
||
dto_tjhtzx dt = ldt[i];
|
||
//根据htfzbm查询公费加项合计
|
||
int gfjx = vsjjx.GetGfjxhjByHtfzbm(dt.htfzbm);
|
||
dt.gfjx = gfjx;
|
||
dt.xj = dt.sjje + dt.wjje + gfjx;
|
||
if (ldt[i].gzfbj == 1)
|
||
{
|
||
dt.sjje = 0;
|
||
dt.wjje = 0;
|
||
dt.xj = dt.gfjx;
|
||
}
|
||
ldtnew.Add(dt);
|
||
//if (ldt[i].gzfbj == 1) //团检自费的时候 实检金额和未检金额设置为0
|
||
//{
|
||
// sjjes += 0;
|
||
// sjrss += dt.sjrs;
|
||
// wjrss += dt.wjrs;
|
||
// wjjes += 0;
|
||
// gfjxs += dt.gfjx;
|
||
// xjs += dt.gfjx;
|
||
//}
|
||
//else
|
||
//{
|
||
// sjjes += dt.sjje;
|
||
// sjrss += dt.sjrs;
|
||
// wjrss += dt.wjrs;
|
||
// wjjes += dt.wjje;
|
||
// gfjxs += dt.gfjx;
|
||
// xjs += dt.xj;
|
||
//}
|
||
wdjyjs += dt.wdjyj;
|
||
djyjs += dt.djyj;
|
||
sjjes += dt.sjje;
|
||
sjrss += dt.sjrs;
|
||
wjrss += dt.wjrs;
|
||
wjjes += dt.wjje;
|
||
gfjxs += dt.gfjx;
|
||
xjs += dt.xj;
|
||
}
|
||
this.gvHTFZ.DataSource = null;
|
||
if (ldtnew != null && ldtnew.Count > 0)
|
||
{
|
||
//给ldtnew加一行合计
|
||
//实检人数 实检金额 未检人数 未检金额 公费加项 小计需要合计
|
||
dto_tjhtzx dthj = new dto_tjhtzx();
|
||
dthj.htfzbm = 0;
|
||
dthj.htfzmc = "合计";
|
||
dthj.sjje = sjjes;
|
||
dthj.djyj = djyjs;
|
||
dthj.wdjyj = wdjyjs;
|
||
dthj.sjrs = sjrss;
|
||
dthj.wjrs = wjrss;
|
||
dthj.wjje = wjjes;
|
||
dthj.gfjx = gfjxs;
|
||
dthj.xj = xjs;
|
||
ldtnew.Add(dthj);
|
||
this.gvHTFZ.DataSource = ldtnew;
|
||
|
||
//合计信息赋值
|
||
fzhj = sjjes + wjjes;
|
||
jxhj = gfjxs;
|
||
yshj = sjjes + gfjxs;
|
||
yjhj = djyjs + wdjyjs;
|
||
this.tbfzhj.Text = fzhj.ToString();
|
||
this.tbjxhj.Text = jxhj.ToString();
|
||
this.tbyshj.Text = yshj.ToString();
|
||
this.tbyjhj.Text = yjhj.ToString();
|
||
}
|
||
//回款合计
|
||
var vsttsf = ServiceContainer.GetService<It_ttsfjl>();
|
||
List<Entities.t_ttsfjl> ltt = vsttsf.GetList(htbm);
|
||
this.gvYJF.DataSource = null;
|
||
if (ltt == null || ltt.Count == 0)
|
||
{
|
||
}
|
||
else
|
||
{
|
||
hkhj = ltt.Sum(t => t.je) / 100;
|
||
this.gvYJF.DataSource = ltt;
|
||
}
|
||
|
||
this.tbhkhj.Text = hkhj.ToString();
|
||
zqk = yshj - hkhj;
|
||
this.tbzqk.Text = zqk.ToString();
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
private void btnAdd_Click(object sender, EventArgs e)
|
||
{
|
||
string jfr = this.cbJFR.SelectedValue == null ? "" : this.cbJFR.SelectedValue.ToString();
|
||
if (string.IsNullOrEmpty(jfr))
|
||
{
|
||
MessageBox.Show("请选择交费人");
|
||
return;
|
||
}
|
||
int jffs = this.cbJFFS.SelectedIndex;
|
||
if (jffs < 0)
|
||
{
|
||
MessageBox.Show("请选择交费方式");
|
||
return;
|
||
}
|
||
DateTime jfrq = this.dtpRQ.Value;
|
||
string sm = this.tbSM.Text.Trim();
|
||
string jfjestr = this.tbJFJE.Text.Trim();
|
||
int jfje = 0;
|
||
if (!Int32.TryParse(jfjestr, out jfje))
|
||
{
|
||
MessageBox.Show("请输入正确格式的交费金额");
|
||
return;
|
||
}
|
||
if (jfje == 0)
|
||
{
|
||
MessageBox.Show("请输入正确格式的交费金额");
|
||
return;
|
||
}
|
||
var vsbasic = ServiceContainer.GetService<IBasic>();
|
||
t_ttsfjl ttt = new t_ttsfjl();
|
||
ttt.htbm = htbm;
|
||
ttt.xh = vsbasic.GetMax("dto.t_ttsfjl", 1);
|
||
ttt.rq = jfrq;
|
||
ttt.jffs = (short)jffs;
|
||
ttt.je = jfje * 100;
|
||
ttt.jfr = jfr;
|
||
ttt.jsr = LoginUser.xm;
|
||
ttt.sm = sm;
|
||
var vstt=ServiceContainer.GetService<It_ttsfjl>();
|
||
OperationResult or = vstt.AddTtsfjl(ttt);
|
||
if (or.State == 1)
|
||
{
|
||
MessageBox.Show(or.Message);
|
||
//更新回款总额
|
||
string hkjestr = this.tbhkhj.Text.Trim();
|
||
int hkje = 0;
|
||
Int32.TryParse(hkjestr, out hkje);
|
||
hkje = hkje + ttt.je / 100;
|
||
this.tbhkhj.Text = hkje.ToString();
|
||
//更新总欠款
|
||
string zqkstr = this.tbzqk.Text.Trim();
|
||
int zqk = 0;
|
||
Int32.TryParse(zqkstr, out zqk);
|
||
zqk = zqk - ttt.je / 100;
|
||
this.tbzqk.Text = zqk.ToString();
|
||
|
||
List<t_ttsfjl> lttt = new List<t_ttsfjl>();
|
||
if(this.gvYJF.DataSource==null)
|
||
{
|
||
lttt.Add(ttt);
|
||
this.gvYJF.DataSource = null;
|
||
this.gvYJF.DataSource = lttt;
|
||
}
|
||
else
|
||
{
|
||
lttt= this.gvYJF.DataSource as List<t_ttsfjl>;
|
||
if (lttt == null || lttt.Count == 0)
|
||
{
|
||
lttt = new List<t_ttsfjl>();
|
||
}
|
||
lttt.Add(ttt);
|
||
this.gvYJF.DataSource = null;
|
||
this.gvYJF.DataSource = lttt;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show(or.Message);
|
||
return;
|
||
}
|
||
}
|
||
|
||
private void btnUpdate_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
private void btnDelete_Click(object sender, EventArgs e)
|
||
{
|
||
if (this.gvYJF.SelectedRows.Count == 0 || this.gvYJF.SelectedRows[0].Index <0)
|
||
{
|
||
MessageBox.Show("请选择已交费信息后删除");
|
||
return;
|
||
}
|
||
int rindex=this.gvYJF.SelectedRows[0].Index;
|
||
t_ttsfjl ttt = this.gvYJF.Rows[rindex].DataBoundItem as t_ttsfjl;
|
||
if (ttt == null)
|
||
{
|
||
MessageBox.Show("请选择已交费信息后删除");
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
//根据xh删除 t_ttsfjl信息
|
||
var vs = ServiceContainer.GetService<It_ttsfjl>();
|
||
OperationResult or = vs.DeleteTtsfjl(ttt);
|
||
if (or.State == 1)
|
||
{
|
||
//更新回款总额
|
||
string hkjestr = this.tbhkhj.Text.Trim();
|
||
int hkje = 0;
|
||
Int32.TryParse(hkjestr, out hkje);
|
||
hkje = hkje - ttt.je / 100;
|
||
this.tbhkhj.Text = hkje.ToString();
|
||
//更新总欠款
|
||
string zqkstr = this.tbzqk.Text.Trim();
|
||
int zqk = 0;
|
||
Int32.TryParse(zqkstr, out zqk);
|
||
zqk = zqk + ttt.je / 100;
|
||
this.tbzqk.Text = zqk.ToString();
|
||
|
||
List<t_ttsfjl> lttt = this.gvYJF.DataSource as List<t_ttsfjl>;
|
||
lttt.Remove(ttt);
|
||
this.gvYJF.DataSource = null;
|
||
if (lttt.Count > 0)
|
||
{
|
||
this.gvYJF.DataSource = lttt;
|
||
}
|
||
MessageBox.Show(or.Message);
|
||
}
|
||
else
|
||
{
|
||
MessageBox.Show(or.Message);
|
||
return;
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
|
||
//加项明细
|
||
private void btnJXMX_Click(object sender, EventArgs e)
|
||
{
|
||
frmTJJXMX tjjxmx = new frmTJJXMX(htbm);
|
||
tjjxmx.ShowDialog();
|
||
}
|
||
|
||
//未检人员
|
||
private void btnWJRY_Click(object sender, EventArgs e)
|
||
{
|
||
//根据htbm获取各个分组下的未检人员
|
||
frmTJWJRY tjwjry = new frmTJWJRY(htbm);
|
||
tjwjry.ShowDialog();
|
||
}
|
||
//体检明细
|
||
private void btnTJMX_Click(object sender, EventArgs e)
|
||
{
|
||
//根据分组编码获取分组下的体检人员明细
|
||
}
|
||
|
||
private void frmTJZXQK_Load(object sender, EventArgs e)
|
||
{
|
||
|
||
}
|
||
|
||
//合同结账
|
||
private void btnHTJZ_Click(object sender, EventArgs e)
|
||
{
|
||
//根据合同编码进行合同结账(有欠款的不允许结账)
|
||
string zqkstr = this.tbzqk.Text; //判断当前窗体中显示的总欠款是否为0
|
||
int zqk = 1;
|
||
Int32.TryParse(zqkstr, out zqk);
|
||
if (zqk > 0)
|
||
{
|
||
MessageBox.Show("交款额不足,总欠款大于0,不能结账");
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
var vs = ServiceContainer.GetService<It_tjhk>();
|
||
OperationResult or = vs.HtJieZhang(htbm);
|
||
if (or.State == 1)
|
||
{
|
||
//结账之后 几个按钮状态需要改变
|
||
this.btnHTJZ.Enabled = false;
|
||
this.btnHTFJ.Enabled = true;
|
||
this.btnAdd.Enabled = false;
|
||
this.btnDelete.Enabled = false;
|
||
}
|
||
MessageBox.Show(or.Message);
|
||
}
|
||
}
|
||
|
||
private void btnHTFJ_Click(object sender, EventArgs e)
|
||
{
|
||
var vs = ServiceContainer.GetService<It_tjhk>();
|
||
OperationResult or = vs.HtFanJie(htbm);
|
||
if (or.State == 1)
|
||
{
|
||
//反结之后 几个按钮状态需要改变
|
||
this.btnHTJZ.Enabled = true;
|
||
this.btnHTFJ.Enabled = false;
|
||
this.btnAdd.Enabled = true;
|
||
this.btnDelete.Enabled = true;
|
||
}
|
||
MessageBox.Show(or.Message);
|
||
}
|
||
|
||
}
|
||
}
|