<%@ Page Language="vb" AutoEventWireup="false" MasterPageFile="~/Admin.Master" CodeBehind="CustomerDetails.aspx.vb" Inherits="Superbowl.CustomerDetails"
    title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

  <script language="javascript" type="text/javascript">
<!--
	function FormValidate()
	{
		msg = ""
		f = document.aspnetForm;

		if(f.ctl00$body$txtCustomerNo.value == "")
			msg += "- Customer Number\n";
		if(f.ctl00$body$strCustomerName.value == "")
			msg += "- Customer Name\n";
		if(f.ctl00$body$ddlBranch.value == 0)
			msg += "- Branch\n";
		if(f.ctl00$body$ddlChannel.value == 0)
			msg += "- Channel\n";
		if(f.ctl00$body$ddlRep.value == "0")
			msg += "- Sales Rep\n";
		if(f.ctl00$body$ddlType1.value == 0)
			msg += "- Type 1\n";
		if(f.ctl00$body$ddlType2.value == 0)
			msg += "- Type 2\n";
		if(f.ctl00$body$txtCountry.value == "")
			msg += "- Country\n";
		if(msg.length > 0){
			alert("Please enter the following values:\n" + msg);
			return false;
		}
		else
		{
			return true;
		}
	}
-->
</script>
	<style type="text/css">
		.cssTxt1
		{
			width: 60px;
		}
		.cssDDL1
		{
			width: 160px;
		}
		.cssDDL2
		{
			width: 240px;
		}
		.cssDDL3
		{
			width:300px;
		}
   </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="body" runat="server">
	<table width="100%" border="0" >
 <tr>
     <td align="center" class="headings" colspan="3">Customer Details</td>
 </tr>
 <tr valign="top" >
   <td align="left" valign="top">
        <table  cellpadding="2" width="100%" border="0">
				<tr 'null tr, controls the width'><td width="30%"></td><td></td></tr>
				<tr >
					<td align="right">Customer Number:</td>
					<td align="left" ><asp:TextBox ID="txtCustomerNo" runat="server" MaxLength="7"
							AutoPostBack="True"></asp:TextBox><X>*</X></td></tr>
				<tr>
				  <td align="right" >Customer Name:</td>
				  <td align="left" >
					  <asp:TextBox ID="strCustomerName" runat="server"
						  CssClass="cssDDL2" MaxLength="80"></asp:TextBox><X>*</X></td></tr>
				<tr>
					<td align="right" >Branch:</td>
					<td align="left" ><asp:DropDownList ID="ddlBranch" runat="server"
							DataSourceID="sdsBranch" CssClass="cssDDL2"
							DataTextField="strBranch" DataValueField="BranchID"></asp:DropDownList><X>*</X></td></tr>
				<tr>
				  <td align="right" >Channel Segment:</td>
				  <td align="left" >
            <asp:DropDownList ID="ddlChannelSegment" runat="server" CssClass="cssDDL3"
						  DataSourceID="sdsChannel" DataTextField="strChannelSegment"
              DataValueField="ChannelSegmentID">
					  </asp:DropDownList><X>*</X></td></tr>
				<tr>
					<td align="right">Rep:</td>
					<td align="left" >
						<asp:DropDownList ID="ddlRep" runat="server"	 CssClass="cssDDL2" AutoPostBack="True"
							DataSourceID="sdsRep" DataTextField="strRep" DataValueField="RepID" /><x>*</x></td></tr>
				<tr>
					<td align="right">MDU:</td>
					<td align="left" >
						<asp:DropDownList ID="ddlRepLux" runat="server" DataSourceID="sdsRep" CssClass="cssDDL2"
							DataTextField="strRep" DataValueField="RepID">
						</asp:DropDownList></td></tr>
				<tr>
					<td align="right">Brand Builder:</td>
					<td align="left" >
						<asp:DropDownList ID="ddlRepBB" runat="server" DataSourceID="sdsRep" CssClass="cssDDL2"
							DataTextField="strRep" DataValueField="RepID">
						</asp:DropDownList></td></tr>
				<tr>
					<td align="right">Delux Brand Builder:</td>
					<td align="left" >
						<asp:DropDownList ID="ddlRepDlx" runat="server" DataSourceID="sdsRep" CssClass="cssDDL2"
							DataTextField="strRep" DataValueField="RepID">
						</asp:DropDownList></td></tr>
				<tr>
					<td align="right">&nbsp;</td>
					<td align="left" >
						&nbsp;</td></tr>
				<tr>
				  <td align="right" >KeyKey Account Group:</td>
				  <td valign="top">
					  <asp:DropDownList ID="ddlKAG" runat="server"
						  DataSourceID="sdsKeyAccountGroup" DataTextField="strKAG"
						  DataValueField="KeyAccount_GroupID" CssClass="cssDDL2">
					  </asp:DropDownList>
					</td></tr>
				<tr>
				  <td align="right" >Country:d>
				  <td valign="top" nowrap>
						<asp:DropDownList ID="ddlCountry" runat="server" CssClass="cssDDL2"
              DataSourceID="sdsCountry" DataTextField="strCountry"
              DataValueField="strCountry" AutoPostBack="True">
            </asp:DropDownList>&nbsp;&gt;&gt;<asp:TextBox ID="txtCountry" runat="server"></asp:TextBox><X>*</X></td></tr>
        </table></td>
    <td align="left" valign="top" width="35%">
        <table cellpadding="2" width="100%" border="0">
				<tr 'null tr, controls the width'><td width="30%"></td><td></td></tr>
				<tr>
				  <td align="right">Type 1:</td>
				  <td align="left" ><asp:DropDownList ID="ddlType1" runat="server"
              DataSourceID="sdsType1" CssClass="cssDDL1" DataTextField="strType1"
              DataValueField="Type1ID" ></asp:DropDownList><X>*</X></td></tr>
				<tr>
				  <td align="right">Type 2:</td>
				  <td align="left" ><asp:DropDownList ID="ddlType2" runat="server"
              DataSourceID="sdsType2" CssClass="cssDDL1" DataTextField="strType2"
              DataValueField="Type2ID" ></asp:DropDownList><X>*</X></td></tr>
				<tr>
				  <td align="right">Snell Area:</td>
				  <td align="left" >
					  <asp:DropDownList ID="ddlSnellArea" runat="server" DataSourceID="sdsSnellArea" CssClass="cssDDL1"
						  DataTextField="strSnellAreaName" DataValueField="SnellAreaCode">
					  </asp:DropDownList>
					</td></tr>
				<tr>
				  <td align="right">Snell Channel:</td>
				  <td align="left" >
					  <asp:TextBox ID="strSnellChannel" runat="server" MaxLength="2"
						  CssClass="cssTxt1" ReadOnly="True"></asp:TextBox>
					</td></tr>
				<tr>
				  <td align="right">Snell cwsireg:</td>
				  <td align="left" >
					  <asp:TextBox ID="strSnellcwsireg" runat="server" CssClass="cssTxt1"
						  MaxLength="4" ReadOnly="True"></asp:TextBox></td></tr>
				<tr>
				  <td align="right">Snell Rep number: </td>
				  <td align="left" ><asp:TextBox ID="strSnellrepno" runat="server"
						  CssClass="cssTxt1" MaxLength="4" ReadOnly="True"></asp:TextBox></td></tr>
				<tr>
				  <td align="right">Snell Supergroup:</td>
				  <td align="left" nowrap><asp:TextBox ID="strSnellsupergroup" runat="server" CssClass="cssTxt1" MaxLength="3" ReadOnly="True"></asp:TextBox>
            <asp:Label ID="lblSnellsupergroupName" runat="server"></asp:Label>
          </td></tr>
				<tr>
				  <td align="right">Snell Grading:</td>
				  <td align="left" >
            <asp:TextBox ID="strSnellgrading" runat="server" MaxLength="25"
						  ReadOnly="True" CssClass="cssDDL1"></asp:TextBox></td></tr>
				<tr>
				  <td align="right" >Promo Account:</td>
				  <td valign="top"><asp:CheckBox ID="chkPromotionalAccount" runat="server" Checked="false" /></td></tr>
				<tr>
				  <td align="right" >Active:</td>
				  <td valign="top"><asp:CheckBox ID="chkActive" runat="server" Checked="True" /></td></tr>
			</table>
	</td>
    <td align="left" width="10%">&nbsp;</td>
 </tr>
 <tr>
     <td align="center" colspan="3">
		  <asp:Label ID="lblMessage" runat="server" Font-Italic="True" Font-Bold="True"
			  CssClass="red" Width="60%"></asp:Label>&nbsp;</td>
 </tr>
 <tr>
   <td align="center" colspan="3"><asp:Button ID="btnSave" runat="server" Text="Save" OnClientClick="return FormValidate()" />&nbsp;<asp:Button ID="btnClose" runat="server" Text="Cancel" /></td>
 </tr>
 <tr>
   <td align="center" colspan="3">&nbsp;</td>
 </tr>
 <tr>
   <td align="center" colspan="3">Last Edit: <asp:Label ID="lblLastEdit" runat="server" Text="New" Font-Italic="True"></asp:Label></td>
 </tr>
 </table>

<asp:SqlDataSource ID="sdsBranch" runat="server"
		ConnectionString="<%$ ConnectionStrings:csStockControl %>"
		SelectCommand="SELECT 0 AS BranchID, '- Select -' AS strBranch
													UNION SELECT BranchID, strBranch +' '+ strCode + CASE WHEN [strBranch] = [strSalesOffice] THEN '' ELSE ' : ' + [strSalesOffice] END AS strBranch FROM mstBranch
													ORDER BY strBranch">
	</asp:SqlDataSource>

	<asp:SqlDataSource ID="sdsRep" runat="server"
		ConnectionString="<%$ ConnectionStrings:csStockControl %>"
		SelectCommand="SELECT '0' AS RepID, '- Select/None -' AS strRep
													UNION SELECT RepID, strRepName + ' - ' + RepID + ' (' + strSegment + ')' AS strRep FROM mstRep LEFT JOIN mstSegment ON SegmentID = refSegmentID
													ORDER BY strRep">
	</asp:SqlDataSource>

	<asp:SqlDataSource ID="sdsSnellArea" runat="server"
		ConnectionString="<%$ ConnectionStrings:csStockControl %>"
		SelectCommand="SELECT '' AS SnellAreaCode, '- Unknown -' AS strSnellAreaName
													UNION SELECT SnellAreaCode, strSnellAreaName + ' - ' + SnellAreaCode AS strSnellArea FROM mstSnellArea
													ORDER BY strSnellAreaName">
	</asp:SqlDataSource>

	<asp:SqlDataSource ID="sdsKeyAccountGroup" runat="server"
		ConnectionString="<%$ ConnectionStrings:csStockControl %>"
		SelectCommand="SELECT 0 AS KeyAccount_GroupID, '- None -' AS strKAG, '' AS strKeyAccount, 0 AS refKeyAccountID
													UNION SELECT mstKeyAccount_Group.KeyAccount_GroupID, mstKeyAccount_Group.strGroupName + CASE WHEN [strGroupName] = [strKeyAccount] THEN '' ELSE ' - ' + [strKeyAccount] END AS strKAG, mstKeyAccount.strKeyAccount, mstKeyAccount_Group.refKeyAccountID FROM mstKeyAccount RIGHT OUTER JOIN mstKeyAccount_Group ON mstKeyAccount.KeyAccountID = mstKeyAccount_Group.refKeyAccountID WHERE (mstKeyAccount.blnActive = 1)
													ORDER BY strKAG">
	</asp:SqlDataSource>

	<asp:SqlDataSource ID="sdsChannel" runat="server"
		ConnectionString="<%$ ConnectionStrings:csStockControl %>"

    SelectCommand="SELECT 0 AS ChannelSegmentID, '- Select -' AS strChannelSegment UNION SELECT ChannelSegmentID, strSegmentPrimary + ' &gt; ' + strSegment + ' &gt; ' + strChannelPrimary + ' &gt; ' + strChannel AS strChannelSegment FROM mstChannelSegment WHERE ChannelSegmentID > 0 ORDER BY strChannelSegment">
	</asp:SqlDataSource>
  <asp:SqlDataSource ID="sdsType1" runat="server"
    ConnectionString="<%$ ConnectionStrings:csStockControl %>"
    SelectCommand="SELECT 0 as Type1ID, '- Select -' AS strType1 UNION SELECT Type1ID, strType1 FROM mstType1 ORDER BY strType1">
  </asp:SqlDataSource>
  <asp:SqlDataSource ID="sdsType2" runat="server"
    ConnectionString="<%$ ConnectionStrings:csStockControl %>"
    SelectCommand="SELECT 0 as Type2ID, '- Select -' AS strType2 UNION SELECT Type2ID, strType2 FROM mstType2 ORDER BY strType2">
  </asp:SqlDataSource>

<asp:SqlDataSource ID="sdsCountry" runat="server"
  ConnectionString="<%$ ConnectionStrings:csStockControl %>"

    SelectCommand="SELECT strCountry FROM mstCustomer GROUP BY strCountry UNION SELECT strCountry FROM mstExports GROUP BY strCountry ORDER BY strCountry">
</asp:SqlDataSource>


	</asp:Content>
