Tady je tabulka pro vstup
<table border="5" cellpadding="2" cellspacing="0"
style="border: 1px solid #0000FF; width: 400px; border-collapse: collapse;"
align="center">
<tr>
<td bgcolor="Blue" colspan="2" style="color: #FFFFFF; font-weight: bold">
Přidání řidiče</td>
</tr>
<tr>
<td align="right" width="100">
Jméno, příjmení</td>
<td align="left" style="width: 516px">
<asp:TextBox ID="iNewName" runat="server" Width="300px"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right">
Osobní číslo</td>
<td align="left" style="width: 516px">
<asp:TextBox ID="iNewPersonalNumber" runat="server" Width="150px"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right">
Volný od</td>
<td align="left" style="width: 516px">
<asp:TextBox ID="iNewFreeFrom" runat="server" Width="150px"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right">
Volný do</td>
<td align="left" style="width: 516px">
<asp:TextBox ID="iNewFreeInto" runat="server" Width="150px"></asp:TextBox>
</td>
</tr>
<tr>
<td align="right" bgcolor="Blue" colspan="2">
<asp:Button ID="Save" runat="server" Text="Uložit" />
<asp:Button ID="Cancel" runat="server" Text="Zrušit" />
</td>
</tr>
</table>
Tady SqlSource
<asp:SqlDataSource ID="DriversP" runat="server"
ConnectionString="<%$ ConnectionStrings:intranetConnectionString %>"
SelectCommand="SELECT [iDriversPId], [iCompanyId], [iClick], [iName], [iPersonalNumber], [iFreeFrom], [iFreeInto], [iComments] FROM [iDriversP] WHERE ([iCompanyId] = @iCompanyId)"
DeleteCommand="DELETE FROM [iDriversP] WHERE [iDriversPId] = @iDriversPId"
InsertCommand="INSERT INTO [iDriversP] ([iCompanyId], [iName], [iPersonalNumber], [iFreeFrom], [iFreeInto]) VALUES (@iCompanyId, @iName, @iPersonalNumber, @iFreeFrom, @iFreeInto)"
UpdateCommand="UPDATE [iDriversP] SET [iClick] = @iClick, [iName] = @iName, [iPersonalNumber] = @iPersonalNumber, [iFreeFrom] = @iFreeFrom, [iFreeInto] = @iFreeInto, [iComments] = @iComments WHERE [iDriversPId] = @iDriversPId">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="iCompanyId"
PropertyName="SelectedValue" Type="Int64" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="iDriversPId" Type="Int64" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="iClick" Type="String" />
<asp:Parameter Name="iName" Type="String" />
<asp:Parameter Name="iPersonalNumber" Type="String" />
<asp:Parameter Name="iFreeFrom" Type="String" />
<asp:Parameter Name="iFreeInto" Type="String" />
<asp:Parameter Name="iComments" Type="String" />
<asp:Parameter Name="iDriversPId" Type="Int64" />
</UpdateParameters>
<InsertParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="iCompanyId"
PropertyName="SelectedValue" Type="Int64" />
<asp:ControlParameter ControlID="iNewName"
Name="iName" PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="iNewPersonalNumber"
Name="iPersonalNumber" PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="iNewFreeFrom"
Name="iFreeFrom" PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="iNewFreeInto"
Name="iFreeInto" PropertyName="Text" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
A tady kod pro tlacitka
Protected Sub Save_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Save.Click
DriversP.Insert()
iNewName.Text = ""
iNewPersonalNumber.Text = ""
iNewFreeFrom.Text = ""
iNewFreeInto.Text = ""
End Sub
Protected Sub Cancel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Cancel.Click
iNewName.Text = ""
iNewPersonalNumber.Text = ""
iNewFreeFrom.Text = ""
iNewFreeInto.Text = ""
End Sub
A tady prvni tabulka
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" HorizontalAlign="Center"
AllowSorting="True" AutoGenerateColumns="False"
DataKeyNames="iDriversPId" DataSourceID="DriversP" Width="700px" CssClass="gridview">
<Columns>
<asp:TemplateField HeaderText="" ItemStyle-HorizontalAlign="Center">
<ItemTemplate>
<asp:Button ID="Save1" runat="server" Text="Zapůjčit" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="iName" HeaderText="Jméno, příjmení"
SortExpression="iName" />
<asp:BoundField DataField="iPersonalNumber" HeaderText="osobní číslo"
SortExpression="iPersonalNumber" />
<asp:BoundField DataField="iFreeFrom" HeaderText="volný od"
SortExpression="iFreeFrom" />
<asp:BoundField DataField="iFreeInto" HeaderText="volný do"
SortExpression="iFreeInto" />
<asp:BoundField DataField="iComments" HeaderText="komentář"
SortExpression="iComments" />
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
</Columns>
</asp:GridView>
|