⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 emlistdbconn.cs

📁 酒店管理系统
💻 CS
字号:
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
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 System.Collections;

/// <summary>
/// emListDBConn 的摘要说明
/// </summary>
public class emListDBConn : DBConn
{
    private string sql = null;
    private SqlCommand comm = null;
    private SqlDataReader reader = null;

	public emListDBConn()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//
	}

    /// <summary>
    /// get all the user login information in the db.
    /// </summary>
    /// <returns></returns>
    public ArrayList getAllUser()
    {
        sql = "SELECT * FROM [User]";
        ArrayList reList = new ArrayList();
        this.Open();
        comm = new SqlCommand(sql, conn);
        reader = comm.ExecuteReader();
        Employee person = null;
        while (reader.Read())
        {
            person = new Employee();
            person.ID = reader.GetString(0);
            person.Password = reader.GetString(1);
            person.Authority = reader.GetInt32(2);
            reList.Add(person);
        }
        reader.Close();
        return reList;
    }

    /// <summary>
    /// 删除选定的用户
    /// </summary>
    /// <param name="id"></param>
    public void delUser(string id)
    {
        sql = "DELETE FROM [User] WHERE [ID] = '" + id + "'";
        this.Open();
        comm = new SqlCommand(sql, conn);

        comm.ExecuteNonQuery();
        this.Close();
    }

    /// <summary>
    /// 更新选定的用户信息
    /// </summary>
    /// <param name="id"></param>
    /// <param name="pw"></param>
    /// <param name="au"></param>
    public void updateUser(string id, string pw, int au)
    {
        sql = "UPDATE [User] SET [password] = '" + pw + "', [authority] = " + au.ToString() + " WHERE [ID] = '" + id + "'";
        this.Open();
        comm = new SqlCommand(sql, conn);
        comm.ExecuteNonQuery();
        this.Close();
    }

    public void insertUser(string id, string pw, int au)
    {
        sql = "INSERT INTO [User] VALUES('" + id + "', '" + pw + "', " + au.ToString() +")";
        this.Open();
        comm = new SqlCommand(sql, conn);
        comm.ExecuteNonQuery();
        this.Close();
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -