| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326 |
- using CallCenterApi.Common;
- using CallCenterApi.DB;
- using CallCenterApi.Interface.App_Start;
- using CallCenterApi.Interface.Controllers.Base;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Web;
- using System.Web.Mvc;
- namespace CallCenterApi.Interface.Controllers.County
- {
- public class CountyBranchController : BaseController
- {
- // GET: CountyBranch
- private BLL.T_Branch_List branchBLL = new BLL.T_Branch_List();
- #region 网点
- /// <summary>
- /// 获取所有网点
- /// </summary>
- /// <returns></returns>
- [OutActionFilter]
- public ActionResult GetCityList(string code,string name)
- {
- string sql = " F_IsDelete=0 ";
- if (!string.IsNullOrEmpty(code))
- {
- sql += " and F_Code like '%" + code + "%' ";
- }
- if (!string.IsNullOrEmpty(name))
- {
- sql += " and F_Name like '%" + name + "%' ";
- }
- DataTable dt = branchBLL.GetList(sql).Tables[0];
- return Success("成功", dt);
- }
- /// <summary>
- /// 获取详情
- /// </summary>
- /// <param name="code"></param>
- /// <returns></returns>
- [OutActionFilter]
- public ActionResult GetCityDetail(string code)
- {
- string sql = " F_IsDelete=0 ";
- if (!string.IsNullOrEmpty(code))
- {
- sql += " and F_Code = '" + code + "' ";
- }
- var model = branchBLL.GetModelList(sql).FirstOrDefault();
- return Success("成功", model);
- }
- /// <summary>
- /// 获取网点列表
- /// </summary>
- /// <returns></returns>
- [Authority]
- public ActionResult GetList(int isdc = 0)
- {
- Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(User.UserData["F_UserCode"]);
- DataTable dt = new DataTable();
- string sql = " and F_IsDelete=0 ";
- string strcode = HttpUtility.UrlDecode(RequestString.GetQueryString("code"));
- string strname = HttpUtility.UrlDecode(RequestString.GetQueryString("name"));
- string strpageindex = RequestString.GetQueryString("page");
- int pageindex = 1;
- string strpagesize = RequestString.GetQueryString("pagesize");
- int pagesize = 10;
- if (strcode.Trim() != "" && strcode != "undefined")
- {
- sql += " and F_Code like '%" + strcode + "%' ";
- }
- if (strname.Trim() != "" && strname != "undefined")
- {
- sql += " and F_Name like '%" + strname + "%' ";
- }
- if (strpageindex.Trim() != "")
- {
- pageindex = Convert.ToInt32(strpageindex);
- }
- if (strpagesize.Trim() != "")
- {
- pagesize = Convert.ToInt32(strpagesize);
- }
- string cols = "*,dbo.GetUserName(F_CreateUser) as UserName";
- if (isdc > 0)
- {
- var dtdc = DbHelperSQL.Query(" select " + cols + " from T_Branch_List where 1=1 " + sql).Tables[0];
- var msg = new NPOIHelper().ExportToExcel("网点列表", dtdc);
- if (msg == "")
- {
- return Success("导出成功");
- }
- else
- {
- return Error("导出失败");
- }
- }
- int recordCount = 0;
- dt = BLL.PagerBLL.GetListPager(
- "T_Branch_List",
- "F_Id",
- cols,
- sql,
- "ORDER BY F_CreateTime DESC",
- pagesize,
- pageindex,
- true,
- out recordCount);
- var obj = new
- {
- state = "success",
- message = "成功",
- rows = dt,
- total = recordCount
- };
- return Content(obj.ToJson());
- }
- /// <summary>
- /// 获取网点列表
- /// </summary>
- /// <returns></returns>
- [Authority]
- public ActionResult GetBranchList()
- {
- DataTable dt = branchBLL.GetList(" F_IsDelete=0 ").Tables[0];
- return Success("加载成功", dt);
- }
- /// <summary>
- /// 获取网点
- /// </summary>
- /// <param name="BranchId"></param>
- /// <returns></returns>
- [Authority]
- public ActionResult GetBranch()
- {
- int id = RequestString.GetInt("id", 0);
- Model.T_Branch_List dModel = branchBLL.GetModel(id);
- if (dModel != null)
- return Success("获取信息成功", dModel);
- return Error("获取信息失败");
- }
- /// <summary>
- /// 添加网点
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [HttpPost]
- [Authority]
- public ActionResult AddBranch()
- {
- Model.T_Sys_UserAccount userModel = new BLL.T_Sys_UserAccount().GetModel(User.UserData["F_UserCode"]);
- int id = RequestString.GetInt("id", 0);
- string code = RequestString.GetFormString("code");
- string name = RequestString.GetFormString("name");
- string pwd = RequestString.GetFormString("pwd");
- string address = RequestString.GetFormString("address");
- string conname = RequestString.GetFormString("conname");
- string conphone = RequestString.GetFormString("conphone");
- string contel = RequestString.GetFormString("contel");
- string conemail = RequestString.GetFormString("conemail");
- string url = RequestString.GetFormString("url");
- string sign = RequestString.GetFormString("sign");
- string wsurl = RequestString.GetFormString("wsurl");
- string phone = RequestString.GetFormString("phone");
- Model.T_Branch_List dModel = new Model.T_Branch_List();
- if (id == 0)
- {
- var list = branchBLL.GetModelList(" F_Name='" + name + "' ");
- if (list.Count > 0)
- {
- return Error("已经存在此网点");
- }
- else
- {
- dModel.F_Code = code;
- dModel.F_Name = name;
- dModel.F_Password = pwd;
- dModel.F_Address = address;
- dModel.F_ConName = conname;
- dModel.F_ConPhone = conphone;
- dModel.F_ConTel = contel;
- dModel.F_ConEmail = conemail;
- dModel.F_Url = url;
- dModel.F_Sign = sign;
- dModel.F_WebSocketUrl = wsurl;
- dModel.F_Phone = phone;
- dModel.F_IsDelete = 0;
- dModel.F_State = 0;
- dModel.F_CreateUser = userModel.F_UserCode;
- dModel.F_CreateTime = DateTime.Now;
- int n = branchBLL.Add(dModel);
- if (n > 0)
- return Success("添加成功", n);
- else
- return Error("添加失败");
- }
- }
- else
- {
- dModel = branchBLL.GetModel(id);
- if (dModel != null)
- {
- var list = branchBLL.GetModelList(" F_Name='" + name + "' and F_Id!='" + id + "' ");
- if (list.Count > 0)
- {
- return Error("已经存在此网点");
- }
- else
- {
- dModel.F_Code = code;
- dModel.F_Name = name;
- dModel.F_Password = pwd;
- dModel.F_Address = address;
- dModel.F_ConName = conname;
- dModel.F_ConPhone = conphone;
- dModel.F_ConTel = contel;
- dModel.F_ConEmail = conemail;
- dModel.F_Url = url;
- dModel.F_Sign = sign;
- dModel.F_WebSocketUrl = wsurl;
- dModel.F_Phone = phone;
- if (branchBLL.Update(dModel))
- return Success("修改成功");
- else
- return Error("修改失败");
- }
- }
- else
- {
- return Error("修改失败");
- }
- }
- }
- /// <summary>
- /// 删除网点
- /// </summary>
- /// <param name="ids"></param>
- /// <returns></returns>
- [Authority]
- public ActionResult DelBranch(string[] ids)
- {
- if (ids == null || ids.Length <= 0)
- return Error("请选择要删除的网点");
- var idStr = string.Join(",", ids);
- if (string.IsNullOrEmpty(idStr.Trim()))
- return Error("请选择要删除的网点");
- if (branchBLL.DeleteList(idStr))
- return Success("删除成功");
- return Error("删除失败");
- }
- /// <summary>
- /// 删除网点
- /// </summary>
- /// <param name="ids"></param>
- /// <returns></returns>
- [Authority]
- public ActionResult DelBranchs(int id)
- {
- if (id > 0)
- {
- if (new BLL.T_Branch_List().Delete(id))
- {
- return Success("删除成功");
- }
- else
- {
- return Error("删除失败");
- }
- }
- else
- {
- return Error("删除失败");
- }
- }
- //大屏展示使用
- /// <summary>
- /// 获取网点列表
- /// </summary>
- /// <returns></returns>
- //[Authority]
- public ActionResult GetBranchListS()
- {
- DataTable dt = branchBLL.GetList(" F_IsDP=1 ").Tables[0];
- return Success("加载成功", dt);
- }
- #endregion
- }
- }
|