protected void GVip_RowUpdating(object sender, GridViewUpdateEventArgs e) { string iid = GVip.DataKeys[GVip.EditIndex][0].ToString(); string iip = ((TextBox)(GVip.Rows[e.RowIndex].FindControl("TextBoxIp"))).Text.Trim(); if (iip.Length < 16) { if (Request.QueryString["Hid"] != null) { string hid = Request.QueryString["Hid"].ToString(); LearnSite.BLL.Ip bll = new LearnSite.BLL.Ip(); if (!bll.ExistsIp(Int32.Parse(hid), iip)) { bll.UpdateIip(iip, Int32.Parse(iid)); } else { LearnSite.Common.WordProcess.Alert("该IP已经存在列表中,请匆重复!", this.Page); } } } else { LearnSite.Common.WordProcess.Alert("请填写完整的IP!", this.Page); } GVip.EditIndex = -1; showIp(); }
protected void ButtonIpExcel_Click(object sender, EventArgs e) { if (Request.Cookies[LearnSite.Common.CookieHelp.mngCookieNname] != null) { if (FileUploadip.HasFile) { if (Request.QueryString["Hid"] != null) { string hid = Request.QueryString["Hid"].ToString(); string aa = LearnSite.Common.DataExcel.SaveIpExcel(FileUploadip); if (!string.IsNullOrEmpty(aa)) { LearnSite.BLL.Ip bll = new LearnSite.BLL.Ip(); bll.DeleteIhid(Int32.Parse(hid));//清空该机房的电脑IP对应表 Labelmsg.Text = LearnSite.Common.DataExcel.DataSettoIps(aa, Int32.Parse(hid)); System.Threading.Thread.Sleep(500); showIp(); } } } else { Labelmsg.Text = "请选择要导入电脑编号与IP对应表格!"; } } else { string ch = "请登录后执行操作!"; LearnSite.Common.WordProcess.Alert(ch, this.Page); } }
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); } } }
private void showIp() { if (Request.QueryString["Hid"] != null) { string hid = Request.QueryString["Hid"].ToString(); LearnSite.BLL.Ip ibll = new LearnSite.BLL.Ip(); GVip.DataSource = ibll.GetHouseIp(Int32.Parse(hid)); GVip.DataBind(); } }
private void showOld() { if (Request.QueryString["Hid"] != null && Request.QueryString["Sgrade"] != null && Request.QueryString["Sclass"] != null) { string hid = Request.QueryString["Hid"].ToString(); if (LearnSite.Common.WordProcess.IsNum(hid)) { string sgrade = Request.QueryString["Sgrade"].ToString(); string sclass = Request.QueryString["Sclass"].ToString(); LearnSite.BLL.House bll = new LearnSite.BLL.House(); LearnSite.Model.House model = new LearnSite.Model.House(); model = bll.GetModel(Int32.Parse(hid)); bool hostnameshow = false; if (model != null) { LabelTitle.Text = model.Hname; firstshows = model.Hseat; LearnSite.BLL.Ip pbll = new LearnSite.BLL.Ip(); StoreMsg.InnerText = pbll.GetSiginStudentStr(Int32.Parse(sgrade), Int32.Parse(sclass), Int32.Parse(hid), hostnameshow); if (firstshows.IndexOf('-') > -1) { string[] old_collects = firstshows.Split('-'); if (old_collects.Length > 3) { string slnum = old_collects[0]; string sallnum = old_collects[1]; string ssortway = old_collects[2]; myhouse.Text = viewseats(Int32.Parse(slnum), Int32.Parse(sallnum), ssortway); } } } } else { LearnSite.Common.WordProcess.Alert("参数格式错误", this.Page); } } }