<%@ Page Language="C#" MasterPageFile="~/MasterPages/Main.master" AutoEventWireup="true" CodeFile="AddMerchant.aspx.cs" Inherits="Business_AddMerchant"  %>
<%@ Register src="../UserControls/DatePicker.ascx" tagname="DatePicker" tagprefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    <script language="javascript">
function validate()
{
    var message = "";
    if (document.getElementById("<%=txtAccNo.ClientID%>").value=="")
    {
        message += "Account Number can not be blank\n";  
        document.getElementById("<%=txtAccNo.ClientID%>").style.backgroundColor="#c8d1e4";
    }
    
    var IndexValue = document.getElementById("<%=ddlClientLevel.ClientID %>").selectedIndex;
    var SelectedVal = document.getElementById("<%=ddlClientLevel.ClientID %>").options[IndexValue].value;

    if(SelectedVal == "003" && document.getElementById("<%=txtParentClientNumber.ClientID%>").value=="")
    {
        message += "Parent Client Number can not be blank\n";
        document.getElementById("<%=txtParentClientNumber.ClientID%>").style.backgroundColor="#c8d1e4";
    }

    if (SelectedVal == "002" && document.getElementById("<%=txtParentClientNumber.ClientID%>").value == "") {
        message += "Parent Client Number can not be blank\n";
        document.getElementById("<%=txtParentClientNumber.ClientID%>").style.backgroundColor = "#c8d1e4";
    }
    
    if(document.getElementById("<%=txtRetailName.ClientID%>").value=="")
    {
        message += "Merchant Name can not be blank\n";
        document.getElementById("<%=txtRetailName.ClientID%>").style.backgroundColor="#c8d1e4";
    }

    if (document.getElementById("<%=txtRetailNameAr.ClientID%>").value == "") {
        message += "Merchant Name (Arabic) can not be blank\n";
        document.getElementById("<%=txtRetailNameAr.ClientID%>").style.backgroundColor = "#c8d1e4";
    }

    if (document.getElementById("<%=ddlCity.ClientID %>").selectedIndex == 0) {
        message += "City can not be blank\n";
        document.getElementById("<%=ddlCity.ClientID%>").style.backgroundColor = "#c8d1e4";
    }

    if (document.getElementById("<%=ddlRegion.ClientID %>").selectedIndex == 0) {
        message += "region can not be blank\n";
        document.getElementById("<%=ddlRegion.ClientID%>").style.backgroundColor = "#c8d1e4";
    }

    if (document.getElementById("<%=ddlRelationshipOfficer.ClientID %>").selectedIndex == 0) {
        message += "Relationship Officer can not be blank\n";
        document.getElementById("<%=ddlRelationshipOfficer.ClientID%>").style.backgroundColor = "#c8d1e4";
    }

    if (document.getElementById("<%=ddlBusinessClass.ClientID %>").selectedIndex == 0) {
        message += "Relationship Officer can not be blank\n";
        document.getElementById("<%=ddlBusinessClass.ClientID%>").style.backgroundColor = "#c8d1e4";
    }
    
//    if (document.getElementById("<%=txtFDR.ClientID%>").value == "") {
//        message += "FDR ID can not be blank\n";
//        document.getElementById("<%=txtFDR.ClientID%>").style.backgroundColor = "#c8d1e4";
//    }

    if (document.getElementById("<%=txtRegNo.ClientID%>").value == "") {
        message += "CRN ID can not be blank\n";
        document.getElementById("<%=txtRegNo.ClientID%>").style.backgroundColor = "#c8d1e4";
    }

    
    if (SelectedVal == "003" && document.getElementById("<%=ddlSettlMethod.ClientID %>").selectedIndex == 0) {
        message += "Settlement Method can not be blank\n";
        document.getElementById("<%=ddlSettlMethod.ClientID%>").style.backgroundColor = "#c8d1e4";
    }


    if(message.length >0)
    {
        message = "please notice the following requirments:\n\n" + message;
        alert(message);
        return false;
    }
      return true;
}

