20210430
This commit is contained in:
@@ -0,0 +1,180 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
/// <summary>
|
||||
/// 费用管理明细
|
||||
/// </summary>
|
||||
public static class CostManageItemService
|
||||
{
|
||||
public static Model.SGGLDB db = Funs.DB;
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键删除费用管理明细
|
||||
/// </summary>
|
||||
/// <param name="costManageItemId"></param>
|
||||
/// <returns></returns>
|
||||
public static Model.CostGoods_CostManageItem GetCostManageItemById(string costManageItemId)
|
||||
{
|
||||
return Funs.DB.CostGoods_CostManageItem.FirstOrDefault(e => e.CostManageItemId == costManageItemId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据费用管理主键获取所有相关明细信息
|
||||
/// </summary>
|
||||
/// <param name="costManageId"></param>
|
||||
/// <returns></returns>
|
||||
public static List<Model.CostGoods_CostManageItem> GetCostManageItemByCostManageId(string costManageId)
|
||||
{
|
||||
return (from x in Funs.DB.CostGoods_CostManageItem where x.CostManageId == costManageId select x).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据项目Id,单位Id和月份获取安全费用管理明细
|
||||
/// </summary>
|
||||
/// <param name="costManageId"></param>
|
||||
/// <returns></returns>
|
||||
public static List<Model.CostGoods_CostManageItem> GetCostManageItemByUnitIdAndDate(string projectId, string unidId, DateTime date)
|
||||
{
|
||||
return (from x in Funs.DB.CostGoods_CostManageItem
|
||||
join y in Funs.DB.CostGoods_CostManage
|
||||
on x.CostManageId equals y.CostManageId
|
||||
where y.ProjectId == projectId && y.UnitId == unidId
|
||||
&& y.CostManageDate.Value.Year == date.Year && y.CostManageDate.Value.Month == date.Month
|
||||
select x).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加费用管理明细
|
||||
/// </summary>
|
||||
/// <param name="costManageItem"></param>
|
||||
public static void AddCostManageItem(Model.CostGoods_CostManageItem costManageItem)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.CostGoods_CostManageItem newCostManageItem = new Model.CostGoods_CostManageItem
|
||||
{
|
||||
CostManageItemId = costManageItem.CostManageItemId,
|
||||
CostManageId = costManageItem.CostManageId,
|
||||
InvestCostProject = costManageItem.InvestCostProject,
|
||||
UseReason = costManageItem.UseReason,
|
||||
Counts = costManageItem.Counts,
|
||||
PriceMoney = costManageItem.PriceMoney,
|
||||
AuditCounts = costManageItem.AuditCounts,
|
||||
AuditPriceMoney = costManageItem.AuditPriceMoney,
|
||||
Remark = costManageItem.Remark
|
||||
};
|
||||
db.CostGoods_CostManageItem.InsertOnSubmit(newCostManageItem);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改费用管理明细
|
||||
/// </summary>
|
||||
/// <param name="costManageItem"></param>
|
||||
public static void UpdateCostManageItem(Model.CostGoods_CostManageItem costManageItem)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.CostGoods_CostManageItem newCostManageItem = db.CostGoods_CostManageItem.FirstOrDefault(e => e.CostManageItemId == costManageItem.CostManageItemId);
|
||||
if (newCostManageItem != null)
|
||||
{
|
||||
newCostManageItem.CostManageId = costManageItem.CostManageId;
|
||||
newCostManageItem.InvestCostProject = costManageItem.InvestCostProject;
|
||||
newCostManageItem.UseReason = costManageItem.UseReason;
|
||||
newCostManageItem.Counts = costManageItem.Counts;
|
||||
newCostManageItem.PriceMoney = costManageItem.PriceMoney;
|
||||
newCostManageItem.AuditCounts = costManageItem.AuditCounts;
|
||||
newCostManageItem.AuditPriceMoney = costManageItem.AuditPriceMoney;
|
||||
newCostManageItem.Remark = costManageItem.Remark;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据费用管理主键删除所有相关明细信息
|
||||
/// </summary>
|
||||
/// <param name="costManageId"></param>
|
||||
public static void DeleteCostManageItemByCostManageId(string costManageId)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
var q = (from x in db.CostGoods_CostManageItem where x.CostManageId == costManageId select x).ToList();
|
||||
if (q != null)
|
||||
{
|
||||
db.CostGoods_CostManageItem.DeleteAllOnSubmit(q);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键删除费用管理信息
|
||||
/// </summary>
|
||||
/// <param name="costManageItemId"></param>
|
||||
public static void DeleteCostManageItemById(string costManageItemId)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.CostGoods_CostManageItem costManageItem = db.CostGoods_CostManageItem.FirstOrDefault(e => e.CostManageItemId == costManageItemId);
|
||||
if (costManageItem != null)
|
||||
{
|
||||
db.CostGoods_CostManageItem.DeleteOnSubmit(costManageItem);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 投入费用项目下拉框内容
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static ListItem[] GetInvestCostProjectList()
|
||||
{
|
||||
ListItem[] lis = new ListItem[29];
|
||||
lis[0] = new ListItem("内业管理", "内业管理");
|
||||
lis[1] = new ListItem("检测器材", "检测器材");
|
||||
lis[2] = new ListItem("警示警戒", "警示警戒");
|
||||
lis[3] = new ListItem("安全奖励", "安全奖励");
|
||||
lis[4] = new ListItem("其他", "其他");
|
||||
lis[5] = new ListItem("安全技术", "安全技术");
|
||||
lis[6] = new ListItem("工业卫生", "工业卫生");
|
||||
lis[7] = new ListItem("安全用电", "安全用电");
|
||||
lis[8] = new ListItem("高处作业及基坑", "高处作业及基坑");
|
||||
lis[9] = new ListItem("临边洞口防护", "临边洞口防护");
|
||||
lis[10] = new ListItem("受限空间内作业", "受限空间内作业");
|
||||
lis[11] = new ListItem("动火作业", "动火作业");
|
||||
lis[12] = new ListItem("机械装备防护", "机械装备防护");
|
||||
lis[13] = new ListItem("吊装运输和起重", "吊装运输和起重");
|
||||
lis[14] = new ListItem("硼砂作业", "硼砂作业");
|
||||
lis[15] = new ListItem("拆除工程", "拆除工程");
|
||||
lis[16] = new ListItem("试压试车与有害介质作业", "试压试车与有害介质作业");
|
||||
lis[17] = new ListItem("特种作业防护", "特种作业防护");
|
||||
lis[18] = new ListItem("应急管理", "应急管理");
|
||||
lis[19] = new ListItem("非常措施", "非常措施");
|
||||
lis[20] = new ListItem("其他安全措施", "其他安全措施");
|
||||
lis[21] = new ListItem("装置区封闭管理", "装置区封闭管理");
|
||||
lis[22] = new ListItem("防爆施工器具", "防爆施工器具");
|
||||
lis[23] = new ListItem("标识标签与锁定", "标识标签与锁定");
|
||||
lis[24] = new ListItem("关键场所封闭", "关键场所封闭");
|
||||
lis[25] = new ListItem("催化剂加装还原", "催化剂加装还原");
|
||||
lis[26] = new ListItem("联动和化工试车", "联动和化工试车");
|
||||
lis[27] = new ListItem("教育培训", "教育培训");
|
||||
lis[28] = new ListItem("防护控制和排放", "防护控制和排放");
|
||||
return lis;
|
||||
}
|
||||
|
||||
public static decimal? GetCostsByUnitId(string unitId, DateTime startTime, DateTime endTime)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
var q = (from x in db.CostGoods_CostManageItem
|
||||
join y in db.CostGoods_CostManage
|
||||
on x.CostManageId equals y.CostManageId
|
||||
where y.UnitId == unitId && y.States == BLL.Const.State_2 && y.CostManageDate >= startTime && y.CostManageDate < endTime
|
||||
select x).ToList();
|
||||
if (q.Count > 0)
|
||||
{
|
||||
return q.Sum(e => (e.AuditCounts * e.AuditPriceMoney));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
/// <summary>
|
||||
/// 安全费用管理
|
||||
/// </summary>
|
||||
public static class CostManageService
|
||||
{
|
||||
public static Model.SGGLDB db = Funs.DB;
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键获取安全费用管理
|
||||
/// </summary>
|
||||
/// <param name="costManageId"></param>
|
||||
/// <returns></returns>
|
||||
public static Model.CostGoods_CostManage GetCostManageById(string costManageId)
|
||||
{
|
||||
return Funs.DB.CostGoods_CostManage.FirstOrDefault(e => e.CostManageId == costManageId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据项目Id,单位Id和月份获取安全费用管理
|
||||
/// </summary>
|
||||
/// <param name="costManageId"></param>
|
||||
/// <returns></returns>
|
||||
public static Model.CostGoods_CostManage GetCostManageByUnitIdAndDate(string projectId, string unidId, DateTime date)
|
||||
{
|
||||
return Funs.DB.CostGoods_CostManage.FirstOrDefault(e => e.CostManageId == projectId && e.UnitId == unidId && e.CostManageDate.Value.Year == date.Year && e.CostManageDate.Value.Month == date.Month);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加安全费用管理
|
||||
/// </summary>
|
||||
/// <param name="costManage"></param>
|
||||
public static void AddCostManage(Model.CostGoods_CostManage costManage)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.CostGoods_CostManage newCostManage = new Model.CostGoods_CostManage
|
||||
{
|
||||
CostManageId = costManage.CostManageId,
|
||||
ProjectId = costManage.ProjectId,
|
||||
CostManageCode = costManage.CostManageCode,
|
||||
CostManageName = costManage.CostManageName,
|
||||
UnitId = costManage.UnitId,
|
||||
ContractNum = costManage.ContractNum,
|
||||
CostManageDate = costManage.CostManageDate,
|
||||
Opinion = costManage.Opinion,
|
||||
SubCN = costManage.SubCN,
|
||||
SubHSE = costManage.SubHSE,
|
||||
SubProject = costManage.SubProject,
|
||||
States = costManage.States,
|
||||
CompileMan = costManage.CompileMan,
|
||||
CompileDate = costManage.CompileDate
|
||||
};
|
||||
db.CostGoods_CostManage.InsertOnSubmit(newCostManage);
|
||||
db.SubmitChanges();
|
||||
CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(Const.ProjectCostManageMenuId, costManage.ProjectId, null, costManage.CostManageId, costManage.CompileDate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改费用管理
|
||||
/// </summary>
|
||||
/// <param name="costManage"></param>
|
||||
public static void UpdateCostManage(Model.CostGoods_CostManage costManage)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.CostGoods_CostManage newCostManage = db.CostGoods_CostManage.FirstOrDefault(e => e.CostManageId == costManage.CostManageId);
|
||||
if (newCostManage != null)
|
||||
{
|
||||
//newCostManage.ProjectId = costManage.ProjectId;
|
||||
newCostManage.CostManageCode = costManage.CostManageCode;
|
||||
newCostManage.CostManageName = costManage.CostManageName;
|
||||
newCostManage.UnitId = costManage.UnitId;
|
||||
newCostManage.ContractNum = costManage.ContractNum;
|
||||
newCostManage.CostManageDate = costManage.CostManageDate;
|
||||
newCostManage.Opinion = costManage.Opinion;
|
||||
newCostManage.SubCN = costManage.SubCN;
|
||||
newCostManage.SubHSE = costManage.SubHSE;
|
||||
newCostManage.SubProject = costManage.SubProject;
|
||||
newCostManage.States = costManage.States;
|
||||
newCostManage.CompileMan = costManage.CompileMan;
|
||||
newCostManage.CompileDate = costManage.CompileDate;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键删除费用管理
|
||||
/// </summary>
|
||||
/// <param name="costManageId"></param>
|
||||
public static void DeleteCostManageById(string costManageId)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.CostGoods_CostManage costManage = db.CostGoods_CostManage.FirstOrDefault(e => e.CostManageId == costManageId);
|
||||
if (costManage != null)
|
||||
{
|
||||
CodeRecordsService.DeleteCodeRecordsByDataId(costManageId);//删除编号
|
||||
ProjectDataFlowSetService.DeleteFlowSetByDataId(costManageId);//删除流程
|
||||
CommonService.DeleteFlowOperateByID(costManageId); //删除审核流程
|
||||
CommonService.DeleteAttachFileById(costManageId);//删除附件
|
||||
db.CostGoods_CostManage.DeleteOnSubmit(costManage);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,199 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
/// <summary>
|
||||
/// 安全费用投入登记明细
|
||||
/// </summary>
|
||||
public static class CostSmallDetailItemService
|
||||
{
|
||||
public static Model.SGGLDB db = Funs.DB;
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键获取安全费用投入登记明细
|
||||
/// </summary>
|
||||
/// <param name="costSmallDetailItemId"></param>
|
||||
/// <returns></returns>
|
||||
public static Model.CostGoods_CostSmallDetailItem GetCostSmallDetailItemById(string costSmallDetailItemId)
|
||||
{
|
||||
return Funs.DB.CostGoods_CostSmallDetailItem.FirstOrDefault(e => e.CostSmallDetailItemId == costSmallDetailItemId);
|
||||
}
|
||||
|
||||
public static List<Model.CostGoods_CostSmallDetailItem> GetCostDetailsByUnitId(string projectId,string unitId, DateTime? startTime, DateTime? endTime)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
return (from x in db.CostGoods_CostSmallDetailItem
|
||||
join y in db.CostGoods_CostSmallDetail on x.CostSmallDetailId equals y.CostSmallDetailId
|
||||
join z in db.Sys_FlowOperate
|
||||
on y.CostSmallDetailId equals z.DataId
|
||||
where y.ProjectId == projectId && y.UnitId == unitId && y.States == BLL.Const.State_2 && z.OperaterTime >= startTime && z.OperaterTime < endTime
|
||||
select x).Distinct().ToList();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据单位和时间及费用类型获取当期费用
|
||||
/// </summary>
|
||||
/// <param name="unitId"></param>
|
||||
/// <param name="startTime"></param>
|
||||
/// <param name="endTime"></param>
|
||||
/// <param name="costType"></param>
|
||||
/// <returns></returns>
|
||||
public static decimal GetCostDetailsByUnitIdAndCostType(string projectId, string unitId, DateTime startTime, DateTime endTime, string costType)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
decimal cost = 0;
|
||||
var q = from x in db.CostGoods_CostSmallDetailItem
|
||||
join y in db.CostGoods_CostSmallDetail on x.CostSmallDetailId equals y.CostSmallDetailId
|
||||
join z in db.Sys_FlowOperate
|
||||
on y.CostSmallDetailId equals z.DataId
|
||||
where y.ProjectId == projectId && y.UnitId == unitId && y.States == BLL.Const.State_2 && z.State == BLL.Const.State_2 && z.OperaterTime >= startTime && z.OperaterTime < endTime && x.CostType.Contains(costType)
|
||||
select x.CostMoney;
|
||||
foreach (var item in q)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
cost += Funs.GetNewDecimalOrZero(item.ToString());
|
||||
}
|
||||
}
|
||||
return cost;
|
||||
//return (from x in Funs.DB.CostGoods_CostSmallDetailItem
|
||||
// join y in Funs.DB.CostGoods_CostSmallDetail on x.CostSmallDetailId equals y.CostSmallDetailId
|
||||
// where y.UnitId == unitId && y.States == BLL.Const.State_2 && y.ApproveDate >= startTime && y.ApproveDate < endTime && x.CostType.Contains(costType)
|
||||
// select x.CostMoney ?? 0).Sum();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据时间及费用类型获取当期费用
|
||||
/// </summary>
|
||||
/// <param name="unitId"></param>
|
||||
/// <param name="startTime"></param>
|
||||
/// <param name="endTime"></param>
|
||||
/// <param name="costType"></param>
|
||||
/// <returns></returns>
|
||||
public static decimal GetCostDetailsByCostType(string projectId, DateTime startTime, DateTime endTime, string costType)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
decimal cost = 0;
|
||||
var q = from x in db.CostGoods_CostSmallDetailItem
|
||||
join y in db.CostGoods_CostSmallDetail on x.CostSmallDetailId equals y.CostSmallDetailId
|
||||
join z in db.Sys_FlowOperate
|
||||
on y.CostSmallDetailId equals z.DataId
|
||||
where y.ProjectId == projectId && y.States == BLL.Const.State_2 && z.State == BLL.Const.State_2 && z.OperaterTime >= startTime && z.OperaterTime < endTime && x.CostType.Contains(costType)
|
||||
select x.CostMoney;
|
||||
foreach (var item in q)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
cost += Funs.GetNewDecimalOrZero(item.ToString());
|
||||
}
|
||||
}
|
||||
return cost;
|
||||
//return (from x in Funs.DB.CostGoods_CostSmallDetailItem
|
||||
// join y in Funs.DB.CostGoods_CostSmallDetail on x.CostSmallDetailId equals y.CostSmallDetailId
|
||||
// where y.UnitId == unitId && y.States == BLL.Const.State_2 && y.ApproveDate >= startTime && y.ApproveDate < endTime && x.CostType.Contains(costType)
|
||||
// select x.CostMoney ?? 0).Sum();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据费用类型获取所有费用
|
||||
/// </summary>
|
||||
/// <param name="unitId"></param>
|
||||
/// <param name="startTime"></param>
|
||||
/// <param name="endTime"></param>
|
||||
/// <param name="costType"></param>
|
||||
/// <returns></returns>
|
||||
public static decimal GetTotalCostDetailsByCostType(string projectId, string costType)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
decimal cost = 0;
|
||||
var q = from x in db.CostGoods_CostSmallDetailItem
|
||||
join y in db.CostGoods_CostSmallDetail on x.CostSmallDetailId equals y.CostSmallDetailId
|
||||
join z in db.Sys_FlowOperate
|
||||
on y.CostSmallDetailId equals z.DataId
|
||||
where y.ProjectId == projectId && y.States == BLL.Const.State_2 && z.State == BLL.Const.State_2 && x.CostType.Contains(costType)
|
||||
select x.CostMoney;
|
||||
foreach (var item in q)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
cost += Funs.GetNewDecimalOrZero(item.ToString());
|
||||
}
|
||||
}
|
||||
return cost;
|
||||
//return (from x in Funs.DB.CostGoods_CostSmallDetailItem
|
||||
// join y in Funs.DB.CostGoods_CostSmallDetail on x.CostSmallDetailId equals y.CostSmallDetailId
|
||||
// where y.UnitId == unitId && y.States == BLL.Const.State_2 && y.ApproveDate >= startTime && y.ApproveDate < endTime && x.CostType.Contains(costType)
|
||||
// select x.CostMoney ?? 0).Sum();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据费用投入登记ID获取所有相关明细信息
|
||||
/// </summary>
|
||||
/// <param name="costSmallDetailId"></param>
|
||||
/// <returns></returns>
|
||||
public static List<Model.CostGoods_CostSmallDetailItem> GetCostSmallDetailItemByCostSmallDetailId(string costSmallDetailId)
|
||||
{
|
||||
return (from x in Funs.DB.CostGoods_CostSmallDetailItem where x.CostSmallDetailId == costSmallDetailId select x).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加费用明细信息
|
||||
/// </summary>
|
||||
/// <param name="pauseNotice">费用明细实体</param>
|
||||
public static void AddCostDetail(string costSmallDetailId, string costType, decimal costMoney, string costDef)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.CostGoods_CostSmallDetailItem newCostSmallDetailItem = new Model.CostGoods_CostSmallDetailItem
|
||||
{
|
||||
CostSmallDetailItemId = SQLHelper.GetNewID(typeof(Model.CostGoods_CostSmallDetailItem)),
|
||||
CostSmallDetailId = costSmallDetailId,
|
||||
CostType = costType,
|
||||
CostMoney = costMoney,
|
||||
CostDef = costDef
|
||||
};
|
||||
db.CostGoods_CostSmallDetailItem.InsertOnSubmit(newCostSmallDetailItem);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键删除费用投入登记明细
|
||||
/// </summary>
|
||||
/// <param name="costSmallDetailItemId"></param>
|
||||
public static void DeleteCostSmallDetailItemById(string costSmallDetailItemId)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.CostGoods_CostSmallDetailItem costSmallDetailItem = db.CostGoods_CostSmallDetailItem.FirstOrDefault(e => e.CostSmallDetailItemId == costSmallDetailItemId);
|
||||
if (costSmallDetailItem != null)
|
||||
{
|
||||
db.CostGoods_CostSmallDetailItem.DeleteOnSubmit(costSmallDetailItem);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键删除所有相关明细信息
|
||||
/// </summary>
|
||||
/// <param name="costSmallDetailId"></param>
|
||||
public static void DeleteCostSmallDetailItemByCostSmallDetailId(string costSmallDetailId)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
var q = (from x in db.CostGoods_CostSmallDetailItem where x.CostSmallDetailId == costSmallDetailId select x).ToList();
|
||||
if (q != null)
|
||||
{
|
||||
db.CostGoods_CostSmallDetailItem.DeleteAllOnSubmit(q);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
/// <summary>
|
||||
/// 安全费用投入登记
|
||||
/// </summary>
|
||||
public static class CostSmallDetailService
|
||||
{
|
||||
public static Model.SGGLDB db = Funs.DB;
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键获取安全费用投入登记
|
||||
/// </summary>
|
||||
/// <param name="costSmallDetailId"></param>
|
||||
/// <returns></returns>
|
||||
public static Model.CostGoods_CostSmallDetail GetCostSmallDetailById(string costSmallDetailId)
|
||||
{
|
||||
return Funs.DB.CostGoods_CostSmallDetail.FirstOrDefault(e => e.CostSmallDetailId == costSmallDetailId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加安全费用投入登记
|
||||
/// </summary>
|
||||
/// <param name="costSmallDetail"></param>
|
||||
public static void AddCostSmallDetail(Model.CostGoods_CostSmallDetail costSmallDetail)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.CostGoods_CostSmallDetail newCostSmallDetail = new Model.CostGoods_CostSmallDetail
|
||||
{
|
||||
CostSmallDetailId = costSmallDetail.CostSmallDetailId,
|
||||
ProjectId = costSmallDetail.ProjectId,
|
||||
CostSmallDetailCode = costSmallDetail.CostSmallDetailCode,
|
||||
UnitId = costSmallDetail.UnitId,
|
||||
States = costSmallDetail.States,
|
||||
//newCostSmallDetail.CompileMan = costSmallDetail.CompileMan;
|
||||
CompileDate = costSmallDetail.CompileDate,
|
||||
Months = costSmallDetail.Months,
|
||||
ReportDate = costSmallDetail.ReportDate,
|
||||
//newCostSmallDetail.CheckMan = costSmallDetail.CheckMan;
|
||||
CheckDate = costSmallDetail.CheckDate,
|
||||
// newCostSmallDetail.ApproveMan = costSmallDetail.ApproveMan;
|
||||
ApproveDate = costSmallDetail.ApproveDate
|
||||
};
|
||||
db.CostGoods_CostSmallDetail.InsertOnSubmit(newCostSmallDetail);
|
||||
db.SubmitChanges();
|
||||
CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(Const.ProjectCostSmallDetailMenuId, costSmallDetail.ProjectId, null, costSmallDetail.CostSmallDetailId, costSmallDetail.CompileDate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改安全费用投入登记
|
||||
/// </summary>
|
||||
/// <param name="costSmallDetail"></param>
|
||||
public static void UpdateCostSmallDetail(Model.CostGoods_CostSmallDetail costSmallDetail)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.CostGoods_CostSmallDetail newCostSmallDetail = db.CostGoods_CostSmallDetail.FirstOrDefault(e => e.CostSmallDetailId == costSmallDetail.CostSmallDetailId);
|
||||
if (newCostSmallDetail != null)
|
||||
{
|
||||
//newCostSmallDetail.ProjectId = costSmallDetail.ProjectId;
|
||||
newCostSmallDetail.CostSmallDetailCode = costSmallDetail.CostSmallDetailCode;
|
||||
newCostSmallDetail.UnitId = costSmallDetail.UnitId;
|
||||
newCostSmallDetail.States = costSmallDetail.States;
|
||||
// newCostSmallDetail.CompileMan = costSmallDetail.CompileMan;
|
||||
//newCostSmallDetail.CompileDate = costSmallDetail.CompileDate;
|
||||
newCostSmallDetail.Months = costSmallDetail.Months;
|
||||
newCostSmallDetail.ReportDate = costSmallDetail.ReportDate;
|
||||
// newCostSmallDetail.CheckMan = costSmallDetail.CheckMan;
|
||||
newCostSmallDetail.CheckDate = costSmallDetail.CheckDate;
|
||||
// newCostSmallDetail.ApproveMan = costSmallDetail.ApproveMan;
|
||||
newCostSmallDetail.ApproveDate = costSmallDetail.ApproveDate;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键删除安全费用投入登记
|
||||
/// </summary>
|
||||
/// <param name="costSmallDetailId"></param>
|
||||
public static void DeleteCostSmallDetailById(string costSmallDetailId)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.CostGoods_CostSmallDetail costSmallDetail = db.CostGoods_CostSmallDetail.FirstOrDefault(e => e.CostSmallDetailId == costSmallDetailId);
|
||||
if (costSmallDetail != null)
|
||||
{
|
||||
CodeRecordsService.DeleteCodeRecordsByDataId(costSmallDetailId);//删除编号
|
||||
CommonService.DeleteAttachFileById(costSmallDetailId);//删除附件
|
||||
////删除流程表
|
||||
BLL.CommonService.DeleteFlowOperateByID(costSmallDetail.CostSmallDetailId);
|
||||
db.CostGoods_CostSmallDetail.DeleteOnSubmit(costSmallDetail);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
public class ExpenseDetailService
|
||||
{
|
||||
public static decimal? GetSumCostMoneyByExpenseId(string expenseId)
|
||||
{
|
||||
return (from x in Funs.DB.CostGoods_ExpenseDetail where x.ExpenseId == expenseId select x.CostMoney).Sum();
|
||||
}
|
||||
|
||||
public static List<Model.CostGoods_ExpenseDetail> GetExpenseDetailsByExpenseId(string expenseId)
|
||||
{
|
||||
return (from x in Funs.DB.CostGoods_ExpenseDetail where x.ExpenseId == expenseId select x).ToList();
|
||||
}
|
||||
|
||||
public static decimal GetSumCostMoneyByExpenseIdAndType(string expenseId, string costType)
|
||||
{
|
||||
Model.CostGoods_ExpenseDetail detail = (from x in Funs.DB.CostGoods_ExpenseDetail where x.ExpenseId == expenseId && x.CostType == costType select x).FirstOrDefault();
|
||||
if (detail != null)
|
||||
{
|
||||
return detail.CostMoney ?? 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据单位和时间获取费用明细集合
|
||||
/// </summary>
|
||||
/// <param name="unitId"></param>
|
||||
/// <param name="startTime"></param>
|
||||
/// <param name="endTime"></param>
|
||||
/// <returns></returns>
|
||||
public static List<Model.CostGoods_ExpenseDetail> GetCostDetailsByUnitId(string unitId, DateTime startTime, DateTime endTime)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
return (from x in db.CostGoods_ExpenseDetail
|
||||
join y in db.CostGoods_Expense on x.ExpenseId equals y.ExpenseId
|
||||
where y.UnitId == unitId && y.States == BLL.Const.State_2 && y.ApproveDate >= startTime && y.ApproveDate < endTime
|
||||
select x).Distinct().ToList();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据单位和时间及费用类型获取当期费用
|
||||
/// </summary>
|
||||
/// <param name="unitId"></param>
|
||||
/// <param name="startTime"></param>
|
||||
/// <param name="endTime"></param>
|
||||
/// <param name="costType"></param>
|
||||
/// <returns></returns>
|
||||
public static decimal GetCostDetailsByUnitIdAndCostType(string unitId, DateTime startTime, DateTime endTime, string costType)
|
||||
{
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
decimal cost = 0;
|
||||
var q = from x in db.CostGoods_ExpenseDetail
|
||||
join y in db.CostGoods_Expense on x.ExpenseId equals y.ExpenseId
|
||||
join z in db.Sys_FlowOperate
|
||||
on y.ExpenseId equals z.DataId
|
||||
where y.UnitId == unitId && y.States == BLL.Const.State_2 && z.State == BLL.Const.State_2 && z.OperaterTime >= startTime && z.OperaterTime < endTime && x.CostType.Contains(costType)
|
||||
select x.CostMoney;
|
||||
foreach (var item in q)
|
||||
{
|
||||
if (item != null)
|
||||
{
|
||||
cost += Funs.GetNewDecimalOrZero(item.ToString());
|
||||
}
|
||||
}
|
||||
return cost;
|
||||
//return (from x in Funs.DB.CostGoods_ExpenseDetail
|
||||
// join y in Funs.DB.CostGoods_Expense on x.ExpenseId equals y.ExpenseId
|
||||
// where y.UnitId == unitId && y.States == BLL.Const.State_2 && y.ApproveDate >= startTime && y.ApproveDate < endTime && x.CostType.Contains(costType)
|
||||
// select x.CostMoney ?? 0).Sum();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加费用明细信息
|
||||
/// </summary>
|
||||
/// <param name="pauseNotice">费用明细实体</param>
|
||||
public static void AddCostDetail(string expenseId, string costType, decimal costMoney, string costDef)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.CostGoods_ExpenseDetail newExpenseDetail = new Model.CostGoods_ExpenseDetail
|
||||
{
|
||||
ExpenseDetailId = SQLHelper.GetNewID(typeof(Model.CostGoods_ExpenseDetail)),
|
||||
ExpenseId = expenseId,
|
||||
CostType = costType,
|
||||
CostMoney = costMoney,
|
||||
CostDef = costDef
|
||||
};
|
||||
db.CostGoods_ExpenseDetail.InsertOnSubmit(newExpenseDetail);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据费用编号和费用类型获取费用明细信息
|
||||
/// </summary>
|
||||
/// <param name="expenseId"></param>
|
||||
/// <param name="costType"></param>
|
||||
/// <returns></returns>
|
||||
public static Model.CostGoods_ExpenseDetail GetCostDetailByExpenseIdAndCostType(string expenseId, string costType)
|
||||
{
|
||||
return Funs.DB.CostGoods_ExpenseDetail.FirstOrDefault(e => (e.ExpenseId == expenseId && e.CostType == costType));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据费用编号删除对应的费用明细信息
|
||||
/// </summary>
|
||||
/// <param name="expenseId">编号</param>
|
||||
public static void DeleteCostDetailByExpenseId(string expenseId)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
var q = (from x in db.CostGoods_ExpenseDetail where x.ExpenseId == expenseId select x).ToList();
|
||||
db.CostGoods_ExpenseDetail.DeleteAllOnSubmit(q);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,119 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
/// <summary>
|
||||
/// 措施费用使用计划
|
||||
/// </summary>
|
||||
public static class ExpenseService
|
||||
{
|
||||
public static Model.SGGLDB db = Funs.DB;
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键获取措施费用使用计划
|
||||
/// </summary>
|
||||
/// <param name="expenseId"></param>
|
||||
/// <returns></returns>
|
||||
public static Model.CostGoods_Expense GetExpenseById(string expenseId)
|
||||
{
|
||||
return Funs.DB.CostGoods_Expense.FirstOrDefault(e => e.ExpenseId == expenseId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据时间获取当期单位Id集合
|
||||
/// </summary>
|
||||
/// <param name="startTime"></param>
|
||||
/// <param name="endTime"></param>
|
||||
/// <returns></returns>
|
||||
public static List<string> GetUnitIdsByTime(DateTime startTime, DateTime endTime, string projectId)
|
||||
{
|
||||
return (from x in Funs.DB.CostGoods_Expense
|
||||
join y in Funs.DB.Sys_FlowOperate
|
||||
on x.ExpenseId equals y.DataId
|
||||
where x.States == BLL.Const.State_2 && x.ProjectId == projectId && y.State == BLL.Const.State_2 && y.OperaterTime >= startTime && y.OperaterTime < endTime
|
||||
select x.UnitId).Distinct().ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加措施费用使用计划
|
||||
/// </summary>
|
||||
/// <param name="expense"></param>
|
||||
public static void AddExpense(Model.CostGoods_Expense expense)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.CostGoods_Expense newExpense = new Model.CostGoods_Expense
|
||||
{
|
||||
ExpenseId = expense.ExpenseId,
|
||||
ProjectId = expense.ProjectId,
|
||||
ExpenseCode = expense.ExpenseCode,
|
||||
UnitId = expense.UnitId,
|
||||
//newExpense.CompileMan = expense.CompileMan;
|
||||
CreateDate = expense.CreateDate,
|
||||
States = expense.States,
|
||||
Months = expense.Months,
|
||||
ReportDate = expense.ReportDate,
|
||||
PlanCostA = expense.PlanCostA,
|
||||
PlanCostB = expense.PlanCostB,
|
||||
CompileDate = expense.CompileDate,
|
||||
// newExpense.CheckMan = expense.CheckMan;
|
||||
CheckDate = expense.CheckDate,
|
||||
// newExpense.ApproveMan = expense.ApproveMan;
|
||||
ApproveDate = expense.ApproveDate
|
||||
};
|
||||
db.CostGoods_Expense.InsertOnSubmit(newExpense);
|
||||
db.SubmitChanges();
|
||||
BLL.CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(Const.ProjectExpenseMenuId, expense.ProjectId, null, expense.ExpenseId, expense.CreateDate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改措施费用使用计划
|
||||
/// </summary>
|
||||
/// <param name="expense"></param>
|
||||
public static void UpdateExpense(Model.CostGoods_Expense expense)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.CostGoods_Expense newExpense = db.CostGoods_Expense.FirstOrDefault(e => e.ExpenseId == expense.ExpenseId);
|
||||
if (newExpense != null)
|
||||
{
|
||||
//newExpense.ProjectId = expense.ProjectId;
|
||||
newExpense.ExpenseCode = expense.ExpenseCode;
|
||||
newExpense.UnitId = expense.UnitId;
|
||||
// newExpense.CompileMan = expense.CompileMan;
|
||||
newExpense.CreateDate = expense.CreateDate;
|
||||
newExpense.States = expense.States;
|
||||
newExpense.Months = expense.Months;
|
||||
newExpense.ReportDate = expense.ReportDate;
|
||||
newExpense.PlanCostA = expense.PlanCostA;
|
||||
newExpense.PlanCostB = expense.PlanCostB;
|
||||
newExpense.CompileDate = expense.CompileDate;
|
||||
//newExpense.CheckMan = expense.CheckMan;
|
||||
newExpense.CheckDate = expense.CheckDate;
|
||||
//newExpense.ApproveMan = expense.ApproveMan;
|
||||
newExpense.ApproveDate = expense.ApproveDate;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键删除措施费用使用计划
|
||||
/// </summary>
|
||||
/// <param name="expenseId"></param>
|
||||
public static void DeleteExpenseById(string expenseId)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
Model.CostGoods_Expense expense = db.CostGoods_Expense.FirstOrDefault(e => e.ExpenseId == expenseId);
|
||||
if (expense != null)
|
||||
{
|
||||
BLL.CodeRecordsService.DeleteCodeRecordsByDataId(expenseId);
|
||||
BLL.CommonService.DeleteAttachFileById(expenseId);
|
||||
////删除审核流程表
|
||||
BLL.CommonService.DeleteFlowOperateByID(expenseId);
|
||||
db.CostGoods_Expense.DeleteOnSubmit(expense);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
/// <summary>
|
||||
/// 物资管理
|
||||
/// </summary>
|
||||
public static class GoodsManageService
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据主键获取物资管理
|
||||
/// </summary>
|
||||
/// <param name="goodsManageId"></param>
|
||||
/// <returns></returns>
|
||||
public static Model.CostGoods_GoodsManage GetGoodsManageById(string goodsManageId)
|
||||
{
|
||||
return Funs.DB.CostGoods_GoodsManage.FirstOrDefault(e => e.GoodsManageId == goodsManageId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加物资管理
|
||||
/// </summary>
|
||||
/// <param name="goodsManage"></param>
|
||||
public static void AddGoodsManage(Model.CostGoods_GoodsManage goodsManage)
|
||||
{
|
||||
Model.CostGoods_GoodsManage newGoodsManage = new Model.CostGoods_GoodsManage
|
||||
{
|
||||
GoodsManageId = goodsManage.GoodsManageId,
|
||||
ProjectId = goodsManage.ProjectId,
|
||||
UnitId = goodsManage.UnitId,
|
||||
GoodsCategoryId = goodsManage.GoodsCategoryId,
|
||||
GoodsCode = goodsManage.GoodsCode,
|
||||
GoodsName = goodsManage.GoodsName,
|
||||
SizeModel = goodsManage.SizeModel,
|
||||
FactoryCode = goodsManage.FactoryCode,
|
||||
CheckDate = goodsManage.CheckDate,
|
||||
EnableYear = goodsManage.EnableYear,
|
||||
CheckPerson = goodsManage.CheckPerson,
|
||||
InTime = goodsManage.InTime,
|
||||
States = goodsManage.States,
|
||||
CompileMan = goodsManage.CompileMan,
|
||||
CompileDate = goodsManage.CompileDate,
|
||||
Remark = goodsManage.Remark
|
||||
};
|
||||
Funs.DB.CostGoods_GoodsManage.InsertOnSubmit(newGoodsManage);
|
||||
Funs.DB.SubmitChanges();
|
||||
|
||||
CodeRecordsService.InsertCodeRecordsByMenuIdProjectIdUnitId(Const.GoodsManageMenuId, goodsManage.ProjectId, goodsManage.UnitId, goodsManage.GoodsManageId, goodsManage.CompileDate);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改物资管理
|
||||
/// </summary>
|
||||
/// <param name="goodsManage"></param>
|
||||
public static void UpdateGoodsManage(Model.CostGoods_GoodsManage goodsManage)
|
||||
{
|
||||
Model.CostGoods_GoodsManage newGoodsManage = Funs.DB.CostGoods_GoodsManage.FirstOrDefault(e => e.GoodsManageId == goodsManage.GoodsManageId);
|
||||
if (newGoodsManage != null)
|
||||
{
|
||||
newGoodsManage.UnitId = goodsManage.UnitId;
|
||||
newGoodsManage.GoodsCategoryId = goodsManage.GoodsCategoryId;
|
||||
newGoodsManage.GoodsCode = goodsManage.GoodsCode;
|
||||
newGoodsManage.GoodsName = goodsManage.GoodsName;
|
||||
newGoodsManage.SizeModel = goodsManage.SizeModel;
|
||||
newGoodsManage.FactoryCode = goodsManage.FactoryCode;
|
||||
newGoodsManage.CheckDate = goodsManage.CheckDate;
|
||||
newGoodsManage.EnableYear = goodsManage.EnableYear;
|
||||
newGoodsManage.CheckPerson = goodsManage.CheckPerson;
|
||||
newGoodsManage.InTime = goodsManage.InTime;
|
||||
newGoodsManage.States = goodsManage.States;
|
||||
newGoodsManage.CompileMan = goodsManage.CompileMan;
|
||||
newGoodsManage.CompileDate = goodsManage.CompileDate;
|
||||
newGoodsManage.Remark = goodsManage.Remark;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键删除物资管理
|
||||
/// </summary>
|
||||
/// <param name="goodsManageId"></param>
|
||||
public static void DeleteGoodsManageById(string goodsManageId)
|
||||
{
|
||||
Model.CostGoods_GoodsManage goodsManage = Funs.DB.CostGoods_GoodsManage.FirstOrDefault(e => e.GoodsManageId == goodsManageId);
|
||||
if (goodsManage != null)
|
||||
{
|
||||
CodeRecordsService.DeleteCodeRecordsByDataId(goodsManageId);//删除编号
|
||||
ProjectDataFlowSetService.DeleteFlowSetByDataId(goodsManageId);//删除流程
|
||||
////删除审核流程表
|
||||
BLL.CommonService.DeleteFlowOperateByID(goodsManageId);
|
||||
Funs.DB.CostGoods_GoodsManage.DeleteOnSubmit(goodsManage);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user