123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- using Ant.Service.Common;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- using MES.Production.Service.IService;
- using ChangFa.Machinery.WebPage.Controllers;
- using Ant.ORM;
- using Ant.Data;
- using MES.Production.Entity;
- using JsonHelper = Ant.Service.Common.JsonHelper;
- namespace ChangFa.Machinery.WebPage.Areas.SysManage.Controllers
- {
- /// <summary>
- /// 省市县镇级联控制器
- /// add 作者: 季健国 QQ:181589805 by 2016-06-16
- /// </summary>
- public class CodeAreaController : BaseController
- {
- ICodeAreaManage CodeAreaManage { get; set; }
- /// <summary>
- /// 获取省份
- /// </summary>
- public ActionResult Prov()
- {
- var json = new JsonHelper() { Status = "y", Msg = "Success" };
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取公告信息" }
- };
- var reslut = orm.Queryable<BaseProvince>().Where(p => p.Id > 0).ToList(res);
- if (reslut.IsSuccess)
- {
- var data = reslut.ResultModel;
- json.Data = JsonConverter.Serialize(data);
- }
- }
- return Json(json);
- }
- /// <summary>
- /// 根据省份获取城市信息
- /// </summary>
- /// <param name="id">省份ID</param>
- /// <returns></returns>
- public ActionResult City(string id)
- {
- var json = new JsonHelper() { Status = "y", Msg = "Success" };
- if (string.IsNullOrEmpty(id))
- {
- json.Msg = "Error";
- json.Status = "n";
- }
- else
- {
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取公告信息" }
- };
- var reslut = orm.Queryable<BaseArea>().Where(p => p.ParentCode == id).ToList(res);
- if (reslut.IsSuccess)
- {
- var data = reslut.ResultModel;
- json.Data = JsonConverter.Serialize(data);
- }
- }
- }
- return Json(json);
- }
- /// <summary>
- /// 根据城市获取县级市信息
- /// </summary>
- /// <param name="id">城市ID</param>
- /// <returns></returns>
- public ActionResult Country(string id)
- {
- var json = new JsonHelper() { Status = "y", Msg = "Success" };
- if (string.IsNullOrEmpty(id))
- {
- json.Msg = "Error";
- json.Status = "n";
- }
- else
- {
- using (AntORM orm = new AntORM())
- {
- orm.db = DataAccessFactory.CreateDataConnection("CyclingItem");
- RequestModel res = new RequestModel
- {
- newSt = new SqlNote() { Author = "季健国", NewSt = new System.Diagnostics.StackTrace(true), SqlDesc = "获取公告信息" }
- };
- var reslut = orm.Queryable<BaseArea>().Where(p => p.ParentCode == id).ToList(res);
- if (reslut.IsSuccess)
- {
- var data = reslut.ResultModel;
- json.Data = JsonConverter.Serialize(data);
- }
- }
- }
- return Json(json);
- }
- }
- }
|