163 lines
6.1 KiB
C#
163 lines
6.1 KiB
C#
using FineUIPro;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
|
|
namespace BLL
|
|
{
|
|
|
|
public static class PhtglInvoicedetailService
|
|
{
|
|
|
|
|
|
|
|
#region 获取列表
|
|
/// <summary>
|
|
/// 记录数
|
|
/// </summary>
|
|
public static int Count
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
public static IEnumerable<Model.PHTGL_InvoiceDetail> GetPHTGL_InvoiceDetailByModle(Model.PHTGL_InvoiceDetail table)
|
|
{
|
|
var q = from x in Funs.DB.PHTGL_InvoiceDetail
|
|
where
|
|
(string.IsNullOrEmpty(table.InvoiceDetailId) || x.InvoiceDetailId.Contains(table.InvoiceDetailId)) &&
|
|
(string.IsNullOrEmpty(table.InvoiceId) || x.InvoiceId.Contains(table.InvoiceId)) &&
|
|
(string.IsNullOrEmpty(table.GoodsOrServicesName) || x.GoodsOrServicesName.Contains(table.GoodsOrServicesName)) &&
|
|
(string.IsNullOrEmpty(table.SpecificationModel) || x.SpecificationModel.Contains(table.SpecificationModel)) &&
|
|
(string.IsNullOrEmpty(table.Unit) || x.Unit.Contains(table.Unit)) &&
|
|
(string.IsNullOrEmpty(table.TaxRate) || x.TaxRate.Contains(table.TaxRate))
|
|
select x
|
|
;
|
|
|
|
return q.ToList();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取分页列表
|
|
/// </summary>
|
|
/// <param name="table"></param>
|
|
/// <param name="grid1"></param>
|
|
/// <returns></returns>
|
|
public static IEnumerable GetListData(Model.PHTGL_InvoiceDetail table, Grid grid1)
|
|
{
|
|
var q = GetPHTGL_InvoiceDetailByModle(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.InvoiceDetailId,
|
|
x.InvoiceId,
|
|
x.GoodsOrServicesName,
|
|
x.SpecificationModel,
|
|
x.Unit,
|
|
x.Quantity,
|
|
x.UnitPrice,
|
|
x.Amount,
|
|
x.TaxRate,
|
|
x.Tax,
|
|
|
|
};
|
|
}
|
|
#endregion
|
|
|
|
public static Model.PHTGL_InvoiceDetail GetPHTGL_InvoiceDetailById(string InvoiceDetailId)
|
|
{
|
|
return Funs.DB.PHTGL_InvoiceDetail.FirstOrDefault(x => x.InvoiceDetailId == InvoiceDetailId);
|
|
}
|
|
public static List<Model.PHTGL_InvoiceDetail> GetPHTGL_InvoiceDetailByInvoiceId(string InvoiceId)
|
|
{
|
|
var list = Funs.DB.PHTGL_InvoiceDetail.Where(x => x.InvoiceId == InvoiceId).ToList();
|
|
return list;
|
|
}
|
|
public static void AddPHTGL_InvoiceDetail(Model.PHTGL_InvoiceDetail newtable)
|
|
{
|
|
if (string.IsNullOrEmpty(newtable.InvoiceDetailId))
|
|
{
|
|
newtable.InvoiceDetailId = SQLHelper.GetNewID();
|
|
}
|
|
Model.PHTGL_InvoiceDetail table = new Model.PHTGL_InvoiceDetail
|
|
{
|
|
InvoiceDetailId = newtable.InvoiceDetailId,
|
|
InvoiceId = newtable.InvoiceId,
|
|
GoodsOrServicesName = newtable.GoodsOrServicesName,
|
|
SpecificationModel = newtable.SpecificationModel,
|
|
Unit = newtable.Unit,
|
|
Quantity = newtable.Quantity,
|
|
UnitPrice = newtable.UnitPrice,
|
|
Amount = newtable.Amount,
|
|
TaxRate = newtable.TaxRate,
|
|
Tax = newtable.Tax,
|
|
};
|
|
Funs.DB.PHTGL_InvoiceDetail.InsertOnSubmit(table);
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
public static void UpdatePHTGL_InvoiceDetail(Model.PHTGL_InvoiceDetail newtable)
|
|
{
|
|
|
|
Model.PHTGL_InvoiceDetail table = Funs.DB.PHTGL_InvoiceDetail.FirstOrDefault(x => x.InvoiceDetailId == newtable.InvoiceDetailId);
|
|
if (table != null)
|
|
{
|
|
table.InvoiceDetailId = newtable.InvoiceDetailId;
|
|
table.InvoiceId = newtable.InvoiceId;
|
|
table.GoodsOrServicesName = newtable.GoodsOrServicesName;
|
|
table.SpecificationModel = newtable.SpecificationModel;
|
|
table.Unit = newtable.Unit;
|
|
table.Quantity = newtable.Quantity;
|
|
table.UnitPrice = newtable.UnitPrice;
|
|
table.Amount = newtable.Amount;
|
|
table.TaxRate = newtable.TaxRate;
|
|
table.Tax = newtable.Tax;
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
|
|
}
|
|
public static void DeletePHTGL_InvoiceDetailById(string InvoiceDetailId)
|
|
{
|
|
|
|
Model.PHTGL_InvoiceDetail table = Funs.DB.PHTGL_InvoiceDetail.FirstOrDefault(x => x.InvoiceDetailId == InvoiceDetailId);
|
|
if (table != null)
|
|
{
|
|
Funs.DB.PHTGL_InvoiceDetail.DeleteOnSubmit(table);
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
|
|
}
|
|
|
|
public static void DeletePHTGL_InvoiceDetailByInvoiceId(string InvoiceId)
|
|
{
|
|
var list = Funs.DB.PHTGL_InvoiceDetail.Where(x => x.InvoiceId == InvoiceId);
|
|
if (list != null)
|
|
{
|
|
Funs.DB.PHTGL_InvoiceDetail.DeleteAllOnSubmit(list);
|
|
Funs.DB.SubmitChanges();
|
|
}
|
|
|
|
}
|
|
public static void BatchAddPHTGL_InvoiveDetail(IEnumerable<Model.PHTGL_InvoiceDetail> list, string invoiceId)
|
|
{
|
|
foreach (var item in list)
|
|
{
|
|
item.InvoiceId = invoiceId;
|
|
AddPHTGL_InvoiceDetail(item);
|
|
}
|
|
}
|
|
public static void BatchAddPHTGL_InvoiveDetail(IEnumerable<Model.PHTGL_InvoiceDetail> list)
|
|
{
|
|
foreach (var item in list)
|
|
{
|
|
AddPHTGL_InvoiceDetail(item);
|
|
}
|
|
}
|
|
}
|
|
} |