185 lines
5.2 KiB
C#
185 lines
5.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using SOH.Data;
|
|
using SOH.Entities;
|
|
using EAS.Data;
|
|
using EAS.Services;
|
|
using EAS.Data.Linq;
|
|
using EAS.Data.ORM;
|
|
namespace SOH.BLL
|
|
{
|
|
[ServiceObject("套餐业务处理")]
|
|
[ServiceBind(typeof(ITaoCan))]
|
|
public class TaoCan : ITaoCan
|
|
{
|
|
public OperationResult SetTaoCan(t_tc tc, List<t_tcxmmx> tcmx)
|
|
{
|
|
//throw new NotImplementedException();
|
|
OperationResult or = new OperationResult();
|
|
using (var db = new DbEntities())
|
|
{
|
|
using (var vtran = db.CreateTransaction())
|
|
{
|
|
try
|
|
{
|
|
if (tc.tcbm == 0)
|
|
{
|
|
tc.tcbm = (short)new BasicBll().GetMax(tc.DbTableName, 1);
|
|
db.t_tcs.Insert(tc);
|
|
}
|
|
else
|
|
{
|
|
db.t_tcs.Update(tc);
|
|
}
|
|
db.t_tcxmmxs.Delete(t => t.tcbm == tc.tcbm);
|
|
foreach (t_tcxmmx mx in tcmx)
|
|
{
|
|
mx.tcbm = tc.tcbm;
|
|
db.t_tcxmmxs.Insert(mx);
|
|
}
|
|
vtran.Commit();
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
vtran.Rollback();
|
|
or.State = 0;
|
|
or.Message = ex.Message;
|
|
return or;
|
|
}
|
|
|
|
}
|
|
}
|
|
or.State = 1;
|
|
or.Message = "操作成功!";
|
|
return or;
|
|
}
|
|
|
|
|
|
public List<t_tc> getTaoCanList(string p)
|
|
{
|
|
//throw new NotImplementedException();
|
|
using (var db = new DbEntities())
|
|
{
|
|
int fddm=0;
|
|
int.TryParse(p,out fddm);
|
|
if (fddm== 0)
|
|
{
|
|
|
|
return db.t_tcs.ToList();
|
|
}
|
|
else
|
|
{
|
|
|
|
return db.t_tcs.Where(t => t.fddm == fddm).ToList();
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
public List<t_tc> getTaoCanList2(string p)
|
|
{
|
|
//throw new NotImplementedException();
|
|
using (var db = new DbEntities())
|
|
{
|
|
int fddm = 0;
|
|
int.TryParse(p, out fddm);
|
|
if (fddm == 0)
|
|
{
|
|
|
|
return db.t_tcs.Where(t=> t.upflag=="0").ToList();
|
|
}
|
|
else
|
|
{
|
|
|
|
return db.t_tcs.Where(t => t.fddm == fddm && t.upflag=="0").ToList();
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
public List<t_tc> getTaoCanListByZX(string p)
|
|
{
|
|
//throw new NotImplementedException();
|
|
using (var db = new DbEntities())
|
|
{
|
|
int fddm = 0;
|
|
int.TryParse(p, out fddm);
|
|
if (fddm == 0)
|
|
{
|
|
|
|
return db.t_tcs.Where(t=> t.zhuxiao==0).ToList();
|
|
}
|
|
else
|
|
{
|
|
|
|
return db.t_tcs.Where(t => t.fddm == fddm && t.zhuxiao==0).ToList();
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
public OperationResult SetZhuxiao(short tcbm, short zxbz)
|
|
{
|
|
OperationResult or = new OperationResult();
|
|
using (var db = new DbEntities())
|
|
{
|
|
try
|
|
{
|
|
var tc = db.t_tcs.FirstOrDefault(t => t.tcbm == tcbm);
|
|
if (tc == null)
|
|
{
|
|
or.State = 0;
|
|
or.Message = "没有找到该套餐,请重新选择!";
|
|
return or;
|
|
}
|
|
tc.zhuxiao = zxbz;
|
|
db.t_tcs.Update(tc);
|
|
|
|
}
|
|
catch (System.Exception ex)
|
|
{
|
|
or.State = 0;
|
|
or.Message = ex.Message;
|
|
return or;
|
|
}
|
|
|
|
}
|
|
or.State = 1;
|
|
or.Message = "操作成功!";
|
|
return or;
|
|
}
|
|
|
|
|
|
public List<t_zhxm> getTCMX(short tcbm)
|
|
{
|
|
//throw new NotImplementedException();
|
|
using (var db = new DbEntities())
|
|
{
|
|
//var tcmx=db.t_tcxmmxs.Where(t=>t.tcbm==tcbm).Select(t=>t.zhbm);
|
|
//return db.t_zhxms.Where(p => tcmx.Contains(p.zhbm)).ToList();
|
|
return db.t_tcxmmxs.Where(t => t.tcbm == tcbm).Join(db.t_zhxms, t => t.zhbm, p => p.zhbm, (t, p) => p).ToList();
|
|
}
|
|
}
|
|
|
|
|
|
public t_tc GetModelBytcbm(int tcid)
|
|
{
|
|
using (var db = new DbEntities())
|
|
{
|
|
var data = db.t_tcs.Where(t => t.tcbm == tcid);
|
|
if (data.Any())
|
|
{
|
|
return data.First();
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|