using System;
using System.Collections.Generic;
//using System.Linq;
using System.Web;
public class Dao
{
private static string ConnectionString = "Data Source=.;Initial Catalog=mydata;User ID=sa;Password=Abcdefg1";
public Dao()
{
}
public static bool login(string username, string userpass)
{
bool b = false;
using (System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection(ConnectionString))
{
System.Data.SqlClient.SqlCommand comm = conn.CreateCommand();
comm.CommandText = "select count(*) from t_user where username = @username and userpass = @userpass";
comm.Parameters.AddWithValue("username", username);
comm.Parameters.AddWithValue("userpass", userpass);
conn.Open();
object o = comm.ExecuteScalar();
int i = Convert.ToInt32(o);
if (i > 0)
{
b = true;
}
}
return b;
}
public static void BangDingUser(System.Web.UI.WebControls.GridView gv)
{
using (System.Web.UI.WebControls.SqlDataSource sds = new System.Web.UI.WebControls.SqlDataSource(Dao.ConnectionString, "select * from t_user order by username asc"))
{
gv.DataSource = sds;
gv.DataBind();
}
}
public static void GridViewUser(System.Web.UI.WebControls.GridView gv)
{
gv.Caption = "用户表";
gv.EmptyDataText = "用户表数据为空";
gv.EmptyDataRowStyle.BackColor = System.Drawing.Color.Red;
gv.GridLines = System.Web.UI.WebControls.GridLines.None;
gv.AllowPaging = true;
gv.HeaderStyle.BackColor = System.Drawing.Color.Gr