public List <StudentAbilityBase> GetDefaults()
        {
            List <StudentAbilityBase> list = new List <StudentAbilityBase>();
            DataTable dt = dbc.GetDataTable("SELECT * FROM A_DefaultItems");

            foreach (DataRow dr in dt.Rows)
            {
                int defaultTypeId = (int)dr["DefaultType"];
                StudentAbilityBase sa;
                switch (defaultTypeId)
                {
                case 1:
                    sa = new PhysicalAbility();
                    break;

                case 2:
                    sa = new CommunityOrientation();
                    break;

                case 3:
                    sa = new CommunityInteraction();
                    break;

                default:
                    sa = new PersonalCare();
                    break;
                }
                sa.StudentAbilityTypeId = (int)dr["DefaultType"];
                sa.Item     = dr["Item"].ToString();
                sa.Selected = true;
                list.Add(sa);
            }
            return(list);
        }
        public void Update(PhysicalAbility pc)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("UPDATE StudentPhysicalAbility SET ");
            sb.Append("Item='" + pc.Item + "'");
            sb.Append(",Description='" + pc.Description.Replace("'", "''") + "'");
            if (pc.Comments != null && pc.Comments != string.Empty)
            {
                sb.Append(",Comments='" + pc.Comments.Replace("'", "''") + "'");
            }
            else
            {
                sb.Append(",Comments=null");
            }
            sb.Append(" WHERE StudentPhysicalAbilityId =" + pc.StudentPhysicalAbilityId);
            string sql = sb.ToString();

            dbc.ExecuteCommand(sql);
        }
        public List <PhysicalAbility> GetList(int PersonId)
        {
            List <PhysicalAbility> list = new List <PhysicalAbility>();
            DataTable dt = dbc.GetDataTable("SELECT * FROM vw_StudentPhysicalAbility WHERE StudentId=" + PersonId);

            dbc.CloseConnection();

            foreach (DataRow dr in dt.Rows)
            {
                PhysicalAbility pc = new PhysicalAbility();
                pc.StudentPhysicalAbilityId = (int)dr["StudentPhysicalAbilityId"];
                pc.StudentId   = (int)dr["StudentId"];
                pc.Item        = dr["Item"].ToString();
                pc.Description = dr["Description"].ToString();
                pc.Comments    = dr["Comments"].ToString();

                list.Add(pc);
            }
            return(list);
        }
        public void Add(PhysicalAbility Pa, int StudentId)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("INSERT INTO StudentPhysicalAbility (StudentId,Item,Description,Comments) VALUES (");
            sb.Append(StudentId);
            sb.Append(",'" + Pa.Item.Replace("'", "''") + "'");
            sb.Append(",'" + Pa.Description.Replace("'", "''") + "'");
            if (Pa.Comments != null && Pa.Comments != string.Empty)
            {
                sb.Append(",'" + Pa.Comments.Replace("'", "''") + "'");
            }
            else
            {
                sb.Append(",null");
            }

            sb.Append(")");
            string sql = sb.ToString();

            dbc.ExecuteCommand(sql);
        }
        public List <StudentAbilityBase> GetList(int PersonId)
        {
            List <StudentAbilityBase> list = new List <StudentAbilityBase>();
            DataTable dt = dbc.GetDataTable("SELECT * FROM vw_StudentAbilities WHERE StudentId=" + PersonId);

            //dbc.CloseConnection();

            foreach (DataRow dr in dt.Rows)
            {
                int studentAbilityTypeId = (int)dr["StudentAbilityTypeId"];
                StudentAbilityBase sa;
                switch (studentAbilityTypeId)
                {
                case 1:
                    sa = new PhysicalAbility();
                    break;

                case 2:
                    sa = new CommunityOrientation();
                    break;

                default:
                    sa = new CommunityInteraction();
                    break;
                }
                sa.StudentAbilityId   = (int)dr["StudentAbilityId"];
                sa.StudentId          = (int)dr["StudentId"];
                sa.Item               = dr["Item"].ToString();
                sa.Description        = dr["Description"].ToString();
                sa.Comments           = dr["Comments"].ToString();
                sa.StudentAbilityType = dr["StudentAbilityType"].ToString();

                list.Add(sa);
            }
            return(list);
        }