ZhiYeJianKang_PeiXun/Song.ServiceImpls/ProductCom/ProductMaterial.cs
2025-02-20 15:41:53 +08:00

99 lines
3.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using WeiSha.Common;
using Song.Entities;
using WeiSha.Data;
using Song.ServiceInterfaces;
using System.Resources;
using System.Reflection;
namespace Song.ServiceImpls
{
public partial class ProductCom : IProduct
{
/// <summary>
/// 新增
/// </summary>
/// <param name="entity"></param>
public void MaterialAdd(ProductMaterial entity)
{
Song.Entities.Organization org = Business.Do<IOrganization>().OrganCurrent();
if (org != null)
{
entity.Org_ID = org.Org_ID;
entity.Org_Name = org.Org_Name;
}
Gateway.Default.Save<ProductMaterial>(entity);
}
/// <summary>
/// 修改
/// </summary>
/// <param name="entity">业务实体</param>
public void MaterialSave(ProductMaterial entity)
{
Gateway.Default.Save<ProductMaterial>(entity);
}
/// <summary>
/// 删除按主键ID
/// </summary>
/// <param name="identify">实体的主键</param>
public void MaterialDelete(int identify)
{
Gateway.Default.Delete<ProductMaterial>(ProductMaterial._.Pmat_Id == identify);
}
/// <summary>
/// 获取单一实体对象按主键ID
/// </summary>
/// <param name="identify">实体的主键</param>
/// <returns></returns>
public ProductMaterial MaterialSingle(int identify)
{
return Gateway.Default.From<ProductMaterial>().Where(ProductMaterial._.Pmat_Id == identify).ToFirst<ProductMaterial>();
}
/// <summary>
/// 获取所有
/// </summary>
/// <param name="isUse"></param>
/// <returns></returns>
public ProductMaterial[] MaterialAll(bool? isUse)
{
WhereClip wc = ProductMaterial._.Pmat_Id > 0;
if (isUse != null)
{
wc.And(ProductMaterial._.Pmat_IsUse == isUse);
}
return Gateway.Default.From<ProductMaterial>().Where(wc).OrderBy(ProductMaterial._.Pmat_Id.Desc).ToArray<ProductMaterial>();
}
/// <summary>
/// 分页获取材质信息
/// </summary>
/// <param name="isUse"></param>
/// <param name="searTxt"></param>
/// <param name="size"></param>
/// <param name="index"></param>
/// <param name="countSum"></param>
/// <returns></returns>
public ProductMaterial[] MaterialPager(bool? isUse, string searTxt, int size, int index, out int countSum)
{
WhereClip wc = ProductMaterial._.Pmat_Id > 0;
if (isUse != null)
{
wc.And(ProductMaterial._.Pmat_IsUse == isUse);
}
if (searTxt != null && searTxt.Trim() != "")
{
wc.And(ProductMaterial._.Pmat_Name.Like("%" + searTxt + "%"));
}
countSum = Gateway.Default.Count<ProductMaterial>(wc);
return Gateway.Default.From<ProductMaterial>().Where(wc).OrderBy(ProductMaterial._.Pmat_Id.Desc).ToArray<ProductMaterial>(size, (index - 1) * size);
}
}
}