Click here to Skip to main content
13,355,726 members (61,366 online)
Click here to Skip to main content

Stats

52.5K views
1.6K downloads
68 bookmarked
Posted 16 Apr 2012

Populating a business logical layer from Stored Procedures

, 22 Sep 2014
A brief look at a technique mapping tables to a basic business layer.
doPersistence
doPersistence.csproj.user
doPersistence.csproj.vspscc
obj
Debug
Release
Properties
doLogicCode
bin
Debug
doLogicCode.vshost.exe.manifest
doLogicCode.csproj.vspscc
obj
x86
Debug
doLogicCode.frmCodeGenerator.resources
doLogicCode.Properties.Resources.resources
Properties
Test
doLogic
bin
Debug
doLogic.dll
doLogic.pdb
doPersistence.dll
doPersistence.pdb
Release
doLogic.dll
doLogic.pdb
doPersistence.dll
doPersistence.pdb
obj
Debug
DesignTimeResolveAssemblyReferencesInput.cache
doLogic.dll
doLogic.pdb
ResolveAssemblyReference.cache
TempPE
Release
DesignTimeResolveAssemblyReferencesInput.cache
doLogic.dll
doLogic.pdb
ResolveAssemblyReference.cache
TempPE
Properties
doLogicCode
bin
Debug
doLogicCode.exe
doLogicCode.pdb
doLogicCode.vshost.exe
doLogicCode.vshost.exe.manifest
doPersistence.dll
doPersistence.pdb
obj
x86
Debug
DesignTimeResolveAssemblyReferencesInput.cache
doLogicCode.exe
doLogicCode.frmCodeGenerator.resources
doLogicCode.pdb
doLogicCode.Properties.Resources.resources
GenerateResource.read.1.tlog
GenerateResource.write.1.tlog
ResolveAssemblyReference.cache
TempPE
Properties.Resources.Designer.cs.dll
Properties
doPersistence
bin
Debug
doPersistence.dll
doPersistence.pdb
Release
doPersistence.dll
doPersistence.pdb
doPersistence.csproj.vspscc
obj
Debug
DesignTimeResolveAssemblyReferencesInput.cache
doPersistence.dll
doPersistence.pdb
TempPE
Release
DesignTimeResolveAssemblyReferencesInput.cache
doPersistence.dll
doPersistence.pdb
TempPE
Properties
Test.suo
TestSite
Account
App_Data
bin
doLogic.dll
doLogic.pdb
doPersistence.dll
doPersistence.pdb
TestSite.dll
TestSite.pdb
Global.asax
obj
Debug
DesignTimeResolveAssemblyReferencesInput.cache
ResolveAssemblyReference.cache
TempPE
TestSite.dll
TestSite.pdb
Release
CSAutoParameterize
original
Account
transformed
Account
Database
DesignTimeResolveAssemblyReferencesInput.cache
Package
PackageTmp
Account
bin
doLogic.dll
doLogic.pdb
doPersistence.dll
doPersistence.pdb
TestSite.dll
TestSite.pdb
Global.asax
Scripts
Styles
ResolveAssemblyReference.cache
TempPE
TestSite.dll
TestSite.pdb
TransformWebConfig
original
transformed
Account
Properties
Scripts
Styles
TestSite.csproj.user
doLogic.dll
doPersistence.dll
doPersistence.dll
doLogic.dll
doPersistence.dll
TestSite.dll
Global.asax
TestSite.csproj.user
doLogic.dll
doLogic.pdb
doPersistence.dll
doPersistence.pdb
doLogic.dll
doLogic.pdb
doPersistence.dll
doPersistence.pdb
DesignTimeResolveAssemblyReferencesInput.cache
doLogic.dll
doLogic.pdb
ResolveAssemblyReference.cache
DesignTimeResolveAssemblyReferencesInput.cache
doLogic.dll
doLogic.pdb
ResolveAssemblyReference.cache
doPersistence.dll
doPersistence.pdb
doPersistence.dll
doPersistence.pdb
DesignTimeResolveAssemblyReferencesInput.cache
doPersistence.dll
doPersistence.pdb
DesignTimeResolveAssemblyReferencesInput.cache
doPersistence.dll
Test.suo
doLogic.dll
doLogic.pdb
doPersistence.dll
doPersistence.pdb
TestSite.dll
TestSite.pdb
Global.asax
DesignTimeResolveAssemblyReferencesInput.cache
ResolveAssemblyReference.cache
TestSite.dll
TestSite.pdb
DesignTimeResolveAssemblyReferencesInput.cache
ResolveAssemblyReference.cache
TestSite.dll
TestSite.pdb
TestSite.csproj.user
PersistenceTest_orig
Account
App_Code
App_Data
Bin
Persistence.pdb
Global.asax
Scripts
Styles
Persistence
bin
Debug
doPersistence.pdb
Persistence.pdb
Release
doPersistence.pdb
doPersistence.csproj.vspscc
obj
Debug
DesignTimeResolveAssemblyReferences.cache
DesignTimeResolveAssemblyReferencesInput.cache
doPersistence.csprojResolveAssemblyReference.cache
doPersistence.pdb
Persistence.pdb
TempPE
Release
DesignTimeResolveAssemblyReferencesInput.cache
doPersistence.pdb
TempPE
Persistence.csproj.user
Properties
PersistenceTest_orig.v11.suo
CodeGenerator
bin
Debug
doLogicCode.pdb
doLogicCode.vshost.exe.manifest
doPersistence.pdb
Persistence.pdb
CodeGenerator.csproj.vspscc
obj
x86
Debug
CodeGenerator.csproj.GenerateResource.Cache
CodeGenerator.csprojResolveAssemblyReference.cache
CodeGenerator.frmCodeGenerator.resources
CodeGenerator.Properties.Resources.resources
DesignTimeResolveAssemblyReferences.cache
DesignTimeResolveAssemblyReferencesInput.cache
doLogicCode.csproj.GenerateResource.Cache
doLogicCode.csprojResolveAssemblyReference.cache
doLogicCode.pdb
TempPE
Properties
AjaxControlToolkit.dll
Persistence.dll
Persistence.pdb
Global.asax
doPersistence.dll
doPersistence.pdb
Persistence.dll
Persistence.pdb
doPersistence.dll
doPersistence.pdb
doPersistence.csproj.vspscc
DesignTimeResolveAssemblyReferences.cache
DesignTimeResolveAssemblyReferencesInput.cache
doPersistence.csprojResolveAssemblyReference.cache
doPersistence.dll
doPersistence.pdb
Persistence.dll
Persistence.pdb
DesignTimeResolveAssemblyReferencesInput.cache
doPersistence.dll
doPersistence.pdb
Persistence.csproj.user
PersistenceTest_orig.v11.suo
doLogicCode.exe
doLogicCode.pdb
doLogicCode.vshost.exe
doLogicCode.vshost.exe.manifest
doPersistence.dll
doPersistence.pdb
Persistence.dll
Persistence.pdb
CodeGenerator.csproj.vspscc
CodeGenerator.csproj.GenerateResource.Cache
CodeGenerator.csprojResolveAssemblyReference.cache
CodeGenerator.frmCodeGenerator.resources
CodeGenerator.Properties.Resources.resources
DesignTimeResolveAssemblyReferences.cache
DesignTimeResolveAssemblyReferencesInput.cache
doLogicCode.csproj.GenerateResource.Cache
doLogicCode.csprojResolveAssemblyReference.cache
doLogicCode.exe
doLogicCode.pdb
Properties.Resources.Designer.cs.dll
<%@ Page Language="C#" MasterPageFile="~/Site.master" EnableEventValidation="false" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">

    <ajaxToolkit:ToolkitScriptManager id="ScriptManager1" runat="server" />

    <asp:UpdatePanel ID="upMain" runat="server">
    <ContentTemplate>

        <div id="divMessages" runat="server" style="border:solid 0px #000;margin:0 auto;margin-bottom:20px;text-align: center;">
			<br />
            <asp:Label ID="lblMessage" runat="server" Visible="false" ForeColor="Red" Font-Bold="True" />
        </div>

		<div style="text-align: right;">
		<asp:Button ID="btnNewClient" runat="server" Text="Add New Client" OnClientClick="javascript:parent.location='Default.aspx?action=new';" />
		</div>

        <asp:GridView ID="gvClient" runat="server" PageSize="1" CssClass="grid-view"
            OnRowDataBound="gvClient_RowDataBound" DataKeyNames="ClientCode" OnRowCommand="gvClient_RowCommand"
            AutoGenerateColumns="False" HorizontalAlign="Center"
            EnableModelValidation="True" CellPadding="0" CellSpacing="0" >
            <Columns>
                <asp:BoundField DataField="ClientName" HeaderText="Client Name" SortExpression="ClientName" />
                <asp:BoundField DataField="PhoneNumberFormatted" HeaderText="Phone" SortExpression="PhoneNumber" />
                <asp:BoundField DataField="BillingAddress" HeaderText="Address" SortExpression="BillingAddress" />
                <asp:BoundField DataField="City" HeaderText="City" SortExpression="City" />
                <asp:BoundField DataField="State" HeaderText="State" SortExpression="State" />
                <asp:BoundField DataField="Zip" HeaderText="Zip" SortExpression="Zip" />
                <asp:BoundField DataField="FaxNumberFormatted" HeaderText="Fax" SortExpression="FaxNumber" />
                <asp:BoundField DataField="EmailAddress" HeaderText="Email" SortExpression="EmailAddress" />
            </Columns>
            <EmptyDataTemplate>
                No client selected
            </EmptyDataTemplate>
            <FooterStyle CssClass="footerrow" />
            <PagerStyle CssClass="gvPagerCss" />
            <HeaderStyle CssClass="headerrow" />
            <RowStyle CssClass="normalrow" Height="25" />
            <SelectedRowStyle CssClass="selectedrow" />
        </asp:GridView>

        <asp:Panel runat="server" ID="pnlEditClient" Visible="false">
            <table>
                <tr><td>Active:</td><td><asp:CheckBox runat="server" ID="chkActive" /></td></tr>
                <tr><td>Client Name:</td><td><asp:TextBox runat="server" ID="txtClientName" Width="400" /></td></tr>
                <tr><td>Short Name:</td><td><asp:TextBox runat="server" ID="txtClientShortName" Width="100" /></td></tr>
                <tr><td>Billing Address:</td><td><asp:TextBox runat="server" ID="txtBillingAddress" Width="400" /></td></tr>
                <tr><td>City/State:</td><td><asp:TextBox runat="server" ID="txtCity" />/<asp:TextBox runat="server" ID="txtState" MaxLength="2" /></td></tr>
                <tr><td>Zip:</td><td><asp:TextBox runat="server" ID="txtZip" MaxLength="5" /></td></tr>
                <tr><td>Contact Title:</td><td><asp:TextBox runat="server" ID="txtContactTitle" /></td></tr>
                <tr><td>Contact First Name:</td><td><asp:TextBox runat="server" ID="txtContactFirstName" /></td></tr>
                <tr><td>Contact Last Name:</td><td><asp:TextBox runat="server" ID="txtContactLastName" /></td></tr>
                <tr><td>Phone/Ext:</td><td><asp:TextBox runat="server" ID="txtPhoneNumber" />/<asp:TextBox runat="server" ID="txtExtension" /></td></tr>
                <tr><td>Fax Number:</td><td><asp:TextBox runat="server" ID="txtFaxNumber" /></td></tr>
                <tr><td>Email Address:</td><td><asp:TextBox runat="server" ID="txtEmailAddress" /></td></tr>
                <tr><td>URL:</td><td><asp:TextBox runat="server" ID="txtURL" /></td></tr>
                <tr><td>Call Center Phone:</td><td><asp:TextBox runat="server" ID="txtCallCenterPhone" /></td></tr>
                <tr><td>Call Center Email:</td><td><asp:TextBox runat="server" ID="txtCallCenterEmail" /></td></tr>
				<tr><td>&nbsp;</td></tr>
				<tr><td>Benefits for client are dependent upon:</td></tr>
                <tr><td>Pay Type:</td><td><asp:CheckBox runat="server" ID="chkPayType" /></td></tr>
                <tr><td>Class:</td><td><asp:CheckBox runat="server" ID="chkClass" /></td></tr>
                <tr><td>Category:</td><td><asp:CheckBox runat="server" ID="chkCategory" /></td></tr>
                <tr><td>UCode:</td><td><asp:CheckBox runat="server" ID="chkUCode" /></td></tr>
            </table>
            <asp:Button runat="server" ID="btnSaveClient" Text="Save" OnClick="btnSaveClient_Click" ValidationGroup="EditClient" OnClientClick="javascript:Page_ClientValidate('EditClient'); return OnUpdateValidators();" />
            <asp:Button runat="server" ID="btnCancelClient" Text="Cancel" OnClick="btnCancelClient_Click" />
            <asp:RequiredFieldValidator runat="server" ID="rfClientName" ControlToValidate="txtClientName" ValidationGroup="EditClient" />
            <asp:RequiredFieldValidator runat="server" ID="rfClientShortName" ControlToValidate="txtClientShortName" ValidationGroup="EditClient" />
        </asp:Panel>

        <table runat="server" id="tblDivisionsAndLocations" width="100%">
            <tr>
                <td valign="top">
                    <br />
                    <div style="text-align:center; font-weight: bold; font-size: medium;">Divisions</div>
                    <hr />
                    <br />

                    <asp:Button runat="server" ID="btnShowAllDivisions" Text="Show All" OnClick="btnShowAllDivisions_Click" />
                    <asp:TextBox runat="server" ID="txtSearchDivisions" />
                    <asp:Button runat="server" ID="btnSearchDivisions" Text="Find Division" OnClick="btnSearchDivisions_Click" />
                    <asp:GridView ID="gridDivisions" runat="server" PageSize="15" CssClass="grid-view"
                        AllowPaging="True" AllowSorting="True" DataKeyNames="DivID"
                        OnRowDataBound="gridDivisions_RowDataBound" OnSelectedIndexChanging="gridDivisions_SelectedIndexChanging"
                        OnPageIndexChanging="gridDivisions_PageIndexChanging" OnSorting="gridDivisions_Sorting"
                        OnRowEditing="gridDivisions_RowEditing" OnRowCancelingEdit="gridDivisions_RowCancelingEdit" OnRowDeleting="gridDivisions_RowDeleting" OnRowUpdating="gridDivisions_RowUpdating"
                        AutoGenerateColumns="False"
                        EnableModelValidation="True"
                        CellSpacing = "0" CellPadding="0" ShowHeader="true" >
                        <Columns>
                            <asp:TemplateField HeaderText="Divisions" HeaderStyle-Width="300px" SortExpression="DivName">
                                <ItemTemplate>
                                    <asp:Label runat="server" ID="txtDivisionName" Text='<%# Eval("DivName") %>' />
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox runat="server" ID="txtDivisionName" Text='<%# Bind("DivName") %>' Width="290px" />
                                    <asp:RequiredFieldValidator runat="server" ID="rfvDivisionName" ControlToValidate="txtDivisionName" ValidationGroup="EditDivision" />
                                </EditItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Action" HeaderStyle-Width="40px" ItemStyle-HorizontalAlign="Center" FooterStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:LinkButton ID="btnDivisionEdit" Text="Edit" runat="server" CommandName="Edit" CausesValidation="false" />
                                    <br />
                                    <asp:LinkButton CssClass="hidden" runat="server" CausesValidation="false" CommandName="Delete" OnClientClick="javascript:if (!confirm('Are you sure you want to delete this division?')) return false;">Delete</asp:LinkButton>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:LinkButton ID="btnDivisionUpdate" Text="Update" runat="server" CommandName="Update" CausesValidation="true" OnClientClick="javascript:Page_ClientValidate('EditDivision'); return OnUpdateValidators();" ValidationGroup="EditDivision" />
                                    <br />
                                    <asp:LinkButton ID="btnDivisionCancel" Text="Cancel" runat="server" CommandName="Cancel" CausesValidation="false" />
                                </EditItemTemplate>
                                <ItemStyle Font-Size="XX-Small" />
                            </asp:TemplateField>
                        </Columns>
                        <EmptyDataTemplate>
                            No divisions found
                        </EmptyDataTemplate>
                        <FooterStyle CssClass="footerrow" />
                        <PagerStyle CssClass="gvPagerCss" />
                        <HeaderStyle CssClass="headerrow" />
                        <RowStyle CssClass="normalrow" Height="25" />
                        <SelectedRowStyle CssClass="selectedrow" />
                    </asp:GridView>

                    Division Name:
                    <asp:TextBox runat="server" ID="txtAddDivName" />
                    <asp:RequiredFieldValidator runat="server" ID="rfvDivAddName" ControlToValidate="txtAddDivName" ValidationGroup="AddDivision" />
                    <asp:Button runat="server" ID="btnAddDivision" Text="Add Division" OnClick="btnAddDivision_Click" CausesValidation="True" OnClientClick="javascript:Page_ClientValidate('AddDivision'); return OnUpdateValidators();" ValidationGroup="AddDivision" />
                    
                </td>
                <td valign="top">
                    <br />
                    <div style="text-align:center; font-weight: bold; font-size: medium;">Locations</div>
                    <hr />
                    <br />

                    <asp:Button runat="server" ID="btnShowAllLocations" Text="Show All" OnClick="btnShowAllLocations_Click" />
                    <asp:TextBox runat="server" ID="txtSearchLocations" /><asp:Button runat="server" ID="btnSearchLocations" Text="Find Location" OnClick="btnSearchLocations_Click" />
                    <asp:GridView ID="gridLocations" runat="server" PageSize="15" CssClass="grid-view"
                        AllowPaging="True" AllowSorting="True" DataKeyNames="LocID"
                        OnRowDataBound="gridLocations_RowDataBound" OnSelectedIndexChanging="gridLocations_SelectedIndexChanging"
                        OnPageIndexChanging="gridLocations_PageIndexChanging" OnSorting="gridLocations_Sorting"
                        OnRowEditing="gridLocations_RowEditing" OnRowCancelingEdit="gridLocations_RowCancelingEdit" OnRowDeleting="gridLocations_RowDeleting" OnRowUpdating="gridLocations_RowUpdating"
                        AutoGenerateColumns="False"
                        EnableModelValidation="True"
                        CellSpacing = "0" CellPadding="0" ShowHeader="true" >
                        <Columns>
                            <asp:TemplateField HeaderText="Locations" HeaderStyle-Width="300px" SortExpression="LocationName">
                                <ItemTemplate>
                                    <asp:Label runat="server" ID="txtLocationName" Text='<%# Eval("LocationName") %>' />
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox runat="server" ID="txtLocationName" Text='<%# Bind("LocationName") %>' Width="290px" />
                                    <asp:RequiredFieldValidator runat="server" ID="rfvLocationName" ControlToValidate="txtLocationName" ValidationGroup="EditLocation" />
                                </EditItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Division" HeaderStyle-Width="100px" SortExpression="DivisionName">
                                <ItemTemplate>
                                    <asp:Label runat="server" ID="lblDivisionName" Text='<%# Eval("DivisionName") %>' />
                                    <asp:HiddenField runat="server" ID="ddlEditDivision" Value='<%# Eval("DivID") %>' />
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:DropDownList runat="server" ID="ddlEditDivision" Width="95px" />
                                    <asp:RequiredFieldValidator runat="server" ID="rfvDivisionName" ControlToValidate="ddlEditDivision" ValidationGroup="EditLocation" />
                                </EditItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Action" HeaderStyle-Width="40px" ItemStyle-HorizontalAlign="Center" FooterStyle-HorizontalAlign="Center">
                                <ItemTemplate>
                                    <asp:LinkButton ID="btnEdit" Text="Edit" runat="server" CommandName="Edit" />
                                    <br />
                                    <asp:LinkButton CssClass="hidden" ID="btnDeleteLocation" Text="Delete" runat="server" CommandName="Delete" OnClientClick="javascript:if (!confirm('Are you sure you want to delete this location?')) return false;" />
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:LinkButton ID="btnUpdate" Text="Update" runat="server" CommandName="Update" CausesValidation="true" OnClientClick="javascript:Page_ClientValidate('EditLocation'); return OnUpdateValidators();" ValidationGroup="EditLocation" />
                                    <br />
                                    <asp:LinkButton ID="btnCancel" Text="Cancel" runat="server" CommandName="Cancel" CausesValidation="false" />
                                </EditItemTemplate>
                                <ItemStyle Font-Size="XX-Small" />
                            </asp:TemplateField>
                        </Columns>
                        <EmptyDataTemplate>
                            No locations found
                        </EmptyDataTemplate>
                        <FooterStyle CssClass="footerrow" />
                        <PagerStyle CssClass="gvPagerCss" />
                        <HeaderStyle CssClass="headerrow" />
                        <RowStyle CssClass="normalrow" Height="25" />
                        <SelectedRowStyle CssClass="selectedrow" />
                    </asp:GridView>

                    Location Name:
                    <asp:TextBox runat="server" ID="txtAddLocation" />
                    <asp:RequiredFieldValidator runat="server" ID="rfvAddLocation" ControlToValidate="txtAddLocation" ValidationGroup="AddLocation" />
                    <asp:DropDownList runat="server" ID="ddlDivisions" ValidationGroup="AddLocation" />
                    <asp:RequiredFieldValidator runat="server" ID="rfvDivisions" ControlToValidate="ddlDivisions" ValidationGroup="AddLocation" />
                    <asp:Button runat="server" ID="btnAddLocation" Text="Add Location" OnClick="btnAddLocation_Click" CausesValidation="True" OnClientClick="javascript:Page_ClientValidate('AddLocation'); return OnUpdateValidators();" ValidationGroup="AddLocation" />
                </td>
            </tr>
        </table>

		<asp:Panel runat="server" ID="pnlManagers">
			<br />
			<hr style="width:90%;" />
			<div style="text-align:center; font-weight: bold; font-size: medium;">Managers</div>
			<hr style="width:90%;" />

			<asp:Button runat="server" ID="btnShowAllManagers" Text="Show All" OnClick="btnShowAllManagers_Click" />
			<asp:TextBox runat="server" ID="txtSearchManagers" /><asp:Button runat="server" ID="btnSearchManagers" Text="Find Manager" OnClick="btnSearchManagers_Click" />

			<div style="display:inline-block;">
			<asp:RadioButton CssClass="hidden" runat="server" ID="rdoClients" Text="Client" GroupName="rdoManagers" OnCheckedChanged="rdoAssignedTo_CheckedChanged" AutoPostBack="true" />
			<asp:RadioButton runat="server" ID="rdoDivisions" Text="Division" GroupName="rdoManagers" OnCheckedChanged="rdoAssignedTo_CheckedChanged" AutoPostBack="true" />
			<br />
			<asp:RadioButton runat="server" ID="rdoLocations" Text="Location" GroupName="rdoManagers" OnCheckedChanged="rdoAssignedTo_CheckedChanged" AutoPostBack="true" />
			</div>

			<table width="100%">
				<tr>
					<td style="vertical-align: top;">
						<asp:GridView ID="gridManagers" runat="server" PageSize="10" CssClass="grid-view"
							AllowPaging="True" AllowSorting="False" DataKeyNames="ManagerID"
							OnRowDataBound="gridManagers_RowDataBound" OnSelectedIndexChanging="gridManagers_SelectedIndexChanging" OnPageIndexChanging="gridManagers_PageIndexChanging"
							OnRowEditing="gridManagers_RowEditing" OnRowCancelingEdit="gridManagers_RowCancelingEdit" OnRowDeleting="gridManagers_RowDeleting" OnRowUpdating="gridManagers_RowUpdating"
							AutoGenerateColumns="False"
							EnableModelValidation="True"
							CellSpacing = "0" CellPadding="0" ShowHeader="true" >
							<Columns>
								<asp:BoundField DataField="FullName" HeaderText="Name" ItemStyle-Width="206" ControlStyle-Width="100" />
								<asp:BoundField DataField="Email" HeaderText="Email" ItemStyle-Width="206" ControlStyle-Width="200" />
							</Columns>
							<EmptyDataTemplate>
								No managers found
							</EmptyDataTemplate>
							<FooterStyle CssClass="footerrow" />
							<PagerStyle CssClass="gvPagerCss" />
							<HeaderStyle CssClass="headerrow" />
							<RowStyle CssClass="normalrow" Height="25" />
							<SelectedRowStyle CssClass="selectedrow" />
						</asp:GridView>
						<asp:Button runat="server" ID="btnAddManager" Text="Add Manager" OnClick="btnAddManager_Click" />
						<asp:Button runat="server" ID="btnDeleteManager" Text="Delete Manager" OnClick="btnDeleteManager_Click" Visible="false" OnClientClick="javascript:if (!confirm('Do you really want to delete this manager?')) return false;" />

						<br /><br />

						<asp:DetailsView runat="server" ID="dvManager" DataKeyNames="ManagerID" OnModeChanging="dvManager_ModeChanging"
							AutoGenerateRows="False"
							OnItemUpdating="dvManager_ItemUpdating"
							OnItemInserting="dvManager_ItemUpdating" EnableModelValidation="True" >
							<Fields>

	<%--                            <asp:TemplateField HeaderText="Divisions">
									<ItemTemplate>
										<asp:DropDownList runat="server" ID="ddlAssignedDivisions" Width="300" />
										<asp:Button runat="server" ID="btnUnassignDivision" Text="Unassign" />
									</ItemTemplate>
								</asp:TemplateField>
								<asp:TemplateField HeaderText="Locations">
									<ItemTemplate>
										<asp:DropDownList runat="server" ID="ddlAssignedLocations" Width="300" />
										<asp:Button runat="server" ID="btnUnassignLocation" Text="Unassign" />
									</ItemTemplate>
								</asp:TemplateField>
	--%>                        
								<asp:TemplateField HeaderText="Title" ItemStyle-Width="150">
									<EditItemTemplate>
										<asp:TextBox ID="txtTitle" runat="server" Text='<%# Bind("Title") %>'></asp:TextBox>
									</EditItemTemplate>
									<InsertItemTemplate>
										<asp:TextBox ID="txtTitle" runat="server" Text='<%# Bind("Title") %>'></asp:TextBox>
									</InsertItemTemplate>
									<ItemTemplate>
										<asp:Label ID="lblTitle" runat="server" Text='<%# Bind("Title") %>'></asp:Label>
									</ItemTemplate>
								</asp:TemplateField>
								<asp:TemplateField HeaderText="First Name">
									<EditItemTemplate>
										<asp:TextBox ID="txtFirstName" runat="server" Text='<%# Bind("FirstName") %>'></asp:TextBox>
										<asp:RequiredFieldValidator runat="server" ID="rfFirstName" ControlToValidate="txtFirstName" ValidationGroup="EditManager" SetFocusOnError="true" />
									</EditItemTemplate>
									<InsertItemTemplate>
										<asp:TextBox ID="txtFirstName" runat="server" Text='<%# Bind("FirstName") %>'></asp:TextBox>
										<asp:RequiredFieldValidator runat="server" ID="rfFirstName" ControlToValidate="txtFirstName" ValidationGroup="EditManager" SetFocusOnError="true" />
									</InsertItemTemplate>
									<ItemTemplate>
										<asp:Label ID="lblFirstName" runat="server" Text='<%# Bind("FirstName") %>'></asp:Label>
									</ItemTemplate>
								</asp:TemplateField>
								<asp:TemplateField HeaderText="Middle Name">
									<EditItemTemplate>
										<asp:TextBox ID="txtMiddleName" runat="server" Text='<%# Bind("MiddleName") %>'></asp:TextBox>
									</EditItemTemplate>
									<InsertItemTemplate>
										<asp:TextBox ID="txtMiddleName" runat="server" Text='<%# Bind("MiddleName") %>'></asp:TextBox>
									</InsertItemTemplate>
									<ItemTemplate>
										<asp:Label ID="lblMiddleName" runat="server" Text='<%# Bind("MiddleName") %>'></asp:Label>
									</ItemTemplate>
								</asp:TemplateField>
								<asp:TemplateField HeaderText="Last Name">
									<EditItemTemplate>
										<asp:TextBox ID="txtLastName" runat="server" Text='<%# Bind("LastName") %>'></asp:TextBox>
										<asp:RequiredFieldValidator runat="server" ID="rfLastName" ControlToValidate="txtLastName" ValidationGroup="EditManager" SetFocusOnError="true" />
									</EditItemTemplate>
									<InsertItemTemplate>
										<asp:TextBox ID="txtLastName" runat="server" Text='<%# Bind("LastName") %>'></asp:TextBox>
										<asp:RequiredFieldValidator runat="server" ID="rfLastName" ControlToValidate="txtLastName" ValidationGroup="EditManager" SetFocusOnError="true" />
									</InsertItemTemplate>
									<ItemTemplate>
										<asp:Label ID="lblLastName" runat="server" Text='<%# Bind("LastName") %>'></asp:Label>
									</ItemTemplate>
								</asp:TemplateField>
								<asp:TemplateField HeaderText="Phone">
									<EditItemTemplate>
										<asp:TextBox ID="txtPhone" runat="server" Text='<%# Bind("PhoneFormatted") %>'></asp:TextBox>
									</EditItemTemplate>
									<InsertItemTemplate>
										<asp:TextBox ID="txtPhone" runat="server" Text='<%# Bind("PhoneFormatted") %>'></asp:TextBox>
									</InsertItemTemplate>
									<ItemTemplate>
										<asp:Label ID="lblPhone" runat="server" Text='<%# Bind("PhoneFormatted") %>'></asp:Label>
									</ItemTemplate>
								</asp:TemplateField>
								<asp:TemplateField HeaderText="Extension">
									<EditItemTemplate>
										<asp:TextBox ID="txtExtension" runat="server" Text='<%# Bind("Extension") %>'></asp:TextBox>
									</EditItemTemplate>
									<InsertItemTemplate>
										<asp:TextBox ID="txtExtension" runat="server" Text='<%# Bind("Extension") %>'></asp:TextBox>
									</InsertItemTemplate>
									<ItemTemplate>
										<asp:Label ID="lblExtension" runat="server" Text='<%# Bind("Extension") %>'></asp:Label>
									</ItemTemplate>
								</asp:TemplateField>
								<asp:TemplateField HeaderText="Email">
									<EditItemTemplate>
										<asp:TextBox ID="txtEmail" runat="server" Text='<%# Bind("Email") %>'></asp:TextBox>
									</EditItemTemplate>
									<InsertItemTemplate>
										<asp:TextBox ID="txtEmail" runat="server" Text='<%# Bind("Email") %>'></asp:TextBox>
									</InsertItemTemplate>
									<ItemTemplate>
										<asp:Label ID="lblEmail" runat="server" Text='<%# Bind("Email") %>'></asp:Label>
									</ItemTemplate>
								</asp:TemplateField>
								<asp:CommandField ButtonType="Button" ShowEditButton="True" ValidationGroup="EditManager" />
							</Fields>
							<FooterStyle CssClass="footerrow" />
							<PagerStyle CssClass="gvPagerCss" />
							<FieldHeaderStyle CssClass="headerrow" />
							<RowStyle CssClass="normalrow" Height="25" Width="300" />
						</asp:DetailsView>
                    
						<!--Button will render, but not actually be visible to the client-->
						<asp:Button ID="btnPageBottom" runat="server" Text="Button" style="margin-left:-999px;" />
					</td>
					<td style="vertical-align: top;">
						<asp:GridView ID="gvAssignedDivisions" runat="server" PageSize="15" CssClass="grid-view"
							AllowPaging="True" AllowSorting="False" DataKeyNames="DivisionID, ManagerID"
							OnRowDataBound="gvAssignedDivisions_RowDataBound" OnSelectedIndexChanging="gvAssignedDivisions_SelectedIndexChanging"
							OnPageIndexChanging="gvAssignedDivisions_PageIndexChanging"
							OnRowDeleting="gvAssignedDivisions_RowDeleting"
							AutoGenerateColumns="False"
							EnableModelValidation="True"
							CellSpacing = "0" CellPadding="0" ShowHeader="true" >
							<Columns>
								<asp:TemplateField HeaderText="Assigned Divisions" HeaderStyle-Width="300px" SortExpression="DivName">
									<ItemTemplate>
										<asp:Label runat="server" ID="txtDivisionName" Text='<%# Eval("DivisionName") %>' />
									</ItemTemplate>
								</asp:TemplateField>
								<asp:TemplateField HeaderText="Primary?">
									<ItemTemplate>
										<asp:CheckBox runat="server" ID="chkDivisionIsPrimary" OnCheckedChanged="chkDivisionIsPrimary_CheckedChanged" Checked='<%# Eval("IsPrimary") %>' />
									</ItemTemplate>
									<ItemStyle HorizontalAlign="Center" />
								</asp:TemplateField>
								<asp:TemplateField HeaderText="Action" HeaderStyle-Width="40px" ItemStyle-HorizontalAlign="Center" FooterStyle-HorizontalAlign="Center">
									<ItemTemplate>
										<asp:Button ID="btnDivisionDelete" Text="Unassign" runat="server" CausesValidation="false" ValidationGroup="EditDivision" CommandName="Delete" />
									</ItemTemplate>
									<ItemStyle Font-Size="XX-Small" />
								</asp:TemplateField>
							</Columns>
							<EmptyDataTemplate>
								This manager is not assigned to any divisions
							</EmptyDataTemplate>
							<FooterStyle CssClass="footerrow" />
							<PagerStyle CssClass="gvPagerCss" />
							<HeaderStyle CssClass="headerrow" />
							<RowStyle CssClass="normalrow" Height="25" />
							<SelectedRowStyle CssClass="selectedrow" />
							<EmptyDataRowStyle CssClass="emptyrow" Font-Bold="true" />
						</asp:GridView>
						Division:
						<asp:DropDownList runat="server" ID="ddlAssignDivision" Width="250" />
						<asp:RequiredFieldValidator runat="server" ID="rfAssignDivision" ControlToValidate="ddlAssignDivision" ValidationGroup="AssignDivision" />
						<asp:CheckBox runat="server" ID="chkDivisionIsPrimary" Text="Primary" />
						<asp:Button runat="server" ID="btnAssignDivision" Text="Assign" OnClick="btnAssignDivision_Click" CausesValidation="True" OnClientClick="javascript:Page_ClientValidate('AssignDivision'); return OnUpdateValidators();" ValidationGroup="AssignDivision" />
                    
						<br /><br />

						<asp:GridView ID="gvAssignedLocations" runat="server" PageSize="15" CssClass="grid-view"
							AllowPaging="True" AllowSorting="False" DataKeyNames="LocationID, ManagerID"
							OnRowDataBound="gvAssignedLocations_RowDataBound" OnSelectedIndexChanging="gvAssignedLocations_SelectedIndexChanging"
							OnPageIndexChanging="gvAssignedLocations_PageIndexChanging"
							OnRowDeleting="gvAssignedLocations_RowDeleting"
							AutoGenerateColumns="False"
							EnableModelValidation="True"
							CellSpacing = "0" CellPadding="0" ShowHeader="true" >
							<Columns>
								<asp:TemplateField HeaderText="Assigned Locations" HeaderStyle-Width="300px" SortExpression="DivName">
									<ItemTemplate>
										<asp:Label runat="server" ID="txtLocationName" Text='<%# Eval("LocationName") %>' />
									</ItemTemplate>
								</asp:TemplateField>
								<asp:TemplateField HeaderText="Primary?">
									<ItemTemplate>
										<asp:CheckBox runat="server" ID="chkLocationIsPrimary" OnCheckedChanged="chkLocationIsPrimary_CheckedChanged" Checked='<%# Eval("IsPrimary") %>' />
									</ItemTemplate>
									<ItemStyle HorizontalAlign="Center" />
								</asp:TemplateField>
								<asp:TemplateField HeaderText="Action" HeaderStyle-Width="40px" ItemStyle-HorizontalAlign="Center" FooterStyle-HorizontalAlign="Center">
									<ItemTemplate>
										<asp:Button ID="btnLocationDelete" Text="Unassign" runat="server" CausesValidation="false" ValidationGroup="EditLocation" CommandName="Delete" />
									</ItemTemplate>
									<ItemStyle Font-Size="XX-Small" />
								</asp:TemplateField>
							</Columns>
							<EmptyDataTemplate>
								This manager is not assigned to any locations
							</EmptyDataTemplate>
							<FooterStyle CssClass="footerrow" />
							<PagerStyle CssClass="gvPagerCss" />
							<HeaderStyle CssClass="headerrow" />
							<RowStyle CssClass="normalrow" Height="25" />
							<SelectedRowStyle CssClass="selectedrow" />
							<EmptyDataRowStyle CssClass="emptyrow" Font-Bold="true" />
						</asp:GridView>
						Location:
						<asp:DropDownList runat="server" ID="ddlAssignLocation" Width="250" />
						<asp:RequiredFieldValidator runat="server" ID="rfAssignLocation" ControlToValidate="ddlAssignLocation" ValidationGroup="AssignLocation" />
						<asp:CheckBox runat="server" ID="chkLocationIsPrimary" Text="Primary" />
						<asp:Button runat="server" ID="btnAssignLocation" Text="Assign" OnClick="btnAssignLocation_Click" CausesValidation="True" OnClientClick="javascript:Page_ClientValidate('AssignLocation'); return OnUpdateValidators();" ValidationGroup="AssignLocation" />
					</td>
				</tr>
			</table>
		</asp:Panel>

    </ContentTemplate>
    </asp:UpdatePanel>

</asp:Content>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

andrewbb@gmail.com
Architect
United States United States
No Biography provided

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.180111.1 | Last Updated 22 Sep 2014
Article Copyright 2012 by andrewbb@gmail.com
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid