public void GetAllBDApps() { VPBDApp _vpapp = null; try { SqlConnection con = new SqlConnection(Global.ConnectionString); SqlCommand cmd = new SqlCommand("qryVPGetAllBDApps", con); cmd.CommandTimeout = Global.TimeOut; cmd.CommandType = CommandType.StoredProcedure; con.Open(); //OleDbDataReader dr = cmd.ExecuteReader(); SqlDataReader dr = cmd.ExecuteReader(); if (dr != null) { // Call Read before accessing data. while (dr.Read()) { _vpapp = new VPBDApp(); _vpapp.BDApp_ID = Convert.ToInt32(dr["BDApp_ID"].ToString()); _vpapp.BDApp_Number = Convert.ToInt32(dr["BDApp_Number"].ToString()); _vpapp.BDApp_Name = dr["BDApp_Name"].ToString(); _vpapp.Available_Launcher = Convert.ToBoolean(dr["Available_Via_Launcher"].ToString()); _vpapp.Rank_Bart = Convert.ToInt32(dr["BART_Ranking"].ToString()); _vpapp.GDPR = Convert.ToBoolean(dr["GDPR"]); _vpapp.DPI = Convert.ToBoolean(dr["DPIA"]); _vpapp.SLA = Convert.ToBoolean(dr["SLA"]); _vpapp.BDApp_Status = Convert.ToInt16(dr["BDApp_Status"].ToString()); byte[] statusimg = (byte[])dr["Status_Image"]; /*read image*/ MemoryStream statusms = new MemoryStream(statusimg); /*set as MemoryStream e*/ _vpapp.Status = new Bitmap(statusms); /*assign as bitmap*/ _vpapp.Status_Description = dr["Status_Description"].ToString(); try { _vpapp.Date_Review = Convert.ToDateTime(dr["Next_Review_Date"].ToString()); } catch { _vpapp.Date_Review = Convert.ToDateTime("01/01/2050 00:00:00"); } try { _vpapp.Date_LastUpdated = Convert.ToDateTime(dr["Date_Updated"].ToString()); } catch { _vpapp.Date_LastUpdated = Convert.ToDateTime("01/01/2050 00:00:00"); } _vpapp.Directorate = dr["Directorate"].ToString(); _vpapp.CGroup = dr["CGroup"].ToString(); _vpapp.BusCrit = dr["BusCrit"].ToString(); _vpapp.BDAppReg = Convert.ToBoolean(dr["BDAppReg"]); _vpapp.ProductOwner = dr["ProductOwner"].ToString(); _vpapp.BusSME = dr["BusinessSME"].ToString(); _vpapp.BusContact = dr["BusinessContact"].ToString(); _vpapp.LeadDev = dr["Full_Name"].ToString(); _vpapp.DataGuardian = dr["DataGuardian"].ToString(); _vpapp.BDAppDescription = dr["BDAppDescription"].ToString(); _vpapp.BDAppNotes = dr["BDAppNotes"].ToString(); _vpapp.ReviewRAG = dr["RAG"].ToString(); _vpapps.Add(_vpapp); } } con.Close(); } catch (SqlException ex) { if (ex.Number == -2) // connection time-out { System.Windows.Forms.MessageBox.Show("The application could not connect to the database, and will now close.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Stop); // Close the application Environment.Exit(1); } } }
// Public methods. public void Add(VPBDApp c) { _vpapps.Add(c); }