/// <summary> /// 获得数据列表 /// </summary> public List <LearnSite.Model.Ip> DataTableToList(DataTable dt) { List <LearnSite.Model.Ip> modelList = new List <LearnSite.Model.Ip>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { LearnSite.Model.Ip model; for (int n = 0; n < rowsCount; n++) { model = new LearnSite.Model.Ip(); if (dt.Rows[n]["Iid"].ToString() != "") { model.Iid = int.Parse(dt.Rows[n]["Iid"].ToString()); } if (dt.Rows[n]["Ihid"].ToString() != "") { model.Ihid = int.Parse(dt.Rows[n]["Ihid"].ToString()); } if (dt.Rows[n]["Inum"].ToString() != "") { model.Inum = int.Parse(dt.Rows[n]["Inum"].ToString()); } model.Iip = dt.Rows[n]["Iip"].ToString(); modelList.Add(model); } } return(modelList); }
protected void ButtonIp_Click(object sender, EventArgs e) { if (Request.QueryString["Hid"] != null) { string hid = Request.QueryString["Hid"].ToString(); string ipgate = TextBoxIpGate.Text.Trim(); string ipbegin = TextBoxIpBegin.Text.Trim(); string ipend = TextBoxIpEnd.Text.Trim(); //检验IP, 清除旧列表,创建新列表 if (ipgate.Length > 6 && LearnSite.Common.WordProcess.IsNum(ipbegin) && LearnSite.Common.WordProcess.IsNum(ipend)) { LearnSite.BLL.Ip ibll = new LearnSite.BLL.Ip(); int Ihid = Int32.Parse(hid); ibll.DeleteIhid(Ihid); System.Threading.Thread.Sleep(200); int firstnum = Int32.Parse(ipbegin); int lastnum = Int32.Parse(ipend); int count = System.Math.Abs(lastnum - firstnum) + 1; bool ispositive = true;//默认正数 if (lastnum - firstnum < 0) { ispositive = false;//如果负数 } if (!ipgate.EndsWith(".")) { ipgate = ipgate + ".";//如果网段最后位没带点则加上 } LearnSite.Model.Ip model = new LearnSite.Model.Ip(); LearnSite.BLL.Ip bll = new LearnSite.BLL.Ip(); for (int i = 0; i < count; i++) { string ipstr = ipgate + firstnum.ToString(); if (ispositive) { firstnum++; } else { firstnum--; } model.Ihid = Ihid; model.Inum = i + 1; model.Iip = ipstr; bll.Add(model); } System.Threading.Thread.Sleep(200); showIp(); } else { LearnSite.Common.WordProcess.Alert("Ip网段和范围填写不正确!", this.Page); } } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(LearnSite.Model.Ip model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(LearnSite.Model.Ip model) { return(dal.Add(model)); }