413 lines
16 KiB
C#
413 lines
16 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using SOH.Entities;
|
|
using EAS.Services;
|
|
using SOH.Data;
|
|
using EAS.Data;
|
|
using EAS.Data.ORM;
|
|
using EAS.Data.Linq;
|
|
using EAS.Data.Access;
|
|
using Newtonsoft.Json;
|
|
using System.Data;
|
|
using SOH.Common;
|
|
|
|
namespace SOH.BLL
|
|
{
|
|
[ServiceObject("体检部位维护")]
|
|
[ServiceBind(typeof(Its_dd))]
|
|
public class ts_ddBll : Its_dd
|
|
{
|
|
/// <summary>
|
|
/// 获取未审核的订单(销售审核开始)
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<Entities.ts_dd> Getwshdd(string p)
|
|
{
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
return db.ts_dds.Where(t => t.ddzt == 1 && t.khbianma.khmc.Contains(p)).ToList();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取未审核的订单(销售审核开始)
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<Entities.ts_dd> Getwshdd2(string p)
|
|
{
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
return db.ts_dds.Where(t => t.ddzt == 1).ToList();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 获取未审核的订单(财务审核开始,必须销售审核成功后才可以财务审核)
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public List<Entities.ts_dd> Getcwsh()
|
|
{
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
return db.ts_dds.Where(t => t.ddzt == 2 && t.xsshtg == 1).ToList();
|
|
}
|
|
}
|
|
|
|
|
|
public Data.OperationResult xssh(int ddbm, string xsshczy)
|
|
{
|
|
OperationResult or = new OperationResult();
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
var data = from d in db.ts_dds
|
|
where d.ddbm == ddbm
|
|
select d;
|
|
if (data.Any())
|
|
{
|
|
ts_dd ddmodel = data.ToList()[0];
|
|
ddmodel.ddzt = 2;
|
|
ddmodel.xsshczy = xsshczy;
|
|
ddmodel.xsshtg = 1;
|
|
ddmodel.xsshyj = "通过";
|
|
db.ts_dds.OrmAccessor.Update(ddmodel);
|
|
or.State = 1;
|
|
or.Message = "该订单审核结果:通过!";
|
|
}
|
|
else
|
|
{
|
|
or.Message = "合同不存在!";
|
|
}
|
|
return or;
|
|
}
|
|
}
|
|
|
|
public OperationResult notxssh(int ddbm, string xsshczy)
|
|
{
|
|
OperationResult or = new OperationResult();
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
var data = from d in db.ts_dds
|
|
where d.ddbm == ddbm
|
|
select d;
|
|
if (data.Any())
|
|
{
|
|
ts_dd ddmodel = data.ToList()[0];
|
|
ddmodel.ddzt = 2;
|
|
ddmodel.xsshczy = xsshczy;
|
|
ddmodel.xsshtg = 0;
|
|
ddmodel.cwshtg = 0;
|
|
ddmodel.xsshyj = "补通过";
|
|
db.ts_dds.OrmAccessor.Update(ddmodel);
|
|
or.State = 1;
|
|
or.Message = "该订单审核结果:不通过!";
|
|
}
|
|
else
|
|
{
|
|
or.Message = "合同不存在!";
|
|
}
|
|
return or;
|
|
}
|
|
}
|
|
|
|
public List<ts_dd> GetList(string param, string tj)
|
|
{
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
var data = db.ts_dds.Where(t => t.khbianma.khmc.Contains(param)).ToList();
|
|
return data.ToList();
|
|
}
|
|
}
|
|
public Data.OperationResult cwsh(int ddbm, string cwshczy)
|
|
{
|
|
OperationResult or = new OperationResult();
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
var data = from d in db.ts_dds
|
|
where d.ddbm == ddbm
|
|
select d;
|
|
if (data.Any())
|
|
{
|
|
ts_dd ddmodel = data.ToList()[0];
|
|
ddmodel.ddzt = 3;
|
|
ddmodel.cwshczy = cwshczy;
|
|
ddmodel.cwshtg = 1;
|
|
ddmodel.cwshyj = "通过";
|
|
db.ts_dds.OrmAccessor.Update(ddmodel);
|
|
or.State = 1;
|
|
or.Message = "该订单审核结果:通过!";
|
|
}
|
|
else
|
|
{
|
|
or.Message = "合同不存在!";
|
|
}
|
|
return or;
|
|
}
|
|
}
|
|
public Data.OperationResult notcwsh(int ddbm, string cwshczy)
|
|
{
|
|
OperationResult or = new OperationResult();
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
var data = from d in db.ts_dds
|
|
where d.ddbm == ddbm
|
|
select d;
|
|
if (data.Any())
|
|
{
|
|
ts_dd ddmodel = data.ToList()[0];
|
|
ddmodel.ddzt = 3;
|
|
ddmodel.cwshczy = cwshczy;
|
|
ddmodel.cwshtg = 0;
|
|
ddmodel.cwshyj = "不通过";
|
|
db.ts_dds.OrmAccessor.Update(ddmodel);
|
|
or.State = 1;
|
|
or.Message = "该订单审核结果:不通过!";
|
|
}
|
|
else
|
|
{
|
|
or.Message = "合同不存在!";
|
|
}
|
|
return or;
|
|
}
|
|
}
|
|
|
|
public Data.OperationResult scht(int ddbm, int khbm)
|
|
{
|
|
OperationResult or = new OperationResult();
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
try
|
|
{
|
|
//判断是否有该客户
|
|
var khdata = db.t_khs.Where(t => t.khbm == khbm);
|
|
t_kh k = new t_kh();
|
|
ts_kh data1 = db.ts_khs.Where(t => t.khbm == khbm).First();
|
|
if (!khdata.Any())
|
|
{
|
|
k.khbm = data1.khbm;
|
|
k.khdz = data1.khdz;
|
|
k.khgddh = data1.khdh;
|
|
//k.khyb = data1.khzy;
|
|
ts_khlxr d = db.ts_khlxrs.Where(t => t.khbm == k.khbm).First();
|
|
k.khlxr = d.xm;
|
|
k.khmc = data1.khmc;
|
|
k.fddm = data1.fddm;
|
|
//k.zjm = StrToPinyin.GetChineseFirstSpell(k.zjm);
|
|
k.zjm = data1.zjm;
|
|
db.t_khs.Insert(k);
|
|
}
|
|
else
|
|
{
|
|
k.khbm = data1.khbm;
|
|
k.khdz = data1.khdz;
|
|
k.khgddh = data1.khdh;
|
|
k.khyb = data1.khzy;
|
|
ts_khlxr d = db.ts_khlxrs.Where(t => t.khbm == k.khbm).First();
|
|
k.khlxr = d.xm;
|
|
k.khmc = data1.khmc;
|
|
k.fddm = data1.fddm;
|
|
k.zjm = data1.zjm;
|
|
db.t_khs.Update(k);
|
|
}
|
|
|
|
var data = db.ts_dds.Where(t => t.ddbm == ddbm && t.ddzt == 3 && t.cwshtg == 1);
|
|
if (data.Any())
|
|
{
|
|
ts_dd dd = data.First();
|
|
using (DbTransaction tran = db.CreateTransaction())
|
|
{
|
|
t_ht htmodel = new t_ht();
|
|
htmodel.htbm = dd.ddbm;
|
|
htmodel.khbm = dd.khbm;
|
|
htmodel.nd = dd.nd;
|
|
htmodel.htbj = dd.ddbj;
|
|
htmodel.yjtjrs = dd.yjtjrs;
|
|
htmodel.htqsrq = dd.qsrq;
|
|
htmodel.htjzrq = dd.jzrq;
|
|
htmodel.khhtlxr = "未通过";
|
|
htmodel.khlxrdh = dd.khbianma.khdh;
|
|
// htmodel.xsydh =
|
|
htmodel.ywdbdm = dd.xsczymc.yonggong.xm;
|
|
htmodel.htzt = 1;
|
|
htmodel.fddm = dd.fddm;
|
|
dd.ddzt = 4;
|
|
db.ts_dds.Update(dd);
|
|
|
|
var dataht = db.t_hts.Where(t => t.htbm == ddbm);
|
|
if (dataht.Any())
|
|
{
|
|
db.t_hts.Update(htmodel);
|
|
}
|
|
else
|
|
{
|
|
db.t_hts.Insert(htmodel);
|
|
}
|
|
|
|
var ddfzb = db.ts_ddfzbs.Where(t => t.ddbm == ddbm);
|
|
|
|
if (ddfzb.Any())
|
|
{
|
|
IList<ts_ddfzb> ddfzblist = ddfzb.ToList();
|
|
|
|
foreach (ts_ddfzb dd1 in ddfzblist)
|
|
{
|
|
t_htfzb fzbmodel = new t_htfzb();
|
|
//fzbmodel.htfzbm = new BasicBll().GetMax(fzbmodel.DbTableName, -1);
|
|
fzbmodel.htfzbm = dd1.ddfzbm;
|
|
fzbmodel.htbm = dd1.ddbm;
|
|
fzbmodel.htfzmc = dd1.ddfzmc;
|
|
fzbmodel.xb = dd1.xb;
|
|
fzbmodel.nlsx = dd1.nlsx;
|
|
fzbmodel.nlxx = dd1.nlxx;
|
|
fzbmodel.hyzk = dd1.hyzk;
|
|
fzbmodel.sfzj = dd1.sfzj;
|
|
fzbmodel.gzfbj = dd1.gzfbj;
|
|
fzbmodel.jxgzfbj = dd1.jxgzfbj;
|
|
fzbmodel.tcbm = dd1.tcbm;
|
|
fzbmodel.jjx = dd1.jjx;
|
|
fzbmodel.fzjg = dd1.fzjg;
|
|
fzbmodel.ssjg = dd1.ssjg;
|
|
fzbmodel.fzzl = dd1.fzzl;
|
|
fzbmodel.jxzl = dd1.jxzl;
|
|
fzbmodel.tjlb = dd1.tjlb;
|
|
fzbmodel.mm = dd1.mm;
|
|
fzbmodel.qbfs = dd1.qbfs;
|
|
|
|
dd1.fzzl = 1;
|
|
|
|
var datahtfzb = db.t_htfzbs.Where(t => t.htfzbm == dd1.ddfzbm);
|
|
if (datahtfzb.Any())
|
|
{
|
|
db.t_htfzbs.Update(fzbmodel);
|
|
}
|
|
else
|
|
{
|
|
db.t_htfzbs.Insert(fzbmodel);
|
|
}
|
|
|
|
db.ts_ddfzbs.Update(dd1);
|
|
var ddxmb = db.ts_ddxmbs.Where(t => t.ddfzbm == dd1.ddfzbm);
|
|
|
|
db.t_htxmbs.Delete(t => t.htfzbm == dd1.ddfzbm);
|
|
|
|
if (ddxmb.Any())
|
|
{
|
|
IList<ts_ddxmb> ddxmblist = ddxmb.ToList();
|
|
foreach (ts_ddxmb xmb in ddxmblist)
|
|
{
|
|
t_htxmb xmbmodel = new t_htxmb();
|
|
xmbmodel.htfzbm = xmb.ddfzbm;
|
|
xmbmodel.zhbm = xmb.zhbm;
|
|
xmbmodel.upflag = 1;
|
|
|
|
var datahtxmb = db.t_htxmbs.Where(t => t.htfzbm == xmb.ddfzbm && t.zhbm == xmb.zhbm);
|
|
if (datahtxmb.Any())
|
|
{
|
|
db.t_htxmbs.Delete(xmbmodel);
|
|
db.t_htxmbs.Insert(xmbmodel);
|
|
}
|
|
else
|
|
{
|
|
db.t_htxmbs.Insert(xmbmodel);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//ts_kh tskh = db.ts_khs.Where(t => t.khbm == khbm).First();
|
|
//ts_htcjrq r = new ts_htcjrq();
|
|
//r.htbm = ddbm;
|
|
//r.htcjrq = dd.jzrq;
|
|
}
|
|
tran.Commit();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
or.State = 2;
|
|
or.Message = e.Message + " 生成合同出错!请联系管理员。";
|
|
}
|
|
}
|
|
or.State = 1;
|
|
or.Message = "合同生成成功!";
|
|
return or;
|
|
}
|
|
|
|
|
|
public List<ts_dd> GetListBykhbm(int khbm)
|
|
{
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
return db.ts_dds.Where(t => t.khbm== khbm).ToList();
|
|
}
|
|
}
|
|
|
|
|
|
public List<ts_dd> GetListByddbm(int ddbm)
|
|
{
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
return db.ts_dds.Where(t => t.ddbm == ddbm).ToList();
|
|
}
|
|
}
|
|
|
|
|
|
public OperationResult Updatedd(ts_dd o)
|
|
{
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
db.ts_dds.OrmAccessor.Update(o);
|
|
var data = db.t_hts.Where(t => t.htbm == o.ddbm);
|
|
if (data.Any())
|
|
{
|
|
db.DataAccessor.Execute("update t_ht set htzt=" + o.ddzt + " where htbm=" + o.ddbm);
|
|
}
|
|
}
|
|
OperationResult or = new OperationResult();
|
|
or.State = 1;
|
|
or.Message = "修改成功";
|
|
or.Tag = Newtonsoft.Json.JsonConvert.SerializeObject(o);
|
|
return or;
|
|
}
|
|
|
|
public OperationResult Insertdd(ts_dd o)
|
|
{
|
|
using (DbEntities db = new DbEntities())
|
|
{
|
|
db.ts_dds.OrmAccessor.Insert(o);
|
|
}
|
|
OperationResult or = new OperationResult();
|
|
or.State = 1;
|
|
or.Message = "添加成功";
|
|
or.Tag = Newtonsoft.Json.JsonConvert.SerializeObject(o);
|
|
return or;
|
|
}
|
|
|
|
public OperationResult Deldd(ts_dd o)
|
|
{
|
|
using (DbEntities db = new DbEntities())
|
|
{ //删除主订单
|
|
|
|
//删除主订单里的套餐
|
|
List<ts_ddfzb> fzbal = db.ts_ddfzbs.Where(t => t.ddbm == o.ddbm).ToList();
|
|
foreach (ts_ddfzb b in fzbal)
|
|
{
|
|
List<ts_ddxmb> xmbal = db.ts_ddxmbs.Where(t => t.ddfzbm == b.ddfzbm).ToList();
|
|
foreach (ts_ddxmb x in xmbal)
|
|
{
|
|
db.ts_ddxmbs.OrmAccessor.Delete(x);
|
|
}
|
|
db.ts_ddfzbs.OrmAccessor.Delete(b);
|
|
}
|
|
//删除套餐里的组合
|
|
db.ts_dds.OrmAccessor.Delete(o);
|
|
}
|
|
OperationResult or = new OperationResult();
|
|
or.State = 1;
|
|
or.Message = "删除成功";
|
|
or.Tag = Newtonsoft.Json.JsonConvert.SerializeObject(o);
|
|
return or;
|
|
}
|
|
}
|
|
}
|