2008-01-12 16:59
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;
using DataLayer;
using BusinessEntity;
using Microsoft.ApplicationBlocks.Data;
using System.Data.SqlClient;
public partial class AdminManage_UserInfo : System.Web.UI.Page
{
BC_USEREntity UEntity = new BC_USEREntity();
DataBC_USER DU = new DataBC_USER();
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
//if (!DataBase.UserCheck())
//{
// ClientScript.RegisterStartupScript(Page.GetType(), "", "window.parent.location.href='../../../Admin_Login.aspx';", true);
// return;
//}
if (Request.QueryString["id"] != null)
{
DataBC_ITEM.GetClass(lbTitle, Convert.ToInt32(Request.QueryString["id"]),"用户信息");
}
DataBase.BindDDLYear(this.ddl_year, 1950);
DataBase.BindDDLMonth(this.ddl_month);
DataBase.BindDDLDay(this.ddl_day, Convert.ToInt32(this.ddl_year.SelectedValue), Convert.ToInt32(this.ddl_month.SelectedValue));
if (Request.QueryString["uid"] != null)
{
int uid = Convert.ToInt32(Request.QueryString["uid"]);
BC_USEREntity UE = DU.GetUser(uid);
lab_pwd.Text = UE.S_password;
txt_loginname.Text = UE.S_loginName;
txt_name.Text = UE.S_name;
if (UE.S_sex == "男")
{
this.rbl_sex.Items[0].Selected = true;
}
else
{
this.rbl_sex.Items[1].Selected = true;
}
txt_tel.Text = UE.S_tel;
txt_mob.Text = UE.S_mob;
txt_card.Text = UE.S_card;
txt_mail.Text = UE.S_mail;
txt_address.Text = UE.S_address;
if (UE.S_birthday.Length == 8)
{
this.ddl_year.SelectedValue = UE.S_birthday.Substring(0, 4);
this.ddl_month.SelectedValue = UE.S_birthday.Substring(4, 2);
this.ddl_day.SelectedValue = UE.S_birthday.Substring(6, 2);
}
}
ImageButton1.Visible = false;
}
}
/// <summary>
/// 角色控制
/// </summary>
public void RoleManage()
{
if (Session["uid"] != null && Request.QueryString["id"] != null) //从项目导航栏进入该页面时
{
string strViewLimit = DataBC_ROLE.getSingleUserLimit(Convert.ToInt32(Session["uid"]), Convert.ToInt32(Request.QueryString["id"]), 1); //查询权
if (strViewLimit == "0")
{
Response.Redirect("AdminLogin.aspx");
}
}
else
{
Response.Redirect("AdminLogin.aspx");
//Response.Redirect("../default.aspx?state=timeout");
}
}
//检查用户登录名是否可用(检重)
bool checkName()
{
string strbolExistName = "select count(*) from BC_USER where S_loginName=@S_loginName and i_ID<>" + Request.QueryString["uid"];
SqlParameter[] parms;
{
parms = new SqlParameter[]{
new SqlParameter("@S_loginName",System.Data.SqlDbType.NVarChar)
};
}
parms[0].Value = this.txt_loginname.Text.Trim();
if (Convert.ToInt32(SqlHelper.ExecuteScalar(DataBase.StrConn, CommandType.Text, strbolExistName,parms)) > 0)
{
ScriptManager.RegisterClientScriptBlock(this.UpdatePanel1, this.GetType(), "", "window.alert('该用户名已经存在,请重新输入!')", true);
this.txt_loginname.Text = "";
return true;
}
else
return false;
}
protected void ib_updateinfo_Click(object sender, ImageClickEventArgs e)
{
}
protected void ib_ok_Click(object sender, ImageClickEventArgs e)
{
if (checkName())
return;
BC_USEREntity usEntity = DU.GetUser(Convert.ToInt32(Request.QueryString["uid"]));
usEntity.I_id = Request.QueryString["uid"].ToString();
usEntity.S_loginName = this.txt_loginname.Text.ToString();
usEntity.S_name = this.txt_name.Text.ToString();
usEntity.S_sex = this.rbl_sex.SelectedValue;
string b = this.ddl_year.SelectedValue + this.ddl_month.SelectedValue + this.ddl_day.SelectedValue;
usEntity.S_birthday = b;
usEntity.S_tel = this.txt_tel.Text.ToString();
usEntity.S_mob = this.txt_mob.Text.ToString();
usEntity.S_card = this.txt_card.Text.ToString();
usEntity.S_mail = this.txt_mail.Text.ToString();
usEntity.S_address = this.txt_address.Text.ToString();
bool sign = DU.UpdateUsers(usEntity);
if (sign)
{
//this.lab.Text = "修改成功!";
ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('修改成功!');window.location.href='UserManage.aspx?id=" + Request.QueryString["id"] + "'", true);
return;
}
else
{
//this.lab.Text = "修改失败!";
ScriptManager.RegisterStartupScript(this.UpdatePanel1, this.GetType(), "", "alert('修改失败!')", true);
return;
}
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
}
protected void ib_updatepwd_Click(object sender, ImageClickEventArgs e)
{
ib_updateinfo.Visible = false;
ib_updatepwd.Visible = false;
ImageButton1.Visible = true;
ib_ok.Visible = false;
}
protected void imgAdd_Click(object sender, ImageClickEventArgs e)
{
}
protected void ddl_month_SelectedIndexChanged(object sender, EventArgs e)
{
DataBase.BindDDLDay(this.ddl_day, Convert.ToInt32(this.ddl_year.SelectedValue), Convert.ToInt32(this.ddl_month.SelectedValue));
}
}