private void RemoveTable(object parameter) { if (SelectedTable == null) { MessageBoxHelper.MessageBoxShowWarning("请选择你要移除的表!"); return; } archiveTableManager.RemoveArchiveTable(SelectedTable); ArchiveTables.Remove(SelectedTable); }
private void AddTable(object parameter) { if (string.IsNullOrEmpty(TableName + DateField)) { MessageBoxHelper.MessageBoxShowWarning("表名称和时间字段都为必填项!"); return; } ArchiveTable archiveTable = ArchiveTables.FirstOrDefault(x => x.TableName.ToLower() == TableName.ToLower()); if (archiveTable != null) { MessageBoxHelper.MessageBoxShowWarning("添加的表名称已存在!"); return; } try { MySqlHelper.ExecuteScalar(EnvironmentInfo.ConnectionString, $"select {DateField} from {TableName} limit 1"); } catch (Exception) { MessageBoxHelper.MessageBoxShowWarning("添加的表名称或者时间字段在数据库中不存在!"); return; } var table = new ArchiveTable() { TableName = TableName, DateField = DateField, Where = Where }; archiveTableManager.AddArchiveTable(table); ArchiveTables.Add(table); this.TableName = ""; this.DateField = ""; this.Where = ""; }