129 lines
4.3 KiB
C#
129 lines
4.3 KiB
C#
using Ninject;
|
||
using System.Web.Mvc;
|
||
using WX.CRM.Common;
|
||
using WX.CRM.IBLL.Wx;
|
||
using WX.CRM.Model.Entity;
|
||
using WX.CRM.WebHelper;
|
||
|
||
namespace WX.CRM.WEB.Controllers.WeiXin
|
||
{
|
||
public class UserIMEIController : BaseController
|
||
{
|
||
private ValidationErrors errors = new ValidationErrors();
|
||
|
||
[Inject]
|
||
public IWX_USERIMEI wx_userIMEI_BL { get; set; }
|
||
|
||
|
||
[AuthorizeRedirect(Roles = InitRights.CONST_手机IMEI管理)]
|
||
public ActionResult Index()
|
||
{
|
||
ToolBar tool = new ToolBar();
|
||
string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.手机IMEI管理, userRightId);
|
||
tool.AllowButton(toolbtn);
|
||
tool.AddOtherButton("Other1", "更新工号", "icon-edit", "UpdateEid_Click", true);
|
||
ViewBag.ToolBar = tool;
|
||
Table tab = new Table("tablist");
|
||
tab.AddHeadCol("IMEI", "30%", "手机IMEI");
|
||
tab.AddHeadCol("EID", "30%", "员工工号");
|
||
tab.AddHeadCol("CTIME", "30%", "创建时间");
|
||
tab.AddHeadRow();
|
||
ViewBag.gridTable = tab.GetHead();
|
||
return View();
|
||
}
|
||
|
||
[HttpPost]
|
||
[AuthorizeRedirect(Roles = InitRights.CONST_手机IMEI管理)]
|
||
public JsonResult GetHtmlList(string imei, decimal? eid, string columns)
|
||
{
|
||
var list = wx_userIMEI_BL.GetList(imei, eid);
|
||
Table table = new Table(columns, true);
|
||
foreach (var model in list)
|
||
{
|
||
table.AddCol(model.IMEI);
|
||
table.AddCol(model.EID);
|
||
table.AddCol(model.CTIME);
|
||
table.AddRow();
|
||
}
|
||
var json = new
|
||
{
|
||
rowsList = table.GetRows()
|
||
};
|
||
return Json(json, JsonRequestBehavior.AllowGet);
|
||
}
|
||
|
||
|
||
[AuthorizeRedirect(Roles = InitRights.CONST_手机IMEI管理)]
|
||
public ActionResult Add()
|
||
{
|
||
WX_USERIMEI model = new WX_USERIMEI();
|
||
return View(model);
|
||
}
|
||
|
||
|
||
[AuthorizeRedirect(Roles = InitRights.CONST_手机IMEI管理)]
|
||
public ActionResult Edit(string imei)
|
||
{
|
||
WX_USERIMEI model;
|
||
if (string.IsNullOrWhiteSpace(imei))
|
||
{
|
||
model = new WX_USERIMEI();
|
||
}
|
||
else
|
||
{
|
||
model = wx_userIMEI_BL.Get(m => m.IMEI == imei);
|
||
}
|
||
return View(model);
|
||
}
|
||
|
||
[HttpPost]
|
||
[AuthorizeToolBar(Roles = InitRights.CONST_手机IMEI管理, TooBarId = InitToolBar.CONST_Add)]
|
||
public JsonResult Add(WX_USERIMEI model)
|
||
{
|
||
if (model == null)
|
||
{
|
||
errors.Add("参数不能为空!");
|
||
return JsonHandler.InsertMessage(errors, false);
|
||
}
|
||
if (string.IsNullOrWhiteSpace(model.IMEI))
|
||
{
|
||
errors.Add("手机IMEI不能为空!");
|
||
return JsonHandler.InsertMessage(errors, false);
|
||
}
|
||
|
||
var userId = InnerUserHelper.Instance.GetUserIdByEid(model.EID);
|
||
if (userId < 2)
|
||
{
|
||
errors.Add("员工工号不正确!");
|
||
return JsonHandler.InsertMessage(errors, false);
|
||
}
|
||
var flag = wx_userIMEI_BL.Insert(ref errors, model.IMEI, model.EID);
|
||
return JsonHandler.InsertMessage(errors, flag);
|
||
}
|
||
|
||
[HttpPost]
|
||
[AuthorizeToolBar(Roles = InitRights.CONST_手机IMEI管理, TooBarId = InitToolBar.CONST_Other1)]
|
||
public JsonResult Edit(WX_USERIMEI model)
|
||
{
|
||
if (model == null)
|
||
{
|
||
errors.Add("参数不能为空!");
|
||
return JsonHandler.InsertMessage(errors, false);
|
||
}
|
||
if (string.IsNullOrWhiteSpace(model.IMEI))
|
||
{
|
||
errors.Add("手机IMEI不能为空!");
|
||
return JsonHandler.InsertMessage(errors, false);
|
||
}
|
||
|
||
var userId = InnerUserHelper.Instance.GetUserIdByEid(model.EID);
|
||
if (userId < 2)
|
||
{
|
||
errors.Add("员工工号不正确!");
|
||
return JsonHandler.InsertMessage(errors, false);
|
||
}
|
||
var flag = wx_userIMEI_BL.Update(ref errors, model.IMEI, model.EID);
|
||
return JsonHandler.InsertMessage(errors, flag);
|
||
}
|
||
}
|
||
} |