Advertisement
Guest User

Untitled

a guest
Apr 7th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASP 15.07 KB | None | 0 0
  1. <%@ Page Title="" Language="C#" MasterPageFile="~/PageTemplate.master" AutoEventWireup="true" CodeFile="Customers.aspx.cs" Inherits="_Customers" %>
  2.  
  3. <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
  4.     <asp:MultiView ID="multiView" runat="server">
  5.         <asp:View ID="selectView" runat="server">
  6.             <h1>Lista klientów</h1>
  7.             <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">
  8.                 <DeleteParameters>
  9.                     <asp:Parameter Name="Id" Type="String" />
  10.                 </DeleteParameters>
  11.                 <InsertParameters>
  12.                     <asp:ControlParameter ControlID="peselInput" Name="Id" PropertyName="Text" Type="String" />
  13.                     <asp:ControlParameter ControlID="accountInput" Name="Konto" PropertyName="SelectedValue" Type="String" />
  14.                     <asp:ControlParameter ControlID="firstInput" Name="Imię" PropertyName="Text" Type="String" />
  15.                     <asp:ControlParameter ControlID="lastInput" Name="Nazwisko" PropertyName="Text" Type="String" />
  16.                     <asp:ControlParameter ControlID="userInput" Name="Użytkownik" PropertyName="SelectedValue" Type="String" />
  17.                     <asp:ControlParameter ControlID="phoneInput" Name="Telefon" PropertyName="Text" Type="Int32" />
  18.                 </InsertParameters>
  19.                 <UpdateParameters>
  20.                     <asp:Parameter Name="Konto" Type="String" />
  21.                     <asp:Parameter Name="Imię" Type="String" />
  22.                     <asp:Parameter Name="Nazwisko" Type="String" />
  23.                     <asp:Parameter Name="Użytkownik" Type="String" />
  24.                     <asp:Parameter Name="Telefon" Type="Int32" />
  25.                     <asp:Parameter Name="Id" Type="String" />
  26.                 </UpdateParameters>
  27.             </asp:SqlDataSource>
  28.             <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">
  29.                 <AlternatingRowStyle BackColor="#E9F8F8" />
  30.                 <Columns>
  31.                     <asp:TemplateField HeaderText="PESEL" SortExpression="Id">
  32.                         <EditItemTemplate>
  33.                             <asp:Label ID="Label1" runat="server" Text='<%# Eval("Id") %>'></asp:Label>
  34.                         </EditItemTemplate>
  35.                         <ItemTemplate>
  36.                             <asp:Label ID="Label1" runat="server" Text='<%# Bind("Id") %>'></asp:Label>
  37.                         </ItemTemplate>
  38.                         <ItemStyle HorizontalAlign="Center" />
  39.                     </asp:TemplateField>
  40.                     <asp:TemplateField HeaderText="Konto" SortExpression="Konto">
  41.                         <EditItemTemplate>
  42.                             <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1" DataTextField="Konto" DataValueField="Konto" SelectedValue='<%# Bind("Konto") %>'></asp:DropDownList>
  43.                         </EditItemTemplate>
  44.                         <ItemTemplate>
  45.                             <asp:Label ID="Label2" runat="server" Text='<%# Bind("Konto") %>'></asp:Label>
  46.                         </ItemTemplate>
  47.                         <ItemStyle HorizontalAlign="Center" />
  48.                     </asp:TemplateField>
  49.                     <asp:TemplateField HeaderText="Imię" SortExpression="Imię">
  50.                         <EditItemTemplate>
  51.                             <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Imię") %>'></asp:TextBox>
  52.                             <asp:RequiredFieldValidator ID="rfvFirstname" runat="server" ErrorMessage="Proszę podać imię!" Text="*" ControlToValidate="TextBox2"></asp:RequiredFieldValidator>
  53.                             <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>
  54.                         </EditItemTemplate>
  55.                         <ItemTemplate>
  56.                             <asp:Label ID="Label3" runat="server" Text='<%# Bind("Imię") %>'></asp:Label>
  57.                         </ItemTemplate>
  58.                     </asp:TemplateField>
  59.                     <asp:TemplateField HeaderText="Nazwisko" SortExpression="Nazwisko">
  60.                         <EditItemTemplate>
  61.                             <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Nazwisko") %>'></asp:TextBox>
  62.                             <asp:RequiredFieldValidator ID="rfvLastname" runat="server" ErrorMessage="Proszę podać nazwisko!" ControlToValidate="TextBox3" Text="*"></asp:RequiredFieldValidator>
  63.                             <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>
  64.                         </EditItemTemplate>
  65.                         <ItemTemplate>
  66.                             <asp:Label ID="Label4" runat="server" Text='<%# Bind("Nazwisko") %>'></asp:Label>
  67.                         </ItemTemplate>
  68.                     </asp:TemplateField>
  69.                     <asp:TemplateField HeaderText="Użytkownik" SortExpression="Użytkownik">
  70.                         <EditItemTemplate>
  71.                             <asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="SqlDataSource1" DataTextField="Użytkownik" DataValueField="Użytkownik" SelectedValue='<%# Bind("Użytkownik") %>'></asp:DropDownList>
  72.                         </EditItemTemplate>
  73.                         <ItemTemplate>
  74.                             <asp:Label ID="Label5" runat="server" Text='<%# Bind("Użytkownik") %>'></asp:Label>
  75.                         </ItemTemplate>
  76.                     </asp:TemplateField>
  77.                     <asp:TemplateField HeaderText="Telefon" SortExpression="Telefon">
  78.                         <EditItemTemplate>
  79.                             <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("Telefon") %>'></asp:TextBox>
  80.                             <asp:RequiredFieldValidator ID="rfvPhone" runat="server" ErrorMessage="Proszę podać numer telefonu!" ControlToValidate="TextBox5" Text="*"></asp:RequiredFieldValidator>
  81.                             <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>
  82.                         </EditItemTemplate>
  83.                         <ItemTemplate>
  84.                             <asp:Label ID="Label6" runat="server" Text='<%# Bind("Telefon") %>'></asp:Label>
  85.                         </ItemTemplate>
  86.                         <ItemStyle HorizontalAlign="Center" />
  87.                     </asp:TemplateField>
  88.                     <asp:TemplateField ShowHeader="False">
  89.                         <EditItemTemplate>
  90.                             <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update" Text="Aktualizuj"></asp:LinkButton>
  91.                             &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel" Text="Anuluj"></asp:LinkButton>
  92.                         </EditItemTemplate>
  93.                         <ItemTemplate>
  94.                             <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Edit" Text="Edytuj"></asp:LinkButton>
  95.                             &nbsp;<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Delete" Text="Usuń" OnClientClick="return confirm('Czy na pewno chcesz usunąć ten wpis?');"></asp:LinkButton>
  96.                         </ItemTemplate>
  97.                         <ItemStyle HorizontalAlign="Center" />
  98.                     </asp:TemplateField>
  99.                 </Columns>
  100.                 <FooterStyle BackColor="#CCCCCC" />
  101.                 <HeaderStyle BackColor="#22A7FF" Font-Bold="True" ForeColor="White" Font-Size="Larger" HorizontalAlign="Center" VerticalAlign="Middle" />
  102.                 <PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Center" />
  103.                 <RowStyle BackColor="White" />
  104.                 <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
  105.                 <SortedAscendingCellStyle BackColor="#F1F1F1" />
  106.                 <SortedAscendingHeaderStyle BackColor="#808080" />
  107.                 <SortedDescendingCellStyle BackColor="#CAC9C9" />
  108.                 <SortedDescendingHeaderStyle BackColor="#383838" />
  109.  
  110.             </asp:GridView>
  111.  
  112.             <asp:ValidationSummary ID="vs" runat="server" />
  113.  
  114.             <h2><a href="Customers.aspx?view=insert">Dodaj nowego klienta</a></h2>
  115.  
  116.         </asp:View>
  117.  
  118.         <asp:View ID="insertView" runat="server">
  119.  
  120.             <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString='<%$ ConnectionStrings:ProjektDBConnectionString %>' SelectCommand="SELECT [Id] FROM [Konta]"></asp:SqlDataSource>
  121.             <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString='<%$ ConnectionStrings:ProjektDBConnectionString %>' SelectCommand="SELECT [Użytkownik] FROM [Użytkownicy]"></asp:SqlDataSource>
  122.             <h1>Dodaj klienta</h1>
  123.             <asp:Table ID="Table1" runat="server" CssClass="Formularz">
  124.  
  125.                 <asp:TableRow>
  126.  
  127.                     <asp:TableCell>
  128.                         PESEL
  129.                         <asp:RequiredFieldValidator ID="rfvPesel" runat="server" ErrorMessage="Proszę podać PESEL!" Text="*" ControlToValidate="peselInput"></asp:RequiredFieldValidator>
  130.                         <asp:RegularExpressionValidator ID="revPesel" runat="server" ErrorMessage="RegularExpressionValidator" ControlToValidate="peselInput" Text="*" ValidationExpression="^[0-9]{11}$"></asp:RegularExpressionValidator>
  131.                     </asp:TableCell>
  132.                     <asp:TableCell>
  133.                         <asp:TextBox ID="peselInput" runat="server"></asp:TextBox>
  134.                     </asp:TableCell>
  135.  
  136.                 </asp:TableRow>
  137.  
  138.                 <asp:TableRow>
  139.  
  140.                     <asp:TableCell>
  141.                         Konto
  142.                     </asp:TableCell>
  143.                     <asp:TableCell>
  144.                         <asp:DropDownList ID="accountInput" runat="server" DataSourceID="SqlDataSource2" DataTextField="Id" DataValueField="Id"></asp:DropDownList>
  145.                     </asp:TableCell>
  146.  
  147.                 </asp:TableRow>
  148.  
  149.                 <asp:TableRow>
  150.  
  151.                     <asp:TableCell>
  152.                         Imię
  153.                         <asp:RequiredFieldValidator ID="rfvFirstname" runat="server" ErrorMessage="Proszę podać imię!" Text="*" ControlToValidate="firstInput"></asp:RequiredFieldValidator>
  154.                         <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>
  155.                     </asp:TableCell>
  156.                     <asp:TableCell>
  157.                         <asp:TextBox ID="firstInput" runat="server"></asp:TextBox>
  158.                     </asp:TableCell>
  159.  
  160.                 </asp:TableRow>
  161.  
  162.                 <asp:TableRow>
  163.  
  164.                     <asp:TableCell>
  165.                         Nazwisko
  166.                         <asp:RequiredFieldValidator ID="rfvLastname" runat="server" ErrorMessage="Proszę podać nazwisko!" ControlToValidate="lastInput" Text="*"></asp:RequiredFieldValidator>
  167.                         <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>
  168.                     </asp:TableCell>
  169.                     <asp:TableCell>
  170.                         <asp:TextBox ID="lastInput" runat="server"></asp:TextBox>
  171.                     </asp:TableCell>
  172.  
  173.                 </asp:TableRow>
  174.  
  175.                 <asp:TableRow>
  176.  
  177.                     <asp:TableCell>
  178.                         Użytkownik
  179.                     </asp:TableCell>
  180.                     <asp:TableCell>
  181.                         <asp:DropDownList ID="userInput" runat="server" DataSourceID="SqlDataSource3" DataTextField="Użytkownik" DataValueField="Użytkownik"></asp:DropDownList>
  182.                     </asp:TableCell>
  183.  
  184.                 </asp:TableRow>
  185.  
  186.                 <asp:TableRow>
  187.  
  188.                     <asp:TableCell>
  189.                         Telefon
  190.                         <asp:RequiredFieldValidator ID="rfvPhone" runat="server" ErrorMessage="Proszę podać numer telefonu!" ControlToValidate="phoneInput" Text="*"></asp:RequiredFieldValidator>
  191.                         <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>
  192.                     </asp:TableCell>
  193.                     <asp:TableCell>
  194.                         <asp:TextBox ID="phoneInput" runat="server"></asp:TextBox>
  195.                     </asp:TableCell>
  196.  
  197.                 </asp:TableRow>
  198.  
  199.             </asp:Table>
  200.             <p>
  201.                 <asp:LinkButton ID="addButton" runat="server" OnClick="addButton_Click">Dodaj</asp:LinkButton>
  202.             </p>
  203.             <asp:ValidationSummary ID="vsAdd" runat="server" />
  204.  
  205.         </asp:View>
  206.  
  207.         <asp:View ID="defaultView" runat="server">
  208.  
  209.             <h1>BRAK DOSTĘPU</h1>
  210.  
  211.             <h1>Chcesz zobaczyć tę stronę? - <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/Login.aspx">zaloguj się</asp:HyperLink></h1>
  212.  
  213.         </asp:View>
  214.  
  215.     </asp:MultiView>
  216.  
  217. </asp:Content>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement