using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace BLL
{
///
/// 税率
///
public class TaxRateService
{
///
/// 根据主键获取税率信息
///
///
///
public static Model.Base_TaxRate GetTaxRateById(string taxRateId)
{
return Funs.DB.Base_TaxRate.FirstOrDefault(e => e.TaxRateId == taxRateId);
}
///
/// 添加税率信息
///
///
public static void AddTaxRate(Model.Base_TaxRate taxRate)
{
Model.Base_TaxRate newTaxRate = new Model.Base_TaxRate();
newTaxRate.TaxRateId = taxRate.TaxRateId;
newTaxRate.TaxRate = taxRate.TaxRate;
newTaxRate.Remarks = taxRate.Remarks;
Funs.DB.Base_TaxRate.InsertOnSubmit(newTaxRate);
Funs.DB.SubmitChanges();
}
///
/// 修改税率信息
///
///
public static void UpdateTaxRate(Model.Base_TaxRate taxRate)
{
Model.Base_TaxRate newTaxRate = Funs.DB.Base_TaxRate.FirstOrDefault(e => e.TaxRateId == taxRate.TaxRateId);
if (newTaxRate!=null)
{
newTaxRate.TaxRate = taxRate.TaxRate;
newTaxRate.Remarks = taxRate.Remarks;
Funs.DB.SubmitChanges();
}
}
///
/// 根据主键删除税率信息
///
///
public static void DeleteTaxRateById(string taxRateId)
{
Model.Base_TaxRate taxRate = Funs.DB.Base_TaxRate.FirstOrDefault(e => e.TaxRateId == taxRateId);
if (taxRate!=null)
{
Funs.DB.Base_TaxRate.DeleteOnSubmit(taxRate);
Funs.DB.SubmitChanges();
}
}
///
/// 验证是否存在相同的税率
///
///
///
///
public static bool IsExitTaxRate(string taxRate, string id)
{
var q = Funs.DB.Base_TaxRate.FirstOrDefault(x => x.TaxRate == Funs.GetNewDecimalOrZero(taxRate) && x.TaxRateId != id);
if (q != null)
{
return true;
}
else
{
return false;
}
}
}
}