コード例 #1
0
        //功能 窗口构造函数
        public 功能(MySqlConnection connection, string name, string password)
        {
            Password1   = password;
            Connection1 = connection;
            Name1       = name;
            //MainWindow m1 = new MainWindow();
            InitializeComponent();
            我的课程_grid1_data data2 = new 我的课程_grid1_data();

            data2.Init(Connection1, Name1, this.我的课程_grid1);
            我的课程_grid1_data data3 = new 我的课程_grid1_data();

            data3.课_init(Connection1, this.课_grid1);
            我的课程_grid1_data data4 = new 我的课程_grid1_data();

            data4.Init2(Connection1, Name1, this.课_grid2);

            //公告
            公告_announcment data5 = new 公告_announcment();

            data5.Init(Connection1, 公告_grid1);

            //讨论
            讨论_discussion data6 = new 讨论_discussion();

            data6.Init(Connection1, 讨论_grid1);
        }
コード例 #2
0
        public void Init(MySqlConnection Connection, Grid grid1)
        {
            var list = new List <公告_announcment>();

            string str1 = "select * from announcment";
            //string str2 = "';";
            MySqlCommand    cmd = new MySqlCommand(str1, Connection);
            MySqlDataReader rdr = cmd.ExecuteReader();

            while (rdr.Read())
            {
                公告_announcment data = new 公告_announcment();
                data.Announcmenttime    = rdr[0].ToString();
                data.Announcmentcontent = rdr[1].ToString();


                list.Add(data);
            }
            grid1.DataContext = list;
            rdr.Close();
        }