Ejemplo n.º 1
0
 /// <summary>
 /// 获取数据
 /// </summary>
 public void GetDate()
 {
     try
     {
         List <SeatManage.ClassModel.AMS_Advertisement> modelList = SeatManage.Bll.AdvertisementOperation.GetAdList(null, SeatManage.EnumType.AdType.TitleAd);
         TitleList.Clear();
         foreach (SeatManage.ClassModel.AMS_Advertisement model in modelList)
         {
             SeatManage.ClassModel.TitleAdvertInfoV2 view = SeatManage.ClassModel.TitleAdvertInfoV2.ToModel(model.AdContent);
             view.AdContent = model.AdContent;
             view.ID        = model.ID;
             TitleList.Add(view);
         }
     }
     catch (Exception ex)
     {
         ErrorMessage = ex.Message;
         SeatManage.SeatManageComm.WriteLog.Write("获取学校通知失败" + ex.Message);
     }
 }
Ejemplo n.º 2
0
        private void readTitles()
        {
            DBClass.openConnection();
            DBClass.sql             = "select titileBook from books";
            DBClass.cmd.CommandType = CommandType.Text;
            DBClass.cmd.CommandText = DBClass.sql;

            DBClass.da = new SqlDataAdapter(DBClass.cmd);
            DBClass.dt = new DataTable();
            DBClass.da.Fill(DBClass.dt);

            // wyciągamy dane
            int i = 0;
            int j = 0;

            TitleList.Clear();
            using (SqlDataReader reader = DBClass.cmd.ExecuteReader())
            {
                while (reader.Read())
                {
                    for (j = 0; j <= reader.FieldCount - 1; j++) // Looping throw colums
                    {
                        data[j] = reader.GetValue(j).ToString();
                        titleList.Add(data[j]);
                    }
                }
            }
            DBClass.closeConnection();

            try
            {
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message);
            }
            DataGrid_Loaded();
        }