📄 admin.cs
字号:
using System;
using System.Data;
using www.kcgx.com.Database;
namespace WindowsApplication3
{
/// <summary>
/// Admin 的摘要说明。
/// </summary>
public class Admin
{
private string m_name;
private string m_sex;
private string m_password;
private string m_position;
private string m_birthday;
private DBAgent db = new DBAgent( );
public string Name
{
get
{
return m_name;
}
}
public string Sex
{
get
{
return m_sex;
}
}
public string Password
{
get
{
return m_password;
}
}
public string Position
{
get
{
return m_position;
}
}
public string Birthday
{
get
{
return m_birthday;
}
}
public Admin(string name,string sex,string password,string position,string birthday)
{
m_name = name;
m_sex = sex;
m_password = password;
m_position = position;
m_birthday = birthday;
db.InitConnectionPool(@"Provider=vfpoledb.1;Data Source=user.dbf" , 1);
}
public Admin(string name ,string password)
{
m_name = name;
m_password = password;
db.InitConnectionPool(@"Provider=vfpoledb.1;Data Source=user.dbf" , 1);
}
public Admin( string name )
{
m_name = name;
db.InitConnectionPool(@"Provider=vfpoledb.1;Data Source=user.dbf" , 1);
}
public void GetObject( )
{
string sqlString = "SELECT * FROM user WHERE username='" + m_name + "'";
DataSet ds = db.ExecuteCommand( sqlString );
m_position = ds.Tables[0].Rows[0]["position"].ToString( ).Trim( );
m_sex = ds.Tables[0].Rows[0]["sex"].ToString( ).Trim( );
m_birthday = ds.Tables[0].Rows[0]["birthday"].ToString( ).Trim( ) ;
m_password = ds.Tables[0].Rows[0]["password"].ToString( ).Trim( );
}
public bool Update( string sex, string position,string password,string birthday )
{
string upstring = "UPDATE user SET sex='" + sex + "',position='" + position +"',password='" + password +"',birthday='" + birthday + "' WHERE username='" + m_name + "'";
int result = db.ExecuteCommandNonQuery( upstring );
if( result == 0 )
{
return false;
}
return true;
}
public bool Register( )
{
string qur = " SELECT * FROM user WHERE username='" + m_name + "'";
DataSet ds = db.ExecuteCommand( qur );
if ( ds.Tables[0].Rows.Count == 1 )
{
return false;
}
else
{
string str = "INSERT INTO user ( username,sex,position,password,birthday) VALUES( '" + m_name + "','" + m_sex + "','" + m_position + "','" +m_password + "','" + m_birthday + "')";
try
{
int result = db.ExecuteCommandNonQuery( str );
if ( result == 0 )
{
return false;
}
return true;
}
catch(Exception ee )
{
string error = ee.Message ;
return false;
}
}
}
/// <summary>
/// 判断登陆用户是否存在
/// </summary>
/// <returns>ture为存在,false为不存在</returns>
public bool IsExist( )
{
string sqlString = "SELECT * FROM user WHERE username='" + m_name + "' AND password='" + m_password + "'";
DataSet ds = db.ExecuteCommand( sqlString );
if (ds.Tables[0].Rows.Count == 1 )
{
m_position = ds.Tables[0].Rows[0]["position"].ToString( ).Trim( );
m_sex = ds.Tables[0].Rows[0]["sex"].ToString( ).Trim( );
m_birthday = ds.Tables[0].Rows[0]["birthday"].ToString( ).Trim( ) ;
return true;
}
else
{
return false;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -