You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
139 lines
4.6 KiB
139 lines
4.6 KiB
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 KlasseController : ControllerBase
|
|
{
|
|
public static List<Klasse> GetAllData()
|
|
{
|
|
dbhelper dbh = new dbhelper();
|
|
dbh.Get_Tabledata("Select * from Klasse", false, true);
|
|
return dbh.ConvertDataTable<Klasse>(dbh.dsdaten.Tables[0]);
|
|
}
|
|
|
|
public static List<Klasse> GetByID(int ID)
|
|
{
|
|
dbhelper dbh = new dbhelper();
|
|
dbh.Get_Tabledata("Select * from Klasse where id=" + ID.ToString(), false, true);
|
|
return dbh.ConvertDataTable<Klasse>(dbh.dsdaten.Tables[0]);
|
|
}
|
|
|
|
public static List<Klasse> GetByLehrerID(int ID)
|
|
{
|
|
dbhelper dbh = new dbhelper();
|
|
dbh.Get_Tabledata("Select * from Klasse where lehrerid=" + ID.ToString(), false, true);
|
|
return dbh.ConvertDataTable<Klasse>(dbh.dsdaten.Tables[0]);
|
|
}
|
|
|
|
|
|
public static List<Klasse> GetLast()
|
|
{
|
|
dbhelper dbh = new dbhelper();
|
|
dbh.Get_Tabledata("Select top 1 * from Klasse order by mutiert_am desc", false, true);
|
|
return dbh.ConvertDataTable<Klasse>(dbh.dsdaten.Tables[0]);
|
|
}
|
|
public static List<Klasse> GetLastByMutierer(string Mutierer)
|
|
{
|
|
dbhelper dbh = new dbhelper();
|
|
dbh.Get_Tabledata("Select top 1 * from Klasse where mutierer='" + Mutierer + "' order by mutiert_am desc", false, true);
|
|
return dbh.ConvertDataTable<Klasse>(dbh.dsdaten.Tables[0]);
|
|
}
|
|
|
|
public static List<Klasse> GetbyUserSQL(string SQL)
|
|
{
|
|
dbhelper dbh = new dbhelper();
|
|
dbh.Get_Tabledata(SQL, false, true);
|
|
return dbh.ConvertDataTable<Klasse>(dbh.dsdaten.Tables[0]);
|
|
}
|
|
|
|
public static int POST(Klasse Klassedata)
|
|
{
|
|
dbhelper dbh = new dbhelper();
|
|
dbh.Get_Tabeldata_for_Update("Select top 1 * from [Klasse] where id=-1", false, true);
|
|
DataRow dr = dbh.dsdaten.Tables[0].NewRow();
|
|
Klassedata.GetType().GetProperties().ToList().ForEach(f =>
|
|
{
|
|
try
|
|
{
|
|
if (f.PropertyType == typeof(DateTime))
|
|
{
|
|
dr[f.Name] = (DateTime)f.GetValue(Klassedata, null);
|
|
|
|
}
|
|
else
|
|
{
|
|
dr[f.Name] = f.GetValue(Klassedata, null);
|
|
}
|
|
}
|
|
catch (Exception ex) { string s = ex.Message; }
|
|
});
|
|
dbh.dsdaten.Tables[0].Rows.Add(dr);
|
|
dbh.Update_Tabeldata();
|
|
List<Klasse> tmplst = GetLastByMutierer(Klassedata.mutierer);
|
|
return tmplst.First<Klasse>().ID;
|
|
}
|
|
|
|
public static void PUT(Klasse Klassedata)
|
|
{
|
|
dbhelper dbh = new dbhelper();
|
|
dbh.Get_Tabeldata_for_Update("Select top 1 * from [Klasse] where id=" + Klassedata.ID.ToString(), false, true);
|
|
DataRow dr = dbh.dsdaten.Tables[0].Rows[0];
|
|
Klassedata.GetType().GetProperties().ToList().ForEach(f =>
|
|
{
|
|
try
|
|
{
|
|
if (f.PropertyType == typeof(DateTime))
|
|
{
|
|
dr[f.Name] = (DateTime)f.GetValue(Klassedata, null);
|
|
}
|
|
else
|
|
{
|
|
dr[f.Name] = f.GetValue(Klassedata, null);
|
|
}
|
|
}
|
|
catch (Exception ex) { string s = ex.Message; }
|
|
});
|
|
dbh.Update_Tabeldata();
|
|
|
|
}
|
|
|
|
public static DataTable Klassenpruefung_Schueler(int KlasseID)
|
|
{
|
|
dbhelper dbh = new dbhelper();
|
|
DataTable spparams = new DataTable();
|
|
spparams.Columns.Clear();
|
|
spparams.Rows.Clear();
|
|
spparams.Columns.Add("Paramname");
|
|
spparams.Columns.Add("Paramvalue");
|
|
|
|
DataRow paramdata = spparams.NewRow();
|
|
paramdata[0] = "Param1";
|
|
paramdata[1] = KlasseID.ToString();
|
|
|
|
|
|
return dbh.Get_Tabledata("chkklasse", true, false, spparams);
|
|
|
|
|
|
}
|
|
|
|
public static void DELETE(Klasse Klassedata)
|
|
{
|
|
dbhelper dbh = new dbhelper();
|
|
dbh.Get_Tabeldata_for_Update("delete from [Klasse] where id=" + Klassedata.ID.ToString(), false, true);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} |