mainsmstypeinfo.aspx.cs
来自「该服务平台解决了计算机网络与移动网络之间信息交换问题」· CS 代码 · 共 135 行
CS
135 行
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class MsgManagement_MainSMSTypeInfo : System.Web.UI.Page
{
private DataAccess.TableAccessor.SMSTypeInfo SMSTypeInfoAccessor;
private Security.RulesManagement rulesManagement;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
rulesManagement = new Security.RulesManagement();
HttpCookie rolesCookie = Request.Cookies["RolesID"];
int rolesID = 0;
try
{
//rolesID = int.Parse(rolesCookie.Value);
rolesID = int.Parse(Session["RolesID"].ToString());
}
catch
{ Response.Close(); }
if (rulesManagement.ValidUserRules(rolesID, 19))
{
btnAddMainSMSType.Visible = rulesManagement.ValidUserRules(rolesID, 20);
btnUpdate.Visible = rulesManagement.ValidUserRules(rolesID, 21);
this.btnDel.Visible = rulesManagement.ValidUserRules(rolesID, 22);
FillGrid();
}
else
{
Response.Redirect("../none.aspx");
}
}
}
private void FillGrid()
{
this.gridView.Columns[2].Visible = true;
SMSTypeInfoAccessor = new DataAccess.TableAccessor.SMSTypeInfo();
DataTable dt = SMSTypeInfoAccessor.GetSMSTypeInfo();
dt.Columns.Add("Id",typeof(int));
//this.gridView.DataSource = SMSTypeInfoAccessor.GetMostMainSMSType();
for (int i = 0; i < dt.Rows.Count; i++)
{
dt.Rows[i]["Id"] = i + 1;
}
this.gridView.DataSource = dt;
this.gridView.DataBind();
this.gridView.Columns[2].Visible = false;
}
protected void btnAddMainSMSType_Click(object sender, EventArgs e)
{
Response.Redirect("MainSMSTypeOperation.aspx?operationID=0&mainTypeID=0");
}
protected void btnUpdate_Click(object sender, EventArgs e)
{
int userCheckCount = 0;
this.gridView.Columns[2].Visible = true;
string smsName = "";
int SMSTypeID = 0;
for (int i = 0; i < gridView.Rows.Count; i++)
{
CheckBox ckb = (CheckBox)gridView.Rows[i].FindControl("chk");
if (ckb.Checked)
{
SMSTypeID = int.Parse(gridView.Rows[i].Cells[2].Text);
string SMSTypeName = gridView.Rows[i].Cells[3].Text;
userCheckCount++;
smsName = HttpUtility.UrlEncode(SMSTypeName);
}
}
if (userCheckCount != 0)
{
string goUrl = string.Format("<script>window.location.href = 'MainSMSTypeOperation.aspx?operationID=1&typeID={0}&typeName={1}'</script>", SMSTypeID, smsName);
Response.Write(goUrl);
}
else
{
Response.Write("<script language='javascript'>alert('至少选择一行进行更改操作!');window.location.href='MainSMSTypeInfo.aspx'</script>");
return;
}
}
protected void btnDel_Click(object sender, EventArgs e)
{
SMSTypeInfoAccessor = new DataAccess.TableAccessor.SMSTypeInfo();
int userCheckCount = 0;
this.gridView.Columns[2].Visible = true;
for (int i = 0; i < gridView.Rows.Count; i++)
{
CheckBox ckb = (CheckBox)gridView.Rows[i].FindControl("chk");
if (ckb.Checked)
{
int SMSTypeID = int.Parse(gridView.Rows[i].Cells[2].Text);
userCheckCount++;
try
{
SMSTypeInfoAccessor.DeleteSMSType(SMSTypeID);
}
catch
{
Response.Write("<script language='javascript'>alert('删除失败!');</script>");
return;
}
}
}
if (userCheckCount == 0)
{
Response.Write("<script language='javascript'>alert('至少选择一行进行删除操作!');window.location.href='MainSMSTypeInfo.aspx'</script>");
return;
}
else
{
FillGrid();
Response.Write("<script>top.Title.window.location='../TreeViewPage.aspx'</script>");
Response.Write("<script language='javascript'>alert('删除成功!');window.location.href='MainSMSTypeInfo.aspx'</script>");
//Response.Write("<script language='javascript'>parent.Treeview.location='../TreeViewPage.aspx';</script>");
}
}
protected void gridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gridView.PageIndex = e.NewPageIndex;
this.FillGrid();
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?