Пример #1
0
 /// <summary>
 /// 显示表结构
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Show_Table(object sender, RoutedEventArgs e)
 {
     if (!AppCache.ExistsTable(AppCache.GetBuildLink()))
     {
         AppCache.SetTableList(DataSchema.TableList(AppCache.GetBuildLink()) ?? new List <BaseTable>(), AppCache.GetBuildLink());
     }
     Dtable.DataContext = AppCache.GetTableList(AppCache.GetBuildLink());
 }
Пример #2
0
        /// <summary>
        /// 编辑表备注
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Dtable_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
        {
            var list = AppCache.GetTableList(AppCache.GetBuildLink());
            var item = e.Row.Item as BaseTable;
            var temp = list.Find(a => a.tabName == item.tabName);

            list.Remove(temp);
            list.Add(item);
            AppCache.SetTableList(list, AppCache.GetBuildLink());

            DataSchema.UpdateTabComments(e.Row.Item as BaseTable, AppCache.GetBuildLink());
        }
Пример #3
0
        /// <summary>
        /// 绑定datagrid中combobox
        /// </summary>
        private void BindComboBox(object selectedItem, DataGrid grid, bool isDataSource = false, bool isTable = false)
        {
            var item = selectedItem as Data_Business_Details ?? new Data_Business_Details();

            if (item == null)
            {
                return;
            }

            //数据源
            var dataBox = Common.GetTemplateColumn <ComboBox>(grid, 1, "DataSourceBox", selectedItem);

            if (dataBox != null && dataBox.ItemsSource == null)
            {
                var itemSource = AppCache.GetAllLink;
                dataBox.ItemsSource  = itemSource;
                dataBox.SelectedItem = itemSource.Find(a => a.Id == item.DataSourceId);
            }

            Common.UpdateWindow();

            //表名
            var tableBox = Common.GetTemplateColumn <ComboBox>(grid, 2, "TabelBox", selectedItem);

            if (isDataSource && tableBox != null)
            {
                tableBox.ItemsSource = null;
            }

            if (tableBox != null && tableBox.ItemsSource == null)
            {
                if (dataBox.SelectedItem != null)
                {
                    var itemSource = AppCache.GetTableList(dataBox.SelectedItem as Data_Source) ?? new List <Cache_Table>();

                    if (itemSource.Count == 0)
                    {
                        itemSource.Add(new Cache_Table {
                            Name = "请加载数据源"
                        });
                    }

                    tableBox.ItemsSource  = itemSource;
                    tableBox.SelectedItem = itemSource.Find(a => a.Name == item.TableName);
                }
            }

            Common.UpdateWindow();

            //列名
            var columnBox = Common.GetTemplateColumn <ComboBox>(grid, 3, "ColumnBox", selectedItem);

            if (isTable && columnBox != null)
            {
                columnBox.ItemsSource = null;
            }

            if (columnBox != null && columnBox.ItemsSource == null)
            {
                if (tableBox.SelectedItem != null)
                {
                    var itemSource = AppCache.GetColumnList(dataBox.SelectedItem as Data_Source, (tableBox.SelectedItem as Cache_Table).Name);
                    columnBox.ItemsSource  = itemSource;
                    columnBox.SelectedItem = itemSource.Find(a => a.Name == item.ColumnName);
                }
            }

            //主键
            var keyBox = Common.GetTemplateColumn <ComboBox>(grid, 4, "KeyBox", selectedItem);

            if (isTable && keyBox != null)
            {
                keyBox.ItemsSource = null;
            }

            if (keyBox != null && keyBox.ItemsSource == null)
            {
                if (tableBox.SelectedItem != null)
                {
                    var itemSource = AppCache.GetColumnList(dataBox.SelectedItem as Data_Source, (tableBox.SelectedItem as Cache_Table).Name);
                    keyBox.ItemsSource  = itemSource;
                    keyBox.SelectedItem = itemSource.Find(a => a.Name == item.Key);
                }
            }

            //排序
            var orderByBox = Common.GetTemplateColumn <ComboBox>(grid, 5, "OrderByBox", selectedItem);

            if (isTable && orderByBox != null)
            {
                orderByBox.ItemsSource = null;
            }

            if (orderByBox != null && orderByBox.ItemsSource == null)
            {
                if (tableBox.SelectedItem != null)
                {
                    var itemSource = AppCache.GetColumnList(dataBox.SelectedItem as Data_Source, (tableBox.SelectedItem as Cache_Table).Name);
                    orderByBox.ItemsSource  = itemSource;
                    orderByBox.SelectedItem = itemSource.Find(a => a.Name == item.OrderBy);
                }
            }

            //字典
            var dicBox = Common.GetTemplateColumn <ComboBox>(grid, 6, "DicBox", selectedItem);

            if (isTable && dicBox != null)
            {
                dicBox.ItemsSource = null;
            }

            if (dicBox != null && dicBox.ItemsSource == null)
            {
                if (tableBox.SelectedItem != null)
                {
                    var tempSource = FastRead.Query <Data_Dic>(a => a.Id != null).ToList <Data_Dic>();
                    dicBox.ItemsSource  = tempSource;
                    dicBox.SelectedItem = tempSource.Find(a => a.Id == item.Dic);
                }
            }
        }
Пример #4
0
 /// <summary>
 /// 更新表结构
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ReLoad_Table(object sender, RoutedEventArgs e)
 {
     AppCache.SetTableList(DataSchema.TableList(AppCache.GetBuildLink(), true) ?? new List <BaseTable>(), AppCache.GetBuildLink());
     Dtable.DataContext = AppCache.GetTableList(AppCache.GetBuildLink());
 }