Nach Update Syncfusion / Anpassungen Nativ
This commit is contained in:
90
Client/Backup/Helper/TableHelper.cs
Normal file
90
Client/Backup/Helper/TableHelper.cs
Normal file
@@ -0,0 +1,90 @@
|
||||
using OnDoc.Klassen;
|
||||
using Syncfusion.WinForms.DataGrid;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Database;
|
||||
using System.Drawing;
|
||||
|
||||
namespace OnDoc.Helper
|
||||
{
|
||||
|
||||
|
||||
public static class TableHelper
|
||||
{
|
||||
public static void SetColumnsOrder(this DataTable dtbl, params String[] columnNames)
|
||||
{
|
||||
List<string> listColNames = columnNames.ToList();
|
||||
|
||||
//Remove invalid column names.
|
||||
foreach (string colName in columnNames)
|
||||
{
|
||||
if (!dtbl.Columns.Contains(colName))
|
||||
{
|
||||
listColNames.Remove(colName);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (string colName in listColNames)
|
||||
{
|
||||
dtbl.Columns[colName].SetOrdinal(listColNames.IndexOf(colName));
|
||||
}
|
||||
}
|
||||
|
||||
public static void FormatTable(ref DataTable tbl, string tablename, ref SfDataGrid grid)
|
||||
{
|
||||
|
||||
DB db = new DB(AppParams.connectionstring);
|
||||
db.Get_Tabledata("Select * from spalten where aktiv=1 and tabelle='" + tablename + "'", false, true);
|
||||
foreach (System.Data.DataRow dr in db.dsdaten.Tables[0].Rows)
|
||||
{
|
||||
foreach (DataColumn dc in tbl.Columns)
|
||||
{
|
||||
if (dr["tabellenspalte"].ToString() == dc.ColumnName)
|
||||
{
|
||||
dc.SetOrdinal(Convert.ToInt32(dr["reihenfolge"].ToString()));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
tbl.AcceptChanges();
|
||||
}
|
||||
grid.DataSource = tbl;
|
||||
foreach (System.Data.DataRow dr in db.dsdaten.Tables[0].Rows)
|
||||
{
|
||||
foreach (GridColumn col in grid.Columns)
|
||||
{
|
||||
if (col.HeaderText.ToString() == dr["tabellenspalte"].ToString())
|
||||
{
|
||||
col.HeaderText = dr["spalte"].ToString();
|
||||
if (Convert.ToInt32(dr["Breite"].ToString()) > 0 )
|
||||
{
|
||||
col.Width = Convert.ToInt32(dr["Breite"].ToString());
|
||||
}
|
||||
if (Convert.ToBoolean(dr["Readonly"]) == true)
|
||||
{
|
||||
col.AllowEditing = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public static string GetCellCValue(ref SfDataGrid grid,string columname)
|
||||
{
|
||||
try {
|
||||
var selectedItem = grid.CurrentItem as DataRowView;
|
||||
var dataRow = (selectedItem as DataRowView).Row;
|
||||
var cellValue = dataRow[columname].ToString();
|
||||
return cellValue;
|
||||
}
|
||||
catch { return ""; }
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user