57 lines
1.7 KiB
C#
57 lines
1.7 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using WX.CRM.IBLL.Base;
|
|
using WX.CRM.Model.Entity;
|
|
|
|
namespace WX.CRM.BLL.Base
|
|
{
|
|
public class BAS_CITY_BL : IBAS_CITY_Q
|
|
{
|
|
public List<BAS_CITY> GetListByProvince(int id)
|
|
{
|
|
using (var db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
return db.BAS_CITY.Where(p => p.PROVINCEID == id).ToList<BAS_CITY>();
|
|
}
|
|
}
|
|
|
|
|
|
public BAS_CITY GetCity(decimal id)
|
|
{
|
|
using (var db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
return db.BAS_CITY.FirstOrDefault(p => p.ID == id);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取省地址
|
|
/// </summary>
|
|
/// <param name="pid"></param>
|
|
/// <param name="cid"></param>
|
|
/// <returns></returns>
|
|
public string GetAddressStr(decimal? pid, decimal? cid)
|
|
{
|
|
if ((!pid.HasValue || pid.Value == 0) && (!cid.HasValue || cid.Value == 0))
|
|
return "";
|
|
using (var db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
string str = "";
|
|
if (pid.HasValue && pid.Value != 0)
|
|
{
|
|
var provice = db.BAS_PROVINCE.FirstOrDefault(m => m.ID == pid);
|
|
if (provice != null)
|
|
str += provice.NAME;
|
|
}
|
|
if (cid.HasValue && cid.Value != 0)
|
|
{
|
|
var ctity = db.BAS_CITY.FirstOrDefault(m => m.ID == cid);
|
|
if (ctity != null)
|
|
str += ctity.NAME;
|
|
}
|
|
return str;
|
|
}
|
|
}
|
|
}
|
|
}
|