CSDN博客

img wildhope

QuicklyBuildModel/UserManage.aspx[快速类建模型后台用户管理页面代码]

发表于2004/6/29 0:48:00  793人阅读

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 objLogin.QuicklyBuildModel
{
 /// <summary>
 /// UserManage 的摘要说明。
 /// </summary>
 public class UserManage : SecurityPage
 {
  protected System.Web.UI.WebControls.Button btnUserRegister;
  protected System.Web.UI.WebControls.RequiredFieldValidator ValidatorToPassword;
  protected System.Web.UI.WebControls.TextBox tbPassword;
  protected System.Web.UI.WebControls.Label Label2;
  protected System.Web.UI.WebControls.TextBox tbUserName;
  protected System.Web.UI.WebControls.Label Label1;
  protected System.Web.UI.WebControls.RequiredFieldValidator ValidatorToUserName;
  protected System.Web.UI.WebControls.Button btnModifyUser;
  protected System.Web.UI.WebControls.Button btnDelUser;
  protected System.Web.UI.WebControls.Button btnSearchUser;

  private User user;
 
  private void Page_Load(object sender, System.EventArgs e)
  {
   // 在此处放置用户代码以初始化页面
//   this.CheckLoginAndSetPage();
   this.user = new User();
  }

  #region Web 窗体设计器生成的代码
  override protected void OnInit(EventArgs e)
  {
   //
   // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
   //
   InitializeComponent();
   base.OnInit(e);
  }
  
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {   
   this.btnUserRegister.Click += new System.EventHandler(this.btnUserRegister_Click);
   this.btnDelUser.Click += new System.EventHandler(this.btnDelUser_Click);
   this.btnModifyUser.Click += new System.EventHandler(this.btnModifyUser_Click);
   this.btnSearchUser.Click += new System.EventHandler(this.btnSearchUser_Click);
   this.Load += new System.EventHandler(this.Page_Load);

  }
  #endregion

  private void btnUserRegister_Click(object sender, System.EventArgs e)
  {
   if(this.user.ReceiveUserInfo(true))
   {
    if(this.user.Register(false))
     Response.Write("注册成功");
    else
     ShowErrorMessage();
   }
   else
    ShowErrorMessage();  

  }

  /// <summary>
  /// 显示接受用户信息失败的原因信息
  /// </summary>
  private void ShowErrorMessage()
  {
   Response.Write(this.user.ErrorMessage);
  }

  private void btnModifyUser_Click(object sender, System.EventArgs e)
  {
   if(this.user.ReceiveUserInfo(true))
   {
    if(this.user.Update(true))
     Response.Write("更新成功");
    else
     this.ShowErrorMessage();
   }
   else
    this.ShowErrorMessage();
  }

  private void btnDelUser_Click(object sender, System.EventArgs e)
  {
   if(this.user.ReceiveUserInfo(true))
   {
    if(this.user.Delete(true))
     Response.Write("删除成功");
    else
     this.ShowErrorMessage();
   }
   else
    this.ShowErrorMessage();
  
  }

  private void btnSearchUser_Click(object sender, System.EventArgs e)
  {
   if(this.user.ReceiveUserInfo(true))
    {
     if(this.user.SeachUser(true))
      Response.Write("找到了");
     else
      this.ShowErrorMessage();
    }
    else
     this.ShowErrorMessage();
  }

  
 }
}

0 0

相关博文

我的热门文章

img
取 消
img