Beispiel #1
0
        protected void btnSaveTable_OnClick(object sender, EventArgs e)
        {
            var model = tableControl.Model;

            var modelConverter  = new TableModelEntityConverter(DataContext);
            var entityConverter = new TableEntityModelConverter(DataContext);
            var columnConverter = new ColumnModelEntityConverter(DataContext);

            var entity = DataContext.LP_Tables.FirstOrDefault(n => n.ID == model.ID);

            if (CopyMode)
            {
                if (entity == null)
                {
                    return;
                }

                var oldModel = entityConverter.Convert(entity);
                oldModel.Status = String.Empty;
                oldModel.Name   = model.Name;

                var newEntity = modelConverter.Convert(oldModel);

                foreach (var columnModel in oldModel.Columns)
                {
                    var columnEntity = columnConverter.Convert(columnModel);
                    newEntity.Columns.Add(columnEntity);
                }

                DataContext.LP_Tables.InsertOnSubmit(newEntity);
            }
            else
            {
                if (entity == null)
                {
                    entity = modelConverter.Convert(model);
                    DataContext.LP_Tables.InsertOnSubmit(entity);
                }
                else
                {
                    modelConverter.FillObject(entity, model);
                }
            }

            DataContext.SubmitChanges();

            FillTablesTree();
        }
Beispiel #2
0
        protected void btnSaveColumn_OnClick(object sender, EventArgs e)
        {
            var model = columnControl.Model;

            var converter = new ColumnModelEntityConverter(DataContext);

            var entity = DataContext.LP_Columns.FirstOrDefault(n => n.ID == model.ID);

            if (entity == null)
            {
                entity = converter.Convert(model);
                DataContext.LP_Columns.InsertOnSubmit(entity);
            }
            else
            {
                converter.FillObject(entity, model);
            }

            DataContext.SubmitChanges();

            FillTablesTree();
        }