update 20251113
This commit is contained in:
123
Client - Kopie/UIControls/Administrator/TableEditor.cs
Normal file
123
Client - Kopie/UIControls/Administrator/TableEditor.cs
Normal file
@@ -0,0 +1,123 @@
|
||||
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];
|
||||
|
||||
try { this.sfDataGrid1.Columns["CreatedOn"].Format = "yyyy-MM-dd HH:mm:ss"; } catch { }
|
||||
try { this.sfDataGrid1.Columns["erstellt_am"].Format = "yyyy-MM-dd HH:mm:ss"; } catch { }
|
||||
try { this.sfDataGrid1.Columns["erstelltam"].Format = "yyyy-MM-dd HH:mm:ss"; } catch { }
|
||||
try { this.sfDataGrid1.Columns["mutiert_am"].Format = "yyyy-MM-dd HH:mm:ss"; } catch { }
|
||||
try { this.sfDataGrid1.Columns["mutiertam"].Format = "yyyy-MM-dd HH:mm:ss"; } catch { }
|
||||
for (int i = 0; i< sfDataGrid1.Columns.Count ; i++)
|
||||
{
|
||||
if (sfDataGrid1.Columns[i].CellType == "DateTime")
|
||||
{
|
||||
sfDataGrid1.Columns[i].Format = "yyyy-MM-dd HH:mm:ss";
|
||||
}
|
||||
}
|
||||
this.sfDataGrid1.AllowResizingColumns = true;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
this.Close();
|
||||
|
||||
}
|
||||
|
||||
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; }
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user