Update 07082021
This commit is contained in:
114
BlazorApp/Controller/KlassenTyp/KlassentypController.cs
Normal file
114
BlazorApp/Controller/KlassenTyp/KlassentypController.cs
Normal file
@@ -0,0 +1,114 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using BWPMModels;
|
||||
using BlazorApp.Helper;
|
||||
using Newtonsoft.Json;
|
||||
using System.Data;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace BlazorApp.Controller
|
||||
|
||||
{
|
||||
|
||||
public class KlassentypController : ControllerBase
|
||||
{
|
||||
public static List<Klassentyp> GetAllData()
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select * from Klassentyp", false, true);
|
||||
return dbh.ConvertDataTable<Klassentyp>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
|
||||
public static List<Klassentyp> GetAllAktiveData()
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select * from Klassentyp where aktiv=1", false, true);
|
||||
return dbh.ConvertDataTable<Klassentyp>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
|
||||
public static List<Klassentyp> GetByID(int ID)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select * from Klassentyp where id=" + ID.ToString(), false, true);
|
||||
return dbh.ConvertDataTable<Klassentyp>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
|
||||
public static List<Klassentyp> GetLast()
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select top 1 * from Klassentyp order by mutiert_am desc", false, true);
|
||||
return dbh.ConvertDataTable<Klassentyp>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
public static List<Klassentyp> GetLastByMutierer(string Mutierer)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select top 1 * from Klassentyp where mutierer='" + Mutierer + "' order by mutiert_am desc", false, true);
|
||||
return dbh.ConvertDataTable<Klassentyp>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
|
||||
public static List<Klassentyp> GetbyUserSQL(string SQL)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata(SQL, false, true);
|
||||
return dbh.ConvertDataTable<Klassentyp>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
|
||||
public static int POST(Klassentyp Klassentypdata)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabeldata_for_Update("Select top 1 * from [Klassentyp] where id=-1", false, true);
|
||||
DataRow dr = dbh.dsdaten.Tables[0].NewRow();
|
||||
Klassentypdata.GetType().GetProperties().ToList().ForEach(f =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (f.PropertyType == typeof(DateTime))
|
||||
{
|
||||
dr[f.Name] = (DateTime)f.GetValue(Klassentypdata, null);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
dr[f.Name] = f.GetValue(Klassentypdata, null);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { string s = ex.Message; }
|
||||
});
|
||||
dbh.dsdaten.Tables[0].Rows.Add(dr);
|
||||
dbh.Update_Tabeldata();
|
||||
List<Klassentyp> tmplst = GetLastByMutierer(Klassentypdata.mutierer);
|
||||
return tmplst.First<Klassentyp>().ID;
|
||||
}
|
||||
|
||||
public static void PUT(Klassentyp Klassentypdata)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabeldata_for_Update("Select top 1 * from [Klassentyp] where id=" + Klassentypdata.ID.ToString(), false, true);
|
||||
DataRow dr = dbh.dsdaten.Tables[0].Rows[0];
|
||||
Klassentypdata.GetType().GetProperties().ToList().ForEach(f =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (f.PropertyType == typeof(DateTime))
|
||||
{
|
||||
dr[f.Name] = (DateTime)f.GetValue(Klassentypdata, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
dr[f.Name] = f.GetValue(Klassentypdata, null);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { string s = ex.Message; }
|
||||
});
|
||||
dbh.Update_Tabeldata();
|
||||
|
||||
}
|
||||
|
||||
public static void DELETE(Klassentyp Klassentypdata)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabeldata_for_Update("delete from [Klassentyp] where id=" + Klassentypdata.ID.ToString(), false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user