Example #1
0
        //Populate method used to populate developer object from DB
        public void Populate(int intID)
        {
            SqlDataReader dr;
            DataSet       ds;

            DataRow[] aDr;

            //Get developer record
            dr = m_DL.GetDeveloper(intID);

            if (!dr.IsClosed)
            {
                if (dr.HasRows)
                {
                    //Only one record should have been returned
                    dr.Read();
                    m_intID     = (int)dr[DataLayer.FldID];
                    m_strName   = (string)dr[DataLayer.FldDeveloperName];
                    m_dblSalary = (double)dr[DataLayer.FldDeveloperSalary];
                    m_blnIsNew  = false;
                }

                dr.Close();
            }
            //Close open connection made for retrieving data reader
            m_DL.CloseDBConnection();

            //At this point if no developer record was retrieved, there's no need to continue
            if (!m_blnIsNew)
            {
                //Get department records
                ds = new DataSet();
                ds = m_DL.GetDeveloperDepartments(m_intID);

                if (ds.Tables.Count > 0)
                {
                    if (ds.Tables[DataLayer.TblDeveloperDepartments].Rows.Count > 0)
                    {
                        aDr = ds.Tables[DataLayer.TblDeveloperDepartments].Select();

                        //Add each department record to Departments collection
                        foreach (DataRow d in aDr)
                        {
                            AddDepartment((int)d[DataLayer.FldDevDeptsDepartmentID]);
                        }
                    }
                }
            }
        }
Example #2
0
        //Populates this department object from DB
        public void Populate(int intID)
        {
            SqlDataReader dr;

            //Get department record
            dr = m_DL.GetDepartment(intID);

            if (!dr.IsClosed)
            {
                if (dr.HasRows)
                {
                    //Only one record should have been returned
                    dr.Read();
                    m_intID    = (int)dr[DataLayer.FldID];
                    m_strName  = (string)dr[DataLayer.FldDepartmentName];
                    m_blnIsNew = false;
                }

                dr.Close();
            }
            //Close open connection made for retrieving data reader
            m_DL.CloseDBConnection();
        }