第三步:WEB层 /展示层 UserInfo.aspx.cs 页

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));
    }
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值