111 lines
3.7 KiB
C#
111 lines
3.7 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Web.Mvc;
|
||
using WX.CRM.Common;
|
||
using WX.CRM.IBLL.Soft;
|
||
using WX.CRM.WebHelper;
|
||
namespace WX.CRM.WEB.Controllers.Soft
|
||
{
|
||
public class RemoteCodeController : BaseController
|
||
{
|
||
private ISOFT_REMOTECODE_Q remoteCodeBiz_Q;
|
||
private ISOFT_REMOTECODE remoteCodeBiz;
|
||
ValidationErrors errors = new ValidationErrors();
|
||
public RemoteCodeController(ISOFT_REMOTECODE_Q _remoteCodeBiz_Q, ISOFT_REMOTECODE _remoteCodeBiz)
|
||
{
|
||
this.remoteCodeBiz_Q = _remoteCodeBiz_Q;
|
||
this.remoteCodeBiz = _remoteCodeBiz;
|
||
|
||
}
|
||
//
|
||
// GET: /RemoteCode/
|
||
|
||
public ActionResult Index()
|
||
{
|
||
|
||
//ToolBar
|
||
ToolBar tool = new ToolBar();
|
||
tool.AllowButton("Other1");
|
||
tool.AddOtherButton("Other1", "申请协调授权", "icon-add", "Create_Click", true);
|
||
ViewBag.ToolBar = tool;
|
||
|
||
//table
|
||
Pager pager = new Pager() { page = 1, rows = 10 };
|
||
string tableId = "tablist";
|
||
Table tab = new Table(tableId);
|
||
tab.AddHeadCol("EID", "10%", "工号");
|
||
tab.AddHeadCol("REMOTECODE", "10%", "授权码");
|
||
tab.AddHeadCol("CTIME", "15%", "申请时间");
|
||
tab.AddHeadCol("REMARK", "", "备注");
|
||
tab.AddHeadRow();
|
||
ViewBag.gridTable = tab.GetTable() + Pagination.GetPage(pager, tableId, "5,8,10,15");
|
||
|
||
return View();
|
||
}
|
||
#region 列表
|
||
[HttpPost]
|
||
/// <summary>
|
||
/// 按照条件获取数据
|
||
/// </summary>
|
||
/// <param name="pager"></param>
|
||
/// <param name="queryStr"></param>
|
||
/// <returns></returns>
|
||
|
||
public JsonResult GetHtmlList(Pager pager, string columns)
|
||
{
|
||
|
||
List<WX.CRM.Model.Entity.SOFT_REMOTECODE> list = remoteCodeBiz_Q.GetList_RemoteCode(ref pager);
|
||
Table table = new Table(columns, true);
|
||
table.gridPager = pager;
|
||
foreach (WX.CRM.Model.Entity.SOFT_REMOTECODE model in list)
|
||
{
|
||
table.AddCol(model.EID);
|
||
table.AddCol(model.REMOTECODE);
|
||
table.AddCol(model.CTIME);
|
||
table.AddCol(model.REMARK);
|
||
table.AddRow();
|
||
}
|
||
|
||
var json = new
|
||
{
|
||
totalPages = pager.totalPages,
|
||
totalRows = pager.totalRows,
|
||
rowsList = table.GetRows()
|
||
};
|
||
return Json(json, JsonRequestBehavior.AllowGet);
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 编辑
|
||
[HttpGet]
|
||
public ActionResult Edit(string id)
|
||
{
|
||
WX.CRM.Model.Entity.SOFT_REMOTECODE model = new WX.CRM.Model.Entity.SOFT_REMOTECODE();
|
||
// 数据初始化
|
||
|
||
return View(model);
|
||
}
|
||
|
||
[HttpPost]
|
||
public JsonResult Edit(WX.CRM.Model.Entity.SOFT_REMOTECODE model)
|
||
{
|
||
if (!ModelState.IsValid)
|
||
return JsonHandler.ValidateFailMessage();
|
||
if (Eid == 0)
|
||
return JsonHandler.ManageMessage("找不到工号,请重新登录", false);
|
||
else if (Eid >= 1000000)
|
||
return JsonHandler.ManageMessage("工号不能大于6位!", false);
|
||
string code = OperationUtil.encyptCodeByEid(Convert.ToInt32(Eid));
|
||
if (string.IsNullOrEmpty(code))
|
||
return JsonHandler.ManageMessage("授权码为空,请重试!", false);
|
||
model.CREATEUSER = UserId;
|
||
model.EID = Eid;
|
||
model.REMOTECODE = code;
|
||
bool result = remoteCodeBiz.Create_RemoteCode(ref errors, model);
|
||
return JsonHandler.InsertMessage(errors, result);
|
||
}
|
||
#endregion
|
||
}
|
||
}
|