?? show.aspx.cs
字號:
?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 show : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
UserLogin.LoginNo();
if (!Page.IsPostBack)
{
Getinfo();
Panel2.Visible = false;
if (Request.QueryString["ac"]=="edit")
{
Panel2.Visible = true;
}
}
}
protected void Getinfo()
{
string urlid = Request.QueryString["id"];
string urlac=Request.QueryString["ac"];
if (urlid != string.Empty)
{
Info info = new Info();
info.ID = Convert.ToInt32(urlid);
Dal dal = new Dal();
DataTable Dt = dal.Getinfo(info);
if (urlac != "edit")
{
Panel1.Visible = true;
Panel2.Visible = false;
name.Text = Dt.Rows[0]["I_UserName"].ToString();
pwd.Text = Dt.Rows[0]["I_Userpwd"].ToString();
isadmin.Text = Dt.Rows[0]["I_IsAdmin"].ToString();
}
else if (urlac == "edit")
{
Panel2.Visible = true;
Panel1.Visible = false;
nametext.Text = Dt.Rows[0]["I_UserName"].ToString();
pwdtext.Text = Dt.Rows[0]["I_Userpwd"].ToString();
admintext.Text = Dt.Rows[0]["I_IsAdmin"].ToString();
}
}
else
{
Response.Write("沒有任何值!");
}
}
protected void Button2_Click(object sender, EventArgs e)
{
string url=Request.RawUrl;
Panel1.Visible = false;
Response.Redirect(url+"&ac=edit");
}
protected void Button1_Click(object sender, EventArgs e)
{
string _id = Request.QueryString["id"];
Info user = new Info();
Dal work = new Dal();
user.ID=Convert.ToInt32(_id);
user.Name = nametext.Text;
user.Pwd = pwdtext.Text;
user.IsAdmin = admintext.Text;
int result= work.Update(user);
if (result!=0)
{
string js = "show.aspx?id=" + Request.QueryString["id"];
Panel1.Visible = true;
Panel2.Visible = false;
Jscript.AlertAndRedirect("修改成功!", js);
}
else
{
Jscript.AlertAndRedirect("修改失敗!", Request.RawUrl);
}
}
protected void Button3_Click(object sender, EventArgs e)
{
//Response.Write("單擊了");
string _id = Request.QueryString["id"];
Info deluser = new Info();
Dal Del= new Dal();
deluser.ID = Convert.ToInt32(_id);
int result = Del.Delete(deluser);
if (result != 0)
{
Jscript.AlertAndRedirect("刪除成功!,返回列表頁面","View.aspx");
}
else
{
Jscript.AlertAndRedirect("刪除失敗!,返回", "View.aspx");
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -