<%@ Page Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="True" CodeBehind="Benutzerverwaltung.aspx.cs" Inherits="QW2021C.Administration.Benutzerverwaltung" %>

<%@ Register Assembly="Syncfusion.EJ.Web, Version=18.3460.0.35, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89" Namespace="Syncfusion.JavaScript.Web" TagPrefix="ej" %>
<%@ Register Assembly="Syncfusion.EJ, Version=18.3460.0.35, Culture=neutral, PublicKeyToken=3d67ed1f87d44c89" Namespace="Syncfusion.JavaScript.Models" TagPrefix="ej" %>

<%@ Register assembly="Syncfusion.EJ" namespace="Syncfusion.JavaScript.Models" tagprefix="ej" %>

<asp:Content ID="MainContent" ContentPlaceHolderID="MainContent" runat="Server">

    <asp:Label runat="server"><h4>Benutzerverwaltung</h4></asp:Label>
<br />
    <ej:Button ID="Button1" runat="server" Text="User für neue Vereine generieren" Type="Button" EnableRTL="true" OnClick="btnGeneratePWk">
    </ej:Button>
     <ej:Button ID="Button2" runat="server" Text="Neuer Benutzer" EnableRTL="true" Type="Button" OnClick="btnNewUser">
    </ej:Button>
     <ej:Button ID="Button3" runat="server" Text="Passworte für Benutzer generieren" Type="Button" OnClick="Button3_Click">
    </ej:Button>
    <br />
    <ej:Grid ID="Grid1" runat="server" CssClass="" DataSourceCachingMode="None" DataSourceID="SqlDataSource1" EnableLoadOnDemand="False" Locale="de-DE" MinWidth="0" AllowPaging="True" AllowScrolling="True" AllowSorting="True" AllowFiltering="True" AllowTextWrap="True">
        <Columns>
            <ej:Column AllowEditing="False" DataType="number" Field="BenutzerNr" IsIdentity="True" IsPrimaryKey="True" HeaderText="Nr" Width="50px">
            </ej:Column>
            <ej:Column DataType="string" Field="UserId">
            </ej:Column>
            <ej:Column DataType="string" Field="Passwort">
            </ej:Column>
            <ej:Column DataType="string" Field="Nachname">
            </ej:Column>
            <ej:Column DataType="string" Field="Vorname">
            </ej:Column>
            <ej:Column DataType="string" Field="Vereinnr" ForeignKeyField="account_code" ForeignKeyValue="account_code_bez" HeaderText="Verein">
            </ej:Column>
            <ej:Column DataType="String" Field="Verein" AllowEditing="false" HeaderText="Verein">

            </ej:Column>
            <ej:Column DataType="string" Field="RolleNr" ForeignKeyField="RolleNr" ForeignKeyValue="Bezeichnung" HeaderText="Rolle">
            </ej:Column>
            <ej:Column DataType="date" Field="Erstellt_am" Format="{0:dd.MM.yyyy hh:mm}" AllowEditing="false">
            </ej:Column>
            <ej:Column DataType="date" Field="Mutiert_am" Format="{0:dd.MM.yyyy hh:mm}" AllowEditing="false">
            </ej:Column>
            <ej:Column DataType="number" Field="Mutierer" HeaderText="M." Width="50px">
            </ej:Column>
            <ej:Column DataType="string" Field="email" HeaderText="E-Mail"> 
            </ej:Column>
            <ej:Column DataType="boolean" Field="aktiv" EditType="BooleanEdit" HeaderText="Aktiv" Width="70px">
            </ej:Column>
        </Columns>
        <EditSettings AllowAdding="True" AllowEditing="True" EditMode="InlineForm" />
    </ej:Grid>

    <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:QWToolConnectionstring %>" SelectCommand="SELECT [NrAccount], [account_name] FROM [base_account]"></asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:QWToolConnectionstring %>"
        SelectCommand="SELECT [iRolleNr], [Bezeichnung] FROM [Rolle]"></asp:SqlDataSource>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:QWToolConnectionstring %>"
        SelectCommand="SELECT dbo.[User].BenutzerNr, dbo.[User].UserId, dbo.[User].Passwort, dbo.[User].Nachname, dbo.[User].Vorname, dbo.[User].Vereinnr, dbo.base_account.account_name AS Verein, dbo.[User].RolleNr, dbo.[User].Erstellt_am, dbo.[User].Mutiert_am, dbo.[User].Mutierer, dbo.[User].email, dbo.[User].aktiv FROM  dbo.[User] LEFT OUTER JOIN dbo.base_account ON dbo.[User].Vereinnr = dbo.base_account.account_code"
        DeleteCommand="DELETE FROM [User] WHERE [BenutzerNr] = @BenutzerNr"
        InsertCommand="INSERT INTO [User] ([UserId], [Passwort], [Nachname], [Vorname], [Vereinnr], [RolleNr], [Erstellt_am], [Mutiert_am], [Mutierer], [email], [aktiv], [vnr]) VALUES (@UserId, @Passwort, @Nachname, @Vorname, @Vereinnr, @RolleNr, @Erstellt_am, @Mutiert_am, @Mutierer, @email, @aktiv,@vnr)"
        UpdateCommand="UPDATE [User] SET [UserId] = @UserId, [Passwort] = @Passwort, [Nachname] = @Nachname, [Vorname] = @Vorname, [Vereinnr] = @Vereinnr, [RolleNr] = @RolleNr, [Mutiert_am] = getdate(), [Mutierer] = @Mutierer, [email] = @email, [aktiv] = @aktiv WHERE [BenutzerNr] = @BenutzerNr">
        <DeleteParameters>
            <asp:Parameter Name="BenutzerNr" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="UserId" Type="String" />
            <asp:Parameter Name="Passwort" Type="String" />
            <asp:Parameter Name="Nachname" Type="String" />
            <asp:Parameter Name="Vorname" Type="String" />
            <asp:Parameter Name="Vereinnr" Type="String" />
            <asp:Parameter Name="RolleNr" Type="String" />
            <asp:Parameter Name="Erstellt_am" Type="DateTime" />
            <asp:Parameter Name="Mutiert_am" Type="DateTime" />
            <asp:Parameter Name="Mutierer" Type="Int32" />
            <asp:Parameter Name="email" Type="String" />
            <asp:Parameter Name="aktiv" Type="Boolean" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="UserId" Type="String" />
            <asp:Parameter Name="Passwort" Type="String" />
            <asp:Parameter Name="Nachname" Type="String" />
            <asp:Parameter Name="Vorname" Type="String" />
            <asp:Parameter Name="Vereinnr" Type="String" />
            <asp:Parameter Name="RolleNr" Type="String" />
            <asp:Parameter Name="Mutierer" Type="Int32" />
            <asp:Parameter Name="email" Type="String" />
            <asp:Parameter Name="aktiv" Type="Boolean" />
            <asp:Parameter Name="BenutzerNr" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>

</asp:Content>
