MODEL层
#region
public class listAccount
{
public int ID { get; set; }
public string Account { get; set; }
public string Password { get; set; }
}
#endregion
DAL层
#region 登录
public static DataTable QuerylistAccount(/*int ID*/)
{
List<SqlParameter> para = new List<SqlParameter>();
string sql = @"SELECT * FROM Account";
//if(ID>0)
//{
// sql += @"AND ID=@Acount";
// para.Add(new SqlParameter("@Account", SqlDbType.Int) { Value = ID });
//}
SqlParameter[] sp = para.ToArray();
MSSQL db = new MSSQL(Global.DataBaseIP, Global.DataBaseName);
return db.ExecuteDataTable(sql, sp);
}
#region 修改密码
public static int UpdatelistAccount(listAccount account)
{
string sql = @"UPDATE listAccount SET Account=@Account WHERE Password=@Password ";
List<SqlParameter> pare = new List<SqlParameter>
{
new SqlParameter("@Password", SqlDbType.Int) { Value = account.Password },
new SqlParameter("@Account", SqlDbType.Int) { Value = account.Account }
};
SqlParameter[] sqls = pare.ToArray();
MSSQL db = new MSSQL(Global.DataBaseIP, Global.DataBaseName);
return db.ExecuteNonQuery(sql, sqls);
}
BLL层
#region 登录
public static List<listAccount> QuerylistAccount(string Account, string text)
{
DataTable dt = UserDAL.QuerylistAccount();
List<listAccount> items = new();
if (dt.Rows.Count > 0)
{
foreach (DataRow row in dt.Rows)
{
listAccount item = new()
{
ID = (int)row[0],
Account = row["Account"].ToString(),
Password=row["Password"].ToString()
};
items.Add(item);
}
}
return items;
}
#region 修改密码
public static int UpdatelistAccount(listAccount account)
{
return UserDAL.UpdatelistAccount(account);
}
UI层
?
UI层有一个登录按钮事件和修改密码按钮事件请问怎么去做