/// <summary> /// 获得数据列表 /// </summary> public List <Sys.Model.SysIpBlock> DataTableToList(DataTable dt) { List <Sys.Model.SysIpBlock> modelList = new List <Sys.Model.SysIpBlock>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Sys.Model.SysIpBlock model; for (int n = 0; n < rowsCount; n++) { model = new Sys.Model.SysIpBlock(); if (dt.Rows[n]["ID"].ToString() != "") { model.ID = int.Parse(dt.Rows[n]["ID"].ToString()); } model.IpStart = long.Parse(dt.Rows[n]["IpStart"].ToString()); model.IpEnd = long.Parse(dt.Rows[n]["IpEnd"].ToString()); model.Name = dt.Rows[n]["Name"].ToString(); if (dt.Rows[n]["BlockType"].ToString() != "") { model.BlockType = int.Parse(dt.Rows[n]["BlockType"].ToString()); } if (dt.Rows[n]["BlockModule"].ToString() != "") { model.BlockModule = int.Parse(dt.Rows[n]["BlockModule"].ToString()); } if (dt.Rows[n]["CreateTime"].ToString() != "") { model.CreateTime = DateTime.Parse(dt.Rows[n]["CreateTime"].ToString()); } modelList.Add(model); } } return(modelList); }
private void Add() { //添加权限 ManageHelper.CheckAdminPower("system_memberipblockadd"); Sys.Common.IP.RestrictionIPResult ip = Sys.Common.IP.BlockIP.GenerateIPList(Name); if (!ip.IsChecked) { err.AddErr("*IP访问规则格式错误"); } Sys.BLL.SysIpBlock bll = new Sys.BLL.SysIpBlock(); if (bll.CheckName(ID, Name, BlockType, BlockModule)) { err.AddErr("*该IP访问规则已经存在"); } err.ChkErr(); Sys.Model.SysIpBlock model = new Sys.Model.SysIpBlock(); model.ID = 0; model.IpStart = ip.StartIP; model.IpEnd = ip.EndIP; model.Name = Name; model.BlockType = BlockType; model.BlockModule = BlockModule; int NewID = bll.Add(model); ManageHelper.AddLog("system_memberipblockadd", "添加了" + BlockModuleName + BlockTypeName + model.Name);//写日志 Response.Write("<script>window.parent.location.href=\"ipblocklist.aspx?BlockModule=" + BlockModule + "&BlockType=" + BlockType + "&sucmsg=IP访问规则添加成功。\";</script>"); Response.End(); }
private void Save() { var msg = "yes"; //修改权限 // ManageHelper.CheckAdminPower("system_memberipblockupdate"); var ip = Sys.Common.IP.BlockIP.GenerateIPList(Name); if (!ip.IsChecked) { msg = "*IP访问规则格式错误"; Response.Write(msg); Response.End(); } var bll = new Sys.BLL.SysIpBlock(); //if (bll.CheckName(ID, Name, BlockType, BlockModule)) // err.AddErr("*该IP访问规则已经存在"); //err.ChkErr(); var model = new Sys.Model.SysIpBlock(); model.ID = ID; model.IpStart = ip.StartIP; model.IpEnd = ip.EndIP; model.Name = Name; model.BlockType = BlockType; model.BlockModule = BlockModule; if (ID == 0) { bll.Add(model); ManageHelper.AddLog("system_memberipblockadd", "添加了" + BlockModuleName + BlockTypeName + model.Name);//写日志 } else { bll.Update(model); ManageHelper.AddLog("system_memberipblockadd", "修改" + Name + "成" + BlockModuleName + BlockTypeName + model.Name);//写日志 } Response.Write(msg); Response.End(); }
/// <summary> /// 更新一条数据 /// </summary> public void Update(Sys.Model.SysIpBlock model) { dal.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Sys.Model.SysIpBlock model) { return(dal.Add(model)); }