public async Task <IActionResult> Edit(int id, [Bind("Id,TimeStamp,InsideOrOutside,Temp,AirHumidity,RiskForMold")] JoinTables joinTables) { if (id != joinTables.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(joinTables); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!JoinTablesExists(joinTables.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(joinTables)); }
//根据查询表(包含主表和关联表)获取所有查询字段 public IEnumerable <FieldViewModel> GetFieldsBySelectedTable() { if (TableMain == null && JoinTables.IsEmpty()) { return(null); } return(Fields.Where(field => (JoinTables.IsNotEmpty() && JoinTables.Select(t => t.Table).Contains(field.tbname)) || (TableMain != null && field.tbname == TableMain.tbname))); }
public async Task <IActionResult> Create([Bind("Id,TimeStamp,InsideOrOutside,Temp,AirHumidity,RiskForMold")] JoinTables joinTables) { if (ModelState.IsValid) { _context.Add(joinTables); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(joinTables)); }
private void buttonCloseJoin_Click(object sender, RoutedEventArgs e) { ContentPresenter obj = App.FindVisualParent <ContentPresenter>(sender as DependencyObject); if (obj == null) { return; } JoinTable join = obj.DataContext as JoinTable; JoinTables.Remove(join); }
public void addJoinTable(JoinTable joinTable) { if (joinTable != null) { if (JoinTables == null) { JoinTables = new Dictionary <string, JoinTable>(); } if (!JoinTables.ContainsKey(joinTable.TableName)) { this.JoinTables[joinTable.TableName] = joinTable; } } }
private void UpdateTextBoxSelectSql() { if (textBoxSelectSql == null) { return; } if (JoinTables.Count == 0) { textBoxSelectSql.Text = string.Empty; return; } string alias = JoinTables[0].Alias; string where = Target.GetKeyConditionSQL(alias, string.Empty, 0); textBoxSelectSql.Text = JoinTables.GetSelectSQL(where, string.Empty, null); }
private void TargetPropertyChanged(DependencyPropertyChangedEventArgs e) { JoinTables.Clear(); JoinTable jt = new JoinTable() { Alias = "a", Table = Target, Kind = JoinKind.Root }; jt.PropertyChanged += JoinTable_PropertyChanged; JoinTables.Add(jt); //dataGridColumns.ItemsSource = Target.Columns; DataGridControllerResult.Table = Target; sortFields.Target = Target; //dataGridReferTo.ItemsSource = Target.ReferTo; //dataGridReferedBy.ItemsSource = Target.ReferFrom; UpdateTextBoxSource(); UpdateTextBoxTemplateSql(); UpdateHiddenLevelDisplayItems(); Dispatcher.Invoke(Fetch, DispatcherPriority.ApplicationIdle); }
private void MenuItemAddJoin_Click(object sender, RoutedEventArgs e) { MenuItem item = (sender as MenuItem); if (item == null) { return; } RefTable refTbl = item.DataContext as RefTable; if (refTbl == null) { return; } ContextMenu menu = App.FindVisualParent <ContextMenu>(item); if (menu == null) { return; } JoinTable join = menu.DataContext as JoinTable; JoinTables.Add(new JoinTable(join, refTbl.Constraint, refTbl.Direction)); }
/// <summary> /// 儲存 layers 、 lines 、 tables /// </summary> /// <param name="ProjectId"></param> /// <param name="body"></param> /// <returns></returns> public async Task <IActionResult> SaveJoinDesign([FromRoute] int ProjectId, [FromBody] SaveLayerDto[] body) { var projectJoinTables = _efCoreHelper.GetList <JoinTables> (_context).Where(x => x.ProjectId == ProjectId).ToList(); var projectJoinLines = _efCoreHelper.GetList <JoinLines> (_context).Where(x => x.ProjectId == ProjectId).ToList(); foreach (var layer in body) { layer.layer.ProjectId = ProjectId; _efCoreHelper.PatchSingle <Layer> (_context, layer.layer, false); var currentLayerJoinTables = projectJoinTables.Where(x => x.LayerId == layer.layer.LayerId).ToList(); var currentLayerJoinLines = projectJoinLines.Where(x => x.LayerId == layer.layer.LayerId).ToList(); for (var i = 0; i < currentLayerJoinLines.Count(); i++) { var tmp = currentLayerJoinLines[i]; if (layer.Lines.Length > i) { //line: input 覆蓋 current tmp.FromTableId = layer.Lines[i].FromTableId; tmp.ToTableId = layer.Lines[i].ToTableId; tmp.FromColName = layer.Lines[i].FromColName; tmp.ToColName = layer.Lines[i].ToColName; _efCoreHelper.PatchSingle <JoinLines> (_context, tmp, true); } else { //line: current 刪除 _efCoreHelper.RemoveSingle <JoinLines, int> (_context, tmp.JoinLineId, true); } } //line: input 新增 if (layer.Lines.Length > currentLayerJoinLines.Count()) { for (var i = currentLayerJoinLines.Count(); i < layer.Lines.Length; i++) { var tmp = new JoinLines() { ProjectId = ProjectId, LayerId = layer.layer.LayerId, FromTableId = layer.Lines[i].FromTableId, ToTableId = layer.Lines[i].ToTableId, FromColName = layer.Lines[i].FromColName, ToColName = layer.Lines[i].ToColName }; _efCoreHelper.PatchSingle <JoinLines> (_context, tmp, true); } } //table: current 有 input 有 foreach (var table in layer.Tables) { var exist = currentLayerJoinTables.FirstOrDefault(x => x.ProjectDataId == table.TableId); if (exist != null) { currentLayerJoinTables = currentLayerJoinTables.Where(x => x.ProjectDataId != table.TableId).ToList(); layer.Tables = layer.Tables.Where(x => x.TableId != table.TableId).ToArray(); exist.Top = table.Top; exist.Left = table.Left; _efCoreHelper.PatchSingle <JoinTables> (_context, exist, true); } } //table: current 沒有 input 有 foreach (var table in layer.Tables) { var tmp = new JoinTables() { ProjectId = ProjectId, ProjectDataId = table.TableId, LayerId = layer.layer.LayerId, Top = table.Top, Left = table.Left }; _efCoreHelper.PatchSingle <JoinTables> (_context, tmp, true); } //table: current 有 input 沒有 foreach (var item in currentLayerJoinTables) { _efCoreHelper.RemoveSingle <JoinTables, int> (_context, item.JoinTableId, true); } await _context.SaveChangesAsync(); } await Task.CompletedTask; return(Ok(JsonConvert.SerializeObject(body, Formatting.Indented))); }