1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<%@ Page Language="C#" MaintainScrollPositionOnPostback="true" %>
<%@ Register Assembly="Adillis.SmartDBForms" Namespace="Adillis.SmartDBForms.DataSource" TagPrefix="smartDataSource" %>
<%@ Register Assembly="Adillis.SmartDBForms" Namespace="Adillis.SmartDBForms" TagPrefix="smartDBforms" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>smartDBforms.NET - Suppliers</title>
    
    <!--  CSS styles used in this page -->
    <style type="text/css" >    
    /* <script  language="CSS">*/
    .bluestyle
    {
      background-color:#4A3C8C;  
      color:white;
      font-weight:bold;             
    }
    
    .notes textarea 
    {
        border: solid 1px #acacac;
        padding: 5px;
        width: 400px;
        height: 90px;
        background-color: #ffffff;
    }   
    
    ul.tabselector
    {
        margin:0px;
        padding: 3px 0;
        border-bottom: 1px solid #778;
        font: bold 12px Verdana, sans-serif;
    }
    
    ul.tabselector li
    {
     list-style: none;
     margin: 0px;
     display: inline;
    }
    
    ul.tabselector li a
    {
        text-decoration:none;   
        padding: 3px 0.5em;        
        margin-left:5px;        
        color:gray;
        background-color:gainsboro;        
        border: 1px solid #778;
        border-bottom: none;
    }    
        
   ul.tabselector a.tabselected 
   {    
        color:blue; 
        background-color:#E7E7FF;   
        border-bottom: 1px solid #E7E7FF;
   }
   
   ul.tabselector a:hover, ul.tabselector a.tabselected:hover
   {
        color:#F7F7F7;
        background-color:#738A9C;
   }
   
   .tabcontent
   {
     border:1px solid #aaa;
     border-top:0;
     background-color:#E7E7FF;
     padding:5px;
     margin:0px;     
   }    
    </style>
    <!-- </script>-->
    
</head>
<body  >
    <form id="form1" runat="server">
    <div>
        <!--  Data source for the GridView-->
        <smartDataSource:SmartDataSource ID="SuppliersDataSource" runat="server" 
            ConnectionString="<%$ ConnectionStrings:LocalSql.Northwind %>" ProviderName="<%$ ConnectionStrings:LocalSql.Northwind.ProviderName %>" ExtractFKRelations="False" SelectCommand="SELECT Suppliers.* FROM Suppliers"
            >
        </smartDataSource:SmartDataSource>
        
        <!--  GridView that displays all records-->
        <asp:GridView ID="GridViewSuppliers" runat="server" AllowPaging="True" AutoGenerateColumns="False"
            BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px"
            CellPadding="3" DataKeyNames="SupplierID" DataSourceID="SuppliersDataSource"
            GridLines="Horizontal" PageSize="4" AllowSorting="True" Width="555px" >
            <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
            <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
            <Columns>
                <asp:CommandField ShowSelectButton="True" >
                    <ControlStyle Font-Bold="True" Font-Size="Smaller" />
                    <ItemStyle Font-Bold="False" />
                </asp:CommandField>
                <asp:BoundField DataField="CompanyName" HeaderText="Company Name" SortExpression="CompanyName">
                    <HeaderStyle HorizontalAlign="Left" />
                </asp:BoundField>
                <asp:BoundField DataField="City" HeaderText="City" SortExpression="City">
                    <HeaderStyle HorizontalAlign="Left" />
                </asp:BoundField>
                <asp:BoundField DataField="Country" HeaderText="Country" SortExpression="Country">
                    <HeaderStyle HorizontalAlign="Left" />
                </asp:BoundField>
                <asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone">
                    <HeaderStyle HorizontalAlign="Left" />
                </asp:BoundField>
            </Columns>
            <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Left" Font-Size="Small" />
            <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
            <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
            <AlternatingRowStyle BackColor="#F7F7F7" />
        </asp:GridView>
        <br />
        
        <!--  SmartDataSource for selecting and updating the selected record-->
        <smartDataSource:SmartDataSource ID="SupplierDetailsDataSource" runat="server" 
            ConnectionString="<%$ ConnectionStrings:LocalSql.Northwind %>" ProviderName="<%$ ConnectionStrings:LocalSql.Northwind.ProviderName %>" SelectCommand="SELECT * FROM Suppliers WHERE (SupplierID = @SupplierID) " CancelSelectOnNullParameter="False" DeleteCommand="DELETE FROM [dbo].[Suppliers] WHERE [SupplierID] = @original_SupplierID" InsertCommand="INSERT INTO [dbo].[Suppliers] ( [CompanyName], [ContactName], [ContactTitle], [Address], [City], [Region], [PostalCode], [Country], [Phone], [Fax], [HomePage] ) VALUES ( @CompanyName, @ContactName, @ContactTitle, @Address, @City, @Region, @PostalCode, @Country, @Phone, @Fax, @HomePage )" MonitorParameters="True" UpdateCommand="UPDATE [dbo].[Suppliers] SET [CompanyName] = @CompanyName, [ContactName] = @ContactName, [ContactTitle] = @ContactTitle, [Address] = @Address, [City] = @City, [Region] = @Region, [PostalCode] = @PostalCode, [Country] = @Country, [Phone] = @Phone, [Fax] = @Fax, [HomePage] = @HomePage WHERE [SupplierID] = @original_SupplierID"
            >
            <SelectParameters>
                <asp:ControlParameter ControlID="GridViewSuppliers" Name="SupplierID" PropertyName="SelectedValue"
                    Type="Int32" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="original_SupplierID" Type="Int32" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter Name="CompanyName" Type="String" />
                <asp:Parameter Name="ContactName" Type="String" />
                <asp:Parameter Name="ContactTitle" Type="String" />
                <asp:Parameter Name="Address" Type="String" />
                <asp:Parameter Name="City" Type="String" />
                <asp:Parameter Name="Region" Type="String" />
                <asp:Parameter Name="PostalCode" Type="String" />
                <asp:Parameter Name="Country" Type="String" />
                <asp:Parameter Name="Phone" Type="String" />
                <asp:Parameter Name="Fax" Type="String" />
                <asp:Parameter Name="HomePage" Type="String" />
            </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="CompanyName" Type="String" />
                <asp:Parameter Name="ContactName" Type="String" />
                <asp:Parameter Name="ContactTitle" Type="String" />
                <asp:Parameter Name="Address" Type="String" />
                <asp:Parameter Name="City" Type="String" />
                <asp:Parameter Name="Region" Type="String" />
                <asp:Parameter Name="PostalCode" Type="String" />
                <asp:Parameter Name="Country" Type="String" />
                <asp:Parameter Name="Phone" Type="String" />
                <asp:Parameter Name="Fax" Type="String" />
                <asp:Parameter Name="HomePage" Type="String" />
                <asp:Parameter Name="original_SupplierID" Type="Int32" />
            </UpdateParameters>
        </smartDataSource:SmartDataSource>
    
    </div>
        
        <!-- Success and error messages-->
	    <smartDBforms:OperationStatus ID="OperationStatus1" Width="555px" runat="server" ControlIDToHandle="SupplierSmartDBView" Font-Size="Smaller">
        </smartDBforms:OperationStatus>	
        
        <!-- SmartDBView Details form-->
        <smartDBforms:SmartDBView ID="SupplierSmartDBView" runat="server" DataSourceID="SupplierDetailsDataSource" Width="555px" DefaultMode="ReadOnly" OnEmptyData="EmptyDataTemplate" BackColor="#F7F7F7" style="padding:5px" BorderColor="#4A3C8C" BorderStyle="Ridge" BorderWidth="2px" OnItemDeleted="SupplierSmartDBView_OperationCompleted" OnItemInserted="SupplierSmartDBView_OperationCompleted" OnItemUpdated="SupplierSmartDBView_OperationCompleted">
            <Content>
               <div class="bluestyle" style="padding:3px;margin-bottom:5px" >Supplier Details</div>
                <asp:Button ID="Button1" runat="server" CausesValidation="False" CommandName="Edit"
                    Enabled="<%# Container.IsReadOnlyMode %>" Text="Edit" UseSubmitBehavior="False"
                    Visible="<%# Container.IsReadOnlyMode %>" CssClass="bluestyle" />
                <asp:Button ID="Button2" runat="server" CausesValidation="True" CommandName="Update"
                    Enabled="<%# Container.IsEditMode %>" Text="Update" UseSubmitBehavior="False"
                    Visible="<%# Container.IsEditMode %>" CssClass="bluestyle" />
                <asp:Button ID="Button3" runat="server" CausesValidation="True" CommandName="Insert"
                    Enabled="<%# Container.IsInsertMode %>" Text="Insert" UseSubmitBehavior="False"
                    Visible="<%# Container.IsInsertMode %>" CssClass="bluestyle" />
                <asp:Button ID="Button4" runat="server" CausesValidation="False" CommandName="Cancel"
                    Enabled="<%# Container.IsNotDefaultMode%>" Text="Cancel" UseSubmitBehavior="False"
                    Visible="<%# Container.IsNotDefaultMode%>" CssClass="bluestyle" />
                <asp:Button ID="Button5" runat="server" CausesValidation="False" CommandName="Delete"
                    Enabled="<%#  Container.IsReadOnlyOrEditMode %>" OnClientClick="if(!confirm('Are you sure?')) return false;"
                    Text="Delete" UseSubmitBehavior="False" Visible="<%#  Container.IsReadOnlyOrEditMode %>" CssClass="bluestyle" />
                <asp:Button ID="Button6" runat="server" CausesValidation="False" CommandName="New"
                    Enabled="<%# Container.IsReadOnlyOrEditMode %>" Text="New" UseSubmitBehavior="False"
                    Visible="<%# Container.IsReadOnlyOrEditMode %>" CssClass="bluestyle" /><br />
                <br />
                <smartDBforms:SmartDBControl ID="ctrlSupplierID" runat="server" Field="SupplierID" />
                <br />
                        <smartDBforms:SmartDBControl ID="ctrlCompanyName" runat="server" Field="CompanyName" />
                        <br />
                <br />
                <!-- Tab selectors-->
                <ul class="tabselector" >
                <li>
                <asp:LinkButton ID="btnContact" CssClass="tabselected" runat="server" OnClick="btnContact_Click" CausesValidation="False">Contact</asp:LinkButton>
                </li>
                <li>
                <asp:LinkButton ID="btnAddress" runat="server" OnClick="btnAddress_Click" CausesValidation="False">Address</asp:LinkButton>
                </li>
                </ul>                
                <!-- Tabs contents-->                 
                <div  class="tabcontent" >
                <asp:MultiView ID="MultiViewSupplier" runat="server" ActiveViewIndex="0">
                  <asp:View ID="viewContact" runat="server">
                        <table>
                            <tr>
                                <td  nowrap=nowrap>
                                    <smartDBforms:SmartDBLabel ID="SmartDBLabel1" runat="server" Field="ContactName" />
                                    &nbsp;
                                </td>
                                <td  nowrap=nowrap>
                        <smartDBforms:SmartDBControl ID="ctrlContactName" runat="server" Field="ContactName" ShowLabel="False" />
                                </td>
                            </tr>
                            <tr >
                                <td nowrap=nowrap>
                                    <smartDBforms:SmartDBLabel ID="SmartDBLabel2" runat="server" Field="ContactTitle" />
                                </td>
                                <td nowrap=nowrap>
                        <smartDBforms:SmartDBControl ID="ctrlContactTitle" runat="server" Field="ContactTitle" ShowLabel="False" />
                                </td>
                            </tr>
                        </table>
                        <br />
                        <smartDBforms:SmartDBControl ID="ctrlPhone" runat="server" Field="Phone" />
                        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                        <smartDBforms:SmartDBControl ID="ctrlFax" runat="server" Field="Fax" />
                        <br />                        <br />
                        <smartDBforms:SmartDBControl ID="ctrlHomePage" runat="server" Field="HomePage" CssClass="notes" />
                    </asp:View>
                    <asp:View ID="viewAddress" runat="server">                    
                         <table>
                            <tr>
                                <td  nowrap=nowrap>
                                <smartDBforms:SmartDBLabel ID="SmartDBLabel3" runat="server" Field="Address" />
                                </td>
                                <td  nowrap=nowrap style="width: 111px">
                                <smartDBforms:SmartDBControl ID="ctrlAddress" runat="server" Field="Address" ShowLabel="False" />
                                </td>
                            </tr>
                            <tr>
                                <td  nowrap=nowrap>
                     
                                    <smartDBforms:SmartDBLabel ID="SmartDBLabel4" runat="server" Field="City" />
                                </td>
                                <td  nowrap=nowrap style="width: 111px">
                                <smartDBforms:SmartDBControl ID="ctrlCity" runat="server" Field="City" ShowLabel="False" />
                                </td>
                            </tr>
                            <tr>
                                <td  nowrap=nowrap>
                                    <smartDBforms:SmartDBLabel ID="SmartDBLabel5" runat="server" Field="Region" />
                                </td>
                                <td  nowrap=nowrap style="width: 111px">
                                <smartDBforms:SmartDBControl ID="ctrlRegion" runat="server" Field="Region" ShowLabel="False" />
                                </td>
                            </tr>
                            <tr>
                                <td  nowrap=nowrap>
                                    <smartDBforms:SmartDBLabel ID="SmartDBLabel6" runat="server" Field="PostalCode" />
                                </td>
                                <td  nowrap=nowrap style="width: 111px">
                                <smartDBforms:SmartDBControl ID="ctrlPostalCode" runat="server" Field="PostalCode" ShowLabel="False" />
                                </td>
                            </tr>
                            <tr>
                                <td  nowrap=nowrap>

                                    <smartDBforms:SmartDBLabel ID="SmartDBLabel7" runat="server" Field="Country" />
                                </td>
                                <td  nowrap=nowrap style="width: 111px">
                                <smartDBforms:SmartDBControl ID="ctrlCountry" runat="server" Field="Country" ShowLabel="False" />
                                </td>
                            </tr>                                                                                                                
                         </table>
                        
                    </asp:View>
                </asp:MultiView>
                </div>
                <br />
                <asp:Button ID="btnEdit" runat="server" CausesValidation="False" CommandName="Edit"
                    Enabled="<%# Container.IsReadOnlyMode %>" Text="Edit" UseSubmitBehavior="False"
                    Visible="<%# Container.IsReadOnlyMode %>" CssClass="bluestyle" />
                <asp:Button ID="btnUpdate" runat="server" CausesValidation="True" CommandName="Update"
                    Enabled="<%# Container.IsEditMode %>" Text="Update" UseSubmitBehavior="False"
                    Visible="<%# Container.IsEditMode %>" CssClass="bluestyle" />
                <asp:Button ID="btnInsert" runat="server" CausesValidation="True" CommandName="Insert"
                    Enabled="<%# Container.IsInsertMode %>" Text="Insert" UseSubmitBehavior="False"
                    Visible="<%# Container.IsInsertMode %>" CssClass="bluestyle" />
                <asp:Button ID="btnCancel" runat="server" CausesValidation="False" CommandName="Cancel"
                    Enabled="<%# Container.IsNotDefaultMode%>" Text="Cancel" UseSubmitBehavior="False"
                    Visible="<%# Container.IsNotDefaultMode%>" CssClass="bluestyle" />
                <asp:Button ID="btnDelete" runat="server" CausesValidation="False" CommandName="Delete"
                    Enabled="<%#  Container.IsReadOnlyOrEditMode %>" OnClientClick="if(!confirm('Are you sure?')) return false;"
                    Text="Delete" UseSubmitBehavior="False" Visible="<%#  Container.IsReadOnlyOrEditMode %>" CssClass="bluestyle" />
                <asp:Button ID="btnNew" runat="server" CausesValidation="False" CommandName="New"
                    Enabled="<%# Container.IsReadOnlyOrEditMode %>" Text="New" UseSubmitBehavior="False"
                    Visible="<%# Container.IsReadOnlyOrEditMode %>" CssClass="bluestyle" />
            </Content>
            <EmptyDataTemplate>
            <div style="padding:4px;FONT-SIZE: medium; COLOR: gray; TEXT-ALIGN: center">
                Select a row from the table or 
                <asp:LinkButton ID="btnNew" runat="server" CausesValidation="False" CommandName="New"
                     Text="Create a new record" />
                 </div>
            </EmptyDataTemplate>
        </smartDBforms:SmartDBView>
    </form>
</body>
</html>

<script runat="server" language="C#">

    protected void btnContact_Click(object sender, EventArgs e)
    {
        // Change the visible tab
        MultiViewSupplier.SetActiveView(viewContact);
        btnContact.CssClass = "tabselected";
        btnAddress.CssClass = "";        
    }

    protected void btnAddress_Click(object sender, EventArgs e)
    {
        // Change the visible tab
        MultiViewSupplier.SetActiveView(viewAddress);

        btnAddress.CssClass = "tabselected";
        btnContact.CssClass = "";

    }

    protected void SupplierSmartDBView_OperationCompleted(SmartDBView sender, SmartDBViewCompletedArgs e)
    {
        // The data has been changed, refresh the GridView
        this.GridViewSuppliers.DataBind();
    }
</script>