📄 getadmininfo.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
using property.model;
using System.Data;
using System.Data.SqlClient;
using property.control.LogInfo;
using property.model.SystemInfo;
using property.model.GetConnection;
namespace property.control.SystemInfo
{
class GetAdminInfo
{
SqlCommand com = null;
SqlConnection con = null;
SqlDataReader dr = null;
DataSet ds = new DataSet();
admInfo adm = new admInfo();
GetConnection getCon = new GetConnection();
#region//浏览用户
public DataSet getDs( )
{
con = getCon.GetCon();
string select = "select * from tb_admInfo ";
SqlDataAdapter da = new SqlDataAdapter(select,con);
da.Fill(ds,"admin");
return ds;
}// end block getDs()
#endregion
#region //用条件查找
public DataSet getDs(admInfo adm)
{
con = getCon.GetCon();
string select = "select admId as 管理员编号,admName as 管理员姓名, admWordk as 工作单位,admPhone as 联系电话,admdate as 注册时间 from tb_admInfo where admName='" + adm.getadmName() + "'";
//string select = "select * from tb_admInfo where admName='" + adm.getadmName() + "'";
SqlDataAdapter da = new SqlDataAdapter(select, con);
da.Fill(ds, "admin");
return ds;
}// end block getDs()
#endregion
#region //检测用户名
public int GetAdminName(admInfo adm)
{
int P_int_adminId;
try {
con = getCon.GetCon();
com = new SqlCommand();
string select = "select count(*) from tb_admInfo where admName='" + adm.getadmName() + "'";
com.CommandText = select;
com.Connection = con;
int p_int_id = (int)com.ExecuteScalar();
if (p_int_id ==1)
{ P_int_adminId = p_int_id; }//end block if 已存在
else
{ P_int_adminId = -1; }// end block mehtod if //不存在
con.Close();
com.Connection.Close();
return P_int_adminId;
}// end block try
catch (Exception e)
{
P_int_adminId = 0;
return P_int_adminId;
}// end bloc catch
}// end block GetAdminName(admInfo adm)
#endregion
#region// 添加管理员
public string AdminAdd(admInfo adm)
{
string result = null;
try
{
con = getCon.GetCon();
com = new SqlCommand();
string insert = "insert into tb_admInfo values('" + adm.getadmName() + "','" + adm.getadmPassword() + "','" + adm.getadmWordk() + "','" + adm.getadmPhone() + "','" + adm.getadmdate() + "')";
com.CommandText = insert;
com.Connection = con;
int inst = com.ExecuteNonQuery();
if (inst == 1)
{
result = "insetOk";
}
else
{
result = "insetNo";
}// end blcok if
com.Connection.Close();
con.Close();
return result;
}// end block try
catch (Exception e)
{
result = "addError";
return result;
}// end blokc catch
}//en block mehtod void AdminAdd()
#endregion
#region//修改管理员信息
public string AdminUpdate(admInfo adm)
{
string result = null;
try
{
con = getCon.GetCon();
com = new SqlCommand();
string update = "update tb_admInfo set admWordk ='" + adm.getadmWordk() + "',admPhone='" + adm.getadmPhone() + "' where admName='" +adm.getadmName()+ "'";
com.CommandText = update;
com.Connection = con;
int inst = com.ExecuteNonQuery();
if (inst == 1)
{
result = "updateOk";
}
else
{
result = "updateNO";
}// end blcok if
com.Connection.Close();
con.Close();
return result;
}// end block try
catch (Exception e)
{
result = "updateError";
return result;
}// end blokc catch
}// end block mehtod AdminUpdate(admInfo adm)
#endregion
#region // 查询返回值
public SqlDataReader getAdminUpdateSelect(admInfo adm)
{
try
{
con = getCon.GetCon();
com = new SqlCommand();
string select = "select * from tb_admInfo where admName='"+adm.getadmName()+"' and admPassword='"+adm.getadmPassword()+"' ";
com.CommandText = select;
com.Connection = con;
SqlDataReader dr= com.ExecuteReader();
return dr;
}// end block try
catch (Exception e)
{
dr= null;
return dr;
}// end blokc catch
}// end block menthod getAdminUpdateSelect(admInfo adm)
#endregion
#region//修改密码
public string AdminUpdatPasswrod(admInfo adm)
{
string result = null;
try
{
con = getCon.GetCon();
com = new SqlCommand();
string updatePassword = "update tb_admInfo set admPassword='"+adm.getadmPassword()+"' where admName='" + adm.getadmName() + "'";
com.CommandText = updatePassword;
com.Connection = con;
int inst = com.ExecuteNonQuery();
if (inst == 1)
{
result = "passwordOk";
}
else
{
result = "passwordNO";
}// end blcok if
com.Connection.Close();
con.Close();
return result;
}// end block try
catch (Exception e)
{
result = "upassworError";
return result;
}// end blokc catch
}//end block mehtod AdminUpdatPasswrod()
#endregion
}// end block mehtod
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -