xinjiang/SGGL/BLL/CQMS/Information/CostReportDetailService.cs

157 lines
6.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BLL
{
public class CostReportDetailService
{
/// <summary>
/// 增加工程签证费用报审表明细信息
/// </summary>
/// <param name="pauseNotice">工程签证费用报审表明细实体</param>
public static void AddCostReportDetail(Model.CQMS_CostReportDetail a)
{
Model.SGGLDB db = Funs.DB;
Model.CQMS_CostReportDetail newCostReportDetail = new Model.CQMS_CostReportDetail();
newCostReportDetail.CostReportDetailId = a.CostReportDetailId;
newCostReportDetail.CostReportId = a.CostReportId;
newCostReportDetail.ConfirmFormId = a.ConfirmFormId;
newCostReportDetail.SortIndex = a.SortIndex;
newCostReportDetail.PlanCost = a.PlanCost;
newCostReportDetail.RealCost = a.RealCost;
newCostReportDetail.Remark = a.Remark;
db.CQMS_CostReportDetail.InsertOnSubmit(newCostReportDetail);
db.SubmitChanges();
}
/// <summary>
/// 修改工程签证费用报审表明细信息
/// </summary>
/// <param name="pauseNotice">工程签证费用报审表明细实体</param>
public static void UpdateCostReportDetail(Model.CQMS_CostReportDetail a)
{
Model.SGGLDB db = Funs.DB;
Model.CQMS_CostReportDetail newCostReportDetail = db.CQMS_CostReportDetail.First(e => e.CostReportDetailId == a.CostReportDetailId);
newCostReportDetail.SortIndex = a.SortIndex;
newCostReportDetail.PlanCost = a.PlanCost;
newCostReportDetail.RealCost = a.RealCost;
newCostReportDetail.Remark = a.Remark;
db.SubmitChanges();
}
/// <summary>
/// 根据工程签证费用报审表明细编号获取工程签证费用报审表明细
/// </summary>
/// <param name="costCode"></param>
public static Model.CQMS_CostReportDetail GetCostReportDetailByCostReportDetailId(string CostReportDetailId)
{
return Funs.DB.CQMS_CostReportDetail.FirstOrDefault(e => e.CostReportDetailId == CostReportDetailId);
}
/// <summary>
/// 下拉框选择(获取text val 参数必须有一个为空)
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
public static string GetValByText(string text, string val)
{
string str = null;
var itemlist = checkType();
if (!string.IsNullOrWhiteSpace(text) && !string.IsNullOrWhiteSpace(val))
{
}
else
{
if (!string.IsNullOrWhiteSpace(text))
{
foreach (var item in itemlist)
{
if (text.Equals(item.Value))
{
str = item.Key.ToString();
}
}
}
if (!string.IsNullOrWhiteSpace(val))
{
foreach (var item in itemlist)
{
if (val.Equals(item.Key.ToString()))
{
str = item.Value;
}
}
}
}
return str;
}
/// <summary>
/// 根据工程签证费用报审表编号获取工程签证费用报审表明细集合
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
public static List<Model.CQMS_CostReportDetail> GetLists(string costReportId)
{
return (from x in Funs.DB.CQMS_CostReportDetail where x.CostReportId == costReportId orderby x.SortIndex select x).ToList();
}
/// <summary>
/// 根据工程签证费用报审表编号获取工程签证费用报审表明细集合
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
public static List<Model.View_CQMS_CostReportDetail> GetViewLists(string costReportId)
{
return (from x in Funs.DB.View_CQMS_CostReportDetail where x.CostReportId == costReportId orderby x.SortIndex select x).ToList();
}
public static Dictionary<string, string> checkType()
{
Dictionary<string, string> dic = new Dictionary<string, string>();
var list = QualityQuestionTypeService.GetQualityQuestionTypeItem();
foreach (var item in list)
{
dic.Add(item.Value, item.Text);
}
return dic;
}
public static void Init(FineUIPro.DropDownList dropName, bool isShowPlease)
{
dropName.DataValueField = "Value";
dropName.DataTextField = "Value";
dropName.DataSource = checkType();
dropName.DataBind();
if (isShowPlease)
{
Funs.FineUIPleaseSelect(dropName);
}
}
/// <summary>
/// 根据工程签证费用报审表明细主键删除一个工程签证费用报审表明细信息
/// </summary>
/// <param name="pauseNoticeCode">工程签证费用报审表明细主键</param>
public static void DeleteCostReportDetailByCostReportId(string CostReportId)
{
Model.SGGLDB db = Funs.DB;
var q = (from x in db.CQMS_CostReportDetail where x.CostReportId == CostReportId select x).ToList();
db.CQMS_CostReportDetail.DeleteAllOnSubmit(q);
db.SubmitChanges();
}
public static void DeleteCostReportDetailById(string id)
{
using (var db = new Model.SGGLDB(Funs.ConnString))
{
var q = (from x in db.CQMS_CostReportDetail where x.CostReportDetailId == id select x).ToList();
db.CQMS_CostReportDetail.DeleteAllOnSubmit(q);
db.SubmitChanges();
}
}
}
}