string comStr = "Data Source=.;Initial Catalog=A2;Integrated Security=True";
public List<Menber> MenberShow()
{
using (var conn = new SqlConnection(comStr))
{
//打开数据库链接
conn.Open();
var cmd = conn.CreateCommand();
cmd.CommandText = "select * from Menber a join Setting b on a.MenberTypeId=b.SettingId";
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
var Shoplist = new List<Menber>();
foreach (DataRow dr in dt.Rows)
{
var m = new Menber();
m.MenberId = Convert.ToInt32(dr["MenberId"]);
m.MenberCard = Convert.ToInt32(dr["MenberCard"]);
m.MenberTypeId = Convert.ToString(dr["MenberTypeId"]);
m.MenberGrade = Convert.ToString(dr["MenberGrade"]);
m.MenberType = Convert.ToString(dr["MenberType"]);
m.SettingGrade = Convert.ToString(dr["SettingGrade"]);
m.MenberName = Convert.ToString(dr["MenberName"]);
m.MenberPhone = Convert.ToString(dr["MenberPhone"]);
m.Cumulative = Convert.ToDecimal(dr["Cumulative"]);
m.Storage = Convert.ToDecimal(dr["Storage"]);
m.Accumulative = Convert.ToDecimal(dr["Accumulative"]);
m.Integral = Convert.ToInt32(dr["Integral"]);
m.Activate = Convert.ToDateTime(dr["Activate"]);
m.Expiration = Convert.ToDateTime(dr["Expiration"]);
m.Condition = Convert.ToBoolean(dr["Condition"]);
Shoplist.Add(m);
}
return Shoplist;
}
}
//绑定品牌列表下拉框
public List<Setting> Brands()
{
using (var conn = new SqlConnection(comStr))
{
conn.Open();
var cmd = conn.CreateCommand();
cmd.CommandText = "select * from Setting";
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
var Brands = new List<Setting>();
foreach (DataRow dr in dt.Rows)
{
var m = new Setting();
m.SettingId = Convert.ToInt32(dr["SettingId"]);
m.MenberType = Convert.ToString(dr["MenberType"]);
m.SettingGrade = Convert.ToString(dr["SettingGrade"]);
Brands.Add(m);
}
return Brands;
}
}