protected
void ldsDestinazioni_Inserting(object sender, LinqDataSourceInsertEventArgs e)
{
Destinazione _nuovaDestinazione = e.NewObject as Destinazione;
_nuovaDestinazione.ID_Azienda =
SessionStore.Utente.ID_Azienda;
_nuovaDestinazione.ID_Cliente = (
int)ID_Cliente;
XSWDataContext _ordiniWeb = new XSWDataContext();
int _idDestinazione = 1;
var _destinazioni = _ordiniWeb.Destinazione.Where(d => (d.ID_Azienda == _nuovaDestinazione.ID_Azienda) &&
(d.ID_Cliente == _nuovaDestinazione.ID_Cliente));
if (_destinazioni.Count() > 0)
_idDestinazione = _destinazioni.Max(t => t.ID_Destinazione) + 1;
_nuovaDestinazione.ID_Destinazione = _idDestinazione;
_ordiniWeb.Destinazione.InsertOnSubmit(_nuovaDestinazione);
_ordiniWeb.SubmitChanges(System.Data.Linq.
ConflictMode.FailOnFirstConflict);
}
| <form id="form1" runat="server"> |
| <telerik:RadCodeBlock ID="radcodeblock1" runat="server"> |
| <script type="text/javascript"> |
| function onToolBarClientButtonClicking(sender, args) { |
| var button = args.get_item(); |
| if (button.get_commandName() == "DeleteSelected") { |
| args.set_cancel(!confirm('Delete all selected hospitals?')); |
| } |
| } |
| </script> |
| </telerik:RadCodeBlock> |
| <telerik:RadScriptManager ID="ScriptManager1" runat="server"> |
| </telerik:RadScriptManager> |
| <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> |
| <AjaxSettings> |
| <telerik:AjaxSetting AjaxControlID="RadGrid1"> |
| <UpdatedControls> |
| <telerik:AjaxUpdatedControl ControlID="RadGrid1" /> |
| </UpdatedControls> |
| </telerik:AjaxSetting> |
| </AjaxSettings> |
| </telerik:RadAjaxManager> |
| <telerik:RadGrid ID="RadGrid1" AllowAutomaticUpdates="true" AllowAutomaticDeletes="true" |
| DataSourceID="ds_Hospitals" Width="97%" AllowSorting="True" |
| AutoGenerateColumns="true" AllowPaging="True" GridLines="None" runat="server" |
| ShowFooter="True" AllowMultiRowSelection="True" PageSize="7" AllowMultiRowEdit="True" |
| HorizontalAlign="NotSet" OnItemDeleted="RadGrid1_ItemDeleted"> |
| <PagerStyle Mode="NextPrevAndNumeric" /> |
| <MasterTableView Width="100%" GridLines="None" CommandItemDisplay="Top" DataSourceID="ds_Hospitals" |
| EditMode="InPlace" HorizontalAlign="NotSet" DataKeyNames="HospID, UserID" AllowAutomaticInserts="True" AutoGenerateColumns="True"> |
| <CommandItemTemplate> |
| <telerik:RadToolBar ID="RadToolBar1" OnButtonClick="RadToolBar1_ButtonClick" runat="server" OnClientButtonClicking="onToolBarClientButtonClicking"> |
| <Items> |
| <telerik:RadToolBarButton Text="Edit selected" CommandName="EditSelected" ImageUrl="~/images/toolbar/Edit.gif" Visible='<%# RadGrid1.EditIndexes.Count = 0 %>'></telerik:RadToolBarButton> |
| <telerik:RadToolBarButton Text="Update" CommandName="UpdateEdited" ImageUrl="~/images/toolbar/Update.gif" Visible='<%# RadGrid1.EditIndexes.Count > 0 %>'></telerik:RadToolBarButton> |
| <telerik:RadToolBarButton Text="Cancel editing" CommandName="CancelAll" ImageUrl="~/images/toolbar/Cancel.gif" Visible='<%# RadGrid1.EditIndexes.Count > 0 OrElse RadGrid1.MasterTableView.IsItemInserted %>'></telerik:RadToolBarButton> |
| <telerik:RadToolBarButton Text="Add new" CommandName="InitInsert" ImageUrl="~/images/toolbar/AddRecord.gif" Visible='<%# Not RadGrid1.MasterTableView.IsItemInserted %>'></telerik:RadToolBarButton> |
| <telerik:RadToolBarButton Text="Add this hospital" CommandName="PerformInsert" ImageUrl="~/images/toolbar/Insert.gif" Visible='<%# RadGrid1.MasterTableView.IsItemInserted %>'></telerik:RadToolBarButton> |
| <telerik:RadToolBarButton Text="Delete selected hospitals" CommandName="DeleteSelected" ImageUrl="~/images/toolbar/Delete.gif"></telerik:RadToolBarButton> |
| <telerik:RadToolBarButton Text="Refresh hospital list" CommandName="RebindGrid" ImageUrl="~/images/toolbar/Refresh.gif"></telerik:RadToolBarButton> |
| </Items> |
| </telerik:RadToolBar> |
| </CommandItemTemplate> |
| </MasterTableView> |
| <ClientSettings> |
| <Selecting AllowRowSelect="True" EnableDragToSelectRows="True" /> |
| </ClientSettings> |
| </telerik:RadGrid> |
| <asp:SqlDataSource ID="ds_Hospitals" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" |
| DeleteCommand="DELETE FROM [Sub_Hospitals] WHERE [HospID] = @HospID" InsertCommand="INSERT INTO [Sub_Hospitals] ([UserID], [Hospitalname]) VALUES (@UserID, @Hospitalname)" |
| SelectCommand="SELECT * FROM [Sub_Hospitals] WHERE ([UserID] = @UserID) ORDER BY [Hospitalname]" |
| UpdateCommand="UPDATE [Sub_Hospitals] SET [UserID] = @UserID, [Hospitalname] = @Hospitalname WHERE [HospID] = @HospID"> |
| <SelectParameters> |
| <asp:CookieParameter CookieName="UserID" Name="UserID" Type="Int32" /> |
| </SelectParameters> |
| <DeleteParameters> |
| <asp:Parameter Name="HospID" Type="Int32" /> |
| </DeleteParameters> |
| <UpdateParameters> |
| <asp:Parameter Name="UserID" Type="Int32" /> |
| <asp:Parameter Name="Hospitalname" Type="String" /> |
| <asp:Parameter Name="HospID" Type="Int32" /> |
| </UpdateParameters> |
| <InsertParameters> |
| <asp:Parameter Name="UserID" Type="Int32" /> |
| <asp:Parameter Name="Hospitalname" Type="String" /> |
| <asp:Parameter Name="HospID" Type="Int32" /> |
| </InsertParameters> |
| </asp:SqlDataSource> |
| </form> |
| <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecoratedControls="All" |
| Skin="Office2007" /> |
| <table> |
| <tr class="disabled"> |
| <th> |
| <label for="disabled"> |
| Disabled</label> |
| </th> |
| <td> |
| <input type="checkbox" id="disabled" disabled="disabled" /> |
| </td> |
| </tr> |
| <tr class="on_off"> |
| <th> |
| <label for="on_off"> |
| Default</label> |
| </th> |
| <td> |
| <input type="checkbox" id="on_off" /> |
| </td> |
| </tr> |
| <tr class="on_off"> |
| <th> |
| <label for="on_off_on"> |
| Default On</label> |
| </th> |
| <td> |
| <input type="checkbox" checked="checked" id="on_off_on" /> |
| </td> |
| </tr> |
| <tr class="css_sized_container"> |
| <th> |
| <label for="css_sized_container"> |
| CSS Sized Container and Handle</label> |
| </th> |
| <td> |
| <input type="checkbox" id="css_sized_container" /> |
| </td> |
| </tr> |
| <tr class="long_tiny"> |
| <th> |
| <label class="left" for="long_tiny"> |
| Long and short labels</label> |
| </th> |
| <td> |
| <input type="checkbox" id="long_tiny" /> |
| </td> |
| </tr> |
| <tr class="onchange"> |
| <th> |
| Event tracking |
| </th> |
| <td> |
| <input type="checkbox" id="onchange" /> |
| <p> |
| Checkbox status is <strong><span id="status">...</span></strong>.</p> |
| </td> |
| </tr> |
| </table> |