Update 07082021
This commit is contained in:
135
BlazorApp/Controller/Firma/AnsprechpartnerController.cs
Normal file
135
BlazorApp/Controller/Firma/AnsprechpartnerController.cs
Normal file
@@ -0,0 +1,135 @@
|
||||
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 AnsprechpartnerController : ControllerBase
|
||||
{
|
||||
public static List<Ansprechpartner> GetAllData()
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select * from Ansprechpartner", false, true);
|
||||
return dbh.ConvertDataTable<Ansprechpartner>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
|
||||
public static List<ViewAnsprechpartner> GetAllAktivData()
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("SELECT ID, FirmaID, name + ' ' + vorname AS Ansprechpartner FROM dbo.Ansprechpartner WHERE aktiv = 1 ORDER BY Ansprechpartner", false, true);
|
||||
return dbh.ConvertDataTable<ViewAnsprechpartner>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
public static List<Ansprechpartner> GetByID(int ID)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select * from Ansprechpartner where id=" + ID.ToString(), false, true);
|
||||
return dbh.ConvertDataTable<Ansprechpartner>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
public static List<Ansprechpartner> GetByFirmaID(int ID)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select * from Ansprechpartner where aktiv=1 and firmaid=" + ID.ToString(), false, true);
|
||||
return dbh.ConvertDataTable<Ansprechpartner>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
|
||||
public static List<Ansprechpartner> GetAllAktivDataByFirmaID(int firmaid)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("SELECT * from Ansprechpartner WHERE aktiv = 1 and firmaid=" + firmaid.ToString() + " ORDER BY Name, Vorname", false, true);
|
||||
return dbh.ConvertDataTable<Ansprechpartner>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
|
||||
|
||||
public static List<Ansprechpartner> GetLast()
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select top 1 * from Ansprechpartner order by mutiert_am desc", false, true);
|
||||
return dbh.ConvertDataTable<Ansprechpartner>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
public static List<Ansprechpartner> GetLastByMutierer(string Mutierer)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select top 1 * from Ansprechpartner where mutierer='" + Mutierer + "' order by mutiert_am desc", false, true);
|
||||
return dbh.ConvertDataTable<Ansprechpartner>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
|
||||
public static List<Ansprechpartner> GetbyUserSQL(string SQL)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata(SQL, false, true);
|
||||
return dbh.ConvertDataTable<Ansprechpartner>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
|
||||
public static int POST(Ansprechpartner Ansprechpartnerdata)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabeldata_for_Update("Select top 1 * from [Ansprechpartner] where id=-1", false, true);
|
||||
DataRow dr = dbh.dsdaten.Tables[0].NewRow();
|
||||
Ansprechpartnerdata.GetType().GetProperties().ToList().ForEach(f =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (f.PropertyType == typeof(DateTime))
|
||||
{
|
||||
dr[f.Name] = (DateTime)f.GetValue(Ansprechpartnerdata, null);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
dr[f.Name] = f.GetValue(Ansprechpartnerdata, null);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { string s = ex.Message; }
|
||||
});
|
||||
dbh.dsdaten.Tables[0].Rows.Add(dr);
|
||||
dbh.Update_Tabeldata();
|
||||
List<Ansprechpartner> tmplst = GetLastByMutierer(Ansprechpartnerdata.mutierer);
|
||||
return tmplst.First<Ansprechpartner>().ID;
|
||||
}
|
||||
|
||||
public static void PUT(Ansprechpartner Ansprechpartnerdata)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabeldata_for_Update("Select top 1 * from [Ansprechpartner] where id=" + Ansprechpartnerdata.ID.ToString(), false, true);
|
||||
DataRow dr = dbh.dsdaten.Tables[0].Rows[0];
|
||||
Ansprechpartnerdata.GetType().GetProperties().ToList().ForEach(f =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (f.PropertyType == typeof(DateTime))
|
||||
{
|
||||
dr[f.Name] = (DateTime)f.GetValue(Ansprechpartnerdata, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
dr[f.Name] = f.GetValue(Ansprechpartnerdata, null);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { string s = ex.Message; }
|
||||
});
|
||||
dbh.Update_Tabeldata();
|
||||
|
||||
}
|
||||
|
||||
public static void DELETE(Ansprechpartner Ansprechpartnerdata)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabeldata_for_Update("delete from [Ansprechpartner] where id=" + Ansprechpartnerdata.ID.ToString(), false, true);
|
||||
}
|
||||
}
|
||||
|
||||
public class ViewAnsprechpartner
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
131
BlazorApp/Controller/Firma/FirmaController.cs
Normal file
131
BlazorApp/Controller/Firma/FirmaController.cs
Normal file
@@ -0,0 +1,131 @@
|
||||
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 FirmaController : ControllerBase
|
||||
{
|
||||
public static List<Firma> GetAllData()
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select * from Firma", false, true);
|
||||
return dbh.ConvertDataTable<Firma>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
|
||||
public static List<Firma> GetByID(int ID)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select * from Firma where id=" + ID.ToString(), false, true);
|
||||
return dbh.ConvertDataTable<Firma>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
|
||||
public static List<Firma> GetLast()
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select top 1 * from Firma order by mutiert_am desc", false, true);
|
||||
return dbh.ConvertDataTable<Firma>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
public static List<Firma> GetLastByMutierer(string Mutierer)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select top 1 * from Firma where mutierer='" + Mutierer + "' order by mutiert_am desc", false, true);
|
||||
return dbh.ConvertDataTable<Firma>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
|
||||
public static List<Firma> GetbyUserSQL(string SQL)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata(SQL, false, true);
|
||||
return dbh.ConvertDataTable<Firma>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
|
||||
public static List<Firma> GetByUserID(string UserID)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select * from Firma where userid='" + UserID + "'", false, true);
|
||||
if (dbh.dsdaten.Tables[0].Rows.Count==0)
|
||||
{
|
||||
Firma Firmadata = new Firma();
|
||||
Firmadata.aktiv = true;
|
||||
Firmadata.erstellt_am = DateTime.Now;
|
||||
Firmadata.mutierer = UserID;
|
||||
Firmadata.mutiert_am = DateTime.Now;
|
||||
Firmadata.userid = UserID;
|
||||
POST(Firmadata);
|
||||
dbh.Get_Tabledata("Select * from Firma where userid='" + UserID + "'", false, true);
|
||||
}
|
||||
return dbh.ConvertDataTable<Firma>(dbh.dsdaten.Tables[0]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static int POST(Firma Firmadata)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabeldata_for_Update("Select top 1 * from [Firma] where id=-1", false, true);
|
||||
DataRow dr = dbh.dsdaten.Tables[0].NewRow();
|
||||
Firmadata.GetType().GetProperties().ToList().ForEach(f =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (f.PropertyType == typeof(DateTime))
|
||||
{
|
||||
dr[f.Name] = (DateTime)f.GetValue(Firmadata, null);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
dr[f.Name] = f.GetValue(Firmadata, null);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { string s = ex.Message; }
|
||||
});
|
||||
dbh.dsdaten.Tables[0].Rows.Add(dr);
|
||||
dbh.Update_Tabeldata();
|
||||
List<Firma> tmplst = GetLastByMutierer(Firmadata.mutierer);
|
||||
return tmplst.First<Firma>().ID;
|
||||
}
|
||||
|
||||
public static void PUT(Firma Firmadata)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabeldata_for_Update("Select top 1 * from [Firma] where id=" + Firmadata.ID.ToString(), false, true);
|
||||
DataRow dr = dbh.dsdaten.Tables[0].Rows[0];
|
||||
Firmadata.GetType().GetProperties().ToList().ForEach(f =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (f.PropertyType == typeof(DateTime))
|
||||
{
|
||||
dr[f.Name] = (DateTime)f.GetValue(Firmadata, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
dr[f.Name] = f.GetValue(Firmadata, null);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { string s = ex.Message; }
|
||||
});
|
||||
dbh.Update_Tabeldata();
|
||||
|
||||
}
|
||||
|
||||
public static void DELETE(Firma Firmadata)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabeldata_for_Update("delete from [Firma] where id=" + Firmadata.ID.ToString(), false, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
116
BlazorApp/Controller/Firma/FirmaberufController.cs
Normal file
116
BlazorApp/Controller/Firma/FirmaberufController.cs
Normal file
@@ -0,0 +1,116 @@
|
||||
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 FirmaberufController : ControllerBase
|
||||
{
|
||||
public static List<Firmaberuf> GetAllData()
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select * from Firmaberuf", false, true);
|
||||
return dbh.ConvertDataTable<Firmaberuf>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
|
||||
public static List<Firmaberuf> GetByID(int ID)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select * from Firmaberuf where id=" + ID.ToString(), false, true);
|
||||
return dbh.ConvertDataTable<Firmaberuf>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
|
||||
public static List<Firmaberuf> GetAllAktiveByFirmaID(int ID)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select * from Firmaberuf where aktiv=1 and firmaid=" + ID.ToString(), false, true);
|
||||
return dbh.ConvertDataTable<Firmaberuf>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
public static List<Firmaberuf> GetLast()
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select top 1 * from Firmaberuf order by mutiert_am desc", false, true);
|
||||
return dbh.ConvertDataTable<Firmaberuf>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
public static List<Firmaberuf> GetLastByMutierer(string Mutierer)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata("Select top 1 * from Firmaberuf where mutierer='" + Mutierer + "' order by mutiert_am desc", false, true);
|
||||
return dbh.ConvertDataTable<Firmaberuf>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
|
||||
public static List<Firmaberuf> GetbyUserSQL(string SQL)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabledata(SQL, false, true);
|
||||
return dbh.ConvertDataTable<Firmaberuf>(dbh.dsdaten.Tables[0]);
|
||||
}
|
||||
|
||||
public static int POST(Firmaberuf Firmaberufdata)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabeldata_for_Update("Select top 1 * from [Firmaberuf] where id=-1", false, true);
|
||||
DataRow dr = dbh.dsdaten.Tables[0].NewRow();
|
||||
Firmaberufdata.GetType().GetProperties().ToList().ForEach(f =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (f.PropertyType == typeof(DateTime))
|
||||
{
|
||||
dr[f.Name] = (DateTime)f.GetValue(Firmaberufdata, null);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
dr[f.Name] = f.GetValue(Firmaberufdata, null);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { string s = ex.Message; }
|
||||
});
|
||||
dbh.dsdaten.Tables[0].Rows.Add(dr);
|
||||
dbh.Update_Tabeldata();
|
||||
List<Firmaberuf> tmplst = GetLastByMutierer(Firmaberufdata.mutierer);
|
||||
return tmplst.First<Firmaberuf>().ID;
|
||||
}
|
||||
|
||||
public static void PUT(Firmaberuf Firmaberufdata)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabeldata_for_Update("Select top 1 * from [Firmaberuf] where id=" + Firmaberufdata.ID.ToString(), false, true);
|
||||
DataRow dr = dbh.dsdaten.Tables[0].Rows[0];
|
||||
Firmaberufdata.GetType().GetProperties().ToList().ForEach(f =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (f.PropertyType == typeof(DateTime))
|
||||
{
|
||||
dr[f.Name] = (DateTime)f.GetValue(Firmaberufdata, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
dr[f.Name] = f.GetValue(Firmaberufdata, null);
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { string s = ex.Message; }
|
||||
});
|
||||
dbh.Update_Tabeldata();
|
||||
|
||||
}
|
||||
|
||||
public static void DELETE(Firmaberuf Firmaberufdata)
|
||||
{
|
||||
dbhelper dbh = new dbhelper();
|
||||
dbh.Get_Tabeldata_for_Update("delete from [Firmaberuf] where id=" + Firmaberufdata.ID.ToString(), false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user