using NFine.Code; using NFine.Data.Extensions; using NFine.Domain.Entity.ProductManage; using NFine.Domain.IRepository.ProductManage; using NFine.Repository.ProductManage; using System; using System.Collections.Generic; using System.Data; using System.Linq; namespace NFine.Application.ProductManage { public class DiscountRateApp { private IICSDiscountRateRepository service = new DiscountRateRepository(); public List GetList(Pagination pagination, string queryJson) { var expression = ExtLinq.True(); var queryParam = queryJson.ToJObject(); if (!queryParam["keyword"].IsEmpty()) { string keyword = queryParam["keyword"].ToString(); expression = expression.And(t => t.CusCode.Contains(keyword)); } expression = expression.And(t => t.CusCode != "RapaPort"); return service.FindList(expression, pagination).OrderBy(t => t.CusCode).ThenBy(t => t.WHType) .ThenBy(t => t.StartValue).ToList(); } public DataTable GetListForCustomer() { DataTable dt = new DataTable(); string sql = @"SELECT F_CusCode,F_CusName FROM Sys_Customer WHERE F_CusCode NOT IN (SELECT DISTINCT CusCode FROM ICSDiscountRate WHERE CusCode <> 'RapaPort')"; dt = SqlHelper.GetDataTableBySql(sql); if (dt == null || dt.Rows.Count <= 0) throw new Exception("No exportable data."); return dt; } public List GetList2(Pagination pagination, string queryJson) { var expression = ExtLinq.True(); var queryParam = queryJson.ToJObject(); if (!queryParam["keyword"].IsEmpty()) { string keyword = queryParam["keyword"].ToString(); expression = expression.And(t => t.CusCode.Contains(keyword)); } expression = expression.And(t => t.CusCode == "RapaPort"); return service.FindList(expression, pagination).OrderBy(t => t.CusCode).ThenBy(t => t.WHType) .ThenBy(t => t.StartValue).ToList(); } public ICSDiscountRateEntity GetForm(string keyValue) { return service.FindEntity(keyValue); } public void DeleteForm(string keyValue) { ICSDiscountRateEntity entity = service.FindEntity(t => t.F_Id == keyValue); service.Delete(t => t.CusCode == entity.CusCode); //service.Delete(t => t.F_Id == keyValue); } public void SubmitForm(ICSDiscountRateEntity productEntity, string keyValue) { if (!string.IsNullOrEmpty(keyValue)) { productEntity.Modify(keyValue); service.Update(productEntity); } else { productEntity.Create(); service.Insert(productEntity); } } public void SubmitForm(List discountrateListEntity, string keyValue) { foreach (ICSDiscountRateEntity discountrateEntity in discountrateListEntity) { if (!string.IsNullOrEmpty(keyValue)) { discountrateEntity.Modify(keyValue); service.Update(discountrateEntity); } else { discountrateEntity.Create(); service.Insert(discountrateEntity); } } } } }