• ado显示下拉


    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;
    }
    }

  • 相关阅读:
    从高版本JDK换成低版本JDK报错Unsupported major.minor version 52.0
    永远不要祈求生活来怜悯你,你只能让自己变的更强
    69 个经典 Spring 面试题和答案
    Jackson 框架,轻易转换JSON
    Apache Commons Codec 编码解码
    演讲
    Shiro源码分析-初始化-Realm
    各个JSON技术的比较
    常见数据库设计(2)——历史数据问题之单记录变更
    fiddler
  • 原文地址:https://www.cnblogs.com/zhang2000/p/13253808.html
Copyright © 2020-2023  润新知