Exemplo n.º 1
0
        public void GetProfilesFamily(ObservableCollection <ProfilesFamily> listFamily, ProfilesNorme selectedNorme)
        {
            #if DEBUG
            Log.Notice(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name);
            #endif
            if (DBConnection == null)
            {
                #if DEBUG
                Log.Error(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                          "DBConnection == null");
                #endif
                return;
            }
            listFamily.Clear();
            if (selectedNorme == null)
            {
                #if DEBUG
                Log.Error(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                          "selectedNorme == null");
                #endif
                return;
            }

            SQLiteCommand sqlcmd = DBConnection.CreateCommand();
            sqlcmd.CommandText = $@"SELECT * FROM TFAMILY WHERE normeid={selectedNorme.id.ToString()} OR norme2id={selectedNorme.id.ToString()}";
            try
            {
                SQLiteDataReader dataReader = sqlcmd.ExecuteReader();
                while (dataReader.Read())
                {
                    listFamily.Add(new ProfilesFamily(Convert.ToInt32(dataReader["id"]),
                                                      Convert.ToString(dataReader["fname"]), Convert.ToInt32(dataReader["normeid"]),
                                                      Convert.ToInt32(dataReader["imageid"]), Convert.ToInt32(dataReader["drawerid"]),
                                                      Convert.ToString(dataReader["descryption"])));
                }
            }
            catch (SQLiteException e)
            {
                // log
                #if DEBUG
                Log.Error(this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name,
                          "SQL Error: " + e.Message.ToString());
                #endif
                listFamily.Clear();
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Load family list from DB in to Controller.familyList
 /// </summary>
 public void LoadProfilesFamily(ProfilesNorme selectedNorme)
 {
     profilesList.Clear();
     DB.GetProfilesFamily(familyList, selectedNorme);
 }