function validate1()
{
    var message = "";
    if(document.getElementById("<%=txtParentClientNumber.ClientID%>").value=="")
    {
        message += "Client Number can not be blank\n";
        document.getElementById("<%=txtParentClientNumber.ClientID%>").style.backgroundColor="#c8d1e4";
    }
    
    if(message.length >0)
    {
        message = "please notice the following requirments:\n\n" + message;
        alert(message);
        return false;
    }
      return true;
}

</script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <table class="body_MainTB" border="0" cellpadding="0" cellspacing="0">
                    <tr align="center">
                        <td valign="top">
                            <!------------------------------------body St  ---------------------------------------------->
                            <table border="0" cellpadding="0" cellspacing="0" class="body_formTitle">
                                <tr>
                                    <td>
                                        Add Merchant</td>
                                </tr>
                            </table>
                            <br>
                            <!------------------------------------body End1 ----------------------------------------------->
                            <table border="0" cellpadding="0" cellspacing="0" class="contTB">
                                <tr>
                                    <td align="center">
                                        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="Frow">
                                            <tr>
                                                <td>
                                                </td>
                                            </tr>
                                        </table>
                                        <br />
                                        <asp:Label ID="lblError" runat="server" Text="" class="fieldError"></asp:Label>
                                            <asp:Panel ID="pnlBR" runat="server" Width="100%">
                                                <fieldset id="addItem">
                                                 <legend id="addItem">Merchant Details</legend>
                                                </fieldset>
                                                <table border="0" width="95%" cellpadding="0" cellspacing="0" class="add_ItemTB1">
                                                     <tr>
                                                        <td class="tdNormal">Registration Date</td>
                                                        <td class="tdNormal"><asp:TextBox ID="txtRegDate" ReadOnly="true" runat="server" class="fieldNormal"></asp:TextBox><uc1:datepicker id="dateRegDate" runat="server" width="250" 
                                                                Visible="False" /></td>
                                                        <td class="tdNormal"></td>
                                                        <td class="tdNormal">
                                                            <asp:Label ID="lblRetailerID" runat="server" Text="Client Number"></asp:Label>
                                                        </td>
                                                        <td class="tdNormal">
                                                            <asp:TextBox ID="txtParentClientNumber" runat="server" 
                                                                class="fieldNormal" MaxLength="10"></asp:TextBox> <asp:Button ID="btnParentData" runat="server" class="Btn_L_Normal1" 
                                                                onclick="btnParentData_Click" OnClientClick="return validate1()" 
                                                                Text="Get Parent Data" />
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="tdNormal">Account Number <span style="color: Red;">*</span> </td>
                                                        <td class="tdNormal">
                                                            <asp:TextBox ID="txtAccNo" MaxLength="10" runat="server" class="fieldNormal"></asp:TextBox>
                                                            <asp:Button ID="btnMW" runat="server" class="Btn_L_Normal1"
                                                                OnClick="btnMW_Click" Text="Verify Account" />
                                                        </td>
                                                        <td class="tdNormal"></td>
                                                        <td class="tdNormal">Merchant Fee Account Number</td>
                                                        <td class="tdNormal">
                                                            <asp:TextBox ID="txtfeemerchantaccno" runat="server" class="fieldNormal"
                                                                Width="150"></asp:TextBox>
                                                        </td>
                                                    </tr>
                                                    <tr runat="server" id="rowParent">
                                                        <td class="tdNormal">Index Number</td>
                                                        <td class="tdNormal">
                                                            <asp:TextBox ID="txtLegalForm" runat="server" class="fieldNormal" MaxLength="15"></asp:TextBox>
                                                        </td>
                                                        <td class="tdNormal"></td>
                                                        <td class="tdNormal">Commercial Registration Number<span style="color:Red;">*</span></td>
                                                        <td class="tdNormal">
                                                            <asp:TextBox ID="txtRegNo" runat="server" class="fieldNormal" MaxLength="20"></asp:TextBox>
                                                        </td>
                                                    </tr>
                                                    
                                                    <tr>
                                                        <td class="tdNormal" style="width:15%">Client Level<span style="color:Red;">*</span></td>
                                                        <td class="tdNormal" style="width:30%"><asp:DropDownList ID="ddlClientLevel" 
                                                                runat="server" DataTextField="cl_desc" 
                                                             DataValueField="cl_code" class="fieldNormal" AutoPostBack=true 
                                                                onselectedindexchanged="ddlClientLevel_SelectedIndexChanged"></asp:DropDownList></td>
                                                        <td class="tdNormal" style="width:10%"></td>
                                                        <td class="tdNormal">FDR ID(Blank:Auto filled from Retailer ID) <span style="color:Red;">*</span></td>
                                        <td class="tdNormal">
                                            <asp:TextBox ID="txtFDR" runat="server" MaxLength="12" Width=150 
                                                class="fieldNormal"></asp:TextBox>
                                            <br />
                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="tdNormal"><asp:Label ID="lblMerchantNameAr" runat="server" 
                                                                Text="Merchant Name (Arabic)"></asp:Label><span style="color:Red;">*</span></td>
                                                        <td class="tdNormal"><asp:TextBox ID="txtRetailNameAr" runat="server" class="fieldNormal" MaxLength="100"></asp:TextBox></td>
                                                        <td class="tdNormal"></td>
                                                        <td class="tdNormal">
                                                            <asp:Label ID="lblMerchantName" runat="server" Text="Merchant Name (English)"></asp:Label><span style="color:Red;">*</span>
                                                        </td>
                                                        <td class="tdNormal">
                                                            <asp:TextBox ID="txtRetailName" runat="server" class="fieldNormal" MaxLength="100"></asp:TextBox>
                                                        </td>
                                                    </tr>
                                                    <tr >
                                                        <td class="tdNormal">Region<span style="color:Red;">*</span></td>                                                        
                                                        <td class="tdNormal">
                                                            <asp:DropDownList ID="ddlRegion" runat="server" AutoPostBack="True" 
                                                                class="fieldNormal" DataTextField="region_name" DataValueField="region_code" 
                                                                onselectedindexchanged="ddlRegion_SelectedIndexChanged">
                                                            </asp:DropDownList>
                                                        </td>
                                                        <td class="tdNormal"></td>
                                                        <td class="tdNormal">City<span style="color:Red;">*</span></td>
                                                        <td class="tdNormal">
                                                            <asp:DropDownList ID="ddlCity" runat="server" class="fieldNormal" 
                                                                DataTextField="c_desc" DataValueField="c_code">
                                                            </asp:DropDownList>
                                                        </td>
                                                    </tr>
                                                   
                                                   
                                                   <%-- <tr style="display:none">
                                                        <td class="tdNormal">Merchant Contact</td>
                                                        <td class="tdNormal">
                                                            <asp:TextBox ID="txtMerchantContact2" runat="server" class="fieldNormal"></asp:TextBox>
                                                        </td>
                                                        <td class="tdNormal"></td>
                                                        <td class="tdNormal" >Branch</td>
                                                        <td class="tdNormal" >
                                                            <asp:DropDownList ID="ddlBranch" runat="server" class="fieldNormal" 
                                                                DataTextField="L_NM" DataValueField="BRANCH_CD">
                                                            </asp:DropDownList>
                                                            <asp:TextBox ID="txtBranch" runat="server" class="fieldNormal" ReadOnly="True"></asp:TextBox>
                                                        </td>
                                                    </tr>--%>
                                                   <tr>
                                                        <td class="tdNormal">Branch<span style="color:Red;">*</span></td>
                                                        <td class="tdNormal"> <asp:DropDownList ID="ddlBranch" runat="server" class="fieldNormal" 
                                                                DataTextField="BRANCH_CD" DataValueField="BRANCH_CD" AutoPostBack ="true" 
                                                                onselectedindexchanged="ddlBranch_SelectedIndexChanged1">
                                                            </asp:DropDownList>
                                                            <asp:TextBox ID="txtBranch" runat="server" class="fieldNormal" ReadOnly="True"></asp:TextBox></td>  
                                                        <td class="tdNormal"></td>
                                                        <td class="tdNormal" ></td>
                                                        <td class="tdNormal" >
                                                           
                                                        </td>
                                                    </tr>
                                                   
                                                    <tr style="display:none">
                                                        <td class="tdNormal">Business Unit</td>
                                                        <td class="tdNormal">
                                                            <asp:DropDownList ID="ddlBusinessUnit" runat="server" AutoPostBack="True" 
                                                                class="fieldNormal" DataTextField="description" DataValueField="bu_code" 
                                                                onselectedindexchanged="ddlBusinessUnit_SelectedIndexChanged">
                                                            </asp:DropDownList>
                                                        </td>
                                                        <td class="tdNormal"></td>
                                                        <td class="tdNormal">Business Unit Account</td>
                                                        <td class="tdNormal">
                                                            <asp:TextBox ID="txtBUAcc" runat="server" class="fieldNormal" ReadOnly="true"></asp:TextBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="tdNormal">Business Class<span style="color:Red;">*</span></td>
                                                        <td class="tdNormal">
                                                            <asp:DropDownList ID="ddlBusinessClass" runat="server" class="fieldNormal" 
                                                                DataTextField="BUSINESS_NAME" DataValueField="MCC">
                                                            </asp:DropDownList>
                                                        </td>
                                                        <td class="tdNormal"></td>
                                                        <td class="tdNormal">Relationship officer<span style="color:Red;">*</span></td>
                                                        <td class="tdNormal">
                                                            <asp:DropDownList ID="ddlRelationshipOfficer" runat="server" 
                                                                class="fieldNormal" DataTextField="RSO_NAME" DataValueField="RSO_CODE" Width="250">
                                                            </asp:DropDownList>
                                                        </td>
                                                    </tr>
                                                    <tr>										   
                                                        <td class="tdNormal">
                                                            Settlement Method
                                                        </td>
                                                        <td class="tdNormal">
                                                            <asp:DropDownList ID="ddlSettlMethod" runat="server" DataTextField="SETTLE_METHOD_NAME"
                                                                DataValueField="SM_CODE" class="fieldNormal">
                                                            </asp:DropDownList>
                                                            <br />
                                                            <asp:DropDownList ID="ddlSettlMethodOld" runat="server" DataTextField="SETTLE_METHOD_NAME"
                                                                DataValueField="SM_CODE" class="fieldNormalold" Enabled="false" Visible="false">
                                                            </asp:DropDownList>
                                                        </td>
                                                        <td class="tdNormal">
                                                        </td>
                                                        <td class="tdNormal">
                                                            Posting Method
                                                        </td>
                                                        <td class="tdNormal">
                                                            <asp:DropDownList ID="ddlPostingMethod" runat="server" DataTextField="POSTING_METHOD_NAME"
                                                                DataValueField="PM_CODE" class="fieldNormal">
                                                            </asp:DropDownList>
                                                        </td>
                                                    </tr>
                                                </table>
                                                <table border="0" cellpadding="0" cellspacing="0" class="action_TB_BgaddItem">
                                                    <tr>
                                                        <td>
                                                            <asp:Button ID="btnSave" runat="server" Text="   Save   "
                                                                class="Btn_M_Normal" onclick="btnSave_Click" OnClientClick="return validate()"/>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </asp:Panel>
                                        <!------------------------------------body End2 ----------------------------------------------->
                                        <br>
                                    </td>
                                </tr>
                            </table>
                            <!------------------------------------body End2 ----------------------------------------------->
                        </td>
                    </tr>
                </table>
</asp:Content>
