Ejemplo n.º 1
0
        /// <summary>
        /// 删除多个
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DelMore_Item(object sender, RoutedEventArgs e)
        {
            var count    = 0;
            var listFrom = AppCache.GetFromList();

            foreach (var item in fromTable.Items)
            {
                var box = Common.GetTemplateColumn <CheckBox>(fromTable, 0, "fromBox", item);
                if (box != null && box.IsChecked == true)
                {
                    count++;
                    var colItem = item as FromItems;
                    listFrom.RemoveAll(a => a.colId == colItem.colId);
                }
            }

            AppCache.SetFromList(listFrom);

            if (count == 0)
            {
                CodeBox.Show("请选择要删除的列", this);
            }
            else
            {
                fromTable.ItemsSource = AppCache.GetFromList();
                Common.DataGridSort(fromTable, "tabName", ListSortDirection.Ascending);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 生成表单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Build_From(object sender, RoutedEventArgs e)
        {
            var info = new EntityInfo();
            var list = new List <BaseColumn>();

            AppCache.GetFromList().ForEach(a => {
                var temp         = new BaseColumn();
                temp.colId       = a.colId;
                temp.fromName    = a.fromName;
                temp.fromParam   = a.fromParam;
                temp.fromType    = a.fromType ?? "text";
                temp.colLength   = a.maxLength;
                temp.isNull      = a.isNull;
                temp.colComments = a.colComments;
                temp.colName     = a.colName;
                temp.colType     = a.colType;
                list.Add(temp);
            });

            info.columns   = list;
            info.modelFile = txtFile;
            info.isFrom    = true;
            info.fromName  = fromName.Text;
            info.fromUrl   = fromUrl.Text;
            info.language  = "C#";

            var table = new BaseTable();

            table.tabName     = tabName.Text;
            table.tabComments = "";
            info.table        = table;
            info.nameSpace    = nameSpace.Text;

            var count = Common.BuildCodeModel(info, "cshtml") == true ? 1 : 0;

            info.isFrom  = false;
            info.isCheck = true;
            info.columns = info.disColType(info.columns, info.language);
            count       += Common.BuildCodeModel(info) == true ? 1 : 0;

            if (count == 2)
            {
                CodeBox.Show("生成成功", this);
                AppCache.SetFromList(null);
            }
            else
            {
                CodeBox.Show("生成失败", this);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 编辑表单元素
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void FromTable_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
        {
            var item     = e.Row.Item as FromItems;
            var fromList = AppCache.GetFromList();

            var colItem = fromList.Find(a => a.colId == item.colId);

            fromList.Remove(colItem);

            colItem.fromName = item.fromName;

            fromList.Add(colItem);

            AppCache.SetFromList(fromList);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 增加表单元素
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Add_FromItem(object sender, RoutedEventArgs e)
        {
            try
            {
                var count    = 0;
                var fromList = AppCache.GetFromList();

                foreach (var item in Dcolumn.Items)
                {
                    var box     = Common.GetTemplateColumn <System.Windows.Controls.CheckBox>(Dcolumn, 0, "colBox", item);
                    var colItem = item as BaseColumn;
                    if (box != null && box.IsChecked == true)
                    {
                        count++;
                        if (!fromList.Exists(a => a.colId == colItem.colId))
                        {
                            var from = new FromItems();
                            from.colId       = colItem.colId;
                            from.fromName    = colItem.colComments;
                            from.fromParam   = colItem.colName;
                            from.maxLength   = colItem.colLength;
                            from.isNull      = colItem.isNull;
                            from.colComments = colItem.colComments;
                            from.colType     = colItem.colType;
                            from.colName     = colItem.colName;
                            fromList.Add(from);
                        }

                        box.IsChecked = false;
                    }
                }

                AppCache.SetFromList(fromList);

                if (count == 0)
                {
                    CodeBox.Show("请选择要增加的表单元素", this);
                }
                else
                {
                    CodeBox.Show("增加成功", this);
                }
            }
            catch
            {
                CodeBox.Show("增加失败", this);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 查看表单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Query_From(object sender, RoutedEventArgs e)
        {
            if (AppCache.GetFromList().Count == 0)
            {
                CodeBox.Show("表单元素为空", this);
            }
            else
            {
                //弹出查询表单元素
                var from = new From();
                from.fromTable.ItemsSource = AppCache.GetFromList();

                Common.DataGridSort(from.fromTable, "tabName", ListSortDirection.Ascending);

                Common.OpenWin(from, this);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 表单类型选择
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void fromType_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (fromTable.SelectedItem != null)
            {
                var fromList = AppCache.GetFromList();
                var item     = fromTable.SelectedItem as FromItems;

                var colItem = fromList.Find(a => a.colId == item.colId);

                fromList.Remove(colItem);

                colItem.fromName = item.fromName;
                colItem.fromType = ((sender as ComboBox).SelectedValue as ComboBoxItem).Content.ToString();

                fromList.Add(colItem);

                AppCache.SetFromList(fromList);
            }
        }