- 热门文章:
- · 任意在datagrid里面添加控件。
- · 三、ASPNET中实现在线用户检测(使用后台守护线程)
- · 二、ASPNET中实现在线用户检测(使用后台守护线程)
- · ASPNET中实现在线用户检测(使用后台守护线程)
- · 通过自定义类来达到向aspx页面加入脚本代码的例子
- · 一个实现自动求和/合并单元格/排序的DataGrid
- · WINDOWS2000服务器账号登陆身份验证
- · .NET中带有口令加密的注册页面(还是发表在这里吧~-~)
- · .NET中带有口令加密的注册页面
- · ASP.NET验证控件祥解(转)
- · 改写我前面的即时消息的发送,包含同时给多人发送信息!
- · 利用.net来发送即时消息:)
上一篇:自定义控件的使用二----DBGlobal.cs部分 >>
自定义控件的使用例子一
using com.joybase.DB;
using com.oztime.WorkShop.CodeBase;
namespace com.oztime.WorkShop.CodeBase.DB
{
/// <summary>
/// Summary description for DBUser.
/// </summary>
public class DBUser:User
{
private int m_UserID;
private string m_UserName;
private string m_Password;
private Sex m_UserSex;
private string m_UserEmail;
private string m_UserTitle;
public DBUser(string p_UserName)
{
this.m_UserEmail=p_UserName;
this.LoadFromDB(0);
}
public DBUser(int p_UserID)
{
this.m_UserID=p_UserID;
this.LoadFromDB(1);
}
public DBUser(string p_username,string p_password)
{
this.m_UserName=p_username;
this.m_Password=p_password;
this.LoadFromDB(2);
}
public DBUser(string p_UserName,string p_Password,Sex p_UserSex,string p_UserEmail,string p_UserTitle)
{
this.m_Password=p_Password;
this.m_UserEmail=p_UserEmail;
this.m_UserName=p_UserName;
this.m_UserSex=p_UserSex;
this.m_UserTitle=p_UserTitle;
this.m_UserID=this.InserIntoDB();
}
private int InserIntoDB()
{
int result=-1;
try
{
Command command=new Command(DBGlobal.DSN);
command.CommandText=DBGlobal.AddNewUser;
command.Parameter["Username"]=this.m_UserName;
command.Parameter["Password"]=this.m_Password;
command.Parameter["UserSex"]=(int)this.m_UserSex;
command.Parameter["UserEmail"]=this.m_UserEmail;
command.Parameter["UserTitle"]=this.m_UserTitle;
command.ReturnType=ResultType.NoResult;
command.Execute();
command.CommandText=DBGlobal.SelectCurrentUserID;
command.ReturnType=ResultType.DataReader;
System.Data.IDataReader dr=(System.Data.IDataReader)command.Execute();
dr.Read();
result=dr.GetInt32(0);
dr.Close();
}
catch
{
throw new Exception("Cannot Add new User");
}
return result;
}
private void LoadFromDB(int p_Type)
{
try
{
Command command=new Command(DBGlobal.DSN);
switch(p_Type)
{
case 0:
command.CommandText=DBGlobal.SelectUserByName;
command.Parameter["UserName"]=this.m_UserName;
break;
case 1:
command.CommandText=DBGlobal.SelectUserByID;
command.Parameter["UserID"]=this.m_UserID;
break;
case 2:
command.CommandText=DBGlobal.SelectUserByNameAndPassword;
command.Parameter["username"]=this.m_UserName;
command.Parameter["password"]=this.m_Password;
break;
default:
throw new Exception("Error Invode LoadFromDB() method!");
}
System.Data.IDataReader dr=(System.Data.IDataReader)command.Execute();
if(dr.Read())
{
this.m_Password=dr["password"].ToString();
this.m_UserEmail=dr["useremail"].ToString();
this.m_UserID=System.Convert.ToInt32(dr["userid"].ToString());
this.m_UserName=dr["username"].ToString();
this.m_UserSex=(Sex)System.Convert.ToInt32(dr["usersex"].ToString());
this.m_UserTitle=dr["usertitle"].ToString();
}
else
{
throw new Exception("Error to Read userInfo!");
}
dr.Close();
}
catch
{
throw new Exception("Error when load user@#s Info");
}
}
public int UserID
{
get
{
return this.m_UserID;
}
set
{
this.m_UserID=value;
}
}
public string UserName
{
get
{
return this.m_UserName;
}
set
{
this.m_UserName=value;
}
}
public string Password
{
get
{
return this.m_Password;
}
set
{
this.m_Password=value;
}
}
public Sex UserSex
{
get
{
return this.m_UserSex;
}
set
{
this.m_UserSex=value;
}
}
public string UserEmail
{
get
{
return this.m_UserEmail;
}
set
{
this.m_UserEmail=value;
}
}
public string UserTitle
{
get
{
return this.m_UserTitle;
}
set
{
this.m_UserTitle=value;
}
}
public System.Collections.ArrayList getMyCourse()
{
System.Collections.ArrayList result=null;
return result;
}
}
}
下一篇:任意在datagrid里面添加控件。 >>
相关文章:
- · 个性化查询(具有分类模糊查询、换页等功能)
- · .net中即时消息发送的实现……
- · 用vb.net做的校友录……(附所有源代码)
- · web.config一个中文解释
- · Application事件的执行顺序
- · asp.net中当服务器出错时显示指定的错误页面,同时把错误信息写入系统日志文件的探讨
- · 完整的网站间共享数据的WebService(Love.NET原创)
- · HOW TO: Create an Assembly with a Strong Name
- · 图象显示和翻转控件(用户自定义控件)--我也来凑凑热闹--(转)
- · web组件的通信---浅谈事件
- · Using DropDownList control in DataGrid
- · KW大师精品文章赏析
- · 实现一个客户端的DataSet-----index.htm
- · 实现一个客户端的DataSet-----ClientDataSetDataProvider.asmx.cs(1)
- · 实现一个客户端的DataSet-----ClientDataSetDataProvider.asmx.cs(2)
- · 实现一个客户端的DataSet-----ClientDataSet.htc
- · 安装framework以后出现不能显示aspx页面,提示用户名和密码不匹配问题的解决(chicken修改补充)
- · IIS5 HTTP500内部错误解决办法(转自eNet)------(一)
- · IIS5 HTTP500内部错误解决办法(转自eNet)------(二)
- · IIS5 HTTP500内部错误解决办法(转自eNet)-------(三)
- · page_Load和page_Init的区别
- · 关于如何添加一个自增的列【原创】
- · 获得存储过程返回值的方法(return的值)
- · 关于返回前面的页面。如何两者兼得,自问自答
- · 在ASP.NET中的变量数值管理------看了这个我基本上对原来的REQUEST.FORM的方法传递变量绝望了
- · XML技术上传文件-转贴
- · 在datagrid中的HyperLinkColumn上达到谈出一个窗口的效果
- · 再datagrid中使用droplist。。。。重要的是其中的几个用法
- · 一个用C#做的HTTP SERVER(从WINFORM搬来的)
- · ViewState 到底是什么?
- · 允许用户一次上传多个文件
- · 用C# 实现Web文件的上传
- · ASP.NET Caching
- · ASP.NET Caching(2)
- · ASP.NET ViewState 初探 (3) 转自msdn
- · ASP.NET ViewState 初探 (2) 转自msdn
- · ASP.NET ViewState 初探 (1) 转自msdn
- · ASP.NET Framework深度历险(3)
