158 lines
7.1 KiB
C#
158 lines
7.1 KiB
C#
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Text;
|
|||
|
|
using System.Windows;
|
|||
|
|
using System.Windows.Controls;
|
|||
|
|
using System.Windows.Data;
|
|||
|
|
using System.Windows.Documents;
|
|||
|
|
using System.Windows.Input;
|
|||
|
|
using System.Windows.Media;
|
|||
|
|
using System.Windows.Media.Imaging;
|
|||
|
|
using System.Windows.Shapes;
|
|||
|
|
using System.Collections;
|
|||
|
|
namespace BeWoAdmin
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// Interaktionslogik für ExtndLicnsWnd.xaml
|
|||
|
|
/// </summary>
|
|||
|
|
public partial class ExtndLicnsWnd : Window
|
|||
|
|
{
|
|||
|
|
private Tenant selectedTenant;
|
|||
|
|
private Window1 parent;
|
|||
|
|
private String extLicenses = null;
|
|||
|
|
private bool bntEnable = false;
|
|||
|
|
|
|||
|
|
public ExtndLicnsWnd(Tenant t, Window1 parent)
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
this.Owner = parent;
|
|||
|
|
this.selectedTenant = t;
|
|||
|
|
this.parent = parent;
|
|||
|
|
|
|||
|
|
this.licnsCount.KeyDown += new KeyEventHandler(licnsCount_KeyDown);
|
|||
|
|
this.licnsCount.TextChanged += new TextChangedEventHandler(licnsCount_TextChanged);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void licnsCount_TextChanged(object sender, TextChangedEventArgs e)
|
|||
|
|
{
|
|||
|
|
this.extLicenses = this.licnsCount.Text;
|
|||
|
|
this.bntEnable = true;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
void licnsCount_KeyDown(object sender, KeyEventArgs e)
|
|||
|
|
{
|
|||
|
|
if (((((int)e.Key) <= 43 && ((int)e.Key) >= 34) || (((int)e.Key) <= 83 && ((int)e.Key) >= 74)) && e.Key != Key.Space)
|
|||
|
|
{
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
e.Handled = true;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void StartDrag(object sender, MouseButtonEventArgs e)
|
|||
|
|
{
|
|||
|
|
this.DragMove();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void chngBtn_Click(object sender, RoutedEventArgs e)
|
|||
|
|
{
|
|||
|
|
int licenses;
|
|||
|
|
if (this.bntEnable)
|
|||
|
|
{
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
if (this.extLicenses.Length > 0 && (licenses = Convert.ToInt32(this.extLicenses)) > 0)
|
|||
|
|
{
|
|||
|
|
// gets last 'Oid' in 'person'
|
|||
|
|
List<String> ret = this.selectedTenant.ExecuteHiddenSqlCommand("SELECT Oid FROM person ORDER BY Oid DESC LIMIT 1");
|
|||
|
|
String tmp; int oid;
|
|||
|
|
if (ret != null)
|
|||
|
|
{
|
|||
|
|
tmp = ret.ElementAt(0);
|
|||
|
|
try
|
|||
|
|
{
|
|||
|
|
oid = Convert.ToInt32(tmp);
|
|||
|
|
oid += 1;
|
|||
|
|
// Building the query
|
|||
|
|
String queryStr = "INSERT INTO `person` (`Oid`, `BankAccountOid`, `AddressOid`, `Tid`, `FirstName`, `LastName`, `DateOfBirth`, `Sex`, `FamilyStatus`, `Profession`, `Type`, `Notice`, `InsTs`, `InsUser`, `Version`, `UdpUser`, `IsActive`, `SystemEntryID`) VALUES ";
|
|||
|
|
for (int i = oid; i < (oid + licenses); i++)
|
|||
|
|
{
|
|||
|
|
if (i != oid)
|
|||
|
|
queryStr += ", ";
|
|||
|
|
queryStr += "(" + i + ",NULL,NULL,1,'Mitarbeiter','" + i + "',NULL,0,NULL,NULL,1,NULL,NULL,'beyondSoft GmbH',1,'beyondSoft GmbH',1,NULL)";
|
|||
|
|
}
|
|||
|
|
queryStr += ";COMMIT;\r\n";
|
|||
|
|
|
|||
|
|
// employee
|
|||
|
|
queryStr += "INSERT INTO `employee` (`Oid`, `PersonOid`, `ApplicationUserOid`, `Tid`, `PersonnelNumber`, `TaxNumber`, `HealthInsurance`, `InsuranceNumber`, `HourlyRate`, `EntryDate`, `CancellationPeriod`, `ProbationPeriod`, `Sequence`, `IsActive`, `Notice`, `InsTs`, `InsUser`, `Version`, `UdpUser`, `SystemEntryID`, `weeklyfls`, `weeklytotalhours`, `leavedays`) VALUES ";
|
|||
|
|
for (int i = oid; i < (oid + licenses); i++)
|
|||
|
|
{
|
|||
|
|
if (i != oid)
|
|||
|
|
queryStr += ", ";
|
|||
|
|
queryStr += "(" + i + ", " + i + ",NULL,2,'" + i + "',NULL,NULL,NULL,NULL,NULL,0,0,NULL,1,NULL,NULL,'beyondSoft GmbH',1,'beyondSoft GmbH',NULL,NULL,NULL,NULL)";
|
|||
|
|
}
|
|||
|
|
queryStr += "; COMMIT;\r\n";
|
|||
|
|
|
|||
|
|
//applicationuser
|
|||
|
|
queryStr += "INSERT INTO `applicationuser` (`Oid`, `EmployeeOid`, `Tid`, `LoginName`, `Password`, `Notice`, `Version`, `UdpUser`, `InsUser`, `InsTs`, `IsActive`, `SystemEntryID`) VALUES ";
|
|||
|
|
for (int i = oid; i < (oid + licenses); i++)
|
|||
|
|
{
|
|||
|
|
if (i != oid)
|
|||
|
|
queryStr += ", ";
|
|||
|
|
queryStr += "(" + i + "," + i + ",28,'m" + i + "','18-14-1D-42-74-94-E6-74-4F-F2-65-A4-AE-07-66-CB',NULL,1,'beyondSoft GmbH','beyondSoft GmbH',NULL,1,NULL)";
|
|||
|
|
}
|
|||
|
|
queryStr += "; COMMIT;\r\n";
|
|||
|
|
|
|||
|
|
//ingroup
|
|||
|
|
queryStr += "INSERT INTO `ingroup` (`UserGroupOid`, `ApplicationUserOid`) VALUES ";
|
|||
|
|
for (int i = oid; i < (oid + licenses); i++)
|
|||
|
|
{
|
|||
|
|
if (i != oid)
|
|||
|
|
queryStr += ", ";
|
|||
|
|
if (i == 1)
|
|||
|
|
queryStr += "(1,1)";
|
|||
|
|
else
|
|||
|
|
queryStr += "(2," + i + ")";
|
|||
|
|
}
|
|||
|
|
queryStr += "; COMMIT;\r\n";
|
|||
|
|
|
|||
|
|
this.selectedTenant.ExecuteSqlCommand(queryStr);
|
|||
|
|
|
|||
|
|
this.parent.showSuccessWnd(licenses + " Lizenzen wurden erfolgreich der Datenbank hinzugefügt");
|
|||
|
|
this.Close();
|
|||
|
|
}
|
|||
|
|
catch (Exception ex)
|
|||
|
|
{
|
|||
|
|
parent.showErrorWnd("Fehler beim konvertieren der Oid: " + ex.Message);
|
|||
|
|
this.Close();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
this.parent.showErrorWnd("Bei einer Datenbankabrake ist ein Fehler aufgetreten");
|
|||
|
|
this.Close();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
this.parent.showErrorWnd("Die Anzahl der zuzufügenden Lizenzen muss größer als 0 sein");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
catch
|
|||
|
|
{
|
|||
|
|
this.parent.showErrorWnd("Ungültiges Zeichen in der Eingabe");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void cnclBtn_Click(object sender, RoutedEventArgs e)
|
|||
|
|
{
|
|||
|
|
this.Close();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|