multi-Radwindows

7 posts, 0 answers
  1. J
    J avatar
    4 posts
    Member since:
    Oct 2011

    Posted 09 Oct 2011 Link to this post

    Hi,
    I have developed the parent page three radwindows. There are two radwindows to be open by click event of image button by calling the code behind command as below coding:
     Protected Sub btnStaff_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnStaff.Click
            Singleton.Windows(0).VisibleOnPageLoad = True
        End Sub

        Protected Sub btnGuest_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnGuest.Click
            Singleton.Windows(1).VisibleOnPageLoad = True
        End Sub 

    Actually Singleton.Windows(0) is only with one button to closed itself by 
     Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnCancel.Click
            InjectScriptLabel.Text = "<script>RefreshParentPage()</" + "script>"
      End Sub

    The function of the Javascript -RefreshParentPage
     function RefreshParentPage()
        {
          //alert ("Dialog is about to reload parent page");
         
          GetRadWindow().BrowserWindow.location.reload();
        }
    Now, I want to open the third Radwindows when Singleton.Windows(0) is closed. - Singleton.Windows(2) by the below function:
     Protected Sub ShowCostCenter()
             Singleton.Windows(2).VisibleOnPageLoad = True
    End Sub

    How can I created the close event to catch Singleton.Windows(0) is closed and call the code behind function "ShowCostCenter"?

    Thank

  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    4609 posts

    Posted 11 Oct 2011 Link to this post

    Hi J,

    You can use the RadWindow's OnClientClose event and in it you can either show the third RadWindow via JavaScript (the recommended approach), or perform a postback. To perform the postback you can either programmatically call the click() method of a hidden button that has the required method added as its Click handler, or you can use the JavaScript __doPostBack() function (more info on that can be found, for example, here).

    I also advise that you examine the following sticky thread on opening RadWindows from the server: http://www.telerik.com/community/forums/aspnet-ajax/window/opening-radwindow-from-the-server.aspx.


    Kind regards,
    Marin
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. J
    J avatar
    4 posts
    Member since:
    Oct 2011

    Posted 16 Oct 2011 Link to this post

    Hi,
    Thank you for your reply.
    I had tried as below
    function OnClientClose(radWindow)
      {    
                 if (radWindow.Name="StaffWindow")
                 {
                      //$get("btnCostCenter").click;                  
                      var oWnd = $find("<%= ShareRatioWindow.ClientID %>");
                          oWnd.show();
                       
                 }
      }    
    When the Radwindow- StaffWindow is closed, this function is triggered. However there is window message box to display error - "Exception while executing client event OnClientClose Error: Object expected"

    But I also tried to have button to show the window by clicking event-
    Singleton.Windows(3).VisibleOnPageLoad = True

    The radwindow was displayed normally.
    What is wrong on the "OnClientClose"?
  4. Marin Bratanov
    Admin
    Marin Bratanov avatar
    4609 posts

    Posted 18 Oct 2011 Link to this post

    Hi J,

    This works as expected on my end: http://screencast.com/t/htCe7tOEvMYe. I am also attaching my test page as are reference. Please note that I am using the get_name() method instead and that the comparison is done properly - with two equals signs, as one only assigns a value. I advise that you adopt these changes and see if it works correctly with you as well. I also changed the variable name so that it does not match the RadWinow's class name.

    The only case I am aware of issues with the RadWindow events is when the AjaxControlToolKit assembly is present in the Bin folder, as some of the MS AJAX scripts get referenced from it instead from the MS assemblies, yet the scripts the ACT returns are modified and do not work correctly. If you have it in the Bin please remove it for the test and see if it helps.


    Greetings,
    Marin
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  5. J
    J avatar
    4 posts
    Member since:
    Oct 2011

    Posted 19 Oct 2011 Link to this post

    Hi Marin,
    Thank for your tutorial movie, I had modified as below:
     <radW:RadWindowManager 
        id="Singleton" 
        runat="server" 
        ClientCallBackFunction="CallBackFunction"
        OnClientShow = "OnClientShow"
        OnClientClose = "OnClientClose"
        >
       
        <windows>
          <radW:RadWindow id="StaffWindow" 
            Modal="true"
            Runat="server" 
            Width="720px"                         
            Height="540px" 
            Title="Select Staff..." 
            InitialBehavior="Pin"
            Behavior="Close"
            OnClientClose="OnClientClosed"
            NavigateUrl="select_staff.aspx">
          </radW:RadWindow>
          
          <radW:RadWindow id="GuestWindow" 
            Modal="true"
            Runat="server" 
            Width="720px"                         
            Height="540px" 
            Title="Select Guest..." 
            InitialBehavior="Pin"
            Behavior="Close"      
            NavigateUrl="select_guest.aspx">
          </radW:RadWindow>
          
          <radW:RadWindow id="ShareRatioWindow" 
            Modal="true"
            Runat="server" 
            Width="720px"                         
            Height="540px" 
            Title="Share Ratio..." 
            InitialBehavior="Pin"
            Behavior="Close"
            NavigateUrl="select_ho_share.aspx">
          </radW:RadWindow>
          
          <radW:RadWindow id="CostCenterWindow" 
            Modal="true"
            Runat="server" 
            Width="720px"                         
            Height="540px" 
            Title="Select Guest..." 
            InitialBehavior="Pin"
            Behavior="Close"
            NavigateUrl="select_cost_share.aspx">
          </radW:RadWindow>
        </windows>
      </radW:RadWindowManager>
      <script type="text/javascript">
        function OnClientClosed(rw)
        {
            if (rw.get_name()=="StaffWindow")
            {
                debugger;
                var oWnd= $ find("<%=CostCenterWindow.ClientID%>");
                oWnd.show();
                }        
            }
        }    

        </script>
    However, the second window still not show on screen, there is error message from browser:
    Webpage error details


    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
    Timestamp: Wed, 19 Oct 2011 06:38:02 UTC




    Message: Expected ';'
    Line: 538
    Char: 25
    Code: 0
    URI: http://localhost:1197/Web/(S(4cskzfjhrzb1kx45exn3ua55))/Transaction/expense_entry_m.aspx

    What's wrong on that?
  6. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 19 Oct 2011 Link to this post

    Hello J,
    I have tried the same and that worked as expected at my end. Here is the full code which I tried. Please make a double check with it.
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="closeWindow.aspx.cs" Inherits="RadWindow_closeWindow" %>
     
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="radw" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <div>
            <radw:RadWindowManager ID="Singleton" runat="server" OnClientClose="OnClientClose">
                <Windows>
                    <radw:RadWindow ID="StaffWindow" Modal="true" runat="server" Width="720px" Height="540px"
                        Title="Select Staff..." InitialBehavior="Pin" Behavior="Close" OnClientClose="OnClientClosed"
                        NavigateUrl="select_staff.aspx" OpenerElementID="Button1">
                    </radw:RadWindow>
                    <radw:RadWindow ID="GuestWindow" Modal="true" runat="server" Width="720px" Height="540px"
                        Title="Select Guest..." InitialBehavior="Pin" Behavior="Close" NavigateUrl="select_guest.aspx">
                    </radw:RadWindow>
                    <radw:RadWindow ID="ShareRatioWindow" Modal="true" runat="server" Width="720px" Height="540px"
                        Title="Share Ratio..." InitialBehavior="Pin" Behavior="Close" NavigateUrl="select_ho_share.aspx">
                    </radw:RadWindow>
                    <radw:RadWindow ID="CostCenterWindow" Modal="true" runat="server" Width="720px" Height="540px"
                        Title="Select Guest..." InitialBehavior="Pin" Behavior="Close" NavigateUrl="http://www.google.com">
                    </radw:RadWindow>
                </Windows>
            </radw:RadWindowManager>
            <asp:Button ID="Button1" runat="server" Text="Button" />
        </div>
        </form>
    </body>
    </html>
    <script type="text/javascript">
        function OnClientClosed(rw) {
            if (rw.get_name() == "StaffWindow") {
                debugger;
                var oWnd = $find("<%=CostCenterWindow.ClientID%>");
                oWnd.show();
            }
        }
        function OnClientClose() {
            alert("Hi");
        
    </script>

    Thanks,
    Shinu.
  7. J
    J avatar
    4 posts
    Member since:
    Oct 2011

    Posted 21 Oct 2011 Link to this post

    Hi ,
    Thank for all your reply,
    However, my web for the RadWidows not visible on load and tracker by button click by code behind to set "StaffWindow" to open

    Singleton.Windows(0).VisibleOnPageLoad = True //"StaffWindow"

    Therefore, I still with error when clicking the back in "StaffWindow" as below:
    Exception while executing client event OnClientClose Error : Object doesn't support this property or method

    I have tried also with the error
    function OnClientClose(radWindow)
      {

            if (radWindow.get_name() == "StaffWindow")
             {


            }
      }    



    Thanks,

    Ref for my expense_entry_m.aspx:
    <%@ Page Language="VB" MasterPageFile="~/MP.master" AutoEventWireup="false" CodeFile="expense_entry_m.aspx.vb" Inherits="FrmExpenseEntryM" title="Untitled Page" %>
    <%@ Register Assembly="RadWindow.Net2" Namespace="Telerik.WebControls" TagPrefix="radW" %>
    <%@ Register Assembly="RadCalendar.Net2" Namespace="Telerik.WebControls" TagPrefix="radCln" %>
    <%@ Register Assembly="RadInput.Net2" Namespace="Telerik.WebControls" TagPrefix="radI" %>
    <%@ Register Assembly="RadComboBox.Net2" Namespace="Telerik.WebControls" TagPrefix="radC" %>
    <%@ Register Assembly="RadTabStrip.Net2" Namespace="Telerik.WebControls" TagPrefix="radTS" %>
    <%@ Register Assembly="RadGrid.Net2" Namespace="Telerik.WebControls" TagPrefix="radG" %>
    <%@ Register Assembly="RadAjax.Net2" Namespace="Telerik.WebControls" TagPrefix="rada" %>




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


      <% System.Web.HttpContext.Current.Response.AddHeader( "Cache-Control","no-cache")
        System.Web.HttpContext.Current.Response.Expires = 0
        System.Web.HttpContext.Current.Response.Cache.SetNoServerCaching()
        System.Web.HttpContext.Current.Response.AddHeader("Pragma", "no-cache")%>


      <script type="text/javascript">
      //Show the window
      function ShowDialog()
      {                    
          //Force reload in order to guarantee that the onload event handler of the dialog which configures it executes on every show.
          var oWnd = window.radopen(null, "StaffWindow");
          oWnd.SetUrl(oWnd.GetUrl());
      }
      
      //Called when a window is being shown. Good for setting an argument to the window 
      function OnClientShow(radWindow)
      {                    
          //Get current content of textarea
          //var oText = document.getElementById("InfoArea").value;
          
          //Create a new Object to be used as an argument to the radWindow
          //var arg = new Object();                    
          //Using an Object as a argument is convenient as it allows setting many properties.
          //arg.TextValue = oText;
          //arg.Color = "red";
          //arg.BackColor = "yellow";
                              
          //Set the argument object to the radWindow        
          //radWindow.Argument = arg;
      }
                                                                              
      function CallBackFunction(radWindow, returnValue)
      {
       
         
          //var oArea = document.getElementById("InfoArea");
          //if (returnValue) oArea.value = returnValue;
          //else alert ("No text was returned");
        
      }
      
      // Called when a window is being closed.
      function OnClientClose(radWindow)
      {
    //        debugger;
            if (radWindow.get_name() == "StaffWindow")
             {
    //            debugger;
    //            var oWnd = $find("<%=CostCenterWindow.ClientID%>");
    //            oWnd.show();
            }


      }    
     
      </script>  
      <h3>Miscellaneous Expense Entry</h3> 
      <asp:Table ID="tblBasicInfo" runat="server" Width="95%">
        <asp:TableRow>
          <asp:TableCell ColumnSpan="2" HorizontalAlign="right">
            <asp:Label ID="lblMsg" runat="server" EnableViewState="false" ForeColor="red" >&nbsp;</asp:Label>&nbsp;( <font color="red">*</font> Compulsory field ) 
          </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow VerticalAlign="Top">
          <asp:TableCell Width="20%">
            Expense No.
          </asp:TableCell>
          <asp:TableCell>
            <asp:Label ID="lblExpNo" runat="server" Text="Not generated"></asp:Label>
          </asp:TableCell>
        </asp:TableRow>
      </asp:Table>
      <asp:Table ID="tblLoan" runat="server" Width="95%">
        <asp:TableRow VerticalAlign="Top">
          <asp:TableCell Width="20%">
            Loan
          </asp:TableCell>
          <asp:TableCell>
            <radC:RadComboBox ID="rcmbLoan" runat="server" Height="200" HighlightTemplatedItems="true" DropDownWidth="400px" AutoPostBack="true" >
              <ItemTemplate>
                <table border="0" cellspacing="0" cellpadding="0">
                  <tr><td>Loan No.:&nbsp;<%# DataBinder.Eval(Container.DataItem, "LoanNo") %></td><td>|</td><td>Purpose:&nbsp;<%# DataBinder.Eval(Container.DataItem, "Purpose") %></td></tr>
                </table>
              </ItemTemplate>
            </radC:RadComboBox>
          </asp:TableCell>
        </asp:TableRow>
      </asp:table>
      <asp:Table ID="tblBasicInfo2" runat="server" Width="95%">
        <asp:TableRow VerticalAlign="Top">
          <asp:TableCell Width="20%">
            <%--Input By / --%>Claimer
          </asp:TableCell>
          <asp:TableCell>
            <asp:Label ID="lblCreatedByUser" runat="server" Visible="false"></asp:Label> <%--/--%> <asp:Label ID="lblClaimer" runat="server"></asp:Label>
          </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow VerticalAlign="Top">
          <asp:TableCell>
            Purpose
          </asp:TableCell>
          <asp:TableCell>
            <font color="red">*</font>
            <radI:RadTextBox ID="rtxtPurpose" runat="server" Width="300" />
            <asp:RequiredFieldValidator ID="RequiredFieldValidator" Runat="server" Display="Dynamic" ControlToValidate="rtxtPurpose" ErrorMessage="&nbsp;Compulsory" />
          </asp:TableCell>
        </asp:TableRow>
         <asp:TableRow VerticalAlign="Top">
          <asp:TableCell>
            Invoice/Debit Note No.
          </asp:TableCell>
          <asp:TableCell>
            <radI:RadTextBox ID="rtxtDr" runat="server"  Width="300" ></radI:RadTextBox>
          </asp:TableCell>
        </asp:TableRow>
        <%--<asp:TableRow VerticalAlign="Top">
          <asp:TableCell>
            Vendor
          </asp:TableCell>
          <asp:TableCell>
            <font color="red">*</font>
            <radC:RadComboBox ID="rcmbVendor" runat="server" Height="200"
            AutoPostBack="True" AllowCustomText="True" ShowToggleImage="True"
            EnableLoadOnDemand="True" MarkFirstMatch="True">
            </radC:RadComboBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" Runat="server" Display="Dynamic" ControlToValidate="rcmbVendor" ErrorMessage="&nbsp;Compulsory" />
          </asp:TableCell>
        </asp:TableRow>--%>
        <%--<asp:TableRow VerticalAlign="Top">
          <asp:TableCell>
            Transaction Date
          </asp:TableCell>
          <asp:TableCell>
            <font color="red">*</font>
            <radCln:RadDatePicker ID="rdpTranDate" runat="server" Width="100" AutoPostBack="true"></radCln:RadDatePicker>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator3" Runat="server" Display="Dynamic" ControlToValidate="rdpTranDate" ErrorMessage="&nbsp;Compulsory" />
          </asp:TableCell>
        </asp:TableRow>--%>
        <asp:TableRow VerticalAlign="Top">
          <asp:TableCell>
            From/To Date
          </asp:TableCell>
          <asp:TableCell>
            <font color="red">*</font>
            <radCln:RadDatePicker ID="rdpFromDate" runat="server" Width="100">
            </radCln:RadDatePicker>
            <%--<asp:RequiredFieldValidator ID="RequiredFieldValidator5" Runat="server" Display="Dynamic" ControlToValidate="rdpFromDate" ErrorMessage="&nbsp;Compulsory" />--%>
             - 
            <font color="red">*</font>
            <radCln:RadDatePicker ID="rdpToDate" runat="server" Width="100">
            </radCln:RadDatePicker>
            <%--<asp:RequiredFieldValidator ID="RequiredFieldValidator6" Runat="server" Display="Dynamic" ControlToValidate="rdpToDate" ErrorMessage="&nbsp;Compulsory" />--%>
            <asp:CompareValidator id="valCompare" runat="server" ControlToValidate="rdpToDate" ControlToCompare="rdpFromDate" Operator="GreaterThanEqual" ErrorMessage="Date: From < To" Display="dynamic" />
          </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow VerticalAlign="Top">
          <asp:TableCell>
            Expense Item Type
          </asp:TableCell>
          <asp:TableCell>
            <font color="red">*</font>
            <radC:RadComboBox ID="rcmbExpItemType" runat="server" Width="250" Height="200" AutoPostBack="True" AppendDataBoundItems="true"><Items></Items></radC:RadComboBox>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" Runat="server" Display="Dynamic" ControlToValidate="rcmbExpItemType" ErrorMessage="&nbsp;Compulsory" />
            &nbsp;
            <radC:RadComboBox ID="rcmbOthers" runat="server" Width="250" Height="200" AutoPostBack="True" AppendDataBoundItems="true"><Items></Items></radC:RadComboBox>
          </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow VerticalAlign="Top">
          <asp:TableCell>
            Amount
          </asp:TableCell>
          <asp:TableCell>
            <font color="red">*</font>
            <radC:RadComboBox ID="rcmbCurrency" runat="server" DataSourceID="ObjectDataSourceCurrency" DataValueField="currencyname" DataTextField="currencyname" AutoPostBack="true" AppendDataBoundItems="true" Height="150"><Items><radC:RadComboBoxItem Text="" Value="" /></Items></radC:RadComboBox>
            &nbsp;
            <font color="red">*</font>
            <radI:RadNumericTextBox ID="rtxtAmt" runat="server" Value="0" AutoPostBack="true" />
            <asp:RequiredFieldValidator ID="RequiredFieldValidator7" Runat="server" Display="Dynamic" ControlToValidate="rtxtAmt" ErrorMessage="&nbsp;Compulsory" />
            <%--<asp:CompareValidator id="valRequired" runat="server" ControlToValidate="rtxtAmt" ValueToCompare="0" Type="Integer" Operator="GreaterThan" ErrorMessage="&nbsp;Amt: > 0" Display="dynamic" />--%>
          </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow VerticalAlign="Top">
          <asp:TableCell>
            Eqv. Amount in <asp:Label ID="lblCompanyCurrency" runat="server" />
          </asp:TableCell>
          <asp:TableCell>
            (&nbsp;<radI:RadNumericTextBox ID="rtxtAmt_" runat="server" Value="0" />
            &nbsp;x&nbsp;
            <radI:RadNumericTextBox ID="rtxtRate" runat="server" NumberFormat-DecimalDigits="6" Skin="Web20" EnableTheming="false" ReadOnly="true" Width="70" />&nbsp;)
            &nbsp;=&nbsp;
            <radI:RadNumericTextBox ID="rtxtAmtEqv" runat="server" ReadOnly="true" Value="0" />
          </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow VerticalAlign="Top">
          <asp:TableCell>
            Eqv. Amount in JPY
          </asp:TableCell>
          <asp:TableCell>
            (&nbsp;<radI:RadNumericTextBox ID="rtxtAmtEqv_" runat="server" ReadOnly="true" Value="0" />
            &nbsp;/&nbsp;
            <radI:RadNumericTextBox ID="rtxtRateJPY" runat="server" NumberFormat-DecimalDigits="6" Skin="Web20" EnableTheming="false" ReadOnly="true" Width="70" />&nbsp;)
            &nbsp;=&nbsp;
            <radI:RadNumericTextBox ID="rtxtAmtEqvJPY" runat="server" NumberFormat-DecimalDigits="0" Skin="Web20" EnableTheming="false" ReadOnly="true" Value="0" />
          </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow VerticalAlign="Top">
          <asp:TableCell >
            Staff Guest
          </asp:TableCell>
          <asp:TableCell>
            <asp:ImageButton ID="btnStaff" AlternateText="Staff..." runat="server" ImageUrl="../images/user_grey.gif" />&nbsp;
            <asp:label ID="lblNoOfStaff" runat="server" Text="0" />
            &nbsp;&nbsp;&nbsp;
           
            
            <asp:ImageButton ID="btnGuest" AlternateText="Guest..." runat="server" ImageUrl="../images/user_red.gif" />&nbsp;
            <asp:label ID="lblNoOfGuest" runat="server" Text="0" />
            &nbsp; &nbsp; &nbsp; &nbsp;
            Insureance class        
            <%--<asp:TableCell>--%>
                <radC:RadComboBox ID="rcmbins_class" runat="server" Width="200px" Height="100px" AutoPostBack="true"></radC:RadComboBox>
           <%-- </asp:TableCell>--%>
          </asp:TableCell>
          
        </asp:TableRow>
        <asp:TableRow VerticalAlign="Top" ID="tbrPaymentMtd" runat="server">
          <asp:TableCell>
            Payment Method
          </asp:TableCell>
          <asp:TableCell>
            <radC:RadComboBox ID="rcmbPaymentMtd" runat="server" Width="250px" Height="100px" AutoPostBack="true"></radC:RadComboBox>
          </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow VerticalAlign="Top">
            <asp:TableCell>
                Cost Center
            </asp:TableCell>
             <asp:TableCell>
              <asp:ImageButton ID="btnCostCenter" AlternateText="CostCenter..." runat="server" ImageUrl="../images/costcenter.png" />&nbsp;
                <asp:label ID="lblCostCenter" runat="server" Text="0" />            
             </asp:TableCell>
         </asp:TableRow>
        <asp:TableRow VerticalAlign="Top">
          <asp:TableCell>
            Remarks
          </asp:TableCell>
          <asp:TableCell>
            <radI:RadTextBox ID="rtxtRemarks" runat="server" TextMode="MultiLine" Width="400" Height="50"></radI:RadTextBox>
          </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow VerticalAlign="Top">
          <asp:TableCell ColumnSpan="2"><hr /></asp:TableCell>
        </asp:TableRow>
      </asp:Table>
      <asp:Table ID="tblHOShare" runat="server" Width="95%">
        <asp:TableRow VerticalAlign="Top">
          <asp:TableCell Width="20%">
            Share
          </asp:TableCell>
          <asp:TableCell>
            <asp:CheckBox ID="chkShareWithHO" runat="server" Text="Share with HO" AutoPostBack="true" />&nbsp;&nbsp;<asp:CheckBox ID="chkBusinessService" runat="server" Text="Business Service for HO" AutoPostBack="true" />
            &nbsp;
          </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow VerticalAlign="Top">
          <asp:TableCell>
            HO Ratio
          </asp:TableCell>
          <asp:TableCell>
            <radI:RadNumericTextBox ID="rtxtRatioHO" NumberFormat-DecimalDigits="2" runat="server" Skin="Web20" EnableTheming="false" ReadOnly="true" Value="0" Width="40" AutoPostBack="true" />&nbsp;%&nbsp;<asp:ImageButton ID="btnShareRatio" AlternateText="Input Share Details..." runat="server" ImageUrl="../images/user_suit.gif" />&nbsp;
          </asp:TableCell>
        </asp:TableRow>
        <asp:TableRow VerticalAlign="Top">
          <asp:TableCell>
            Share in JPY
          </asp:TableCell>
          <asp:TableCell>
            (&nbsp;<radI:RadNumericTextBox ID="rtxtAmtEqvJPY_" runat="server" NumberFormat-DecimalDigits="0" Skin="Web20" EnableTheming="false" ReadOnly="true" Value="0" />
            &nbsp;x&nbsp;
            <radI:RadNumericTextBox ID="rtxtRatioHO_" runat="server" NumberFormat-DecimalDigits="2" Skin="Web20" EnableTheming="false" ReadOnly="true" Width="40" />&nbsp;%&nbsp;)
            &nbsp;=&nbsp;
            <radI:RadNumericTextBox ID="rtxtShare_HO_JPY" runat="server" NumberFormat-DecimalDigits="0" Skin="Web20" EnableTheming="false" ReadOnly="true" Value="0" />
          </asp:TableCell>
        </asp:TableRow>
      </asp:Table>


      <asp:Table ID="tblButtons" runat="server" Width="95%">
        <asp:TableRow VerticalAlign="Top">
          <asp:TableCell ColumnSpan="2" HorizontalAlign="Right">
            <asp:ImageButton ID="btnUpdate" ImageUrl="..\RadControls\Grid\Skins\Web20\Update.gif" AlternateText="Save" runat="server" CommandName="Save">
            </asp:ImageButton>
            &nbsp;
            <asp:ImageButton ID="btnCancel" ImageUrl="..\RadControls\Grid\Skins\Web20\Cancel.gif" AlternateText="Cancel" runat="server" CausesValidation="False"
            CommandName="Cancel"></asp:ImageButton>
          </asp:TableCell>
        </asp:TableRow>
      </asp:Table>


      <radW:RadWindowManager 
        id="Singleton" 
        runat="server" 
        ClientCallBackFunction="CallBackFunction"
        OnClientShow = "OnClientShow"
        OnClientClose = "OnClientClose"
        >
       
        <windows>
          <radW:RadWindow id="StaffWindow" 
            Modal="true"
            Runat="server" 
            Width="720px"                         
            Height="540px" 
            Title="Select Staff..." 
            InitialBehavior="Pin"
            Behavior="Close"        
            NavigateUrl="select_staff.aspx">
          </radW:RadWindow>
          
          <radW:RadWindow id="GuestWindow" 
            Modal="true"
            Runat="server" 
            Width="720px"                         
            Height="540px" 
            Title="Select Guest..." 
            InitialBehavior="Pin"
            Behavior="Close"      
            NavigateUrl="select_guest.aspx">
          </radW:RadWindow>
          
          <radW:RadWindow id="ShareRatioWindow" 
            Modal="true"
            Runat="server" 
            Width="720px"                         
            Height="540px" 
            Title="Share Ratio..." 
            InitialBehavior="Pin"
            Behavior="Close"
            NavigateUrl="select_ho_share.aspx">
          </radW:RadWindow>
          
          <radW:RadWindow id="CostCenterWindow" 
            Modal="true"
            Runat="server" 
            Width="720px"                         
            Height="540px" 
            Title="Select Cost Center..." 
            InitialBehavior="Pin"
            Behavior="Close"
            NavigateUrl="select_cost_share.aspx">
          </radW:RadWindow>
         
         
          
        </windows>
      </radW:RadWindowManager>
      <%--<script type="text/javascript">
        function OnClientClosed(rw) {
            
        }
    //    function OnClientClose() {
    //        alert("Hi");
    //    } 
    </script>--%>
      <asp:ObjectDataSource ID="ObjectDataSourceCurrency" runat="server" 
        TypeName="Facade.CurrencyRateFacade"
        SelectMethod="GetCurrenciesFromCompany">
        <SelectParameters>
          <asp:Parameter Name="coid" Type="int32" Direction="Input" />
        </SelectParameters>
      </asp:ObjectDataSource>
      <rada:RadAjaxManager id="RadAjaxManager1" runat="server">
        <AjaxSettings>
          <rada:AjaxSetting AjaxControlID="btnUpdate">
            <UpdatedControls>
              <rada:AjaxUpdatedControl ControlID="lblMsg" LoadingPanelID=""></rada:AjaxUpdatedControl>
            </UpdatedControls>
          </rada:AjaxSetting>
          <%--<rada:AjaxSetting AjaxControlID="rcmbVendor">
            <UpdatedControls>
              <rada:AjaxUpdatedControl ControlID="rcmbVendor" LoadingPanelID=""></rada:AjaxUpdatedControl>
            </UpdatedControls>
          </rada:AjaxSetting>--%>
          <rada:AjaxSetting AjaxControlID="rtxtRatioHO">
            <UpdatedControls>
              <rada:AjaxUpdatedControl ControlID="rtxtRatioHO_" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtShare_HO_JPY" LoadingPanelID=""></rada:AjaxUpdatedControl>
            </UpdatedControls>
          </rada:AjaxSetting>
          <rada:AjaxSetting AjaxControlID="chkShareWithHO">
            <UpdatedControls>
              <rada:AjaxUpdatedControl ControlID="chkBusinessService" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtRatioHO" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="btnShareRatio" LoadingPanelID=""></rada:AjaxUpdatedControl>
            </UpdatedControls>
          </rada:AjaxSetting>
          <rada:AjaxSetting AjaxControlID="chkBusinessService">
            <UpdatedControls>
              <rada:AjaxUpdatedControl ControlID="chkShareWithHO" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtRatioHO" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="btnShareRatio" LoadingPanelID=""></rada:AjaxUpdatedControl>
           </UpdatedControls>
          </rada:AjaxSetting>
          <rada:AjaxSetting AjaxControlID="btnShareRatio">
            <UpdatedControls>
              <rada:AjaxUpdatedControl ControlID="Singleton" LoadingPanelID=""></rada:AjaxUpdatedControl>
            </UpdatedControls>
          </rada:AjaxSetting>
          <rada:AjaxSetting AjaxControlID="btnStaff">
            <UpdatedControls>
              <rada:AjaxUpdatedControl ControlID="Singleton" LoadingPanelID=""></rada:AjaxUpdatedControl>
            </UpdatedControls>
          </rada:AjaxSetting>
          <rada:AjaxSetting AjaxControlID="btnCostCenter">
            <UpdatedControls>
              <rada:AjaxUpdatedControl ControlID="Singleton" LoadingPanelID=""></rada:AjaxUpdatedControl>
            </UpdatedControls>
          </rada:AjaxSetting>
          <rada:AjaxSetting AjaxControlID="btnGuest">
            <UpdatedControls>
              <rada:AjaxUpdatedControl ControlID="Singleton" LoadingPanelID=""></rada:AjaxUpdatedControl>
            </UpdatedControls>
          </rada:AjaxSetting>
          <%--<rada:AjaxSetting AjaxControlID="rdpTranDate">--%>
          <rada:AjaxSetting AjaxControlID="rdpFromDate">
            <UpdatedControls>
              <%--<rada:AjaxUpdatedControl ControlID="rdpTranDate" LoadingPanelID=""></rada:AjaxUpdatedControl>--%>
              <rada:AjaxUpdatedControl ControlID="rdpFromDate" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtRate" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtAmtEqv" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtAmtEqv_" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtRateJPY" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtAmtEqvJPY" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <%--<rada:AjaxUpdatedControl ControlID="rtxtAmtEqvJPY_" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtShare_HO_JPY" LoadingPanelID=""></rada:AjaxUpdatedControl>--%>
            </UpdatedControls>
          </rada:AjaxSetting>
          <rada:AjaxSetting AjaxControlID="rcmbCurrency">
            <UpdatedControls>
              <rada:AjaxUpdatedControl ControlID="rtxtRate" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtAmtEqv" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtAmtEqv_" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtRateJPY" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtAmtEqvJPY" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <%--<rada:AjaxUpdatedControl ControlID="rtxtAmtEqvJPY_" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtShare_HO_JPY" LoadingPanelID=""></rada:AjaxUpdatedControl>--%>
           </UpdatedControls>
          </rada:AjaxSetting>
          <rada:AjaxSetting AjaxControlID="rtxtAmt">
            <UpdatedControls>
              <rada:AjaxUpdatedControl ControlID="rcmbCurrency" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtRate" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtAmt_" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtAmtEqv" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtAmtEqv_" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtRateJPY" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtAmtEqvJPY" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <%--<rada:AjaxUpdatedControl ControlID="rtxtAmtEqvJPY_" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtShare_HO_JPY" LoadingPanelID=""></rada:AjaxUpdatedControl>--%>
            </UpdatedControls>
          </rada:AjaxSetting>
          <rada:AjaxSetting AjaxControlID="rcmbPaymentMtd">
            <UpdatedControls>
              <rada:AjaxUpdatedControl ControlID="rtxtAmt_" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtAmtEqv" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtAmtEqv_" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtAmtEqvJPY" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <%--<rada:AjaxUpdatedControl ControlID="rtxtAmtEqvJPY_" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtShare_HO_JPY" LoadingPanelID=""></rada:AjaxUpdatedControl>--%>
            </UpdatedControls>
          </rada:AjaxSetting>
          
          <rada:AjaxSetting AjaxControlID="rcmbins_class">
            <UpdatedControls>
              <rada:AjaxUpdatedControl ControlID="rcmbins_class" LoadingPanelID=""></rada:AjaxUpdatedControl>          
            </UpdatedControls>        
          </rada:AjaxSetting>
          
          <rada:AjaxSetting AjaxControlID="rcmbExpItemType">
            <UpdatedControls>
              <rada:AjaxUpdatedControl ControlID="rcmbExpItemType" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <%--<rada:AjaxUpdatedControl ControlID="rcmbOthers" LoadingPanelID=""></rada:AjaxUpdatedControl>--%>
            </UpdatedControls>
          </rada:AjaxSetting>
          <%--<rada:AjaxSetting AjaxControlID="rcmbOthers">
            <UpdatedControls>
              <rada:AjaxUpdatedControl ControlID="rcmbOthers" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rcmbExpItemType" LoadingPanelID=""></rada:AjaxUpdatedControl>
            </UpdatedControls>
          </rada:AjaxSetting>--%>
          <rada:AjaxSetting AjaxControlID="rcmbLoan">
            <UpdatedControls>
              <rada:AjaxUpdatedControl ControlID="rtxtPurpose" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rdpFromDate" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rdpToDate" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <%--<rada:AjaxUpdatedControl ControlID="rcmbVendor" LoadingPanelID=""></rada:AjaxUpdatedControl>--%>
              <rada:AjaxUpdatedControl ControlID="rtxtAmt_" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtAmtEqv" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtAmtEqv_" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtAmtEqvJPY" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <%--<rada:AjaxUpdatedControl ControlID="rtxtAmtEqvJPY_" LoadingPanelID=""></rada:AjaxUpdatedControl>
              <rada:AjaxUpdatedControl ControlID="rtxtShare_HO_JPY" LoadingPanelID=""></rada:AjaxUpdatedControl>--%>
            </UpdatedControls>
          </rada:AjaxSetting>
        </AjaxSettings>
      </rada:radajaxmanager>
    </asp:Content>

    Ref for my expense_entry_m.aspx.vb:
    Imports Facade
    Imports BusinessObjects
    Imports Telerik.WebControls
    Imports System.Collections.Generic


    Partial Class FrmExpenseEntryM : Inherits PageBase
        'dim Is_Staff_Open as Boolean
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load, Me.Load


            If Not Page.IsPostBack Then
                Dim companyfacade As CompanyFacade = New CompanyFacade
                Dim userfacade As UserProfileFacade = New UserProfileFacade


                lblClaimer.Text = LoggedInProfile.Fullname
                lblCompanyCurrency.Text = companyfacade.GetCompanyCurrency(LoggedInProfile.Company.Id)
                BindExpItemTypeAndOther()
                BindPaymentMtd()
                BindInsurance_Class()
                If LoggedInProfile.Company.Id = 72 Then
                    rcmbins_class.SelectedValue = 298248
                End If


                If expid > 0 Then
                    BindExpense()
                End If
                BindLoan()


                btnShareRatio.Enabled = False
            Else


                rcmbCurrency.AllowCustomText = False
               
            End If
            SecurityCheck()
        End Sub


      Private Sub SecurityCheck()
        Dim userfacade As UserProfileFacade = New UserProfileFacade


        ' Check if user has the right to create administrative expense
        If userfacade.CheckSecParamFromUser(LoggedInProfile.Id, "applyAdminExpense", "True") Then
          rcmbOthers.Visible = True
          RadAjaxManager1.AjaxSettings.AddAjaxSetting(rcmbExpItemType, rcmbOthers, Nothing)
          RadAjaxManager1.AjaxSettings.AddAjaxSetting(rcmbOthers, rcmbOthers, Nothing)
          RadAjaxManager1.AjaxSettings.AddAjaxSetting(rcmbOthers, rcmbExpItemType, Nothing)
        Else
          rcmbOthers.Visible = False
        End If


        If Resources.Resource.EnableLoan = "T" Then
          tblLoan.Visible = True
        Else
          tblLoan.Visible = False
        End If


        If Resources.Resource.EnableInputPaymentMtdInExpense = "T" Then
          tbrPaymentMtd.Visible = True
        Else
          tbrPaymentMtd.Visible = False
        End If


        If Resources.Resource.EnableHOShare = "T" Then
          tblHOShare.Visible = True
          ' rdpTranDate
          'RadAjaxManager1.AjaxSettings.AddAjaxSetting(rdpTranDate, rtxtAmtEqvJPY_, Nothing)
          'RadAjaxManager1.AjaxSettings.AddAjaxSetting(rdpTranDate, rtxtShare_HO_JPY, Nothing)
          ' rdpFromDate
          RadAjaxManager1.AjaxSettings.AddAjaxSetting(rdpFromDate, rtxtAmtEqvJPY_, Nothing)
          RadAjaxManager1.AjaxSettings.AddAjaxSetting(rdpFromDate, rtxtShare_HO_JPY, Nothing)
          ' rcmbCurrency
          RadAjaxManager1.AjaxSettings.AddAjaxSetting(rcmbCurrency, rtxtAmtEqvJPY_, Nothing)
          RadAjaxManager1.AjaxSettings.AddAjaxSetting(rcmbCurrency, rtxtShare_HO_JPY, Nothing)
          ' rtxtAmt
          RadAjaxManager1.AjaxSettings.AddAjaxSetting(rtxtAmt, rtxtAmtEqvJPY_, Nothing)
          RadAjaxManager1.AjaxSettings.AddAjaxSetting(rtxtAmt, rtxtShare_HO_JPY, Nothing)
          ' rcmbPaymentMtd
          RadAjaxManager1.AjaxSettings.AddAjaxSetting(rcmbPaymentMtd, rtxtAmtEqvJPY_, Nothing)
          RadAjaxManager1.AjaxSettings.AddAjaxSetting(rcmbPaymentMtd, rtxtShare_HO_JPY, Nothing)
          ' rcmbLoan
          RadAjaxManager1.AjaxSettings.AddAjaxSetting(rcmbLoan, rtxtAmtEqvJPY_, Nothing)
          RadAjaxManager1.AjaxSettings.AddAjaxSetting(rcmbLoan, rtxtShare_HO_JPY, Nothing)
        Else
          tblHOShare.Visible = False
        End If


      End Sub


      Private Sub BindPaymentMtd()
        Dim company As Company = New Company
        Dim facade As Payment_MethodFacade = New Payment_MethodFacade
        Dim item As RadComboBoxItem = New RadComboBoxItem
        item.Value = "-1"
        item.Text = ""


        company.Id = LoggedInProfile.Company.Id
        With rcmbPaymentMtd
          .DataTextField = "Paymentmtd_Name"
          .DataValueField = "id"
          .DataSource = facade.GetPayment_MethodsFromCompany(company.Id)
          .DataBind()
          .Items.Insert(0, item)
          ' Hard code to delete Local Travelling / Parking type of expense
          '.Items(0).Remove()
          '.Items(2).Remove()
        End With


        For Each radcomboboxitem As RadComboBoxItem In rcmbPaymentMtd.Items
          If radcomboboxitem.Text.ToLower = "cash" Then
            radcomboboxitem.Selected = True
          End If
        Next
      End Sub


        Private Sub BindInsurance_Class()
            Dim company As Company = New Company
            Dim facade As InsuranceClassesFacade = New InsuranceClassesFacade
            Dim item As RadComboBoxItem = New RadComboBoxItem
            item.Value = "-1"
            item.Text = ""


            company.Id = LoggedInProfile.Company.Id
            With rcmbins_class
                .DataTextField = "InsClassDesc"
                .DataValueField = "id"
                .DataSource = facade.GetInsurance_ClassesFromCompany(company.Id)
                .DataBind()
                .Items.Insert(0, item)
                
            End With
        End Sub
      'Protected Sub rcmbVendor_ItemsRequested(ByVal o As Object, ByVal e As Telerik.WebControls.RadComboBoxItemsRequestedEventArgs) Handles rcmbVendor.ItemsRequested
      '  Dim keyword As String
      '  Dim facade As VendorFacade = New VendorFacade


      '  keyword = e.Text.Replace("'", "''")


      '  With rcmbVendor
      '    .DataTextField = "VendorName"
      '    .DataValueField = "id"
      '    .DataSource = facade.GetVendorsFromKeyword(loggedinprofile.company.id, keyword)
      '    .DataBind()
      '  End With


      'End Sub


      'Protected Sub rcmbVendor_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rcmbVendor.TextChanged
      '  If rcmbVendor.Text.Trim <> "" Then
      '    If rcmbVendor.Value = "" Or rcmbVendor.Value = "-1" Then
      '      rcmbVendor.Text = ""
      '    End If
      '  End If
      'End Sub


      Private Sub BindLoan()
        Dim loanfacade As LoanFacade = New LoanFacade
        Dim expense As Expense = New Expense
        Dim expitemtypefacade As ExpItemTypeFacade = New ExpItemTypeFacade
        Dim userprofile As UserProfile = New UserProfile
        Dim exptype As ExpType = New ExpType
        expense.Id = expid
        userprofile.Id = loggedinprofile.id
        exptype.Id = exptypeid


        Dim radcomboboxitem As RadComboBoxItem = New RadComboBoxItem
        radcomboboxitem.Text = ""
        radcomboboxitem.Value = -1


        With rcmbLoan
          .DataTextField = "LoanNo"
          .DataValueField = "ID"
          .DataSource = loanfacade.GetSelectableLoans(userprofile, Expense)
          .DataBind()
          .Items.Insert(0, radcomboboxitem)
        End With
      End Sub


      Private Sub BindExpItemTypeAndOther()
        Dim userfacade As UserProfileFacade = New UserProfileFacade
        Dim company As Company = New Company
        Dim expitemtypefacade As ExpItemTypeFacade = New ExpItemTypeFacade
        Dim radcomboboxitem As RadComboBoxItem = New RadComboBoxItem
        radcomboboxitem.Text = "Others"
        radcomboboxitem.Value = "-999"
        Dim radcomboboxitem_ As RadComboBoxItem = New RadComboBoxItem
        radcomboboxitem_.Text = "Others"
        radcomboboxitem_.Value = "-999"
        Dim radcomboboxitem1 As RadComboBoxItem = New RadComboBoxItem
        radcomboboxitem1.Text = ""
        radcomboboxitem1.Value = "-1"
        Dim radcomboboxitem3 As RadComboBoxItem = New RadComboBoxItem
        radcomboboxitem3.Text = ""
        radcomboboxitem3.Value = "-1"
        Dim radcomboboxitem2 As RadComboBoxItem = New RadComboBoxItem
        radcomboboxitem2.Text = "<<"
        radcomboboxitem2.Value = "-1"


        company.Id = loggedinprofile.company.id
        With rcmbExpItemType
          .Items.Clear()
          .Items.Add(radcomboboxitem1)
          If userfacade.CheckSecParamFromUser(LoggedInProfile.Id, "applyAdminExpense", "True") Then .Items.Add(radcomboboxitem)
          .DataTextField = "ExpItemType_Name"
          .DataValueField = "ID"
          .DataSource = expitemtypefacade.GetMiscExpItemTypes(company, True)
          .DataBind()
          If userfacade.CheckSecParamFromUser(LoggedInProfile.Id, "applyAdminExpense", "True") Then
            .Items.RemoveAt(1)
            .Items.Add(radcomboboxitem_)
          End If
        End With


        With rcmbOthers
          .Items.Clear()
          .Items.Add(radcomboboxitem3)
          .DataTextField = "ExpItemType_Name"
          .DataValueField = "ID"
          .DataSource = expitemtypefacade.GetOthersExpItemTypes(company, True)
          .DataBind()
          .Items.Add(radcomboboxitem2)
        End With


        rcmbExpItemType.Enabled = True
        rcmbOthers.Enabled = False


      End Sub


      Private Sub BindExpense()
        Dim expensefacade As ExpenseFacade = New ExpenseFacade()
        Dim userprofilefacade As UserProfileFacade = New UserProfileFacade()
        Dim expitemtypefacade As ExpItemTypeFacade = New ExpItemTypeFacade()
        Dim expense As Expense = New Expense


        expense = expensefacade.GetExpense(expid)


        ' Basic Info
        lblExpNo.Text = expense.ExpNo
        lblClaimer.Text = expense.Claimer.Fullname
        lblCreatedByUser.Text = expense.Claimer.Fullname
        rtxtPurpose.Text = expense.Purpose
        'rdpTranDate.SelectedDate = expense.Tran_Date
        rdpFromDate.SelectedDate = expense.From_Date
        rdpToDate.SelectedDate = expense.To_Date
        lblCompanyCurrency.Text = expense.Curr_Code_EQV
        rtxtAmtEqv.Text = expense.Cost_EQV
        rtxtAmtEqv_.Text = expense.Cost_EQV
        rtxtAmtEqvJPY.Text = expense.Cost_JPY
        rtxtAmtEqvJPY_.Text = expense.Cost_JPY
        rtxtRatioHO.Text = expense.Ratio_HO * 100
        rtxtRatioHO_.Text = expense.Ratio_HO * 100
        rtxtShare_HO_JPY.Text = expense.Share_HO_JPY
        chkShareWithHO.Checked = expense.Is_Share_HO
        chkBusinessService.Checked = expense.Is_Service_HO
        If Not IsDBNull(expense.Loan.Id) Then
          If expense.Loan.Id <> -1 Then
            rcmbLoan.SelectedValue = expense.Loan.Id
          End If
        End If
        rtxtRemarks.Text = expense.Remarks
        If expense.PaymentMethod.Id <> -1 Then rcmbPaymentMtd.SelectedValue = expense.PaymentMethod.Id
        If expense.Insurance_Class.Id <> -1 Then rcmbins_class.SelectedValue = expense.Insurance_Class.Id
        ' expense item
        Dim expenseitem As ExpenseItem = expensefacade.GetMiscExpenseItemFromExpense(expid)
        If Not expenseitem Is Nothing Then
          itemid = expenseitem.Id
          rcmbCurrency.Text = expenseitem.Curr_Code
          expenseitem.ExpItemType = expitemtypefacade.GetExpItemType(expenseitem.ExpItemType.Id)
          If Not expenseitem.ExpItemType Is Nothing Then
            If expenseitem.ExpItemType.Show_In_Others = True Then
              rcmbExpItemType.SelectedValue = "-999"
              rcmbOthers.SelectedValue = expenseitem.ExpItemType.Id
              rcmbExpItemType.Enabled = False
              rcmbOthers.Enabled = True
            Else
              rcmbExpItemType.SelectedValue = expenseitem.ExpItemType.Id
              rcmbOthers.SelectedValue = "-1"
              rcmbExpItemType.Enabled = True
              rcmbOthers.Enabled = False
            End If
          End If
        End If
        lblNoOfStaff.Text = expenseitem.No_Of_Staff
        lblNoOfGuest.Text = expenseitem.No_Of_Guest
        rtxtRate.Text = expenseitem.Rate_To_EQV
        rtxtAmt.Text = expenseitem.Cost
        rtxtAmt_.Text = expenseitem.Cost
        rtxtAmtEqv.Text = expenseitem.Cost_EQV
        rtxtAmtEqv_.Text = expenseitem.Cost_EQV
        rtxtRateJPY.Text = expenseitem.Rate_To_JPY
        rtxtAmtEqvJPY.Text = expenseitem.Cost_JPY
        'If Not expenseitem.Vendor Is Nothing Then
        '  rcmbVendor.Text = expenseitem.Vendor.VendorName
        '  rcmbVendor.Value = expenseitem.Vendor.Id
        'End If


      End Sub


      Private Sub updateExpenseItem()
        Dim calfacade As CalculationFacade = New CalculationFacade
        Dim rate As Rate = New Rate
        'Dim currencyratefacade As CurrencyRateFacade = New CurrencyRateFacade


        Dim expitemtypefacade As ExpItemTypeFacade = New ExpItemTypeFacade
        Dim expensefacade As ExpenseFacade = New ExpenseFacade()
        Dim expenseitem As ExpenseItem = expensefacade.GetMiscExpenseItemFromExpense(expid)


        With expenseitem
          .Tran_Date = rdpFromDate.SelectedDate
          Dim expitemtype As ExpItemType = New ExpItemType
          Dim coa As COA = New COA
          coa.Id = -1
          expitemtype.COA_DR = coa
          If rcmbExpItemType.Text = "Others" Then
            If rcmbOthers.SelectedValue <> "-1" And rcmbOthers.SelectedValue <> "" Then expitemtype = expitemtypefacade.GetExpItemType(rcmbOthers.SelectedValue)
          Else
            If rcmbExpItemType.SelectedValue <> "-1" And rcmbExpItemType.SelectedValue <> "" Then expitemtype = expitemtypefacade.GetExpItemType(rcmbExpItemType.SelectedValue)
          End If
          'If rcmbExpItemType.Text = "Others" Then
          '  If rcmbOthers.SelectedValue <> "-1" And rcmbOthers.SelectedValue <> "" Then expitemtype.Id = rcmbOthers.SelectedValue
          'Else
          '  If rcmbExpItemType.SelectedValue <> "-1" And rcmbExpItemType.SelectedValue <> "" Then expitemtype.Id = rcmbExpItemType.SelectedValue
          'End If
          .ExpItemType = expitemtype
          Dim vendor As Vendor = New Vendor
          'If rcmbVendor.Value <> "-1" And rcmbVendor.Value <> "" Then
          '  vendor.Id = rcmbVendor.Value
          'End If
          .Vendor = vendor
          .Curr_Code = rcmbCurrency.Text
          .Cost = rtxtAmt.Text
          .Curr_Code_EQV = lblCompanyCurrency.Text
          .Rate_To_EQV = rtxtRate.Text
          .Cost_EQV = rtxtAmtEqv.Text
          .Rate_To_JPY = rtxtRateJPY.Text
          .Cost_JPY = rtxtAmtEqvJPY.Text
        End With


        expensefacade.UpdateExpenseItem(expenseitem, loggedinprofile)
      End Sub


      Private Sub updateExpense()
        Dim expense As Expense = New Expense
        Dim expensefacade As New ExpenseFacade
            Dim paymentmtd As Payment_Method = New Payment_Method


            Dim Insurance_Class As InsuranceClass = New InsuranceClass
            Insurance_Class.Id = rcmbins_class.SelectedValue


            expense = expensefacade.GetExpense(expid)
            expense.Insurance_Class = Insurance_Class
        expense.Purpose = rtxtPurpose.Text.Trim
            expense.Tran_Date = rdpFromDate.SelectedDate


        'expense.Tran_Date = rdpTranDate.SelectedDate
        'expense.From_Date = rdpFromDate.SelectedDate
        'expense.To_Date = rdpToDate.SelectedDate


            paymentmtd.Id = rcmbPaymentMtd.SelectedValue
            expense.PaymentMethod = paymentmtd


            expense.Insurance_Class.Id = rcmbins_class.SelectedValue


        ' Get from / to date from page.
        'If IsDBNull(rdpFromDate.SelectedDate) Or rdpFromDate.SelectedDate.ToString.Trim = "" Then
        '  expense.From_Date = Format(rdpTranDate.SelectedDate, "yyyy/MM/dd")
        'Else
        '  expense.From_Date = Format(rdpFromDate.SelectedDate, "yyyy/MM/dd")
        'End If


        'If IsDBNull(rdpToDate.SelectedDate) Or rdpToDate.SelectedDate.ToString.Trim = "" Then
        '  expense.To_Date = Format(rdpTranDate.SelectedDate, "yyyy/MM/dd")
        'Else
        '  expense.To_Date = Format(rdpToDate.SelectedDate, "yyyy/MM/dd")
        'End If


        expense.From_Date = Format(rdpFromDate.SelectedDate, "yyyy/MM/dd")
        expense.To_Date = Format(rdpToDate.SelectedDate, "yyyy/MM/dd")


        expense.Is_Share_HO = chkShareWithHO.Checked
        expense.Is_Service_HO = chkBusinessService.Checked
        expense.Ratio_HO = rtxtRatioHO.Text / 100
        expense.Share_HO_JPY = rtxtShare_HO_JPY.Text


        Dim loan As Loan = New Loan
        If rcmbLoan.SelectedValue <> "-1" Then
          loan.Id = rcmbLoan.SelectedValue
          expense.Loan = loan
          expense.Has_Loan = True
        Else
          expense.Has_Loan = False
        End If


        expense.Remarks = rtxtRemarks.Text.trim()




        expensefacade.UpdateExpense(expense, loggedinprofile)


      End Sub


      Protected Sub ObjectDataSourceCurrency_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles ObjectDataSourceCurrency.Load
        ObjectDataSourceCurrency.SelectParameters(0).DefaultValue = loggedinprofile.company.id
        End Sub


      




      'Protected Sub rdpTranDate_SelectedDateChanged(ByVal sender As Object, ByVal e As Telerik.WebControls.SelectedDateChangedEventArgs) Handles rdpTranDate.SelectedDateChanged
      '  updateRate()
      '  updateCost()
      '  updateExpenseItem()
      '  updateShare()


      '  'updateExpenseAmt()
      'End Sub


      Protected Sub rdpFromDate_SelectedDateChanged(ByVal sender As Object, ByVal e As Telerik.WebControls.SelectedDateChangedEventArgs) Handles rdpFromDate.SelectedDateChanged
        updateRate()
        updateCost()
        updateExpenseItem()
        updateShare()


        'updateExpenseAmt()
      End Sub




      Protected Sub rcmbCurrency_SelectedIndexChanged(ByVal o As Object, ByVal e As Telerik.WebControls.RadComboBoxSelectedIndexChangedEventArgs) Handles rcmbCurrency.SelectedIndexChanged
        updateRate()
        updateCost()
        updateExpenseItem()
        updateShare()


        ' updateExpenseAmt()
      End Sub


      Protected Sub rtxtAmt_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rtxtAmt.TextChanged
        rtxtAmt_.text = rtxtAmt.Text
        updateRate()
        updateCost()
        updateExpenseItem()
        updateShare()


        'updateExpenseAmt()
      End Sub


      Private Sub updateRate()
        Dim destinationfacade As DestinationFacade = New DestinationFacade
        Dim currencyratefacade As CurrencyRateFacade = New CurrencyRateFacade
        Dim destination As Destination = New Destination


        ' On board salary currency
        'destination = destinationfacade.GetDestination(rcmbDestination.Value)
        'rcmbCurrency.Text = destination.OnBoardSalaryCurr.CurrencyName


        ' On board salary rate
        Dim yr As String
        Dim mth As String
        Dim currency As Currency = New Currency
        Dim rate As Rate = New Rate
        yr = Date.Parse(rdpFromDate.SelectedDate).Year.ToString
        mth = Date.Parse(rdpFromDate.SelectedDate).Month.ToString
        currency = currencyratefacade.GetCurrency(LoggedInProfile.Company.Id, rcmbCurrency.Text)
        rate = currencyratefacade.GetRate(yr, mth, currency)
        rtxtRate.Text = rate.Rate


        currency = currencyratefacade.GetCurrency(LoggedInProfile.Company.Id, "JPY")
        rate = currencyratefacade.GetRate(yr, mth, currency)
        rtxtRateJPY.Text = rate.Rate


      End Sub


      'Private Sub updateExpenseAmt()
      '  Dim calculatefacade As CalculationFacade = New CalculationFacade
      '  Dim expense As Expense = New Expense
      '  expense.Id = expid


      '  rtxtAmtEqv.Text = calculatefacade.GetAmts(expense).Cost_EQV
      'End Sub


      Private Sub updateCost()
        Dim calfacade As CalculationFacade = New CalculationFacade
        Dim expenseitem As ExpenseItem = New ExpenseItem


        With expenseitem
          .Curr_Code = rcmbCurrency.Text
          .Curr_Code_EQV = lblCompanyCurrency.Text
          .Rate_To_EQV = Decimal.Parse(rtxtRate.Text)
          .Rate_To_JPY = Decimal.Parse(rtxtRateJPY.Text)
          .Cost = Decimal.Parse(rtxtAmt.Text)
        End With


        Dim paymentmtd As New Payment_Method
        paymentmtd.Id = rcmbPaymentMtd.SelectedValue
        paymentmtd.Paymentmtd_Name = rcmbPaymentMtd.Text
        expenseitem = calfacade.Calculate(expenseitem, paymentmtd)


        rtxtAmtEqv.Text = expenseitem.Cost_EQV
        rtxtAmtEqv_.Text = expenseitem.Cost_EQV
        rtxtAmtEqvJPY.Text = expenseitem.Cost_JPY
        rtxtAmtEqvJPY_.Text = expenseitem.Cost_JPY
      End Sub


      Private Sub updateShare()
        rtxtRatioHO_.Text = rtxtRatioHO.Text
        rtxtShare_HO_JPY.Text = Decimal.Round(rtxtAmtEqvJPY.Text * rtxtRatioHO.Text / 100, 0, MidpointRounding.AwayFromZero)
      End Sub


      Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnUpdate.Click
        If Resources.Resource.EnableMiscFormChecking = "T" Then
          If Not validateSave() Then
            Exit Sub
          End If
        End If


        Dim expensefacade As ExpenseFacade = New ExpenseFacade()
        Dim expense As Expense = New Expense
        expense.Id = expid
        Dim expensebatch As ExpenseBatch = New ExpenseBatch
        expensebatch.Id = btchid
        expense.ExpenseBatch = expensebatch
        expense.ShadowFrom = shadowfrom_expid


        updateExpense()
        expensefacade.SaveExpense(expense, LoggedInProfile)
        Response.Redirect("~/Transaction/expensebatch_entry.aspx")
      End Sub


      Private Function validateSave() As Boolean
        ' Entertainment must input guest
        If rcmbExpItemType.SelectedItem.Text.ToUpper Like "ENTERTAINMENT*" Or rcmbOthers.SelectedItem.Text.ToUpper Like "ENTERTAINMENT*" Then
          If Integer.Parse(lblNoOfGuest.Text) <= 0 Then
            lblMsg.Text = "There must be guest in entertainment expense item type."
            Return False
          End If
        End If


        ' Staff meeting must input staff and no guest
        If rcmbExpItemType.SelectedItem.Text.ToUpper Like "STAFF MEETING*" Or rcmbOthers.SelectedItem.Text.ToUpper Like "STAFF MEETING*" Then
          If Integer.Parse(lblNoOfGuest.Text) > 0 Or Integer.Parse(lblNoOfStaff.Text) <= 0 Then
            lblMsg.Text = "There must only be staff (i.e. no guest) in staff meeting expense item type."
            Return False
          End If
        End If


        Return True
      End Function


      Protected Sub btnCancel_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnCancel.Click
        Dim facade As ExpenseFacade = New ExpenseFacade
        Dim expense As Expense = New Expense
            expense.Id = expid


        Dim expensebatch As ExpenseBatch = New ExpenseBatch
            expensebatch.Id = btchid
            Dim Insurance_Class As InsuranceClass = New InsuranceClass


            expense.Insurance_Class = Insurance_Class


        expense.ExpenseBatch = expensebatch
        expense.ShadowFrom = shadowfrom_expid
        facade.CancelUpdateExpense(expense, LoggedInProfile)
        Response.Redirect("~/Transaction/expensebatch_entry.aspx")
      End Sub


      Protected Sub rcmbExpItemType_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rcmbExpItemType.TextChanged
        If rcmbExpItemType.Text = "Others" Then
          rcmbExpItemType.Enabled = False
          rcmbOthers.Enabled = True
        End If
      End Sub


      Protected Sub rcmbOthers_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rcmbOthers.TextChanged
        If rcmbOthers.Text = "<<" Then
          rcmbExpItemType.Enabled = True
          rcmbOthers.Enabled = False
        End If


        End Sub


       


      Protected Sub Singleton_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Singleton.Load
            Singleton.Windows(0).VisibleOnPageLoad = False
            Singleton.Windows(1).VisibleOnPageLoad = False
            Singleton.Windows(2).VisibleOnPageLoad = False
            Singleton.Windows(3).VisibleOnPageLoad = False
        'BindExpense()
        End Sub


        Public Sub ShowCostCenter()
            
        End Sub


        Protected Sub btnCostCenter_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnCostCenter.Click


            Singleton.Windows(3).VisibleOnPageLoad = True
        End Sub
        'Protected Sub ShowCostCenter()


        '    MsgBox("VB")
        '    Singleton.Windows(3).VisibleOnPageLoad = True
        'End Sub


        Protected Sub btnStaff_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnStaff.Click
            updateExpense()
            Singleton.Windows(0).VisibleOnPageLoad = True


        End Sub


        Protected Sub btnGuest_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnGuest.Click
            updateExpense()
            Singleton.Windows(1).VisibleOnPageLoad = True
        End Sub


        Protected Sub btnShareRatio_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnShareRatio.Click
            updateExpense()
            Singleton.Windows(2).VisibleOnPageLoad = True
        End Sub


        Protected Sub chkBusinessService_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkBusinessService.CheckedChanged
            If chkBusinessService.Checked = True Then
                Dim facade As ExpenseFacade = New ExpenseFacade
                Dim hoshares As IList(Of ExpenseHOShare) = New List(Of ExpenseHOShare)()


                hoshares = facade.GetExpenseHOSharesFromExpense(expid)
                For Each hoshare As ExpenseHOShare In hoshares
                    facade.DeleteExpenseHOShare(hoshare.Id)
                Next


                chkShareWithHO.Checked = False
                rtxtRatioHO.ReadOnly = False
            Else
                rtxtRatioHO.ReadOnly = True
            End If
            btnShareRatio.Enabled = False
            rtxtRatioHO.Text = "0"
        End Sub


        Protected Sub chkShareWithHO_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles chkShareWithHO.CheckedChanged
            If chkShareWithHO.Checked = True Then
                chkBusinessService.Checked = False
                btnShareRatio.Enabled = True
            Else
                btnShareRatio.Enabled = False
            End If
            rtxtRatioHO.ReadOnly = True
            rtxtRatioHO.Text = "0"
        End Sub


        Protected Sub rtxtRatioHO_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rtxtRatioHO.TextChanged
            If chkBusinessService.Checked = True Then
                updateShare()
            End If
        End Sub


        Protected Sub rcmbLoan_SelectedIndexChanged(ByVal o As Object, ByVal e As Telerik.WebControls.RadComboBoxSelectedIndexChangedEventArgs) Handles rcmbLoan.SelectedIndexChanged
            Dim loan As Loan = New Loan
            Dim loanfacade As LoanFacade = New LoanFacade
            loan = loanfacade.GetLoan(rcmbLoan.SelectedValue)


            If Not loan Is Nothing Then
                rtxtPurpose.Text = loan.Purpose
                rdpFromDate.SelectedDate = loan.From_Date
                rdpToDate.SelectedDate = loan.To_Date
                'rcmbVendor.Text = loan.Vendor.VendorName
                'rcmbVendor.Value = loan.Vendor.Id
            End If
            updateRate()
            updateCost()
            updateExpenseItem()
            updateShare()
        End Sub


        Protected Sub rcmbPaymentMtd_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rcmbPaymentMtd.TextChanged
            updateCost()
            updateExpenseItem()
            updateShare()
        End Sub


        Private Function allRequiredFieldsWithValues() As Boolean
            'If rdpTranDate.SelectedDate.HasValue And rcmbCurrency.Value <> "" Then
            If rdpFromDate.SelectedDate.HasValue And rcmbCurrency.Value <> "" Then
                Return True
            Else
                Return False
            End If
        End Function




      
       
    End Class



Back to Top