コード例 #1
0
        public void GetAllApps()
        {
            BDApp _app = null;

            try
            {
                SqlConnection con = new SqlConnection(Global.ConnectionString);
                SqlCommand    cmd = new SqlCommand("qryGetAllApps", 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())
                    {
                        _app                     = new BDApp();
                        _app.BDApp_ID            = Convert.ToInt32(dr["BDApp_ID"].ToString());
                        _app.BDApp_Number        = Convert.ToInt32(dr["BDApp_Number"].ToString());
                        _app.BDApp_Name          = dr["BDApp_Name"].ToString();
                        _app.BDApp_Friendly_Name = dr["BDApp_Friendly_Name"].ToString();
                        _app.Restricted_BDApp    = Convert.ToBoolean(dr["Restricted_BDApp"].ToString());
                        _app.BDApp_Governing_DL  = Convert.ToInt16(dr["BDApp_Governing_DL"].ToString());

                        _app.BDApp_Admin_Contact  = dr["BDApp_Admin_Contact"].ToString();
                        _app.BDApp_Version_Number = dr["BDApp_Version_Number"].ToString();
                        _app.BDApp_Install_File   = dr["BDApp_Install_File"].ToString();
                        _app.BDApp_Status         = Convert.ToInt16(dr["BDApp_Status"].ToString());
                        _app.Updated_By           = Convert.ToInt32(dr["Updated_By"].ToString());
                        try
                        {
                            _app.Date_Updated = Convert.ToDateTime(dr["Date_Updated"].ToString());
                        }
                        catch
                        {
                            _app.Date_Updated = Convert.ToDateTime("01/01/1900 00:00:00");
                        }
                        _app.Update_Process     = dr["Update_Process"].ToString();
                        _app.Status_Description = dr["Status_Description"].ToString();
                        _app.Governing_DL       = dr["Governing_DL"].ToString();
                        _app.List_Managers      = dr["List_Managers"].ToString();
                        _apps.Add(_app);
                    }
                }
            }
            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);
                }
            }
        }
コード例 #2
0
        public void GetUserApps(int intPID)
        {
            BDApp _app = null;

            try
            {
                SqlConnection con = new SqlConnection(Global.ConnectionString);
                SqlCommand    cmd = new SqlCommand("qryGetUserApps", con);
                cmd.CommandTimeout = Global.TimeOut;
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.Parameters.Clear();
                SqlParameter prmID253 = cmd.Parameters.Add("@PID", SqlDbType.Int);
                prmID253.Value = intPID;

                con.Open();

                //OleDbDataReader dr = cmd.ExecuteReader();
                SqlDataReader dr = cmd.ExecuteReader();


                if (dr != null)
                {
                    // Call Read before accessing data.
                    while (dr.Read())
                    {
                        _app                      = new BDApp();
                        _app.BDApp_ID             = Convert.ToInt32(dr["BDApp_ID"].ToString());
                        _app.BDApp_Number         = Convert.ToInt32(dr["BDApp_Number"].ToString());
                        _app.App_Fav              = Convert.ToInt16(dr["Favourite_App"].ToString());
                        _app.BDApp_Name           = _app.App_Fav == 1 ? dr["BDAppName"].ToString() + " #" : dr["BDAppName"].ToString(); /* Toggled with friendly name.  Favourites flagged with #. */
                        _app.Restricted_BDApp     = Convert.ToBoolean(dr["Restricted_BDApp"].ToString());
                        _app.BDApp_Governing_DL   = Convert.ToInt16(dr["BDApp_Governing_DL"].ToString());
                        _app.BDApp_Install_File   = dr["BDApp_Install_File"].ToString();
                        _app.BDApp_Command        = dr["BDApp_Command"].ToString();
                        _app.BDApp_Admin_Contact  = dr["BDApp_Admin_Contact"].ToString();
                        _app.BDApp_Version_Number = dr["BDApp_Version_Number"].ToString();
                        _app.BDApp_Install_File   = dr["BDApp_Install_File"].ToString();
                        _app.BDApp_Status         = Convert.ToInt16(dr["BDApp_Status"].ToString());
                        _app.Updated_By           = Convert.ToInt32(dr["Updated_By"].ToString());
                        try
                        {
                            _app.Date_Updated = Convert.ToDateTime(dr["Date_Updated"].ToString());
                        }
                        catch
                        {
                            _app.Date_Updated = Convert.ToDateTime("01/01/1900 00:00:00");
                        }
                        _app.Update_Process = dr["Update_Process"].ToString();
                        _app.App_Odr        = Convert.ToInt16(dr["odr"].ToString());
                        byte[]       img = (byte[])dr["BDApp_Image"]; /*read image*/
                        MemoryStream ms  = new MemoryStream(img);     /*set as MemoryStream e*/
                        _app.App_Img = new Bitmap(ms);                /*assign as bitmap*/
                        //_app.Governing_DL = dr["Governing_DL"].ToString();
                        //_app.List_Managers = dr["List_Managers"].ToString();
                        _apps.Add(_app);
                    }
                }
            }
            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);
                }
            }
        }
コード例 #3
0
 // Public methods.
 public void Add(BDApp c)
 {
     _apps.Add(c);
 }