Example #1
0
        //Загружаем категории
        private void ShowCategory()
        {
            StringBuilder sql = new StringBuilder("SELECT * from продукция.viewКатегории order by pid_category");

            //sql.Append(" FROM продукция.категории order by order_category ");
            //   string sql = "SELECT id_category, pid_category, name_category, order_category FROM продукция.категории order by order_category";
            comm = new NpgsqlCommand(sql.ToString(), conn);
            try
            {
                NpgsqlDataReader dr = comm.ExecuteReader();

                while (dr.Read())
                {
                    categoryList.Add(new Record
                    {
                        Name       = dr["name_category"].ToString(),
                        TreeId     = (int)dr["id_category"],
                        ParentId   = (int)dr["pid_category"],
                        ParentName = dr["parentname"].ToString(),
                    }
                                     );
                }
                var root = CategoryModel.CreateTree(categoryList);
                tree.ItemsSource = new[] { root };
            }
            catch { }


            conn.Close();
            //}
            //catch (Exception ex)
            //{
            //    MessageBox.Show(ex.Message);
            //}
        }