using System; using System.Web.Mvc; using WX.CRM.Common; using WX.CRM.IBLL.Csvr; using WX.CRM.IBLL.Res; using WX.CRM.IBLL.Util; using WX.CRM.Model.Entity; using WX.CRM.WebHelper; using WX.CRM.WebHelper.UserRight; namespace WX.CRM.WEB.Controllers.Csvr { public class ApplyPrimNumController : BaseController { // // GET: /ApplyPrimNum/ private ICSVR_APPLYPRIMARYNUMBER _applyprimayNum; private ICSVR_APPLYPRIMARYNUMBER_Q _applyprimayNumQ; private readonly IRES_CUSTOMERDETAIL _customerdetail; private readonly IRES_CUSTOMERDETAIL_Q _customerdetailQ; private ICACHE_Q _cacheQ; ValidationErrors errors = new ValidationErrors(); WebHelper.RedisFactory.RedisFactory redisFactory = new WebHelper.RedisFactory.RedisFactory(); public ApplyPrimNumController( ICSVR_APPLYPRIMARYNUMBER applyprimayNum, ICSVR_APPLYPRIMARYNUMBER_Q applyprimayNumQ, IRES_CUSTOMERDETAIL customerdetail , ICACHE_Q cacheQ, IRES_CUSTOMERDETAIL_Q customerdetailQ ) { this._applyprimayNum = applyprimayNum; this._applyprimayNumQ = applyprimayNumQ; this._customerdetail = customerdetail; this._cacheQ = cacheQ; this._customerdetailQ = customerdetailQ; } [AuthorizeRedirect(Roles = InitRights.CONST_主号码修改审核)] public ActionResult Index() { var tool = new ToolBar(); string[] toolbtn = new ToolButtonView().ToolButtonRight(InitRights.主号码修改审核, userRightId); tool.AllowButton(toolbtn); //tool.AllowButton("Other1", "Delete"); tool.AddOtherButton("Other1", "审核", "icon-check", "Check_Click", true); ViewBag.ToolBar = tool; var pager = new Pager() { page = 1, rows = 10 }; var tableId = "tablist"; var tab = new Table(tableId); tab.AddHiddenHeadCol("PKID", ""); tab.AddHeadCol("RESID", "10%", "客户ID "); tab.AddHeadCol("MEMO", "30%", "申请原因"); tab.AddHeadCol("CREATEUSER", "10%", "申请人"); tab.AddHeadCol("CTIME", "", "申请时间"); tab.AddHeadRow(); ViewBag.List = tab.GetTable() + Pagination.GetPage(pager, tableId, "10,20,30"); return View(); } [HttpPost] [AuthorizeRedirect(Roles = InitRights.CONST_主号码修改审核)] public JsonResult GetHtmlList(Pager pager, string columns) { var table = new Table(columns, true); var list = _applyprimayNumQ.GetList(ref pager); table.gridPager = pager; foreach (var model in list) { table.AddHiddenCol(model.PKID); table.AddCol(model.RESID); table.AddCol(model.MEMO); table.AddCol(InnerUserHelper.Instance.EidAndName(model.CREATEUSER)); table.AddCol(model.CTIME); table.AddRow(); } var json = new { totalPages = pager.totalPages, totalRows = pager.totalRows, rowsList = table.GetRows() }; return Json(json, JsonRequestBehavior.AllowGet); } #region 新增 [HttpGet] public ActionResult Edit(string resid, string type) { ViewBag.ResId = resid; return View(); } [HttpPost] public ActionResult Edit(string resid) { CSVR_APPLYPRIMARYNUMBER apply = new CSVR_APPLYPRIMARYNUMBER(); string memo = Request.Form["applyMemo"]; apply.RESID = resid; apply.CREATEUSER = UserId; apply.CTIME = DateTime.Now; apply.MEMO = memo; apply.CHECKSTATUS = 0;//0是未审核 1是已审核 2是已删除 bool result = _applyprimayNum.Create(ref errors, apply); OperationLogHelper op = new OperationLogHelper(); op.AddOperationLog(UserId, Eid, "申请修改主号码!"); return JsonHandler.UpdateMessage(errors, result); } #endregion #region 审核 [HttpPost] [AuthorizeToolBar(InitRights.CONST_主号码修改审核, InitToolBar.CONST_Other1)] public ActionResult Update(string pkid, string resid) { bool result = false; try { var resdata = new RES_CUSTOMERDETAIL(); resdata.ISPRIMARYNUM = 1; resdata.RESID = resid; result = _customerdetail.UpdateStatus(ref errors, resdata); CSVR_APPLYPRIMARYNUMBER apply = new CSVR_APPLYPRIMARYNUMBER(); apply.PKID = Convert.ToDecimal(pkid); apply.CHECKUSER = UserId; apply.CHECKSTATUS = 1; result = _applyprimayNum.UpdateStatus(ref errors, apply); } catch (Exception ex) { LogHelper.Error(ex.Message); } return JsonHandler.UpdateMessage(errors, result); } #endregion #region 删除 [AuthorizeToolBar(InitRights.CONST_主号码修改审核, InitToolBar.CONST_Delete)] public JsonResult Delete(string pkid) { if (string.IsNullOrWhiteSpace(pkid)) { return JsonHandler.ManageMessage("参数不对!", false); } CSVR_APPLYPRIMARYNUMBER apply = new CSVR_APPLYPRIMARYNUMBER(); apply.PKID = Convert.ToDecimal(pkid); apply.CHECKUSER = UserId; apply.CHECKSTATUS = 2; bool result = _applyprimayNum.UpdateStatus(ref errors, apply); return JsonHandler.DeleteMessage(errors, result); } #endregion } }