189 lines
8.0 KiB
C#
189 lines
8.0 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using FineUIPro;
|
|
using Model;
|
|
|
|
namespace BLL
|
|
{
|
|
public static class PhtglContracttrackprogressService
|
|
{
|
|
#region 获取列表
|
|
|
|
/// <summary>
|
|
/// 记录数
|
|
/// </summary>
|
|
public static int Count { get; set; }
|
|
|
|
public static List<PHTGL_ContractTrackProgress> GetPHTGL_ContractTrackProgressByModle(
|
|
PHTGL_ContractTrackProgress table)
|
|
{
|
|
var q = from x in Funs.DB.PHTGL_ContractTrackProgress
|
|
where
|
|
(string.IsNullOrEmpty(table.ContractTrackProgressId) ||
|
|
x.ContractTrackProgressId.Contains(table.ContractTrackProgressId)) &&
|
|
(string.IsNullOrEmpty(table.ContractTrackId) ||
|
|
x.ContractTrackId.Contains(table.ContractTrackId)) &&
|
|
(string.IsNullOrEmpty(table.BCWS_Quantity) || x.BCWS_Quantity.Contains(table.BCWS_Quantity)) &&
|
|
(string.IsNullOrEmpty(table.BCWS_OutputValue) ||
|
|
x.BCWS_OutputValue.Contains(table.BCWS_OutputValue)) &&
|
|
(string.IsNullOrEmpty(table.BCWS_Percentage) ||
|
|
x.BCWS_Percentage.Contains(table.BCWS_Percentage)) &&
|
|
(string.IsNullOrEmpty(table.ACWP_Quantity) || x.ACWP_Quantity.Contains(table.ACWP_Quantity)) &&
|
|
(string.IsNullOrEmpty(table.ACWP_OutputValue) ||
|
|
x.ACWP_OutputValue.Contains(table.ACWP_OutputValue)) &&
|
|
(string.IsNullOrEmpty(table.ACWP_Percentage) ||
|
|
x.ACWP_Percentage.Contains(table.ACWP_Percentage)) &&
|
|
(string.IsNullOrEmpty(table.Date) ||
|
|
x.Date.Contains(table.Date))
|
|
orderby x.Date
|
|
select x
|
|
;
|
|
|
|
return q.ToList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取分页列表
|
|
/// </summary>
|
|
/// <param name="table"></param>
|
|
/// <param name="grid1"></param>
|
|
/// <returns></returns>
|
|
public static IEnumerable GetListData(PHTGL_ContractTrackProgress table, Grid grid1)
|
|
{
|
|
var q = GetPHTGL_ContractTrackProgressByModle(table);
|
|
Count = q.Count();
|
|
if (Count == 0) return null;
|
|
q = q.Skip(grid1.PageSize * grid1.PageIndex).Take(grid1.PageSize).ToList();
|
|
// q = SortConditionHelper.SortingAndPaging(q, Grid1.SortField, Grid1.SortDirection, Grid1.PageIndex, Grid1.PageSize);
|
|
return from x in q
|
|
select new
|
|
{
|
|
x.ContractTrackProgressId,
|
|
x.ContractTrackId,
|
|
x.BCWS_Quantity,
|
|
x.BCWS_OutputValue,
|
|
x.BCWS_Percentage,
|
|
x.ACWP_Quantity,
|
|
x.ACWP_OutputValue,
|
|
x.ACWP_Percentage,
|
|
x.Date
|
|
};
|
|
}
|
|
|
|
#endregion
|
|
|
|
public static PHTGL_ContractTrackProgress GetPHTGL_ContractTrackProgressById(string ContractTrackProgressId)
|
|
{
|
|
return Funs.DB.PHTGL_ContractTrackProgress.FirstOrDefault(x =>
|
|
x.ContractTrackProgressId == ContractTrackProgressId);
|
|
}
|
|
|
|
public static void CreateTemplateByContractTrackId(string ContractTrackId)
|
|
{
|
|
var model = PhtglContractTrackService.GetPHTGL_ContractTrackById(ContractTrackId);
|
|
if (model == null) return;
|
|
var contractNum=model.ContractNum;
|
|
var contractmode = ContractService.GetContractByContractNum(contractNum);
|
|
if (contractmode.ContractStartDate != null && contractmode.ContractEndDate != null)
|
|
{
|
|
var startDate = (DateTime)contractmode.ContractStartDate;
|
|
var endDate = (DateTime)contractmode.ContractEndDate;
|
|
List<DateTime> months = GetMonthsBetween(startDate, endDate);
|
|
|
|
foreach (DateTime month in months)
|
|
{
|
|
var querymodel = new Model.PHTGL_ContractTrackProgress
|
|
{
|
|
ContractTrackId = ContractTrackId,
|
|
Date= month.ToString("yyyy-MM")
|
|
};
|
|
if (!GetPHTGL_ContractTrackProgressByModle(querymodel).Any())
|
|
{
|
|
var newmodel = new Model.PHTGL_ContractTrackProgress();
|
|
newmodel.ContractTrackProgressId = SQLHelper.GetNewID(typeof(Model.PHTGL_ContractTrackProgress));
|
|
newmodel.ContractTrackId = ContractTrackId;
|
|
newmodel.Date = month.ToString("yyyy-MM");
|
|
AddPHTGL_ContractTrackProgress(newmodel);
|
|
}
|
|
//Console.WriteLine(month.ToString("yyyy-MM"));
|
|
}
|
|
}
|
|
}
|
|
public static List<DateTime> GetMonthsBetween(DateTime startDate, DateTime endDate)
|
|
{
|
|
List<DateTime> months = new List<DateTime>();
|
|
|
|
DateTime currentMonth = new DateTime(startDate.Year, startDate.Month, 1);
|
|
DateTime lastMonth = new DateTime(endDate.Year, endDate.Month, 1);
|
|
|
|
while (currentMonth <= lastMonth)
|
|
{
|
|
months.Add(currentMonth);
|
|
currentMonth = currentMonth.AddMonths(1);
|
|
}
|
|
|
|
return months;
|
|
}
|
|
public static void AddPHTGL_ContractTrackProgress(PHTGL_ContractTrackProgress newtable)
|
|
{
|
|
var table = new PHTGL_ContractTrackProgress
|
|
{
|
|
ContractTrackProgressId = newtable.ContractTrackProgressId,
|
|
ContractTrackId = newtable.ContractTrackId,
|
|
BCWS_Quantity = newtable.BCWS_Quantity,
|
|
BCWS_OutputValue = newtable.BCWS_OutputValue,
|
|
BCWS_Percentage = newtable.BCWS_Percentage,
|
|
ACWP_Quantity = newtable.ACWP_Quantity,
|
|
ACWP_OutputValue = newtable.ACWP_OutputValue,
|
|
ACWP_Percentage = newtable.ACWP_Percentage,
|
|
Date = newtable.Date
|
|
|
|
};
|
|
Funs.DB.PHTGL_ContractTrackProgress.InsertOnSubmit(table);
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
|
|
|
|
public static void UpdatePHTGL_ContractTrackProgress(PHTGL_ContractTrackProgress newtable)
|
|
{
|
|
var table = Funs.DB.PHTGL_ContractTrackProgress.FirstOrDefault(x =>
|
|
x.ContractTrackProgressId == newtable.ContractTrackProgressId);
|
|
if (table != null)
|
|
{
|
|
table.ContractTrackProgressId = newtable.ContractTrackProgressId;
|
|
table.ContractTrackId = newtable.ContractTrackId;
|
|
table.BCWS_Quantity = newtable.BCWS_Quantity;
|
|
table.BCWS_OutputValue = newtable.BCWS_OutputValue;
|
|
table.BCWS_Percentage = newtable.BCWS_Percentage;
|
|
table.ACWP_Quantity = newtable.ACWP_Quantity;
|
|
table.ACWP_OutputValue = newtable.ACWP_OutputValue;
|
|
table.ACWP_Percentage = newtable.ACWP_Percentage;
|
|
table.Date =newtable.Date;
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
}
|
|
|
|
public static void DeleteModleById(string ContractTrackProgressId)
|
|
{
|
|
var table = Funs.DB.PHTGL_ContractTrackProgress.FirstOrDefault(x =>
|
|
x.ContractTrackProgressId == ContractTrackProgressId);
|
|
if (table != null)
|
|
{
|
|
Funs.DB.PHTGL_ContractTrackProgress.DeleteOnSubmit(table);
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
}
|
|
public static void DeleteModleByContractTrackId(string ContractTrackId)
|
|
{
|
|
var table = Funs.DB.PHTGL_ContractTrackProgress.Where(x =>
|
|
x.ContractTrackId == ContractTrackId);
|
|
if (table != null)
|
|
{
|
|
Funs.DB.PHTGL_ContractTrackProgress.DeleteAllOnSubmit(table);
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
}
|
|
}
|
|
} |