Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <%@ Page Title="" Language="C#" MasterPageFile="~/PageTemplate.master" AutoEventWireup="true" CodeFile="Customers.aspx.cs" Inherits="_Customers" %>
- <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
- <asp:MultiView ID="multiView" runat="server">
- <asp:View ID="selectView" runat="server">
- <h1>Lista klientów</h1>
- <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString='<%$ ConnectionStrings:ProjektDBConnectionString %>' SelectCommand="SELECT [Id], [Konto], [Imię], [Nazwisko], [Użytkownik], [Telefon] FROM [Klienci]" DeleteCommand="DELETE FROM [Klienci] WHERE [Id] = @Id" InsertCommand="INSERT INTO [Klienci] ([Id], [Konto], [Imię], [Nazwisko], [Użytkownik], [Telefon]) VALUES (@Id, @Konto, @Imię, @Nazwisko, @Użytkownik, @Telefon)" UpdateCommand="UPDATE [Klienci] SET [Konto] = @Konto, [Imię] = @Imię, [Nazwisko] = @Nazwisko, [Użytkownik] = @Użytkownik, [Telefon] = @Telefon WHERE [Id] = @Id" OnDeleted="SqlDataSource1_Deleted" OnUpdated="SqlDataSource1_Updated">
- <DeleteParameters>
- <asp:Parameter Name="Id" Type="String" />
- </DeleteParameters>
- <InsertParameters>
- <asp:ControlParameter ControlID="peselInput" Name="Id" PropertyName="Text" Type="String" />
- <asp:ControlParameter ControlID="accountInput" Name="Konto" PropertyName="SelectedValue" Type="String" />
- <asp:ControlParameter ControlID="firstInput" Name="Imię" PropertyName="Text" Type="String" />
- <asp:ControlParameter ControlID="lastInput" Name="Nazwisko" PropertyName="Text" Type="String" />
- <asp:ControlParameter ControlID="userInput" Name="Użytkownik" PropertyName="SelectedValue" Type="String" />
- <asp:ControlParameter ControlID="phoneInput" Name="Telefon" PropertyName="Text" Type="Int32" />
- </InsertParameters>
- <UpdateParameters>
- <asp:Parameter Name="Konto" Type="String" />
- <asp:Parameter Name="Imię" Type="String" />
- <asp:Parameter Name="Nazwisko" Type="String" />
- <asp:Parameter Name="Użytkownik" Type="String" />
- <asp:Parameter Name="Telefon" Type="Int32" />
- <asp:Parameter Name="Id" Type="String" />
- </UpdateParameters>
- </asp:SqlDataSource>
- <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" BackColor="#CCCCCC" BorderColor="#999999" BorderStyle="Solid" BorderWidth="3px" CellPadding="4" CellSpacing="2" ForeColor="Black" PageSize="20" DataKeyNames="Id" Font-Names="Consolas" Font-Size="Large" HorizontalAlign="Center">
- <AlternatingRowStyle BackColor="#E9F8F8" />
- <Columns>
- <asp:TemplateField HeaderText="PESEL" SortExpression="Id">
- <EditItemTemplate>
- <asp:Label ID="Label1" runat="server" Text='<%# Eval("Id") %>'></asp:Label>
- </EditItemTemplate>
- <ItemTemplate>
- <asp:Label ID="Label1" runat="server" Text='<%# Bind("Id") %>'></asp:Label>
- </ItemTemplate>
- <ItemStyle HorizontalAlign="Center" />
- </asp:TemplateField>
- <asp:TemplateField HeaderText="Konto" SortExpression="Konto">
- <EditItemTemplate>
- <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1" DataTextField="Konto" DataValueField="Konto" SelectedValue='<%# Bind("Konto") %>'></asp:DropDownList>
- </EditItemTemplate>
- <ItemTemplate>
- <asp:Label ID="Label2" runat="server" Text='<%# Bind("Konto") %>'></asp:Label>
- </ItemTemplate>
- <ItemStyle HorizontalAlign="Center" />
- </asp:TemplateField>
- <asp:TemplateField HeaderText="Imię" SortExpression="Imię">
- <EditItemTemplate>
- <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Imię") %>'></asp:TextBox>
- <asp:RequiredFieldValidator ID="rfvFirstname" runat="server" ErrorMessage="Proszę podać imię!" Text="*" ControlToValidate="TextBox2"></asp:RequiredFieldValidator>
- <asp:RegularExpressionValidator ID="revFirstname" runat="server" ErrorMessage="Imię powinno składać się wyłącznie z liter, pierwsza z nich musi być duża, a ilość liter powinna być pomiędzy 2 a 24!" Text="*" ControlToValidate="TextBox2" ValidationExpression="^[A-Z]{1}[a-z]{1,23}$"></asp:RegularExpressionValidator>
- </EditItemTemplate>
- <ItemTemplate>
- <asp:Label ID="Label3" runat="server" Text='<%# Bind("Imię") %>'></asp:Label>
- </ItemTemplate>
- </asp:TemplateField>
- <asp:TemplateField HeaderText="Nazwisko" SortExpression="Nazwisko">
- <EditItemTemplate>
- <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Nazwisko") %>'></asp:TextBox>
- <asp:RequiredFieldValidator ID="rfvLastname" runat="server" ErrorMessage="Proszę podać nazwisko!" ControlToValidate="TextBox3" Text="*"></asp:RequiredFieldValidator>
- <asp:RegularExpressionValidator ID="revLastnamer" runat="server" ErrorMessage="Nazwisko powinno składać się wyłącznie z liter, pierwsza z nich musi być duża, a ilość liter powinna być pomiędzy 2 a 24!" Text="*" ControlToValidate="TextBox3" ValidationExpression="^[A-Z]{1}[a-z]{1,23}$"></asp:RegularExpressionValidator>
- </EditItemTemplate>
- <ItemTemplate>
- <asp:Label ID="Label4" runat="server" Text='<%# Bind("Nazwisko") %>'></asp:Label>
- </ItemTemplate>
- </asp:TemplateField>
- <asp:TemplateField HeaderText="Użytkownik" SortExpression="Użytkownik">
- <EditItemTemplate>
- <asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="SqlDataSource1" DataTextField="Użytkownik" DataValueField="Użytkownik" SelectedValue='<%# Bind("Użytkownik") %>'></asp:DropDownList>
- </EditItemTemplate>
- <ItemTemplate>
- <asp:Label ID="Label5" runat="server" Text='<%# Bind("Użytkownik") %>'></asp:Label>
- </ItemTemplate>
- </asp:TemplateField>
- <asp:TemplateField HeaderText="Telefon" SortExpression="Telefon">
- <EditItemTemplate>
- <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("Telefon") %>'></asp:TextBox>
- <asp:RequiredFieldValidator ID="rfvPhone" runat="server" ErrorMessage="Proszę podać numer telefonu!" ControlToValidate="TextBox5" Text="*"></asp:RequiredFieldValidator>
- <asp:RangeValidator ID="rvPhone" runat="server" ErrorMessage="Numer telefonu to 9 cyfrowa liczba bez żadnych spacji!" Text="*" ControlToValidate="TextBox5" MaximumValue="999999999" MinimumValue="100000000" Type="Integer"></asp:RangeValidator>
- </EditItemTemplate>
- <ItemTemplate>
- <asp:Label ID="Label6" runat="server" Text='<%# Bind("Telefon") %>'></asp:Label>
- </ItemTemplate>
- <ItemStyle HorizontalAlign="Center" />
- </asp:TemplateField>
- <asp:TemplateField ShowHeader="False">
- <EditItemTemplate>
- <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update" Text="Aktualizuj"></asp:LinkButton>
- <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel" Text="Anuluj"></asp:LinkButton>
- </EditItemTemplate>
- <ItemTemplate>
- <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit" Text="Edytuj"></asp:LinkButton>
- <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Delete" Text="Usuń" OnClientClick="return confirm('Czy na pewno chcesz usunąć ten wpis?');"></asp:LinkButton>
- </ItemTemplate>
- <ItemStyle HorizontalAlign="Center" />
- </asp:TemplateField>
- </Columns>
- <FooterStyle BackColor="#CCCCCC" />
- <HeaderStyle BackColor="#22A7FF" Font-Bold="True" ForeColor="White" Font-Size="Larger" HorizontalAlign="Center" VerticalAlign="Middle" />
- <PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Center" />
- <RowStyle BackColor="White" />
- <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
- <SortedAscendingCellStyle BackColor="#F1F1F1" />
- <SortedAscendingHeaderStyle BackColor="#808080" />
- <SortedDescendingCellStyle BackColor="#CAC9C9" />
- <SortedDescendingHeaderStyle BackColor="#383838" />
- </asp:GridView>
- <asp:ValidationSummary ID="vs" runat="server" />
- <h2><a href="Customers.aspx?view=insert">Dodaj nowego klienta</a></h2>
- </asp:View>
- <asp:View ID="insertView" runat="server">
- <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString='<%$ ConnectionStrings:ProjektDBConnectionString %>' SelectCommand="SELECT [Id] FROM [Konta]"></asp:SqlDataSource>
- <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString='<%$ ConnectionStrings:ProjektDBConnectionString %>' SelectCommand="SELECT [Użytkownik] FROM [Użytkownicy]"></asp:SqlDataSource>
- <h1>Dodaj klienta</h1>
- <asp:Table ID="Table1" runat="server" CssClass="Formularz">
- <asp:TableRow>
- <asp:TableCell>
- PESEL
- <asp:RequiredFieldValidator ID="rfvPesel" runat="server" ErrorMessage="Proszę podać PESEL!" Text="*" ControlToValidate="peselInput"></asp:RequiredFieldValidator>
- <asp:RegularExpressionValidator ID="revPesel" runat="server" ErrorMessage="RegularExpressionValidator" ControlToValidate="peselInput" Text="*" ValidationExpression="^[0-9]{11}$"></asp:RegularExpressionValidator>
- </asp:TableCell>
- <asp:TableCell>
- <asp:TextBox ID="peselInput" runat="server"></asp:TextBox>
- </asp:TableCell>
- </asp:TableRow>
- <asp:TableRow>
- <asp:TableCell>
- Konto
- </asp:TableCell>
- <asp:TableCell>
- <asp:DropDownList ID="accountInput" runat="server" DataSourceID="SqlDataSource2" DataTextField="Id" DataValueField="Id"></asp:DropDownList>
- </asp:TableCell>
- </asp:TableRow>
- <asp:TableRow>
- <asp:TableCell>
- Imię
- <asp:RequiredFieldValidator ID="rfvFirstname" runat="server" ErrorMessage="Proszę podać imię!" Text="*" ControlToValidate="firstInput"></asp:RequiredFieldValidator>
- <asp:RegularExpressionValidator ID="revFirstname" runat="server" ErrorMessage="Imię powinno składać się wyłącznie z liter, pierwsza z nich musi być duża, a ilość liter powinna być pomiędzy 2 a 24!" Text="*" ControlToValidate="firstInput" ValidationExpression="^[A-Z]{1}[a-z]{1,23}$"></asp:RegularExpressionValidator>
- </asp:TableCell>
- <asp:TableCell>
- <asp:TextBox ID="firstInput" runat="server"></asp:TextBox>
- </asp:TableCell>
- </asp:TableRow>
- <asp:TableRow>
- <asp:TableCell>
- Nazwisko
- <asp:RequiredFieldValidator ID="rfvLastname" runat="server" ErrorMessage="Proszę podać nazwisko!" ControlToValidate="lastInput" Text="*"></asp:RequiredFieldValidator>
- <asp:RegularExpressionValidator ID="revLastnamer" runat="server" ErrorMessage="Nazwisko powinno składać się wyłącznie z liter, pierwsza z nich musi być duża, a ilość liter powinna być pomiędzy 2 a 24!" Text="*" ControlToValidate="lastInput" ValidationExpression="^[A-Z]{1}[a-z]{1,23}$"></asp:RegularExpressionValidator>
- </asp:TableCell>
- <asp:TableCell>
- <asp:TextBox ID="lastInput" runat="server"></asp:TextBox>
- </asp:TableCell>
- </asp:TableRow>
- <asp:TableRow>
- <asp:TableCell>
- Użytkownik
- </asp:TableCell>
- <asp:TableCell>
- <asp:DropDownList ID="userInput" runat="server" DataSourceID="SqlDataSource3" DataTextField="Użytkownik" DataValueField="Użytkownik"></asp:DropDownList>
- </asp:TableCell>
- </asp:TableRow>
- <asp:TableRow>
- <asp:TableCell>
- Telefon
- <asp:RequiredFieldValidator ID="rfvPhone" runat="server" ErrorMessage="Proszę podać numer telefonu!" ControlToValidate="phoneInput" Text="*"></asp:RequiredFieldValidator>
- <asp:RangeValidator ID="rvPhone" runat="server" ErrorMessage="Numer telefonu to 9 cyfrowa liczba bez żadnych spacji!" Text="*" ControlToValidate="phoneInput" MaximumValue="999999999" MinimumValue="100000000" Type="Integer"></asp:RangeValidator>
- </asp:TableCell>
- <asp:TableCell>
- <asp:TextBox ID="phoneInput" runat="server"></asp:TextBox>
- </asp:TableCell>
- </asp:TableRow>
- </asp:Table>
- <p>
- <asp:LinkButton ID="addButton" runat="server" OnClick="addButton_Click">Dodaj</asp:LinkButton>
- </p>
- <asp:ValidationSummary ID="vsAdd" runat="server" />
- </asp:View>
- <asp:View ID="defaultView" runat="server">
- <h1>BRAK DOSTĘPU</h1>
- <h1>Chcesz zobaczyć tę stronę? - <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Login.aspx">zaloguj się</asp:HyperLink></h1>
- </asp:View>
- </asp:MultiView>
- </asp:Content>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement