| | |
| | | } |
| | | |
| | | |
| | | public List<CustomerDto> GetCustomerList(string no,string name, int? type, string linkMan, string phone, int page, int limit, out int count) |
| | | public async Task<List<CustomerDto>> GetCustomerList(string no, string name, int? type, string linkMan, string phone, int page, int limit, RefAsync<int> count) |
| | | { |
| | | try |
| | | { |
| | |
| | | .AndIF(!string.IsNullOrWhiteSpace(phone), it => it.Phone.Contains(phone.Trim())) |
| | | .ToExpression();//注意 这一句 不能少 |
| | | |
| | | var data = CustomerRst.GetAllByOrderPageAsync(item, limit, page, out int counts) |
| | | var data = await CustomerRst.GetAllByOrderPage(item, limit, page, out int counts) |
| | | .Includes(x => x.CreateUserInfo) |
| | | .Includes(x => x.UpdateUserInfo) |
| | | .ToList(); |
| | | .ToListAsync(); |
| | | count = counts; |
| | | |
| | | return data.Select(m => new CustomerDto() |
| | |
| | | } |
| | | } |
| | | |
| | | public SysCustomer GetCustomer(int id) |
| | | public async Task<SysCustomer> GetCustomer(int id) |
| | | { |
| | | try |
| | | { |
| | | var data = CustomerRst.GetOneById(id); |
| | | var data = await CustomerRst.GetOneByIdAsync(id); |
| | | return data; |
| | | } |
| | | catch (Exception e) |
| | |
| | | } |
| | | } |
| | | |
| | | public List<SysCustomer> GetCustomerSelect() |
| | | public async Task<List<SysCustomer>> GetCustomerSelect() |
| | | { |
| | | try |
| | | { |
| | | var data = CustomerRst.GetAllAsync().ToList(); |
| | | var data = await CustomerRst.GetAllAsync(); |
| | | return data; |
| | | } |
| | | catch (Exception e) |
| | |
| | | } |
| | | } |
| | | |
| | | public bool AddCustomer(string no, string name, int type, string address, string linkMan, string phone, string bankAccount, string creditRating, string demo, int userId) |
| | | public async Task<bool> AddCustomer(string no, string name, int type, string address, string linkMan, string phone, string bankAccount, string creditRating, string demo, int userId) |
| | | { |
| | | try |
| | | { |
| | | //判断是否重复 |
| | | var customer = CustomerRst.GetAllWhereAsync(m => m.CustomerNo == no && m.IsDel == "0").First(); |
| | | var customer = CustomerRst.GetAllWhere(m => m.CustomerNo == no && m.IsDel == "0").First(); |
| | | if (customer != null) |
| | | { |
| | | throw new Exception("相同编码的客户已存在,请勿重复添加"); |
| | | } |
| | | var num = CustomerRst.Add(new SysCustomer() |
| | | var num = await CustomerRst.AddAsync(new SysCustomer() |
| | | { |
| | | CustomerNo = no, |
| | | CustomerName = name, |
| | |
| | | } |
| | | } |
| | | |
| | | public bool EditCustomer(int id, string no, string name, int type, string address, string linkMan, string phone, |
| | | public async Task<bool> EditCustomer(int id, string no, string name, int type, string address, string linkMan, string phone, |
| | | string bankAccount, string creditRating, string demo, int userId) |
| | | { |
| | | try |
| | | { |
| | | var customer = CustomerRst.GetOneById(id); |
| | | var customer = await CustomerRst.GetOneByIdAsync(id); |
| | | if (customer == null) |
| | | { |
| | | throw new Exception("未查询到客户信息"); |
| | |
| | | customer.Demo = demo; |
| | | customer.UpdateUser = userId; |
| | | customer.UpdateTime = DateTime.Now; |
| | | var num = CustomerRst.Edit(customer); |
| | | var num = await CustomerRst.EditAsync(customer); |
| | | return num > 0; |
| | | } |
| | | catch (Exception e) |
| | |
| | | } |
| | | } |
| | | |
| | | public bool DelCustomer(int id, int userId) |
| | | public async Task<bool> DelCustomer(int id, int userId) |
| | | { |
| | | try |
| | | { |
| | | var num = CustomerRst.Remove(id, userId); |
| | | var num = await CustomerRst.RemoveAsync(id, userId); |
| | | return num > 0; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new Exception(e.Message); |
| | | } |
| | | } |
| | | |
| | | public bool DelsCustomer(List<int> ids, int userId) |
| | | public async Task<bool> DelsCustomer(List<int> ids, int userId) |
| | | { |
| | | try |
| | | { |
| | | var list = CustomerRst.GetAllWhereAsync(m => ids.Contains(m.Id)).ToList(); |
| | | var list = await CustomerRst.GetAllWhere(m => ids.Contains(m.Id)).ToListAsync(); |
| | | for (int i = 0; i < list.Count; i++) |
| | | { |
| | | _operation.InsertOperation("基础信息", "客户管理", list[i].CustomerNo, "删除", "删除客户信息 客户号:" + list[i].CustomerNo, userId); |
| | | await _operation.InsertOperation("基础信息", "客户管理", list[i].CustomerNo, "删除", "删除客户信息 客户号:" + list[i].CustomerNo, userId); |
| | | } |
| | | var num = CustomerRst.RemoveAll(list, userId); |
| | | var num = await CustomerRst.RemoveAllAsync(list, userId); |
| | | return num > 0; |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | throw new Exception(e.Message); |
| | | } |
| | | } |
| | | } |
| | | } |