using Microsoft.Office.Interop.Word; using OnDoc.Klassen; using Syncfusion.WinForms.DataGrid; using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using Syncfusion.Windows.Forms.Tools; using Syncfusion.WinForms.Controls; using Syncfusion.WinForms.DataGrid.Enums; namespace OnDoc.UIControls.Administrator { public partial class TableEditor : SfForm { public string TableName { get; set; } = ""; public string SQL { get; set; } = ""; Database.DB db = new Database.DB(AppParams.connectionstring); public TableEditor() { InitializeComponent(); this.Style.TitleBar.BackColor = Theaming.Titelbar(); this.Style.TitleBar.ForeColor = Theaming.TitelFontColor(); this.Style.ShadowOpacity = Theaming.ShadowOpacity; this.Style.InactiveShadowOpacity = Theaming.InactivShadowOpacity; } public TableEditor(string tablename, bool allowdelete) { InitializeComponent(); this.Style.TitleBar.BackColor = Theaming.Titelbar(); this.Style.TitleBar.ForeColor = Theaming.TitelFontColor(); this.Style.ShadowOpacity = Theaming.ShadowOpacity; this.Style.InactiveShadowOpacity = Theaming.InactivShadowOpacity; TableName = tablename; this.Text = tablename; this.sfDataGrid1.AllowDeleting = allowdelete; } private void TableEditor_Load(object sender, EventArgs e) { update_data(); } private void update_data() { if (this.SQL != "") { db.Get_Tabledata_for_Update(SQL, false, true); this.toolStripButton2.Enabled = false; } else { db.Get_Tabledata_for_Update("Select * from " + TableName, false, true); this.toolStripButton2.Enabled = true; } sfDataGrid1.DataSource = db.daten.Tables[0]; } private void toolStripButton2_Click(object sender, EventArgs e) { db.Update_Data(); ToastMessage.ShowToast("Speichern", "Daten erfolgreich gespeichert"); } private void sfDataGrid1_AddNewRowInitiating(object sender, Syncfusion.WinForms.DataGrid.Events.AddNewRowInitiatingEventArgs e) { var data = e.NewObject as dynamic; data["aktiv"] = true; data["erstellt_am"] = DateTime.Now; data["mutiert_am"] = DateTime.Now; data["mutierer"]=AppParams.CurrentMitarbeiter; } private void toolStripButton1_Click(object sender, EventArgs e) { } public void editmode(bool allow) { sfDataGrid1.AllowEditing = allow; } public void deletemode(bool allow) { sfDataGrid1.AllowDeleting = allow; } public void addmode(bool allow) { if (!allow) { sfDataGrid1.AddNewRowPosition = RowPosition.None; } else { sfDataGrid1.AddNewRowPosition = RowPosition.Top; } } } }