tijian_tieying/web/dccdc.BLL/DiQu.cs
2025-02-20 12:14:39 +08:00

311 lines
9.3 KiB
C#

using dccdc.DAL;
using dccdc.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace dccdc.BLL
{
public class DiQu
{
DiQuDal cont = new DiQuDal();
public List<DQmodel> getDqModelList()
{
return cont.getDqModelList();
}
#region
public List<Sz_province> getShengList(int page, int pagesize)
{
//throw new NotImplementedException();
List<Sz_province> rd = cont.getSzprovince(page, pagesize);
return rd;
}
public List<Sz_province> getShengAllList()
{
return cont.getSzprovinceAllList();
}
public int getShengCount()
{
return cont.getSzprovinceCount();
}
public Sz_province getProvince(string code)
{
Sz_province provinceinfo = cont.getProvince(code);
return provinceinfo;
}
public DQmodel getDqModel(DQmodel model)
{
if (model != null)
{
switch (model.type)
{
case "P":
Sz_province province = this.getProvince(model.dqid);
break;
case "C":
break;
case "O":
break;
case "T":
break;
}
}
return null;
}
public object saveDqModel(DQmodel model)
{
var result = new Object();
if (model != null)
{
switch (model.type)
{
case "P":
Sz_province province = new Sz_province();
province.provinceCode = model.dqid;
province.provinceName = model.text;
result = cont.saveProvince(province);
break;
case "C":
Sz_city city = new Sz_city();
city.cityCode = model.dqid;
city.cityName = model.text;
city.provinceCode = model.pid;
result = cont.saveCity(city);
break;
case "O":
Sz_county county = new Sz_county();
county.countyCode = model.dqid;
county.countyName = model.text;
county.cityCode = model.pid;
result = cont.saveCounty(county);
break;
case "T":
Sz_town town = new Sz_town();
town.townCode = model.dqid;
town.townName = model.text;
town.countyCode = model.pid;
result = cont.saveTown(town);
break;
}
}
return result;
}
//public OperationResult delSheng(int id)
//{
// var s = cont.Szcity.Where(t => t.SzprovinceID == id).Any();
// if (s)
// {
// return new OperationResult { State = 0, Message = "你所要删除的省分已经使用不能删除!" };
// }
// var sf = cont.Szprovince.Where(t => t.id == id).FirstOrDefault();
// if (sf == null)
// {
// return new OperationResult { State = 0, Message = "你要删除的省份不存在!" };
// }
// cont.Szprovince.Remove(sf);
// try
// {
// cont.SaveChanges();
// return new OperationResult { State = 1, Message = "删除成功!" };
// }
// catch (Exception ex)
// {
// return new OperationResult { State = 0, Message = ex.Message };
// }
//}
public Sz_province getSzprovincebyCode(int code)
{
//throw new NotImplementedException();
return cont.getSzprovincebyCode(code);
}
public object saveProvince(Sz_province dtomodel)
{
return cont.saveProvince(dtomodel);
}
//public OperationResult saveProvince(Sz_province province)
//{
// //throw new NotImplementedException();
// if (province.provinceCode == 0)
// {
// cont.Szprovince.Add(sf);
// try
// {
// cont.SaveChanges();
// return new OperationResult { State = 1, Message = "添加成功!" };
// }
// catch (Exception ex)
// {
// return new OperationResult { State = 0, Message = ex.Message };
// }
// }
// else
// {
// var msf = cont.Szprovince.FirstOrDefault(t => t.id == sf.id);
// if (msf == null)
// {
// return new OperationResult { State = 0, Message = "你要修改的省份不存在!" };
// }
// else
// {
// msf.SzprovinceMingCheng = sf.SzprovinceMingCheng;
// try
// {
// cont.SaveChanges();
// return new OperationResult { State = 1, Message = "修改成功!" };
// }
// catch (Exception ex)
// {
// return new OperationResult { State = 0, Message = ex.Message };
// }
// }
// }
//}
#endregion
#region
public List<Sz_city> getSzcityList(int page, int pagesize)
{
//throw new NotImplementedException();
List<Sz_city> rd = cont.getSzcityList(page, pagesize);
return rd;
}
public int getShiCount()
{
return cont.getSzcityCount();
}
//public OperationResult delShi(int id)
//{
// var s = cont.DiQu.Where(t => t.SzcityID == id).Any();
// if (s)
// {
// return new OperationResult { State = 0, Message = "你所要删除的城市已经使用不能删除!" };
// }
// var sf = cont.Szcity.Where(t => t.id == id).FirstOrDefault();
// if (sf == null)
// {
// return new OperationResult { State = 0, Message = "你要删除的城市不存在!" };
// }
// cont.Szcity.Remove(sf);
// try
// {
// cont.SaveChanges();
// return new OperationResult { State = 1, Message = "删除成功!" };
// }
// catch (Exception ex)
// {
// return new OperationResult { State = 0, Message = ex.Message };
// }
//}
public Sz_city getSzcityBycityCode(string code)
{
return cont.getSzcityBycityCode(code);
}
public object saveCity(Sz_city sf)
{
return cont.saveCity(sf);
}
public List<Sz_city> getSzcityByShengID(int id)
{
return cont.getSzcityByShengID(id);
}
#endregion
#region
public List<Sz_county> getSzcountyList(int page, int pagesize)
{
//throw new NotImplementedException();
List<Sz_county> rd = cont.getSzcountyList(page, pagesize);
return rd;
}
public List<Sz_county> getSzcountyByShiID(int cityCode)
{
return cont.getSzcountyByShiID(cityCode);
}
public int getSzcountyCount()
{
return cont.getSzcountyCount();
}
//public OperationResult delQu(int id)
//{
// var s = cont.TiJianZhongXin.Where(t => t.SuoZaiQuYu == id).Any();
// if (s)
// {
// return new OperationResult { State = 0, Message = "你所要删除的区已经使用不能删除!" };
// }
// var sf = cont.DiQu.Where(t => t.id == id).FirstOrDefault();
// if (sf == null)
// {
// return new OperationResult { State = 0, Message = "你要删除的区不存在!" };
// }
// cont.DiQu.Remove(sf);
// try
// {
// cont.SaveChanges();
// return new OperationResult { State = 1, Message = "删除成功!" };
// }
// catch (Exception ex)
// {
// return new OperationResult { State = 0, Message = ex.Message };
// }
//}
public Sz_county getSzcounty(string countyCode)
{
//throw new NotImplementedException();
Sz_county county = cont.getSzcounty(countyCode);
return county;
}
public object saveCounty(Sz_county sf)
{
return cont.saveCounty(sf);
}
#endregion
public Sz_town getTown(int towncode)
{
throw new NotImplementedException();
}
public object saveTown(Sz_town town)
{
return cont.saveTown(town);
}
}
}