2023-08-23
This commit is contained in:
@@ -0,0 +1,119 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using FineUIPro;
|
||||
using Model;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
public static class PHTGL_MainProjectQuantityService
|
||||
{
|
||||
public static PHTGL_MainProjectQuantity GetPHTGL_MainProjectQuantityById(string MainProjectQuantityId)
|
||||
{
|
||||
return Funs.DB.PHTGL_MainProjectQuantity.FirstOrDefault(x =>
|
||||
x.MainProjectQuantityId == MainProjectQuantityId);
|
||||
}
|
||||
|
||||
|
||||
public static void AddPHTGL_MainProjectQuantity(PHTGL_MainProjectQuantity newtable)
|
||||
{
|
||||
var table = new PHTGL_MainProjectQuantity
|
||||
{
|
||||
MainProjectQuantityId = newtable.MainProjectQuantityId,
|
||||
MainProjectQuantityCode = newtable.MainProjectQuantityCode,
|
||||
MainProjectQuantityName = newtable.MainProjectQuantityName,
|
||||
QuantityId = newtable.QuantityId
|
||||
};
|
||||
Funs.DB.PHTGL_MainProjectQuantity.InsertOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
|
||||
public static void UpdatePHTGL_MainProjectQuantity(PHTGL_MainProjectQuantity newtable)
|
||||
{
|
||||
var table = Funs.DB.PHTGL_MainProjectQuantity.FirstOrDefault(x =>
|
||||
x.MainProjectQuantityId == newtable.MainProjectQuantityId);
|
||||
if (table != null)
|
||||
{
|
||||
table.MainProjectQuantityId = newtable.MainProjectQuantityId;
|
||||
table.MainProjectQuantityCode = newtable.MainProjectQuantityCode;
|
||||
table.MainProjectQuantityName = newtable.MainProjectQuantityName;
|
||||
table.QuantityId = newtable.QuantityId;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeleteById(string MainProjectQuantityId)
|
||||
{
|
||||
var table = Funs.DB.PHTGL_MainProjectQuantity.FirstOrDefault(x =>
|
||||
x.MainProjectQuantityId == MainProjectQuantityId);
|
||||
if (table != null)
|
||||
{
|
||||
Funs.DB.PHTGL_MainProjectQuantity.DeleteOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public static void DeleteByBidProjectQuantityId(string bidProjectQuantityId)
|
||||
{
|
||||
var table = Funs.DB.PHTGL_MainProjectQuantity.Where(x =>
|
||||
x.QuantityId == bidProjectQuantityId);
|
||||
if (table.Any())
|
||||
{
|
||||
foreach (var item in table)
|
||||
PHTGL_QuantityService.DeletePHTGL_QuantityByParentId(item.MainProjectQuantityId);
|
||||
Funs.DB.PHTGL_MainProjectQuantity.DeleteAllOnSubmit(table);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
#region 获取列表
|
||||
|
||||
/// <summary>
|
||||
/// 记录数
|
||||
/// </summary>
|
||||
public static int count { get; set; }
|
||||
|
||||
public static List<PHTGL_MainProjectQuantity> GetPHTGL_MainProjectQuantityByModle(
|
||||
PHTGL_MainProjectQuantity table)
|
||||
{
|
||||
var q = from x in Funs.DB.PHTGL_MainProjectQuantity
|
||||
where
|
||||
(string.IsNullOrEmpty(table.MainProjectQuantityId) ||
|
||||
x.MainProjectQuantityId.Contains(table.MainProjectQuantityId)) &&
|
||||
(string.IsNullOrEmpty(table.MainProjectQuantityCode) ||
|
||||
x.MainProjectQuantityCode.Contains(table.MainProjectQuantityCode)) &&
|
||||
(string.IsNullOrEmpty(table.MainProjectQuantityName) ||
|
||||
x.MainProjectQuantityName.Contains(table.MainProjectQuantityName)) &&
|
||||
(string.IsNullOrEmpty(table.QuantityId) || x.QuantityId.Contains(table.QuantityId))
|
||||
select x
|
||||
;
|
||||
|
||||
return q.ToList();
|
||||
}
|
||||
|
||||
/// 获取分页列表
|
||||
/// </summary>
|
||||
/// <param name="PageIndex">页码</param>
|
||||
/// <param name="PageSize">每页数量</param>
|
||||
/// <returns></returns>
|
||||
public static IEnumerable getListData(PHTGL_MainProjectQuantity table, Grid Grid1)
|
||||
{
|
||||
var q = GetPHTGL_MainProjectQuantityByModle(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.MainProjectQuantityId,
|
||||
x.MainProjectQuantityCode,
|
||||
x.MainProjectQuantityName,
|
||||
x.QuantityId
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user