Ejemplo n.º 1
0
        public void GetBDAppComp(int intBDAppID)
        {
            VPComp _vpcomp = null;

            try
            {
                SqlConnection con = new SqlConnection(Global.ConnectionString);
                SqlCommand    cmd = new SqlCommand("qryVPGetBDAppComp", con);
                cmd.CommandTimeout = Global.TimeOut;
                cmd.CommandType    = CommandType.StoredProcedure;
                cmd.Parameters.Clear();
                SqlParameter prmBDAppID = cmd.Parameters.Add("@BDAppID", SqlDbType.Int);
                prmBDAppID.Value = intBDAppID;

                con.Open();

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

                if (dr != null)
                {
                    // Call Read before accessing data.
                    while (dr.Read())
                    {
                        _vpcomp              = new VPComp();
                        _vpcomp.BDApp_ID     = Convert.ToInt32(dr["BDApp_ID"].ToString());
                        _vpcomp.BDApp_Number = Convert.ToInt32(dr["BDApp_Number"].ToString());
                        _vpcomp.GDPR         = Convert.ToBoolean(dr["GDPR"]);
                        _vpcomp.DPI          = Convert.ToBoolean(dr["DPIA"]);
                        _vpcomp.SLA          = Convert.ToBoolean(dr["SLA"]);
                        _vpcomps.Add(_vpcomp);
                    }
                }
            }
            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);
                }
            }
        }
Ejemplo n.º 2
0
 // Public methods.
 public void Add(VPComp c)
 {
     _vpcomps.Add(c);
 }