📄 popedomlist.aspx.cs
字号:
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace Com.SMS.SMSUI
{
/// <summary>
/// PopedomList 的摘要说明。
/// </summary>
public class PopedomList : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Table Table1;
protected System.Web.UI.WebControls.Button Button1;
int userId;
static int upaId;
bool isHave=true;
string usersPopedom="";
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
JudgePopedom();
userId=Convert.ToInt32(Request["userId"]);
LoadPopedomList();
if(!this.IsPostBack)
{
BindPopedomList();
}
}
void JudgePopedom()
{
Dal.PopedomMake pdm=new Com.SMS.Dal.PopedomMake();
Dal.UserAndPopedomMake uapm=new Com.SMS.Dal.UserAndPopedomMake();
Entity.Popedom pd=pdm.FindByPage("PopedomList.aspx");
Entity.User us=(Entity.User)Session["User"];
DataTable dt=uapm.FindByUser(us.UserId);
string popedom="";
try
{
popedom=dt.Rows[0][2].ToString();
}
catch(Exception)
{
Response.Write("<script>opener.location.href='Popedom.aspx?message='+encodeURIComponent('对不起,你权限不够!!!')+'&turnUrl=Index.aspx&encode=utf8';window.close();</script>");
}
if(popedom.IndexOf(pd.PdId.ToString())==-1)
{
Response.Write("<script>opener.location.href='Popedom.aspx?message='+encodeURIComponent('对不起,你权限不够!!!')+'&turnUrl=Index.aspx&encode=utf8';window.close();</script>");
}
}
void LoadPopedomList()
{
Dal.UserAndPopedomMake uap=new Com.SMS.Dal.UserAndPopedomMake();
DataTable dtp=uap.FindByUser(userId);
try
{
upaId=Convert.ToInt32(dtp.Rows[0][0].ToString());
usersPopedom=dtp.Rows[0][2].ToString();
}
catch(Exception)
{
isHave=false;
}
}
void BindPopedomList()
{
Dal.PopedomMake pdm=new Com.SMS.Dal.PopedomMake();
DataTable dt=pdm.Find();
int rowCount=dt.Rows.Count;
int n=3;
TableRow tr=new TableRow();
this.Table1.Rows.Add(tr);
TableCell tc;
for(int i=0;i<rowCount;i++)
{
string key=dt.Rows[i][0].ToString();
string text=dt.Rows[i][1].ToString();
if(i!=0 && i%n==0)
{
tr=new TableRow();
this.Table1.Rows.Add(tr);
}
tc=new TableCell();
tr.Cells.Add(tc);
string checkedstate = usersPopedom.IndexOf(key) != -1 ? "checked" : "";
tc.Controls.Add(new LiteralControl("<input type=\"checkbox\" name=\"ck_Authority\" value=\"" + key + "\" " + checkedstate + ">" + text));
}
}
#region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void Button1_Click(object sender, System.EventArgs e)
{
string uAuthority = "";
if (Request["ck_Authority"] != null)
uAuthority = Request["ck_Authority"];
int adminId=Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings["Admin"]);
if(userId==adminId && uAuthority.IndexOf("1")==-1)
{
uAuthority+=",1";
}
Entity.UserAndPopedom uap=new Com.SMS.Entity.UserAndPopedom();
uap.UserId=userId;
uap.PdId=uAuthority;
Dal.UserAndPopedomMake uad=new Com.SMS.Dal.UserAndPopedomMake();
if(isHave)
{
uad.Update(uap,upaId);
}
else
{
uad.Insert(uap);
}
Response.Write("<script>window.close();</script>");
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -