Nach Update Syncfusion / Anpassungen Nativ
This commit is contained in:
56
Client/Backup/Helper/ConvertHelper.cs
Normal file
56
Client/Backup/Helper/ConvertHelper.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OnDoc.Helper
|
||||
{
|
||||
public static class ConvertHelper
|
||||
{
|
||||
//public static MemoryStream Base64ToMemoryStram(string Base64String)
|
||||
//{
|
||||
// //data:image/gif;base64,
|
||||
// //this image is a single pixel (black)
|
||||
// byte[] bytes = Convert.FromBase64String(Base64String);
|
||||
|
||||
// using (MemoryStream ms = new MemoryStream(bytes))
|
||||
// {
|
||||
// image = Image.FromStream(ms);
|
||||
// }
|
||||
|
||||
// return image;
|
||||
//}
|
||||
|
||||
public enum DateTimeFormat{
|
||||
datumshort,
|
||||
datummedium,
|
||||
datumlong,
|
||||
|
||||
}
|
||||
public static string Datum(DateTime date, DateTimeFormat format) {
|
||||
switch (format)
|
||||
{
|
||||
case DateTimeFormat.datumshort:
|
||||
return date.ToShortDateString();
|
||||
break;
|
||||
case DateTimeFormat.datummedium:
|
||||
return date.ToString("dd.MMMM yyyy");
|
||||
break;
|
||||
case DateTimeFormat.datumlong:
|
||||
return date.ToLongDateString();
|
||||
break;
|
||||
default:
|
||||
return date.ToShortDateString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return date.ToString("dd.mm.yyyy");
|
||||
}
|
||||
}
|
||||
}
|
||||
26
Client/Backup/Helper/FileHelper.cs
Normal file
26
Client/Backup/Helper/FileHelper.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OnDoc.Helper
|
||||
{
|
||||
public class FileHelper
|
||||
{
|
||||
public bool SaveBase64ToFile(string Base64String, string filename)
|
||||
{
|
||||
try
|
||||
{
|
||||
System.IO.File.WriteAllBytes(filename, Convert.FromBase64String(Base64String));
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
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