<%@ WebHandler Language="C#" Class="GwTransfer" %>
|
|
using System;
|
using System.Web;
|
using Dao;
|
using Model;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Diagnostics;
|
using System.IO;
|
using System.Text;
|
using System.Text.RegularExpressions;
|
|
|
/// <summary>
|
/// 携号转网处理程序
|
/// </summary>
|
public class GwTransfer : PageHandler<SysUser>
|
{
|
private GwTransferDao _dao = new GwTransferDao();
|
|
public override JsonPageResult ProcessRequestInternal(PageContext<SysUser> context)
|
{
|
string @string = context.GetString("action");
|
switch (@string)
|
{
|
case "loadGwTransfer":
|
return this.LoadGwTransfer(context);
|
case "save":
|
return this.Save(context);
|
case "deleteMobile":
|
return this.DeleteMobile(context);
|
default:
|
throw new Exception("Invalid Action=" + @string);
|
}
|
}
|
|
/// <summary>
|
/// 加载携号转网
|
/// </summary>
|
/// <param name="context"></param>
|
/// <returns></returns>
|
private JsonPageResult LoadGwTransfer(PageContext<SysUser> context)
|
{
|
string mobile = context.GetString("mobile");
|
int recordcount = 0;
|
int int1 = context.GetInt("pageIndex", 1);
|
int int2 = context.GetInt("pageSize", 20);
|
string str = "";
|
using (GwTransferDao Dao = new GwTransferDao())
|
{
|
List<Model.GwTransfer> list = Dao.LoadInfoList(mobile, out recordcount, int1, int2);
|
if (list != null && list.Count > 0)
|
{
|
foreach (Model.GwTransfer gw in list)
|
{
|
str = str + (object)"<tr ><td>" + gw.Mobile + "</td><td>" + (object)gw.Operator + "</td>";
|
str += "<td>";
|
str += string.Format("<a class=\"action-delete btnbtn btn btn-default btn-xs\" href=\"javascript:;\" data-id=\"{0}\">", (object)gw.Id);
|
str += "<i class='fa fa-trash'></i> 删除 </a>";
|
str += "</td>";
|
str += "</tr>";
|
}
|
}
|
else
|
{
|
str += "<tr><td colspan=\"3\" style=\"text-align: center;\">暂无信息</td></tr>";
|
}
|
}
|
return new JsonPageResult(true, (object)new
|
{
|
Table = str.ToString(),
|
TotalCount = recordcount
|
});
|
}
|
|
|
|
private JsonPageResult Save(PageContext<SysUser> context)
|
{
|
string mobile = context.GetString("telphone");
|
string mOperator = context.GetString("selectId");
|
if (string.IsNullOrEmpty(mobile))
|
throw new ArgumentException("手机号码称不能为空!");
|
if (this._dao.IsExitsMobile(mobile))
|
throw new ArgumentException("手机号码已存在!");
|
this._dao.Add(new Model.GwTransfer()
|
{
|
Mobile =mobile,
|
Operator =mOperator
|
});
|
return new JsonPageResult(true, (object)"创建成功!");
|
}
|
|
private JsonPageResult DeleteMobile(PageContext<SysUser> context)
|
{
|
int @int = context.GetInt("mobileId");
|
this._dao.Delete(@int);
|
return new JsonPageResult(true, (object)"删除号码成功!");
|
}
|
|
}
|