This is a migrated thread and some comments may be shown as answers.

editing functionality for the grid inside onother grid

7 Answers 122 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Sudhakar
Top achievements
Rank 1
Sudhakar asked on 15 Oct 2014, 01:14 PM
Hi Team,

I have a grid which is having some rows in it. When I expand each row three tabs needs to show.
when I click on the each tab needs to display another grid.
I need to implement the batch editing functionality for that grid.

How to achieve this functionality.

Aspx file:

<telerik:RadGrid ID="LoadingRadGrid" OnItemDataBound="LoadingRadGridFormat_OnItemDataBound"
                            runat="server" AutoGenerateColumns="false" CssClass="TransferGridPanel" Height="375px"
                            Width="500px" OnNeedDataSource="LoadingRadGrid_NeedDataSource"
                             OnUpdateCommand="LoadingRadGrid_UpdateCommand" OnBatchEditCommand="LoadingRadGrid_BatchEditCommand" OnInsertCommand="LoadingRadGrid_InsertCommand"
                             OnItemCommand="LoadingRadGrid_ItemCommand" OnSelectedIndexChanged="LoadingRadGrid_SelectedIndexChanged" OnCancelCommand="LoadingRadGrid_CancelCommand"
                             AllowAutomaticInserts="false" AllowAutomaticUpdates="false" AllowAutomaticDeletes="false">
                            <MasterTableView ShowHeadersWhenNoRecords="true" CommandItemDisplay="Top" EditMode="Batch" DataKeyNames="Loading_ID">
                                <CommandItemSettings ShowRefreshButton="false" AddNewRecordText="Add NewLoad" />
                            <BatchEditingSettings EditType="Cell" />
                                <NestedViewTemplate>
                                
                                    <telerik:RadTabStrip runat="server" ID="LoadTabStip" MultiPageID="LoadMultipage" ClickSelectedTab="True"
                                        SelectedIndex="0" OnTabClick="LoadTabStip_TabClick" Orientation="HorizontalTop">
                                        <Tabs runat="server">
                                            <telerik:RadTab runat="server" Text="Details" PageViewID="RadPageViewDetails">
                                            </telerik:RadTab>
                                            <telerik:RadTab runat="server" Text="Compartments" PageViewID="RadPageViewCompartments">
                                            </telerik:RadTab>
                                            <telerik:RadTab runat="server" Text="Products" PageViewID="RadPageViewProducts">
                                            </telerik:RadTab>
                                        </Tabs>
                                    </telerik:RadTabStrip>
                                    <telerik:RadMultiPage runat="server" ID="LoadMultipage" SelectedIndex="0" RenderSelectedPageOnly="false">
                                   
                                        <telerik:RadPageView runat="server" ID="RadPageViewDetails">
                                       
                                            <div class="contactWrap">
                                                <table cellpadding="0" cellspacing="0">
                                                    <tr>
                                                       <td><asp:Label ID="lbl_TerminalId" runat="server" Text='Terminal Id:' Font-Bold="true"></asp:Label></td>
                                                       <td><asp:Label ID="lbl_TerminalIdValue" runat="server"></asp:Label> </td> 
                                                    </tr>
                                                    <tr>
                                                        <td><asp:Label ID="lbl_TerminalName" runat="server" Text='TerminalName:' Font-Bold="true"></asp:Label></td>
                                                        <td><asp:Label ID="lbl_TerminalNameValue" runat="server"></asp:Label> </td>
                                                       
                                                    </tr>
                                                </table>
                                            </div>
                                        </telerik:RadPageView>
                                        <telerik:RadPageView runat="server" ID="RadPageViewCompartments">
                                       
                                            <telerik:RadGrid ID="CompartmentLevelLoadRadGrid" runat="server" AutoGenerateColumns="false" CssClass="TransferGridPanel"
                                                Height="233px" Width="475px" OnItemDataBound="CompartmentLevelLoadRadGrid_ItemDataBound"
                                                OnUpdateCommand="CompartmentLevelLoadRadGrid_UpdateCommand" OnBatchEditCommand="CompartmentLevelLoadRadGrid_BatchEditCommand" OnInsertCommand="CompartmentLevelLoadRadGrid_InsertCommand">
                                                <MasterTableView ShowHeadersWhenNoRecords="true" CommandItemDisplay="Top" EditMode="Batch">
                                                     <CommandItemSettings ShowRefreshButton="false" AddNewRecordText="Add Line Item"/>
                                                     <BatchEditingSettings EditType="Cell" />                                              
                                                    <Columns>
                                                   
                                                        <telerik:GridBoundColumn UniqueName="CompNo" DataField="CompartmentIndex" HeaderText="Comp No." ReadOnly="true">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="PriorToLoad" DataField="PTL" HeaderText="PriorTo Load">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="PlannedLoadProd" DataField="PlannedProductName" HeaderText="Planned Product" ReadOnly="true">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="ActualLoadProd" DataField="ActualProductName" HeaderText="Actual Product" >
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="PlannedLoadQty" DataField="PlannedQuantity" HeaderText="Planned Quantity" ReadOnly="true">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="ActualLoadQty" DataField="ActualQuantity" HeaderText="Actual Quantity">
                                                        </telerik:GridBoundColumn>
                                                    </Columns>
                                                </MasterTableView>
                                            </telerik:RadGrid>
                                           
                                        </telerik:RadPageView>
                                        <telerik:RadPageView runat="server" ID="RadPageViewProducts">
                                       
                                            <telerik:RadGrid ID="ProductLevelLoadRadGrid" runat="server" AutoGenerateColumns="false" CssClass="TransferGridPanel"
                                                Height="233px" Width="475px" OnItemDataBound="ProductLevelLoadRadGrid_ItemDataBound" >
                                                <MasterTableView ShowHeadersWhenNoRecords="true">                                               
                                                    <Columns>
                                                        <telerik:GridBoundColumn UniqueName="PlannedLoadProd" DataField="PlannedProductName" HeaderText="Planned Product" Visible="false">
                                                        </telerik:GridBoundColumn>                                                    
                                                        <telerik:GridBoundColumn UniqueName="ActualLoadProd" DataField="ActualProductName" HeaderText="Product">
                                                        </telerik:GridBoundColumn>                                                       
                                                        <telerik:GridBoundColumn  UniqueName="PriorToLoadQty" DataField="PTL"  HeaderText="PriorTo Load">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="PlannedLoadQty" DataField="PlannedQuantity" HeaderText="Planned Quantity">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="ActualLoadQty" DataField="ActualQuantity" HeaderText="Actual Quantity">
                                                        </telerik:GridBoundColumn>
                                                    </Columns>
                                                </MasterTableView>
                                            </telerik:RadGrid>
                                           
                                        </telerik:RadPageView>
                                    </telerik:RadMultiPage>
                                 
                                </NestedViewTemplate>
                               
                                <Columns>
                                    <telerik:GridBoundColumn UniqueName="LoadId" DataField="Loading_ID" ReadOnly="true">                                       
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="TerminalId" DataField="Plant_ID">
                                        <ColumnValidationSettings EnableRequiredFieldValidation="true">                                           
                                            <RequiredFieldValidator ForeColor="Red" Text="Plant_ID is required" Display="Dynamic">                               
                                            </RequiredFieldValidator>
                                        </ColumnValidationSettings>
                                    </telerik:GridBoundColumn>
                                   
                                    <telerik:GridBoundColumn UniqueName="TerminalName" DataField="TerminalName" ReadOnly="true">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="LoadingStartTime" DataField="LoadingStartTime" ReadOnly="true">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="LoadingEndTime" DataField="LoadingEndTime" ReadOnly="true">
                                    </telerik:GridBoundColumn>
                                </Columns>
                            </MasterTableView>
                            <ClientSettings>
                                <Scrolling AllowScroll="true" />
                            </ClientSettings>
                        </telerik:RadGrid>

7 Answers, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 20 Oct 2014, 10:56 AM
Hello,

Could you please elaborate more on the exact issue in the illustrated setup? From the code I noticed that there is a OnBatchEditCommand handler assigned for the grid, meaning that you should be able to make things work. Are the changes not being transferred to the server?

Please elaborate more on the above and share the entire page contents(markup and code-behind) thus facilitating us in providing a straight to the point answer.

Regards,
Angel Petrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Sudhakar
Top achievements
Rank 1
answered on 22 Oct 2014, 09:21 AM
Hi Petrov,

I have a grid which is having some rows in it. When I expand each row  I am displaying three tabs.
 when I click on the each tab needs to display another grid.
 I need to implement the batch editing functionality for that grid.

For this requirement I designed the Aspx file like below:
I am not writing any thing in the code behind right now.


ASPX FILE:
<telerik:RadGrid ID="LoadingRadGrid" OnItemDataBound="LoadingRadGridFormat_OnItemDataBound"
                            runat="server" AutoGenerateColumns="false" CssClass="TransferGridPanel" Height="375px"
                            Width="500px" OnNeedDataSource="LoadingRadGrid_NeedDataSource"
                             OnUpdateCommand="LoadingRadGrid_UpdateCommand" OnBatchEditCommand="LoadingRadGrid_BatchEditCommand" OnInsertCommand="LoadingRadGrid_InsertCommand"
                             OnItemCommand="LoadingRadGrid_ItemCommand" OnSelectedIndexChanged="LoadingRadGrid_SelectedIndexChanged" OnCancelCommand="LoadingRadGrid_CancelCommand"
                              >
                            <MasterTableView ShowHeadersWhenNoRecords="true" CommandItemDisplay="Top" EditMode="Batch" DataKeyNames="Loading_ID">
                                <CommandItemSettings ShowRefreshButton="false" AddNewRecordText="Add NewLoad" />
                            <BatchEditingSettings EditType="Cell" />
                                <NestedViewTemplate>
                                
                                    <telerik:RadTabStrip runat="server" ID="LoadTabStip" MultiPageID="LoadMultipage" ClickSelectedTab="True"
                                        SelectedIndex="0" OnTabClick="LoadTabStip_TabClick" Orientation="HorizontalTop">
                                        <Tabs runat="server">
                                            <telerik:RadTab runat="server" Text="Details" PageViewID="RadPageViewDetails">
                                            </telerik:RadTab>
                                            <telerik:RadTab runat="server" Text="Compartments" PageViewID="RadPageViewCompartments">
                                            </telerik:RadTab>
                                            <telerik:RadTab runat="server" Text="Products" PageViewID="RadPageViewProducts">
                                            </telerik:RadTab>
                                        </Tabs>
                                    </telerik:RadTabStrip>
                                    <telerik:RadMultiPage runat="server" ID="LoadMultipage" SelectedIndex="0" RenderSelectedPageOnly="false">
                                   
                                        <telerik:RadPageView runat="server" ID="RadPageViewDetails">
                                       
                                            <div class="contactWrap">
                                                <table cellpadding="0" cellspacing="0">
                                                    <tr>
                                                       <td><asp:Label ID="lbl_TerminalId" runat="server" Text='Terminal Id:' Font-Bold="true"></asp:Label></td>
                                                       <td><asp:Label ID="lbl_TerminalIdValue" runat="server"></asp:Label> </td> 
                                                    </tr>
                                                    <tr>
                                                        <td><asp:Label ID="lbl_TerminalName" runat="server" Text='TerminalName:' Font-Bold="true"></asp:Label></td>
                                                        <td><asp:Label ID="lbl_TerminalNameValue" runat="server"></asp:Label> </td>
                                                       
                                                    </tr>
                                                </table>
                                            </div>
                                        </telerik:RadPageView>
                                        <telerik:RadPageView runat="server" ID="RadPageViewCompartments">
                                       
                                            <telerik:RadGrid ID="CompartmentLevelLoadRadGrid" runat="server" AutoGenerateColumns="false" CssClass="TransferGridPanel"
                                                Height="233px" Width="475px" OnItemDataBound="CompartmentLevelLoadRadGrid_ItemDataBound"
                                                OnUpdateCommand="CompartmentLevelLoadRadGrid_UpdateCommand" OnBatchEditCommand="CompartmentLevelLoadRadGrid_BatchEditCommand" OnInsertCommand="CompartmentLevelLoadRadGrid_InsertCommand">
                                                <MasterTableView ShowHeadersWhenNoRecords="true" CommandItemDisplay="Top" EditMode="Batch">
                                                     <CommandItemSettings ShowRefreshButton="false" AddNewRecordText="Add Line Item"/>
                                                     <BatchEditingSettings EditType="Cell" />                                              
                                                    <Columns>
                                                   
                                                        <telerik:GridBoundColumn UniqueName="CompNo" DataField="CompartmentIndex" HeaderText="Comp No." ReadOnly="true">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="PriorToLoad" DataField="PTL" HeaderText="PriorTo Load">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="PlannedLoadProd" DataField="PlannedProductName" HeaderText="Planned Product" ReadOnly="true">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="ActualLoadProd" DataField="ActualProductName" HeaderText="Actual Product" >
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="PlannedLoadQty" DataField="PlannedQuantity" HeaderText="Planned Quantity" ReadOnly="true">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="ActualLoadQty" DataField="ActualQuantity" HeaderText="Actual Quantity">
                                                        </telerik:GridBoundColumn>
                                                    </Columns>
                                                </MasterTableView>
                                            </telerik:RadGrid>
                                           
                                        </telerik:RadPageView>
                                        <telerik:RadPageView runat="server" ID="RadPageViewProducts">
                                       
                                            <telerik:RadGrid ID="ProductLevelLoadRadGrid" runat="server" AutoGenerateColumns="false" CssClass="TransferGridPanel"
                                                Height="233px" Width="475px" OnItemDataBound="ProductLevelLoadRadGrid_ItemDataBound" >
                                                <MasterTableView ShowHeadersWhenNoRecords="true">                                               
                                                    <Columns>
                                                        <telerik:GridBoundColumn UniqueName="PlannedLoadProd" DataField="PlannedProductName" HeaderText="Planned Product" Visible="false">
                                                        </telerik:GridBoundColumn>                                                    
                                                        <telerik:GridBoundColumn UniqueName="ActualLoadProd" DataField="ActualProductName" HeaderText="Product">
                                                        </telerik:GridBoundColumn>                                                       
                                                        <telerik:GridBoundColumn  UniqueName="PriorToLoadQty" DataField="PTL"  HeaderText="PriorTo Load">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="PlannedLoadQty" DataField="PlannedQuantity" HeaderText="Planned Quantity">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="ActualLoadQty" DataField="ActualQuantity" HeaderText="Actual Quantity">
                                                        </telerik:GridBoundColumn>
                                                    </Columns>
                                                </MasterTableView>
                                            </telerik:RadGrid>
                                           
                                        </telerik:RadPageView>
                                    </telerik:RadMultiPage>
                                 
                                </NestedViewTemplate>
                               
                                <Columns>
                                    <telerik:GridBoundColumn UniqueName="LoadId" DataField="Loading_ID" ReadOnly="true">                                       
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="TerminalId" DataField="Plant_ID">
                                        <ColumnValidationSettings EnableRequiredFieldValidation="true">                                           
                                            <RequiredFieldValidator ForeColor="Red" Text="Plant_ID is required" Display="Dynamic">                               
                                            </RequiredFieldValidator>
                                        </ColumnValidationSettings>
                                    </telerik:GridBoundColumn>
                                   
                                    <telerik:GridBoundColumn UniqueName="TerminalName" DataField="TerminalName" ReadOnly="true">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="LoadingStartTime" DataField="LoadingStartTime" ReadOnly="true">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="LoadingEndTime" DataField="LoadingEndTime" ReadOnly="true">
                                    </telerik:GridBoundColumn>
                                </Columns>
                            </MasterTableView>
                            <ClientSettings>
                                <Scrolling AllowScroll="true" />
                            </ClientSettings>
                        </telerik:RadGrid>

ASPX.CS FILE:
protected void CompartmentLevelLoadRadGrid_BatchEditCommand(object source, GridBatchEditingEventArgs e)
    {    }
    protected void CompartmentLevelLoadRadGrid_InsertCommand(object source, GridCommandEventArgs e)
     {     }
    protected void CompartmentLevelLoadRadGrid_UpdateCommand(object source, GridCommandEventArgs e)
    {    }

My issue here is when i expand the row for the parent grid i am getting the below error:
"Collection was modified; enumeration operation may not execute".
Why i am getting this error,
And also what can i write in the code behind file.

Expecting the answer ASAP.
Thanks in advance.
0
Angel Petrov
Telerik team
answered on 27 Oct 2014, 06:59 AM
Hi,

Based on the information provided it would be hard to tell what exactly is causing the illustrated behavior but it may be related to the way the child grids are being populated. Could you please share information on how are the grids in the NestedViewTemplate being bound? Can you post the server-side code so we could review it?

Note that if the child grids use simple data-binding it is expected for abnormalities to occur as data editing is not supported with such type of binding. If the scenario falls into the described case I would recommend modifying the logic so that advanced data-binding is used.

As for accessing the changes which the user had made on the server, currently there are to ways to achieve this.
  1. Subscribe to the OnBatchEditCommand and obtain a reference to the new and old values collection as demonstrated here. Bear in mind that in the event handler you can access all the changes.
  2. Subscribe to the OnItemCommand or OnInsertCommand,OnDeleterCommand and OnUpdateCommand events and again extract the changes from the arguments(example of this can also be observed in the above linked article). Here the difference is that inside the event handlers one can access the changes made for the separate grid item and not for all of them.

Regards,
Angel Petrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Sudhakar
Top achievements
Rank 1
answered on 28 Oct 2014, 02:06 PM
Hi Petrov,


I am sending the full aspx and aspx.cs files.Can you please check and let me know wether I am using simple or advanced data binding for the child grids.
And also can you please implement the batch editing functionality for the child grids and forward me the code.

Loading grid,compartmentlevelloadgrid,productlevelloadgrid,dischrgegrid,compartmentleveldichargegrid,productleveldischargegrid are the grid's we need to implement the batch edit functionality.ignore all other grid's.
ASPX FILE:
<%@ Page Title="" Language="C#" MasterPageFile="~/SectorMainWeb/HomePage.master"
    AutoEventWireup="true" CodeFile="WorkSchedule.aspx.cs" Inherits="SectorMainWeb_Default" %><%@ Import Namespace="Shell.CFMS.Common" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentDisplay" runat="Server">
    <asp:ScriptManagerProxy ID="smp" runat="server" >
    </asp:ScriptManagerProxy>
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">        <script type="text/javascript">
            var currentLoadingPanel = null;
            var currentUpdatedControl = null;
            var currentUpdatedControl2 = null;
            var historyList = [];
            var state = true;
            var newShipmentCounter = 0;
            var treeState = true;
            var shiftSectionPanel = null;
            var shipmentSection = null;
            var dischargeSection = null;
            var loadingSection = null;
            var ajaxLocked = false;
            var O25filedownload = false;
            var isLoaded = false;            function onShowingContextMenu(sender, args) {
                var treeNode = args.get_node();
                treeNode.set_selected(true);
                setMenuItemsState(args.get_menu().get_items(), treeNode);
            }
            function setMenuItemsState(menuItems, treeNode) {
                var dirArray = treeNode._imageUrl.split('/');
                var currentState;
                for (i = 0; i < dirArray.length; i++) {
                    if (dirArray[i].endsWith("png")) {
                        currentState = dirArray[i].split(".")[0];
                    }
                }                for (var i = 0; i < menuItems.get_count(); i++) {
                    var menuItem = menuItems.getItem(i);
                    menuItem.set_enabled(true);                    if (treeNode._attributes._data.NodeType == "Vehicle") {
                        disableElementWithValue(menuItem, "SendToGsap");
                    }
                   
                    switch (menuItem.get_value()) {
                        case "SendToGsap":
                            if (treeNode._attributes._data.EnableSendToGsap != "True") {
                                disableElementWithValue(menuItem, "SendToGsap");
                            }
                            break;
                        case "SendToDevice":
                            if (treeNode._attributes._data.EnableSendToDevice != "True") {
                                formatMenuItem(menuItem, currentState);
                            }
                            if (treeNode._attributes._data.NodeType != "Vehicle") {
                                disableElementWithValue(menuItem, "BalanceSheet");
                                if (currentState == "IncompleteShift") {
                                    disableElementWithValue(menuItem, "SendToDevice");
                                }
                            }
                            if (currentState == "DeliveryConfirmationSent") {
                                disableElementWithValue(menuItem, "SendToDevice");
                            }
                            if (treeNode._attributes._data.EnableSendToDevice == "SHELLSUPPORT") {
                                disableElementWithValue(menuItem, "SendToDevice");
                            }
                            break;
                        case "ErrorLog":
                            if (treeNode._attributes._data.EnableErrorLog == "False") {
                                disableElementWithValue(menuItem, "ErrorLog");
                            }
                            else
                            { formatMenuItem(menuItem, currentState); }
                            break;
                        case "DischargeScreen":
                            if (treeNode._attributes._data.NodeType != "Vehicle") {
                                disableElementWithValue(menuItem, "DischargeScreen");
                            }
                            formatMenuItem(menuItem, currentState);
                            break;
                        case "BalanceSheet":
                            formatMenuItem(menuItem, currentState);
                            if (treeNode._attributes._data.NodeType != "Vehicle") {
                                disableElementWithValue(menuItem, "BalanceSheet");
                            }
                            break;
                        case "ShiftOverview":
                            formatMenuItem(menuItem, currentState);
                            // Code added for CR : 5869
//                            if (treeNode._attributes._data.NodeType != "Vehicle") {
//                                disableElementWithValue(menuItem, "ShiftOverview");
//                            }
                            break;
                        case "DropShift":
                            formatMenuItem(menuItem, currentState);
                            if (treeNode._attributes._data.NodeType == "Vehicle") {
                                disableElementWithValue(menuItem, "DropShift");
                            }
                            if (treeNode._attributes._data.DisableDelete == "True") {
                                disableElementWithValue(menuItem, "DropShift");
                            }
                            break;
                            //code added for 1.05.08 requirement
                        case "NewShipment":
                            formatMenuItem(menuItem, currentState);
                            if (treeNode._attributes._data.NodeType != "Vehicle") {
                                disableElementWithValue(menuItem, "NewShipment");
                            }
                            break;
                        case "NewLoad":
                            formatMenuItem(menuItem, currentState);
                            if (treeNode._attributes._data.NodeType != "Shipment") {
                                disableElementWithValue(menuItem, "NewLoad");
                            }
                            break;                        case "NewDischarge":
                            formatMenuItem(menuItem, currentState);
                            if (treeNode._attributes._data.NodeType != "Shipment") {
                                disableElementWithValue(menuItem, "NewDischarge");
                            }
                            break;
                    }
                }
            }
           
            function formatMenuItem(menuItem, currentState) {
                switch (currentState) {
                    case "IncompleteShift":                                     // Errors with Shift
                        //disableElementWithValue(menuItem, "SendToDevice");
                        disableElementWithValue(menuItem, "DischargeScreen");
                        break;
                    case "ErrorShellData":                                      // New bad shift. Can't be sent to vehicles
                        //disableElementWithValue(menuItem, "ShiftOverview");
                        disableElementWithValue(menuItem, "SendToDevice");
                        disableElementWithValue(menuItem, "DischargeScreen");
                        disableElementWithValue(menuItem, "BalanceSheet");
                        break;
                    case "CompleteShift":                                       // Complete but not send to GSAP yet
                        disableElementWithValue(menuItem, "SendToDevice");
                        break;
                    case "NewShiftReady":                                       // New good shift ready to be sent to device
                        disableElementWithValue(menuItem, "DischargeScreen");
                        disableElementWithValue(menuItem, "BalanceSheet");
                        break;
                    case "ReceivedFromAppNoError":                              // Vehicle Level
                        disableElementWithValue(menuItem, "SendToDevice");
                        break;
                    case "ReceivedFromAppWithError":                            // Vehicle Level
                        disableElementWithValue(menuItem, "SendToDevice");
                        break;
                    case "ShiftReceivedByApp":                                  // Vehicle Level, no ack
                        disableElementWithValue(menuItem, "SendToDevice");
                        disableElementWithValue(menuItem, "DischargeScreen");
                        disableElementWithValue(menuItem, "BalanceSheet");
                        break;
                    case "ShiftSent":
                        disableElementWithValue(menuItem, "SendToDevice");
                        disableElementWithValue(menuItem, "DischargeScreen");
                        disableElementWithValue(menuItem, "BalanceSheet");                                         // Vehicle Level sent to Vehicles
                        break;
                    case "ReadyToSendToGsap":                                   // All vehicle complete, no errors, ready to send to gsap
                        disableElementWithValue(menuItem, "SendToDevice");
                        break;
                    case "DeliveryConfirmationSent":                                     // Shift complete and sent GSAP
                        disableElementWithValue(menuItem, "SendToDevice");
                        disableElementWithValue(menuItem, "DischargeScreen");
                        break;
                }
            }            function disableElementWithValue(menuItem, value) {
                if (menuItem.get_value() == value) {
                    menuItem.set_enabled(false);
                }
            }            function contextMenuItemSelected(sender, args) {
                debugger;
                var treeNode = args.get_node();
                var shiftId, vehicleId, shiftdate,shipmentId;
                var nodeType = treeNode._attributes._data.NodeType;
                var selectedOption = args._menuItem.get_value();
               
                switch (selectedOption) {
                    case "SendToGsap":
                        {
                            if (nodeType == "Shift") {
                                shiftId = treeNode._attributes.getAttribute("ShiftId");
                                vehicleId = -0000;
                            } else if (nodeType == "Vehicle") {
                                shiftId = treeNode._attributes.getAttribute("ShiftIndex");
                                vehicleId = treeNode._attributes.getAttribute("VehicleId");
                            }
                            SendToGsapClick(shiftId, vehicleId);
                            //6485
                            O25filedownload = true;
                            break;
                        }
                    case "SendToDevice":
                        {
                            if (nodeType == "Shift") {
                                shiftId = treeNode._attributes.getAttribute("ShiftId");
                                vehicleId = -9999;
                            } else if (nodeType == "Vehicle") {
                                shiftId = treeNode._attributes.getAttribute("ShiftIndex");
                                vehicleId = treeNode._attributes.getAttribute("VehicleId");
                            }
                            SendToDeviceClick(shiftId, vehicleId);
                            break;
                        }
                    case "ErrorLog":
                        {
                            if (nodeType == "Shift") {
                                shiftId = treeNode._attributes.getAttribute("ShiftId");
                                vehicleId = -0000;
                            } else if (nodeType == "Vehicle") {
                                shiftId = treeNode._attributes.getAttribute("ShiftIndex");
                                vehicleId = treeNode._attributes.getAttribute("VehicleId");
                            }
                            ErrorLogClick(shiftId, vehicleId);
                            break;
                        }
                    case "DischargeScreen":
                        {
                            if (nodeType == "Shift") {
                                shiftId = treeNode._attributes.getAttribute("ShiftId");
                                vehicleId = -0000;
                            } else if (nodeType == "Vehicle") {
                                shiftId = treeNode._attributes.getAttribute("ShiftIndex");
                                vehicleId = treeNode._attributes.getAttribute("VehicleId");
                            }
                            DischargeScreenClick(shiftId, vehicleId);
                            break;
                        }
                    case "BalanceSheet":
                        {
                            if (nodeType == "Shift") {
                                shiftId = treeNode._attributes.getAttribute("ShiftId");
                                vehicleId = -0000;
                            } else if (nodeType == "Vehicle") {
                                shiftId = treeNode._attributes.getAttribute("ShiftIndex");
                                vehicleId = treeNode._attributes.getAttribute("VehicleId");
                            }
                            BalanceSheetClick(shiftId, vehicleId);
                            break;
                        }
                      
                      
                    case "ShiftOverview":
                        {
                            // Code added for CR : 5869
                            if (nodeType == "Shift") {
                                shiftId = treeNode._attributes.getAttribute("ShiftId");
                                vehicleId = -0000;
                                shiftdate = ""; //value not required
                                //  alert(nodeType + "shift Id : + " + shiftId + "vehicle Id:" + vehicleId);
                            } else if (nodeType == "Vehicle") {
                                shiftId = treeNode._attributes.getAttribute("ShiftIndex");
                                vehicleId = treeNode._attributes.getAttribute("VehicleId");
                                shiftdate = treeNode._attributes.getAttribute("ShiftDate");
                                // alert(nodeType + "shift Id : + " + shiftId + "vehicle Id:" + vehicleId);
                            }
                            //ShiftOverviewClick(treeNode._attributes.getAttribute("ShiftIndex"), treeNode._attributes.getAttribute("VehicleId"));
                            ShiftOverviewClick(shiftId, vehicleId, shiftdate);
                            break;
                        }
                    case "DropShift":
                        {
                            if (nodeType == "Shift") {
                                shiftId = treeNode._attributes.getAttribute("ShiftId");
                                function removeShiftPostBack(arg) {
                                    if (arg) {
                                        $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("dropShift" + "/" + shiftId);
                                    }
                                }
                                radconfirm(transMessages.SDP_GUI_WS_PROMPT_DELETE_SHIFT, removeShiftPostBack, 330, 170, null, transMessages.SDP_GUI_CONFIRM);                            } break;
                        }                        //code added for 1.05.08 R2 requirement
                    case "NewShipment":
                        {
                            debugger;
                            if (nodeType == "Shift") {
                                shiftId = treeNode._attributes.getAttribute("ShiftId");
                                vehicleId = -0000;
                                shiftdate = "";
                            } else if (nodeType == "Vehicle") {
                                shiftId = treeNode._attributes.getAttribute("ShiftIndex");
                                vehicleId = treeNode._attributes.getAttribute("VehicleId");
                                shiftdate = treeNode._attributes.getAttribute("ShiftDate");
                            }
                            NewShipmentClick(shiftId, vehicleId, shiftdate);
                            break;
                        }                    case "NewLoad":
                        {
                            debugger;
                            if (nodeType == "Shift") {
                                shiftId = treeNode._attributes.getAttribute("ShiftId");
                                vehicleId = -0000;
                                shiftdate = "";
                            } else if (nodeType == "Vehicle") {
                                shiftId = treeNode._attributes.getAttribute("ShiftIndex");
                                vehicleId = treeNode._attributes.getAttribute("VehicleId");                            } else if (nodeType == "Shipment") {
                                shiftId = treeNode._attributes.getAttribute("ShiftIndex");
                                vehicleId = treeNode._attributes.getAttribute("VehicleId");
                                shipmentId = treeNode._attributes.getAttribute("ShipmentId");                            }
                            NewLoadClick(shiftId, vehicleId, shipmentId);
                            break;
                        }                    case "NewDischarge":
                        {
                            debugger;
                            if (nodeType == "Shift") {
                                shiftId = treeNode._attributes.getAttribute("ShiftId");
                                vehicleId = -0000;
                                shiftdate = "";
                            } else if (nodeType == "Vehicle") {
                                shiftId = treeNode._attributes.getAttribute("ShiftIndex");
                                vehicleId = treeNode._attributes.getAttribute("VehicleId");                            } else if (nodeType == "Shipment") {
                                shiftId = treeNode._attributes.getAttribute("ShiftIndex");
                                vehicleId = treeNode._attributes.getAttribute("VehicleId");
                                shipmentId = treeNode._attributes.getAttribute("ShipmentId");                            }
                            NewDischargeClick(shiftId, vehicleId, shipmentId);
                            break;
                        }                }
            }            function SendToGsapClick(shiftId, vehicleId) {
                $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("sendToGsap" + "/" + vehicleId + "/" + shiftId);
            }
            function SendToDeviceClick(shiftId, vehicleId) {
                $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("sendToDevice" + "/" + vehicleId + "/" + shiftId);
            }
            function ErrorLogClick(shiftId, vehicleid) {
                window.radopen("Portals/ErrorLog.aspx?ShiftId=" + shiftId + "&VehicleId=" + vehicleid, "PortalDialog", 950, 600);
            }
            function DischargeScreenClick(shiftId, vehicleid) {
                window.radopen("Portals/Discharge.aspx?ShiftId=" + shiftId + "&VehicleId=" + vehicleid, "PortalDischarge", 950, 600);
            }
            function BalanceSheetClick(shiftId, vehicleid) {
                window.radopen("Portals/Balance.aspx?ShiftId=" + shiftId + "&VehicleId=" + vehicleid, "PortalDialog", 950, 600);
            }
           
            function ShiftOverviewClick(shiftId, vehicleid, shiftdate) {
                // Code added for CR : 5869
                if (vehicleid == 0) {
                    // All the vehicles
                    window.radopen("Portals/ShiftOverviewAll.aspx?ShiftId=" + shiftId + "&VehicleId=" + vehicleid, "ShiftOverviewDialog", 990, 530);
                }
                else {
                    window.radopen("Portals/ShiftOverview.aspx?ShiftId=" + shiftId + "&VehicleId=" + vehicleid + "&ShiftDate=" + shiftdate, "ShiftOverviewDialog", 990, 530);
                }
                //window.radopen("Portals/ShiftOverview.aspx?ShiftId=" + shiftId + "&VehicleId=" + vehicleid, "ShiftOverviewDialog");
            }            //code added for 1.05 R2
            function NewShipmentClick(shiftId, vehicleid, shiftdate) {
                window.radopen("Portals/NewShipment.aspx?ShiftId=" + shiftId + "&VehicleId=" + vehicleid + "&ShiftDate=" + shiftdate, "PortalDialog", 950, 600);
            }
            function NewLoadClick(shiftId, vehicleid, shipmentId) {
                window.radopen("Portals/NewLoad.aspx?ShiftId=" + shiftId + "&VehicleId=" + vehicleid + "&ShipmentId=" + shipmentId, "PortalDialog", 950, 600);
            }            function NewDischargeClick(shiftId, vehicleid, shipmentId) {
                window.radopen("Portals/NewDischarge.aspx?ShiftId=" + shiftId + "&VehicleId=" + vehicleid + "&ShipmentId=" + shipmentId, "PortalDialog", 950, 600);
            }            function DownloadO25() {
                var iframe = $("<iframe/>").load(function() {
                }).attr({
                    src: "downloadO25File.aspx",
                    frameborder: 0,
                    height: 1,
                    width:1
                }).appendTo($("#contentHolder"));
            }
            function RequestInitiated(sender, args) {
               
                if (!ajaxLocked) {
                    var ajaxArg = args._eventArgument;
                    currentLoadingPanel = $find("<%= loadingPanelOverlay.ClientID %>");
                    if (ajaxArg.split('/')[0] == "treeNodeSelected") {
                        currentUpdatedControl = "<%= ShiftOverviewGrid.ClientID %>";
                    } else if (ajaxArg.split('/')[0] == "loadNodeSelected") {
                        currentUpdatedControl = "<%= LoadingRadGrid.ClientID %>";
                        currentUpdatedControl2 = "<%= DischargeRadGrid.ClientID %>";
                        currentLoadingPanel.show(currentUpdatedControl);
                        currentLoadingPanel.show(currentUpdatedControl2);
                    } else if (ajaxArg.split('/')[0] == "selectedDateChanged") {
                        currentUpdatedControl = "<%= ShiftTreeView.ClientID %>";
                    }
                    else if (ajaxArg.split('/')[0] == "shipmentNodeSelected") {
                        currentUpdatedControl = "<%= ShipmentRadGrid.ClientID %>";
                    } else if (ajaxArg.split('/')[0] == "sendToDevice") {
                        currentUpdatedControl = "<%= ShiftTreeView.ClientID %>";
                        currentLoadingPanel.show(currentUpdatedControl);
                    }
                    ajaxLocked = true;
                }
            }            function RequestEnded(sender, args) {
                if (currentLoadingPanel != null)
                    currentLoadingPanel.hide(currentUpdatedControl);
                if (currentUpdatedControl2 != null && currentLoadingPanel != null)
                    currentLoadingPanel.hide(currentUpdatedControl2);
                currentUpdatedControl = null;
                currentLoadingPanel = null;
                ajaxLocked = false;
                resetTimeout();
                //6831
                if(O25filedownload == true) {
                    O25filedownload = false;
                    DownloadO25();
                }
            }
            function doubleClickedNode(sender, eventArgs) {            }
            function treeNodeItemSelected(sender, eventArgs) {
               
                if (ajaxLocked) {
                    return;
                }
                if (treeState) {
                    treeState = false;
                    var nodeType = eventArgs._node._attributes.getAttribute("NodeType");
                    if (nodeType == "Vehicle") {
                        var shiftIndex = eventArgs._node._attributes.getAttribute("ShiftIndex");
                        $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("treeNodeSelected" + "/" + sender._element.value + "/" + shiftIndex);
                        //code added for 1.06 R2
                        var shipmentPane = $find("<%= RadPane1.ClientID %>");
                        shipmentPane.set_visible(false);
                        var vehicleIDPane = $find("<%= vehicleIDPane.ClientID %>");
                        vehicleIDPane.set_visible(true);
                        var splitbar = $find("<%= RadSplitBar2.ClientID %>");
                        splitbar.set_visible(false);
                    }
                    //code added for 1.06 R2
                    else if (nodeType == "Shipment") {
                        var vehicleId = eventArgs._node._attributes.getAttribute("VehicleId");
                        var vehicleIDPane = $find("<%= vehicleIDPane.ClientID %>");
                        vehicleIDPane.set_visible(false);
                        var shipmentPane = $find("<%= RadPane1.ClientID %>");
                        shipmentPane.set_visible(true);
                        var splitbar = $find("<%= RadSplitBar2.ClientID %>");
                        splitbar.set_visible(false);
                        $find("ctl00_ContentDisplay_radAjaxManager").ajaxRequest("shipmentNodeSelected" + "/" + sender._element.value + "/" + vehicleId);
                    }
                }
                setTimeout(function() {
                    if (!treeState) {
                        treeState = true;
                    }
                }, 1000);
                setInterval(function() {
                    shipmentSectionId = "<%= ShipmentRadGrid.ClientID %>";
                    currentLoadingPanel = $find("<%= loadingPanelOverlay.ClientID %>");
                    currentLoadingPanel.hide(shipmentSectionId);
                }, 1000);
            }
            //added for 1.06 R2 Requirement
            function pageLoad() {
               
                if (isLoaded == false) {
                    isLoaded = true;
                    var shipmentPane = $find("<%= RadPane1.ClientID %>");
                    shipmentPane.set_visible(true);
                    var vehicleIDPane = $find("<%= vehicleIDPane.ClientID %>");
                    vehicleIDPane.set_visible(false);
                    var splitbar = $find("<%= RadSplitBar2.ClientID %>");
                    splitbar.set_visible(false);
                }
            }
            //added for 1.05 R2 Requirement
           <%-- function batchEditOpening(sender, args) {
                debugger;
                if (args) {
                    $find('<%= LoadingRadGrid.ClientID %>');
                }
                radconfirm(transMessages.SDP_ALERT_WHILE_ADD_NEW_LOAD, batchEditOpening, 330, 170, null, transMessages.SDP_GUI_CONFIRM);
            }
            function batchEditClosing(sender, args) {
                debugger;
                if (!confirm("Are you sure?")) {
                    args.set_cancel(true);
                }            }--%>
            function confirmCallBackFn(sender, args) {
                var ajaxManager = $find('<%=radAjaxManager.ClientID%>');
                if (args) {
                    ajaxManager.ajaxRequest('ok');
                }
                else {
                    ajaxManager.ajaxRequest('cancel');
                }
            }            function OnRowDouble_DetailTable(sender, args) {            }
            function OnRowSelect_RowDataSelected(sender, args) {
                if (ajaxLocked) {
                    return;
                }
                var grid = $find("<%=ShipmentRadGrid.ClientID%>");
                sender.saveClientState();
                try {
                    var transferType = args._dataKeyValues.TransferType
                    var transferId = args._dataKeyValues.Transfer_ID;
                } catch (err) {
                    // do nothing
                }
                if (transferId != undefined && transferType != undefined) {
                    $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("loadNodeSelected" + "/" + transferType + "/" + transferId);
                }
                return false;
            }            function OnSelectedDateChanged(sender, arg) {
                $find("<%= radAjaxManager.ClientID %>").ajaxRequest("selectedDateChanged");
            }            function displayInbox() {
                if (state) {
                    $("#shipmentInbox").animate({
                        backgroundColor: "#fff",
                        color: "black",
                        width: 300,
                        height: 300
                    }, 300)
                    $("#shipmentListDiv").animate({
                        opacity: 1.00,
                        height:285
                    }, 300)                } else {
                    $("#shipmentInbox").animate({
                        backgroundColor: "Transparent",
                        color: "black",
                        width: 58,
                        height: 16
                    }, 300)
                    $("#shipmentListDiv").animate({
                        opacity: 0.0,
                        height:10
                    }, 300)
                   
                }
                state = !state;
            }
          
            function AddInfoToMenu(sender, arg) {
                var list = $('.rtImg');
                var imageName;
                var currentItem;
                var lstimagepath;
               
                for (i = 0; i < list.length; i++) {
                    currentItem = list[i];
                    lstimagepath = $('.rtImg')[i].src.split('/');                    imageName = lstimagepath[lstimagepath.length - 1].split('.')[0];
                   
                    switch (imageName) {                        case 'CompleteShift':
                            {
                                currentItem.title = transMessages.SDP_GUI_WS_VEHICLE_HOVER_COMPLETESHIFT;
                                currentItem.alt = transMessages.SDP_GUI_WS_VEHICLE_HOVER_COMPLETESHIFT;
                                break;
                            }
                        case 'DeliveryConfirmationSent':
                            {
                                currentItem.title = transMessages.SDP_GUI_WS_VEHICLE_HOVER_DCS;
                                currentItem.alt = transMessages.SDP_GUI_WS_VEHICLE_HOVER_DCS;
                                break;
                            }
                        case 'ErrorShellData':
                            {
                                currentItem.title = transMessages.SDP_GUI_WS_VEHICLE_HOVER_ERRORSHELLDATA;
                                currentItem.alt = transMessages.SDP_GUI_WS_VEHICLE_HOVER_ERRORSHELLDATA;
                                break;
                            }
                        case 'IncompleteShift':
                            {
                                currentItem.title = transMessages.SDP_GUI_WS_VEHICLE_HOVER_INCOMPLETESHIFT;
                                currentItem.alt = transMessages.SDP_GUI_WS_VEHICLE_HOVER_INCOMPLETESHIFT;
                                break;
                            }
                        case 'NewShiftReady':
                            {
                                currentItem.title = transMessages.SDP_GUI_WS_VEHICLE_HOVER_NEWSHIFTREADY;
                                currentItem.alt = transMessages.SDP_GUI_WS_VEHICLE_HOVER_NEWSHIFTREADY;
                                break;
                            }
                        case 'ReadyToSendToGsap':
                            {
                                currentItem.title = transMessages.SDP_GUI_WS_VEHICLE_HOVER_RSTGSAP;
                                currentItem.alt = transMessages.SDP_GUI_WS_VEHICLE_HOVER_RSTGSAP;
                                break;
                            }
                        case 'ReceivedFromAppNoError':
                            {
                                currentItem.title = transMessages.SDP_GUI_WS_VEHICLE_HOVER_RFANE;
                                currentItem.alt = transMessages.SDP_GUI_WS_VEHICLE_HOVER_RFANE;
                                break;
                            }
                        case 'ReceivedFromAppWithError':
                            {
                                currentItem.title = transMessages.SDP_GUI_WS_VEHICLE_HOVER_RFAWE;
                                currentItem.alt = transMessages.SDP_GUI_WS_VEHICLE_HOVER_RFAWE;
                                break;
                            }
                        case 'ShiftReceivedByApp':
                            {
                                currentItem.title = transMessages.SDP_GUI_WS_VEHICLE_HOVER_SRBA;
                                currentItem.alt = transMessages.SDP_GUI_WS_VEHICLE_HOVER_SRBA;
                                break;
                            }
                        case 'ShiftSent':
                            {
                                currentItem.title = transMessages.SDP_GUI_WS_VEHICLE_HOVER_SHIFTSENT;
                                currentItem.alt = transMessages.SDP_GUI_WS_VEHICLE_HOVER_SHIFTSENT;
                                break;
                            }
                        case 'ShiftSentToGsap':
                            {
                                currentItem.title = transMessages.SDP_GUI_WS_VEHICLE_HOVER_SSTGSAP;
                                currentItem.alt = transMessages.SDP_GUI_WS_VEHICLE_HOVER_SSTGSAP;
                                break;
                            }
                    }
                }
            }
          
           
        </script>    </telerik:RadCodeBlock>
    <telerik:RadAjaxManager ID="radAjaxManager" runat="server" OnAjaxRequest="radAjaxManager_OnAjaxRequest">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="radAjaxManager">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="ShipmentRadGrid" />
                    <telerik:AjaxUpdatedControl ControlID="DischargePanel" />
                    <telerik:AjaxUpdatedControl ControlID="LoadingPanel" />
                    <telerik:AjaxUpdatedControl ControlID="DischargeRadGrid" />
                    <telerik:AjaxUpdatedControl ControlID="LoadingRadGrid" />
                    <telerik:AjaxUpdatedControl ControlID="ShiftTreeView" />
                    <telerik:AjaxUpdatedControl ControlID="ShiftTreeContextMenu" />
                    <telerik:AjaxUpdatedControl ControlID="lbl_LoadingHeader" />
                    <telerik:AjaxUpdatedControl ControlID="lbl_DischargeHeader" />
                    <telerik:AjaxUpdatedControl ControlID="lbl_ShipmentHeader" />
                    <telerik:AjaxUpdatedControl ControlID="shipmentInboxDecoy" />
                    <telerik:AjaxUpdatedControl ControlID="lblHistoryHolder" />
                    <telerik:AjaxUpdatedControl ControlID="indexCounter" />
                    <telerik:AjaxUpdatedControl ControlID="lbl_ShiftHeader" />
                    <telerik:AjaxUpdatedControl ControlID="ShipmentRadGrid" />
                    <telerik:AjaxUpdatedControl ControlID="DischargePanel" />
                    <telerik:AjaxUpdatedControl ControlID="LoadingPanel" />
                    <telerik:AjaxUpdatedControl ControlID="DischargeRadGrid" />
                    <telerik:AjaxUpdatedControl ControlID="LoadingRadGrid" />
                    <telerik:AjaxUpdatedControl ControlID="ShiftTreeView" />
                    <telerik:AjaxUpdatedControl ControlID="ShiftTreeContextMenu" />
                    <telerik:AjaxUpdatedControl ControlID="lbl_LoadingHeader" />
                    <telerik:AjaxUpdatedControl ControlID="lbl_DischargeHeader" />
                    <telerik:AjaxUpdatedControl ControlID="lbl_ShipmentHeader" />
                    <telerik:AjaxUpdatedControl ControlID="shipmentInboxDecoy" />
                    <telerik:AjaxUpdatedControl ControlID="lblHistoryHolder" />
                    <telerik:AjaxUpdatedControl ControlID="indexCounter" />
                    <telerik:AjaxUpdatedControl ControlID="lbl_ShiftHeader" />                   
                   <%--code added for 1.06 r2--%>
                    <telerik:AjaxUpdatedControl ControlID="ShiftOverviewGrid" />
                    <telerik:AjaxUpdatedControl ControlID="txt_shiftStartValue" />
                    <telerik:AjaxUpdatedControl ControlID="txt_shiftEndValue" />
                    <telerik:AjaxUpdatedControl ControlID="txt_ShipmentNo" />
                    <telerik:AjaxUpdatedControl ControlID="txt_ShipmentStartValue" />
                    <telerik:AjaxUpdatedControl ControlID="txt_ShipmentEndValue" />
                    <telerik:AjaxUpdatedControl ControlID="lbl_ShipementForVehicle" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <%--code added for 1.06 R2--%>
            <telerik:AjaxSetting AjaxControlID="ShiftOverviewGrid">           
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="ShiftOverviewGrid" LoadingPanelID="loadingPanelOverlay" />
                    <telerik:AjaxUpdatedControl ControlID="lbl_ShipementForVehicle" />
                    <telerik:AjaxUpdatedControl ControlID="txt_shiftStartValue" />
                    <telerik:AjaxUpdatedControl ControlID="txt_shiftEndValue" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="ShiftTreeView">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="ShipmentRadGrid"  />
                    <telerik:AjaxUpdatedControl ControlID="DischargeRadGrid" />
                    <telerik:AjaxUpdatedControl ControlID="LoadingRadGrid" />
                    <telerik:AjaxUpdatedControl ControlID="lbl_LoadingHeader" />
                    <telerik:AjaxUpdatedControl ControlID="lbl_DischargeHeader" />
                    <telerik:AjaxUpdatedControl ControlID="lbl_ShipementForVehicle" />
                    <telerik:AjaxUpdatedControl ControlID="ShiftOverviewGrid" />
                    <telerik:AjaxUpdatedControl ControlID="txt_shiftStartValue" />
                    <telerik:AjaxUpdatedControl ControlID="txt_shiftEndValue" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="ShipmentRadGrid">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="LoadingPanel" />
                    <telerik:AjaxUpdatedControl ControlID="DischargePanel" />
                    <telerik:AjaxUpdatedControl ControlID="LoadingRadGrid" />
                    <telerik:AjaxUpdatedControl ControlID="DischargeRadGrid" />
                    <telerik:AjaxUpdatedControl ControlID="ShiftOverviewGrid" />
                    <telerik:AjaxUpdatedControl ControlID="lbl_ShipementForVehicle" />
                    <telerik:AjaxUpdatedControl ControlID="txt_shiftStartValue" />
                    <telerik:AjaxUpdatedControl ControlID="txt_shiftEndValue" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="DischargeRadGrid">
                <UpdatedControls>                 
                    <telerik:AjaxUpdatedControl ControlID="DischargeRadGrid" />                 
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="btnAutoRefresh" />
        </AjaxSettings>
        <ClientEvents OnRequestStart="RequestInitiated" OnResponseEnd="RequestEnded" />
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel runat="server" ID="loadingPanelOverlay" HorizontalAlign="Center"
        ScrollBars="Auto">
    </telerik:RadAjaxLoadingPanel>
    <asp:Label runat="server" CssClass="formHeader" ID="lblHeader"></asp:Label>
    <div id="contentHolder">
       
        <telerik:RadSplitter Orientation="Vertical" ID="RadSplitterMain" runat="server" Width="970px"
            Height="600px">
            <telerik:RadPane ID="ShiftPane" runat="server" Width="20%" CssClass="noOverflow">
                <div class="paneHeader">
                    <div class="paneHeaderBorder">
                        <span class="headerPaneText">
                            <asp:Label ID="lbl_ShiftHeader" runat="server"></asp:Label></span>
                    </div>
                </div>
                <!-------------------------------------
                  ---------SHIFT SECTION---------------
                  ------------------------------------->
                 
                  <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server" onload="UpdatePanel1_Load">
                   <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="btnAutoRefresh" EventName="Click" />
                    </Triggers>
                   
                   <ContentTemplate>
                  
                  <div id="refreshSection" style="height: 35px">
                                <telerik:RadButton ID="btnAutoRefresh" EnableTheming="False" EnableViewState="False"
                                ButtonType="SkinnedButton" Height="19px" Font-Size="XX-Small" OnClick="btnAutoRefresh_OnClick"
                                CssClass="autoRefreshButton" runat="server"></telerik:RadButton>    
                                <%--<asp:Button ID="btnAutoRefresh" Height="19px" OnClick="btnAutoRefresh_OnClick" Font-Size="XX-Small"
                                CssClass="FilterComboItem clsButOK" Text="Refresh" runat="server" />--%>
                </div>
               
               
                  
               
               
                <div id="divShftTree">
                <telerik:RadAjaxPanel ID="ShiftPanel" runat="server" CssClass="radPaneContentFull mediumPadding">
                    <div id="datePickerDiv">
                        <asp:Label for="RadDate_ShiftFrom" id="lblFromDate" runat="server"></asp:Label>
                       
                        <telerik:RadDatePicker runat="server" ID="RadDate_ShiftFrom">
                            <Calendar runat="server">
                                <SpecialDays>
                                    <telerik:RadCalendarDay >
                                    </telerik:RadCalendarDay>
                                </SpecialDays>
                            </Calendar>
                            <ClientEvents OnDateSelected="OnSelectedDateChanged" />
                        </telerik:RadDatePicker>
                        <br />
                        <asp:Label for="RadDate_ShiftTo" id="lblToDate" runat="server">
                            </asp:Label>
                        <telerik:RadDatePicker runat="server" ID="RadDate_ShiftTo">
                            <Calendar runat="server">
                                <SpecialDays>
                                    <telerik:RadCalendarDay >
                                    </telerik:RadCalendarDay>
                                </SpecialDays>
                            </Calendar>
                            <ClientEvents OnDateSelected="OnSelectedDateChanged" />
                        </telerik:RadDatePicker>
                    </div>
                    <telerik:RadTreeView ID="ShiftTreeView" runat="server" OnClientContextMenuItemClicked="contextMenuItemSelected"
                        OnClientContextMenuShowing="onShowingContextMenu" OnClientDoubleClick="doubleClickedNode"
                        OnClientNodeClicked="treeNodeItemSelected" OnClientLoad="AddInfoToMenu" Height="440px">
                        <ContextMenus>
                            <telerik:RadTreeViewContextMenu ID="ShiftTreeContextMenu" runat="server">
                            </telerik:RadTreeViewContextMenu>
                        </ContextMenus>
                    </telerik:RadTreeView>
                </telerik:RadAjaxPanel>
                </div>
               </ContentTemplate>
                </asp:UpdatePanel>
            </telerik:RadPane>
            <telerik:RadSplitBar runat="server" ID="RadSplitBar1" EnableResize="false" CollapseMode="Forward">
            </telerik:RadSplitBar>
            <!--code added for 1.06 R2-->
            <telerik:RadPane ID="vehicleIDPane" runat="server" Width="500px" CssClass="noOverflow">
                <div class="paneHeader">
                    <div class="paneHeaderBorder">
                        <span class="headerPaneText">
                            <asp:Label ID="lbl_ShipementForVehicle" runat="server"></asp:Label></span>
                    </div>
                </div>
                <%--</asp:UpdatePanel>--%>
                <!-----------------------------------
                  ---------SHIPMENT For VehicleID SECTION -----------
                  ------------------------------------->
                <div id="vehicleIDPane1" runat="server" class="radPaneContent">
                    <telerik:RadAjaxPanel ID="FilterOptionPanel" CssClass="FilterSection" runat="server">
                        <table>
                            <tr>
                                <td>
                                    <asp:Label runat="server" Font-Bold="true" ID="lbl_shiftStart"></asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox runat="server" ID="txt_shiftStartValue" CssClass="shiftDivTextBoxDate"
                                        Enabled="false"></asp:TextBox>
                                </td>
                                <td>
                                </td>
                                <td>
                                    <asp:Label runat="server" Font-Bold="true" ID="lbl_shiftEnd"></asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox runat="server" ID="txt_shiftEndValue" CssClass="shiftDivTextBoxDate"
                                        Enabled="false"></asp:TextBox>
                                </td>
                            </tr>
                        </table>
                    </telerik:RadAjaxPanel>
                    <telerik:RadGrid runat="server" ID="ShiftOverviewGrid" ShowHeader="true" >
                        <%--OnNeedDataSource="ErrorRadGrid_NeedDataSource"--%>
                        <MasterTableView AutoGenerateColumns="false" ShowHeadersWhenNoRecords="true" PageSize="50">
                            <Columns>
                                <telerik:GridBoundColumn DataField="ProductName">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="PriorToLoad" UniqueName="PriorToLoad">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="ActualLoadQuantity" UniqueName="LoadedQty">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="ActualDischargeQuantity" UniqueName="DischargeQty">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="LeftOnBoard" UniqueName="LeftOnBoard">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn HeaderText="" DataField="ShipmentId" UniqueName="ShipmentId"
                                    Visible="false">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn HeaderText="" DataField="PlannedSequence" UniqueName="PlannedSequence"
                                    Visible="false">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn HeaderText="" DataField="PlannedSequence" UniqueName="ActualSequence"
                                    Visible="false">
                                </telerik:GridBoundColumn>
                            </Columns>
                        </MasterTableView>
                    </telerik:RadGrid>
                </div>
            </telerik:RadPane>
            <telerik:RadSplitBar runat="server" ID="RadSplitBar2" EnableResize="false" >
            </telerik:RadSplitBar>
            <!--added for 1.06 r2-->
            <telerik:RadPane ID="RadPane1" runat="server" Width="1000px" CssClass="noOverflow">
                <telerik:RadSplitter runat="server" ID="RadSplitter1" Orientation="Horizontal" Height="100%">
                    <telerik:RadPane ID="ShipmentPane" runat="server" Width="80%" Height="200px" CssClass="noOverflow">
                        <div class="paneHeader">
                            <div class="paneHeaderBorder">
                                <span class="headerPaneText">
                                    <asp:Label ID="lbl_ShipmentHeader" runat="server"></asp:Label></span>
                            </div>
                        </div>
                        <!-----------------------------------
                  ---------SHIPMENT SECTION -----------
                  ------------------------------------->
                        <div id="ShipmentPanel" runat="server" class="radPaneContent">
                            <telerik:RadAjaxPanel ID="RadAjaxPanel1" CssClass="FilterSection" runat="server">
                                <table>
                                    <tr>
                                        <td>
                                            <asp:Label runat="server" Font-Bold="true" ID="lbl_ShipmentNo"></asp:Label>
                                        </td>
                                        <td>
                                            <asp:TextBox runat="server" ID="txt_ShipmentNo" CssClass="shiftDivTextBoxDate" Enabled="false"></asp:TextBox>
                                        </td>
                                        <td>
                                        </td>
                                        <td>
                                            <asp:Label runat="server" Font-Bold="true" ID="lbl_ShipmentStart"></asp:Label>
                                        </td>
                                        <td>
                                            <asp:TextBox runat="server" ID="txt_ShipmentStartValue" CssClass="shiftDivTextBoxDate"
                                                Enabled="false"></asp:TextBox>
                                        </td>
                                        <td>
                                        </td>
                                        <td>
                                            <asp:Label runat="server" Font-Bold="true" ID="lbl_ShipmentEnd"></asp:Label>
                                        </td>
                                        <td>
                                            <asp:TextBox runat="server" ID="txt_ShipmentEndValue" CssClass="shiftDivTextBoxDate"
                                                Enabled="false"></asp:TextBox>
                                        </td>
                                    </tr>
                                </table>
                            </telerik:RadAjaxPanel>
                            <telerik:RadGrid AllowPaging="True" ShowStatusBar="true" ID="ShipmentRadGrid" BorderStyle="None"
                                AllowSorting="True" runat="server" AutoGenerateColumns="false" OnDetailTableDataBind="ShipmentRadGrid_DetailTableDataBind"
                                AllowFilteringByColumn="false" OnNeedDataSource="ShipmentRadGrid_NeedDataSource" onitemdatabound="ShipmentRadGrid_ItemDataBound"
                                Height="230px" Width="475px">
                                <MasterTableView AutoGenerateColumns="false" ShowHeadersWhenNoRecords="true" PageSize="50">
                                    <Columns>
                                        <telerik:GridBoundColumn DataField="ProductName">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="PriorToLoad" UniqueName="PriorToLoad">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="ActualLoadQuantity" UniqueName="LoadedQty">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="ActualDischargeQuantity" UniqueName="DischargeQty">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn DataField="LeftOnBoard" UniqueName="LeftOnBoard">
                                        </telerik:GridBoundColumn>
                                    </Columns>
                                </MasterTableView>
                                <%--<ClientSettings>
                            <Selecting AllowRowSelect="true" />
                            <ClientEvents OnRowSelected="OnRowSelect_RowDataSelected" OnRowDblClick="OnRowDouble_DetailTable" />
                            <Scrolling AllowScroll="true" UseStaticHeaders="true"></Scrolling>
                        </ClientSettings>--%>
                            </telerik:RadGrid>
                        </div>
                    </telerik:RadPane>
            <telerik:RadSplitBar runat="server" ID="RadSplitBar3" EnableResize="false">
            </telerik:RadSplitBar>
           
            <telerik:RadPane ID="LoadingDischargePane" runat="server" Width="1000px" CssClass="noOverflow">
                <telerik:RadSplitter runat="server" ID="RadSplitterChild" Orientation="Vertical"
                    Height="100%">
                    <telerik:RadPane ID="LoadingPane" runat="server" CssClass="noOverflow">
                        <div id="LoadingPanelHeader" class="paneHeader">
                            <span class="headerPaneText">
                                <asp:Label ID="lbl_LoadingHeader" runat="server"></asp:Label></span>
                        </div>
                        <!------------------------------------
                           ---------LOADING SECTION -----------
                           ------------------------------------->
                        <telerik:RadAjaxPanel ID="LoadingPanel" runat="server" CssClass="radPaneContent TransferHeader">
                           
                        </telerik:RadAjaxPanel>
                        <telerik:RadGrid ID="LoadingRadGrid" OnItemDataBound="LoadingRadGridFormat_OnItemDataBound"
                            runat="server" AutoGenerateColumns="false" CssClass="TransferGridPanel" Height="375px"
                            Width="500px" OnNeedDataSource="LoadingRadGrid_NeedDataSource"
                             OnUpdateCommand="LoadingRadGrid_UpdateCommand" OnBatchEditCommand="LoadingRadGrid_BatchEditCommand" OnInsertCommand="LoadingRadGrid_InsertCommand"
                             OnItemCommand="LoadingRadGrid_ItemCommand" OnSelectedIndexChanged="LoadingRadGrid_SelectedIndexChanged" OnCancelCommand="LoadingRadGrid_CancelCommand">
                              
                            <MasterTableView ShowHeadersWhenNoRecords="true" CommandItemDisplay="Top" EditMode="Batch" DataKeyNames="Loading_ID">
                                <CommandItemSettings ShowRefreshButton="false" AddNewRecordText="Add NewLoad" />
                            <BatchEditingSettings EditType="Cell" />
                                <NestedViewTemplate>
                                
                                    <telerik:RadTabStrip runat="server" ID="LoadTabStip" MultiPageID="LoadMultipage" ClickSelectedTab="True"
                                        SelectedIndex="0" OnTabClick="LoadTabStip_TabClick" Orientation="HorizontalTop">
                                        <Tabs runat="server">
                                            <telerik:RadTab runat="server" Text="Details" PageViewID="RadPageViewDetails">
                                            </telerik:RadTab>
                                            <telerik:RadTab runat="server" Text="Compartments" PageViewID="RadPageViewCompartments">
                                            </telerik:RadTab>
                                            <telerik:RadTab runat="server" Text="Products" PageViewID="RadPageViewProducts">
                                            </telerik:RadTab>
                                        </Tabs>
                                    </telerik:RadTabStrip>
                                    <telerik:RadMultiPage runat="server" ID="LoadMultipage" SelectedIndex="0" RenderSelectedPageOnly="false">
                                   
                                        <telerik:RadPageView runat="server" ID="RadPageViewDetails">
                                       
                                            <div class="contactWrap">
                                                <table cellpadding="0" cellspacing="0">
                                                    <tr>
                                                       <td><asp:Label ID="lbl_TerminalId" runat="server" Text='Terminal Id:' Font-Bold="true"></asp:Label></td>
                                                       <td><asp:Label ID="lbl_TerminalIdValue" runat="server"></asp:Label> </td> 
                                                    </tr>
                                                    <tr>
                                                        <td><asp:Label ID="lbl_TerminalName" runat="server" Text='TerminalName:' Font-Bold="true"></asp:Label></td>
                                                        <td><asp:Label ID="lbl_TerminalNameValue" runat="server"></asp:Label> </td>
                                                       
                                                    </tr>
                                                </table>
                                            </div>
                                        </telerik:RadPageView>
                                        <telerik:RadPageView runat="server" ID="RadPageViewCompartments">
                                       
                                            <telerik:RadGrid ID="CompartmentLevelLoadRadGrid" runat="server" AutoGenerateColumns="false" CssClass="TransferGridPanel"
                                                Height="233px" Width="475px" OnItemDataBound="CompartmentLevelLoadRadGrid_ItemDataBound" OnNeedDataSource="CompartmentLevelLoadingRadGrid_NeedDataSource"
                                                OnUpdateCommand="CompartmentLevelLoadRadGrid_UpdateCommand" OnBatchEditCommand="CompartmentLevelLoadRadGrid_BatchEditCommand" OnInsertCommand="CompartmentLevelLoadRadGrid_InsertCommand">
                                                <MasterTableView ShowHeadersWhenNoRecords="true" CommandItemDisplay="Top" EditMode="Batch">
                                                     <CommandItemSettings ShowRefreshButton="false" AddNewRecordText="Add Line Item"/>
                                                     <BatchEditingSettings EditType="Cell" />                                              
                                                    <Columns>
                                                   
                                                        <telerik:GridBoundColumn UniqueName="CompNo" DataField="CompartmentIndex" HeaderText="Comp No." ReadOnly="true">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="PriorToLoad" DataField="PTL" HeaderText="PriorTo Load">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="PlannedLoadProd" DataField="PlannedProductName" HeaderText="Planned Product" ReadOnly="true">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="ActualLoadProd" DataField="ActualProductName" HeaderText="Actual Product" >
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="PlannedLoadQty" DataField="PlannedQuantity" HeaderText="Planned Quantity" ReadOnly="true">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="ActualLoadQty" DataField="ActualQuantity" HeaderText="Actual Quantity">
                                                        </telerik:GridBoundColumn>
                                                    </Columns>
                                                </MasterTableView>
                                            </telerik:RadGrid>
                                           
                                        </telerik:RadPageView>
                                        <telerik:RadPageView runat="server" ID="RadPageViewProducts">
                                       
                                            <telerik:RadGrid ID="ProductLevelLoadRadGrid" runat="server" AutoGenerateColumns="false" CssClass="TransferGridPanel"
                                                Height="233px" Width="475px" OnItemDataBound="ProductLevelLoadRadGrid_ItemDataBound" OnNeedDataSource="ProductLevelLoadingRadGrid_NeedDataSource">
                                                <MasterTableView ShowHeadersWhenNoRecords="true">                                               
                                                    <Columns>
                                                        <telerik:GridBoundColumn UniqueName="PlannedLoadProd" DataField="PlannedProductName" HeaderText="Planned Product" Visible="false">
                                                        </telerik:GridBoundColumn>                                                    
                                                        <telerik:GridBoundColumn UniqueName="ActualLoadProd" DataField="ActualProductName" HeaderText="Product">
                                                        </telerik:GridBoundColumn>                                                       
                                                        <telerik:GridBoundColumn  UniqueName="PriorToLoadQty" DataField="PTL"  HeaderText="PriorTo Load">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="PlannedLoadQty" DataField="PlannedQuantity" HeaderText="Planned Quantity">
                                                        </telerik:GridBoundColumn>
                                                        <telerik:GridBoundColumn UniqueName="ActualLoadQty" DataField="ActualQuantity" HeaderText="Actual Quantity">
                                                        </telerik:GridBoundColumn>
                                                    </Columns>
                                                </MasterTableView>
                                            </telerik:RadGrid>
                                           
                                        </telerik:RadPageView>
                                    </telerik:RadMultiPage>
                                 
                                </NestedViewTemplate>
                               
                                <Columns>
                                    <telerik:GridBoundColumn UniqueName="LoadId" DataField="Loading_ID" ReadOnly="true">                                       
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="TerminalId" DataField="Plant_ID">
                                        <ColumnValidationSettings EnableRequiredFieldValidation="true">                                           
                                            <RequiredFieldValidator ForeColor="Red" Text="Plant_ID is required" Display="Dynamic">                               
                                            </RequiredFieldValidator>
                                        </ColumnValidationSettings>
                                    </telerik:GridBoundColumn>
                                   
                                    <telerik:GridBoundColumn UniqueName="TerminalName" DataField="TerminalName" ReadOnly="true">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="LoadingStartTime" DataField="LoadingStartTime" ReadOnly="true">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn UniqueName="LoadingEndTime" DataField="LoadingEndTime" ReadOnly="true">
                                    </telerik:GridBoundColumn>
                                </Columns>
                            </MasterTableView>
                            <ClientSettings>
                                <Scrolling AllowScroll="true" />
                            </ClientSettings>
                        </telerik:RadGrid>
                    </telerik:RadPane>
                    <telerik:RadSplitBar EnableResize="false" runat="server">
                    </telerik:RadSplitBar>
                    <telerik:RadPane ID="DischargePane" runat="server" CssClass="noOverflow">
                        <div class="paneHeader">
                            <div class="paneHeaderBorder">
                                <span class="headerPaneText">
                                    <asp:Label ID="lbl_DischargeHeader" runat="server"></asp:Label></span>
                            </div>
                        </div>
                        <!------------------------------------
                          ---------DISCHARGE SECTION-----------
                          ------------------------------------->
                        <telerik:RadAjaxPanel ID="DischargePanel" runat="server" CssClass="radPaneContent TransferHeader">
                           
                        </telerik:RadAjaxPanel>
                        <div style="position: absolute;">
                      <telerik:RadGrid ID="DischargeRadGrid"   OnItemDataBound="DsichargeRadGridFormat_OnItemDataBound" runat="server" AutoGenerateColumns="false"
                            CssClass="TransferGridPanel" Height="370px" Width="500px" OnItemCommand="DischargeRadGrid_ItemCommand"
                           OnUpdateCommand="DischargeRadGrid_UpdateCommand" OnBatchEditCommand="DischargeRadGrid_BatchEditCommand" OnInsertCommand="DischargeRadGrid_InsertCommand">
                           <MasterTableView ShowHeadersWhenNoRecords="true" CommandItemDisplay="Top" EditMode="Batch" DataKeyNames="Discharge_ID">
                            <CommandItemSettings ShowRefreshButton="false" AddNewRecordText="Add NewDelivery" />
                               <BatchEditingSettings EditType="Cell" />
                            <NestedViewTemplate>
                             <telerik:RadTabStrip runat="server" ID="DischargeTabStrip" MultiPageID="DischargeMultipage" ClickSelectedTab="True"
                                 SelectedIndex="0" OnTabClick="DischargeTabStip_TabClick">
                        <Tabs>
                            <telerik:RadTab runat="server" Text="Details" PageViewID="DischargePageViewDetails">
                            </telerik:RadTab>
                            <telerik:RadTab runat="server" Text="Compartments" PageViewID="DischargePageViewCompartments">
                            </telerik:RadTab>
                            <telerik:RadTab runat="server" Text="Products" PageViewID="DischargePageViewProducts">
                            </telerik:RadTab>
                        </Tabs>
                    </telerik:RadTabStrip>
                    <telerik:RadMultiPage runat="server" ID="DischargeMultipage" SelectedIndex="0" RenderSelectedPageOnly="false">
                        <telerik:RadPageView runat="server" ID="DischargePageViewDetails">
                            <div class="contactWrap">
                                <table cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td>
                                            <asp:Label ID="lbl_ShipTo" runat="server" Text='ShipTo:' Font-Bold="true"></asp:Label>
                                        </td>
                                        <td>
                                            <asp:Label ID="lbl_ShipToValue" runat="server"></asp:Label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <asp:Label ID="lbl_SiteName" runat="server" Text='Name:' Font-Bold="true"></asp:Label>
                                        </td>
                                        <td>
                                            <asp:Label ID="lbl_SiteNameValue" runat="server"></asp:Label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <asp:Label ID="lbl_Address" runat="server" Text='Address:' Font-Bold="true"></asp:Label>
                                        </td>
                                        <td>
                                            <asp:Label ID="lbl_AddressValue" runat="server"></asp:Label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <asp:Label ID="lbl_SplInstruction" runat="server" Text='SpecialInstructions:' Font-Bold="true"></asp:Label>
                                        </td>
                                        <td>
                                            <asp:Label ID="lbl_SplInstructionValue" runat="server"></asp:Label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <asp:Label ID="lbl_PONumber" runat="server" Text='PONumber:' Font-Bold="true"></asp:Label>
                                        </td>
                                        <td>
                                            <asp:Label ID="lbl_PONumberValue" runat="server"></asp:Label>
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </telerik:RadPageView>
                        <telerik:RadPageView runat="server" ID="DischargePageViewCompartments">
                            <telerik:RadGrid ID="CompartmentLevelDischargeRadGrid" runat="server" AutoGenerateColumns="false"
                                CssClass="TransferGridPanel" Height="233px" Width="475px" OnItemDataBound="CompartmentLevelDischargeRadGrid_ItemDataBound">
                                <MasterTableView ShowHeadersWhenNoRecords="true">
                                    <Columns>
                                        <telerik:GridBoundColumn UniqueName="ItemNo" DataField="CompartmentIndex" HeaderText="Comp No.">
                                        </telerik:GridBoundColumn>
                                       
                                        <telerik:GridBoundColumn UniqueName="PlannedDischargeProd" DataField="PlannedProductName" HeaderText="Planned Product">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="ActualDischargeProd" DataField="ActualProductName" HeaderText="Actual Product">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="PlannedDischargeQty" DataField="PlannedQuantity" HeaderText="Planned Quantity">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="ActualDischargeQty" DataField="ActualQuantity" HeaderText="Actual Quantity">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="PlannedTank" DataField="TankIndex" HeaderText="Planned Tank">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="ActualTank" DataField="ActualTankIndex" HeaderText="Actual Tank">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="LeftOnBoard" DataField="LOB" HeaderText="LOB">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="Adjustment" DataField="Adjustment" HeaderText="Adjustment">
                                        </telerik:GridBoundColumn>
                                    </Columns>
                                </MasterTableView>
                            </telerik:RadGrid>
                        </telerik:RadPageView>
                    <telerik:RadPageView runat="server" ID="DischargePageViewProducts">
                    <telerik:RadGrid ID="ProductLevelDischargeRadGrid" runat="server" AutoGenerateColumns="false"
                                CssClass="TransferGridPanel" Height="233px" Width="475px" OnItemDataBound="ProductLevelDischargeRadGrid_ItemDataBound">
                                <MasterTableView ShowHeadersWhenNoRecords="true">
                                    <Columns>
                                    <telerik:GridBoundColumn UniqueName="PlannedDischargeProd" DataField="PlannedProductName" HeaderText="Planned Product" Visible="false">
                                        </telerik:GridBoundColumn>                                       
                                        <telerik:GridBoundColumn UniqueName="ActualDischargeProd" DataField="ActualProductName" HeaderText="Actual Product">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="PlannedDischargeQty" DataField="PlannedQuantity" HeaderText="Planned Quantity">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="ActualDischargeQty" DataField="ActualQuantity" HeaderText="Actual Quantity">
                                        </telerik:GridBoundColumn>                                       
                                        <telerik:GridBoundColumn UniqueName="ActualTank" DataField="ActualTankIndex" HeaderText="Actual Tank">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="CaluculatedDifference" DataField="CaluculatedDifference" HeaderText="Caluculated Difference">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="PreDip" DataField="PreDip" HeaderText="PreDip">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="PostDip" DataField="PostDip" HeaderText="PostDip">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="PreSMR" DataField="PreSMR" HeaderText="SMR Start">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="PostSMR" DataField="PostSMR" HeaderText="SMR End">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="LeftOnBoard" DataField="LOB" HeaderText="LOB">
                                        </telerik:GridBoundColumn>
                                        <telerik:GridBoundColumn UniqueName="Adjustment" DataField="Adjustment" HeaderText="Adjustment">
                                        </telerik:GridBoundColumn>                                  
                                    </Columns>
                                </MasterTableView>
                            </telerik:RadGrid>
                    </telerik:RadPageView>
                    </telerik:RadMultiPage>
                    </NestedViewTemplate>                                <Columns>
                                    <telerik:GridBoundColumn  UniqueName="DeliveryNo" DataField="Discharge_ID">
                                        <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                            <RequiredFieldValidator ForeColor="Red" Text="*This field is required" Display="Dynamic">                               
                                            </RequiredFieldValidator>
                                        </ColumnValidationSettings>
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn  UniqueName="ShipTo"
                                        DataField="Site_ID">
                                        <ColumnValidationSettings EnableRequiredFieldValidation="true">
                                            <RequiredFieldValidator ForeColor="Red" Text="*This field is required" Display="Dynamic">                               
                                            </RequiredFieldValidator>
                                        </ColumnValidationSettings>
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn  UniqueName="ShipToName"
                                        DataField="SiteAddress" ReadOnly="true">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn  UniqueName="DischargeStart"
                                        DataField="DischargeStartTime" ReadOnly="true">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn  UniqueName="DischargeEnd"
                                        DataField="DischargeEndTime">
                                    </telerik:GridBoundColumn>
                                </Columns>
                            </MasterTableView>
                            <ClientSettings>                           
                           
                            <Scrolling AllowScroll="true"/></ClientSettings>
                        </telerik:RadGrid>
                        </div>
                    </telerik:RadPane>
                </telerik:RadSplitter>
            </telerik:RadPane>
            </telerik:RadSplitter>
       
        </telerik:RadPane>
        </telerik:RadSplitter>
    </div>
   
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true">
        <Windows>
            <telerik:RadWindow ID="ShiftOverviewDialog" runat="server" Height="530px" Width="990px"
                Left="150px" Animation="Fade" ReloadOnShow="true" ShowContentDuringLoad="false"
                Modal="true">
            </telerik:RadWindow>
            <telerik:RadWindow ID="PortalDialog" runat="server" Height="600px" Width="950px"
                Left="150px" Animation="Fade" ReloadOnShow="true" ShowContentDuringLoad="false"
                Modal="true">
            </telerik:RadWindow>
            <telerik:RadWindow ID="PortalDischarge" runat="server" Height="680px" Width="950px"
                Left="150px" Animation="Fade" ReloadOnShow="true" ShowContentDuringLoad="false"
                Modal="true">
            </telerik:RadWindow>
            <telerik:RadWindow Width="400" Height="200" ID="LogoutPrompt" runat="server" ReloadOnShow="true"
                ShowContentDuringLoad="false" Modal="true" OnClientClose="OnClientClose">
            </telerik:RadWindow>
        </Windows>
    </telerik:RadWindowManager>
    <asp:Label ID="indexCounter" runat="server" Text="0" CssClass="isHidden"></asp:Label>
</asp:Content>


ASPX.CS FILE:


using System.Web.UI;
using Shell.DrivePartner.EntityObjects;
using Shell.CFMS.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using Telerik.Web.UI;
using Resources;
using Shell.DrivePartner.Business.Manager;
using Shell.DrivePartner.EntityObjects.GSAP;
using Shell.DrivePartner.Business.GSAP;
using Shell.CFMS.Common.ExtensionMethods;
using System.Threading;
using System.Globalization;
using Shell.CFMS.Logging;
using System.Text;
using System.Web.UI.WebControls;
using System.Data;
using System.Drawing;
using Shell.CFMS.DataAccess.DAL;
using System.Collections;
public partial class SectorMainWeb_Default : System.Web.UI.Page
{
    //added for 1.06 R2
    Int64 loadId;
    Int64 dischargeID;   
    BalanceManager balanceManager = new BalanceManager();
    VehicleManager vehicleManager = new VehicleManager();
    DischargeManager dischargeManager = new DischargeManager();
    GenericShipmentManager gsm = new GenericShipmentManager();
    ShiftManager shiftManager = new ShiftManager();
    ShipmentManager shipmentManager = new ShipmentManager();
    LoadingDetailManager loadingDetailManager = new LoadingDetailManager();
    DischargeDetailManager dischargeDetailManager = new DischargeDetailManager();
    AuditLogManager auditLogManager = new AuditLogManager();
    List<ShiftEntity> shiftList;
    List<ShipmentEntity> shipmentList;
    List<LoadingDetailExtraEntity> loadingDetailWsList;
    List<DischargeDetailExtraEntity> dischargeDetailWsList;
    Dictionary<String, Int32> Priority;
    JobManager jobManager;
    String _sesLastUpdated = "_sesLastUpdated";
    String _lastShipmentSelect = "_lastShipmentSelect";
    String _lastDischargeSelect ="_lastDischargeSelect";
    String _lastLoadingSelect = "_lastLoadingSelect";
    String _sesLastVehicleSelect = "_sesLastVehicleSelect";
    String _lastDischargeHeader = "_lastDischargeHeader";
    //added for 1.06 R2
    String _lastDischargeSelect1 = "_lastDischargeSelect1";
    String _lastLoadingSelect1 = "_lastLoadingSelect1";
    String _lastLoadHeader = "_lastLoadHeader";
    String _sesSelShift = "_sesSelShift";
    String _025FilePath = "_025FilePath";
    String _025FileName = "_025FileName";
    List<String> shipmentHistory = new List<string>();
    Int32 updateCounter;
    List<ShipmentEntity> tempShipmentList;
    //List<ShipmentEntity> ShipmentIDList;  
    ApplicationUserEntity user;
    //added for 1.06 R2
    String _storeCompartmentLoadTable = "_storeCompartmentLoadTable";
    String _storeProductLoadTable = "_storeProductLoadTable";
    String _lastSubmitType = "_lastSubmitType";
    String _lastShiftValue = "_lastShiftValue";
    String _lastVehicle = "_lastVehicle";
    String _lastBalanceResult = "_lastErrorResult";
    String _VehicleList = "_VehicleList";
    String _loadhaulierLoc = "_loadhaulierLoc";
    String vehclelst;
  
  
    static int flag = 0;    protected void Page_Load(object sender, EventArgs e)
    {
        user = SessionManager.ApplicationUser;
        SetUserCulture(user);
        jobManager = new JobManager(new JobEntity());
        Priority = new Dictionary<string, int>();
        Priority.Add("NewShiftReady", 0);
        Priority.Add("ShiftSent", 1);
        Priority.Add("ReceivedFromAppNoError", 2);
        Priority.Add("Ignored", 2);
        Priority.Add("ShiftReceivedByApp", 3);
        Priority.Add("DeliveryConfirmationSent", -1);
        Priority.Add("ReceivedFromAppWithError", 5);
        Priority.Add("ErrorShellData", 6);        // Code added for the fixing of defect : 6337
        //ShipmentRadGrid.MasterTableView.DetailTables[0].GetColumn("Transfer_ID").ItemStyle.BackColor = System.Drawing.Color.White;
        //ShipmentRadGrid.MasterTableView.DetailTables[0].GetColumn("TransferType").ItemStyle.BackColor = System.Drawing.Color.White;
       
        // Code added for the fixing of defect : 6366
     
        if (RadDate_ShiftFrom.SelectedDate != null)
        {
            Session["PreviousDateFrom"] = Convert.ToString(RadDate_ShiftFrom.SelectedDate);
        }
       
        if (RadDate_ShiftTo.SelectedDate != null)
        {
            Session["PreviousDateTo"] = Convert.ToString(RadDate_ShiftTo.SelectedDate);
        }
       
        if (!Page.IsPostBack)
        {
            loadingDetailWsList = new List<LoadingDetailExtraEntity>();
            dischargeDetailWsList = new List<DischargeDetailExtraEntity>();
            LoadingRadGrid.DataSource = loadingDetailWsList;
            DischargeRadGrid.DataSource = dischargeDetailWsList;
            ClearSelectedSession();
            Session["_sesUpdateCounter"] = indexCounter.Text.ConvertToInt32();
            TranslatePage();
           
            if (SectorMainWeb_MasterPage.haulierLocationChangeFlag == true)
            {
                flag = 0;
                Session["PreviousDateFrom"] = Convert.ToString(SessionManager.SelectedDate.AddDays(-1));
                Session["PreviousDateTo"] = Convert.ToString(SessionManager.SelectedDate.AddDays(7));            }
            else
            {
                ShiftTreeView.Nodes.Clear();
                ShiftTreeContextMenu.Items.Clear();
            }            if (Session["SessionFlag"] != null)
            {
                if (Session["SessionFlag"].ToString() == "1")
                {
                    flag = 0;
                    Session["PreviousDateFrom"] = Convert.ToString(SessionManager.SelectedDate.AddDays(-1));
                    Session["PreviousDateTo"] = Convert.ToString(SessionManager.SelectedDate.AddDays(7));
                }
            }
            else
            {
                Session["SessionFlag"] = 1;
            }            if (flag != 0)
            {
                if ((RadDate_ShiftTo.SelectedDate != null) || (RadDate_ShiftFrom.SelectedDate != null))
                {
                    if ((RadDate_ShiftFrom.SelectedDate != SessionManager.SelectedDate.AddDays(-1)) || (RadDate_ShiftTo.SelectedDate != SessionManager.SelectedDate.AddDays(7)))
                    {
                        RadDate_ShiftFrom.SelectedDate = Convert.ToDateTime(Session["PreviousDateFrom"]);
                        RadDate_ShiftTo.SelectedDate = Convert.ToDateTime(Session["PreviousDateTo"]);
                    }
                    else
                    {
                        RadDate_ShiftFrom.SelectedDate = SessionManager.SelectedDate.AddDays(-1);
                        Session["PreviousDateFrom"] = Convert.ToString(SessionManager.SelectedDate.AddDays(-1));
                        RadDate_ShiftTo.SelectedDate = SessionManager.SelectedDate.AddDays(7);
                        Session["PreviousDateTo"] = Convert.ToString(SessionManager.SelectedDate.AddDays(7));
                    }
                }
                else
                {
                    if (Session["SessionFlag"].ToString() == "1")
                    {
                        RadDate_ShiftFrom.SelectedDate = SessionManager.SelectedDate.AddDays(-1);
                        Session["PreviousDateFrom"] = Convert.ToString(SessionManager.SelectedDate.AddDays(-1));
                        RadDate_ShiftTo.SelectedDate = SessionManager.SelectedDate.AddDays(7);
                        Session["PreviousDateTo"] = Convert.ToString(SessionManager.SelectedDate.AddDays(7));
                    }
                    else
                    {
                        RadDate_ShiftFrom.SelectedDate = Convert.ToDateTime(Session["PreviousDateFrom"]);
                        RadDate_ShiftTo.SelectedDate = Convert.ToDateTime(Session["PreviousDateTo"]);
                    }
                }
            }
            else
            {  
                    RadDate_ShiftFrom.SelectedDate = SessionManager.SelectedDate.AddDays(-1);
                    Session["PreviousDateFrom"] = Convert.ToString(SessionManager.SelectedDate.AddDays(-1));
                    RadDate_ShiftTo.SelectedDate = SessionManager.SelectedDate.AddDays(7);
                    Session["PreviousDateTo"] = Convert.ToString(SessionManager.SelectedDate.AddDays(7));
            }
            flag = 1;
            //6346
            //RadDate_ShiftFrom.SelectedDate = DateTime.Now.AddDays(-1);
            //RadDate_ShiftTo.SelectedDate = DateTime.Now.AddDays(7);
        }
       
        lbl_ShiftHeader.Text = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_WS_SHIFT_HAULIER + " " + SessionManager.ApplicationUser.SelectedHaulierID + "</span>";
        updateCounter = (Int32) (Session["_sesUpdateCounter"] ?? default(int));
        TranslatePage();        TranslateGridMenuItems(ShipmentRadGrid);        LogoutPrompt.Behaviors = WindowBehaviors.None;        if (Session[_sesLastUpdated] == null)
        {
            Session[_sesLastUpdated] = DateTime.UtcNow;
        }
    }    protected Boolean isWithinDate(ShiftEntity se)
    {
        Boolean isWithinDate = false;
        if (RadDate_ShiftFrom.SelectedDate.Value.CompareTo(se.ScheduledDate) <= 0 && RadDate_ShiftTo.SelectedDate.Value.CompareTo(se.ScheduledDate) >= 0)
        {
            isWithinDate = true;
        }
        return isWithinDate;
    }    /// <summary>
    /// update panel load event
    /// </summary>
    protected void UpdatePanel1_Load(object sender, EventArgs e)
    {
        //added to refresh tree view
    }    protected void PopulateTreeNode()
    {
         ShiftTreeView.Nodes.Clear();
        ShiftTreeContextMenu.Items.Clear();        RadMenuItem menuItem1 = new RadMenuItem(MyGlobal.SDP_GUI_WORKSCHED_MENU_SENDTOGSAP);
        RadMenuItem menuItem2 = new RadMenuItem(MyGlobal.SDP_GUI_WORKSCHED_MENU_SENDTODEV);
        RadMenuItem menuItem3 = new RadMenuItem(MyGlobal.SDP_GUI_ERROR_LBL_HEADER);
        RadMenuItem menuItem4 = new RadMenuItem(MyGlobal.SDP_GUI_WORKSCHED_MENU_DISCHSCRN);
        RadMenuItem menuItem5 = new RadMenuItem(MyGlobal.SDP_GUI_WORKSCHED_MENU_BLNCSHEET);
        RadMenuItem menuItem6 = new RadMenuItem(MyGlobal.SDP_GUI_WORKSCHED_MENU_SHFITOVERV);
        RadMenuItem menuItem7 = new RadMenuItem(MyGlobal.SDP_GUI_WS_DELETE_SHIFT);
        RadMenuItem menuItem8 = new RadMenuItem(MyGlobal.SDP_GUI_WS_NEW_SHIPMNET);
        RadMenuItem menuItem9 = new RadMenuItem(MyGlobal.SDP_GUI_WS_NEW_LOAD);
        RadMenuItem menuItem10 = new RadMenuItem(MyGlobal.SDP_GUI_WS_NEW_DISHARGE);        menuItem1.Value = "SendToGsap";
        menuItem2.Value = "SendToDevice";
        menuItem3.Value = "ErrorLog";
        menuItem4.Value = "DischargeScreen";
        menuItem5.Value = "BalanceSheet";
        menuItem6.Value = "ShiftOverview";
        menuItem7.Value = "DropShift";
        menuItem8.Value = "NewShipment";
        menuItem9.Value = "NewLoad";
        menuItem10.Value = "NewDischarge";        ShiftTreeContextMenu.Items.Add(menuItem1);
        ShiftTreeContextMenu.Items.Add(menuItem2);
        ShiftTreeContextMenu.Items.Add(menuItem3);
        ShiftTreeContextMenu.Items.Add(menuItem4);
        ShiftTreeContextMenu.Items.Add(menuItem5);
        ShiftTreeContextMenu.Items.Add(menuItem6);
        ShiftTreeContextMenu.Items.Add(menuItem7);
        ShiftTreeContextMenu.Items.Add(menuItem8);
        ShiftTreeContextMenu.Items.Add(menuItem9);
        ShiftTreeContextMenu.Items.Add(menuItem10);        //shiftList.Sort((x, y) => DateTime.Compare(x.ScheduledDate, y.ScheduledDate));
        if (shiftList == null)
        { return; }
        shiftList = shiftList.OrderBy(x => x.ScheduledDate).ThenBy(y => y.ShiftIndex).ToList();
        shiftList.Reverse();        //ShipmentState currentShipmentState = new ShipmentState();
        ShiftState currentShiftState = new ShiftState();        foreach (ShiftEntity s in shiftList)
        {
            if (!isWithinDate(s))
            {
                continue;
            }
            List<Int64> vehicleIdList = new List<Int64>();
            String timeOfDay = "";
            if (s.ShiftIndex == 1) { timeOfDay = "AM"; }
            if (s.ShiftIndex == 2) { timeOfDay = "PM"; }
            RadTreeNode rootNode = new RadTreeNode(s.ScheduledDate.Date.ToShortDateString() + " / " + timeOfDay);
            Boolean disableDelete = false;
            //shipmentList.Sort((x,y)=> x.Vehicle_ID.CompareTo(y.Vehicle_ID));
            tempShipmentList = shipmentList.FindAll(sh => sh.Shift_ID == s.Shift_ID);
            //currentShipmentState =  ShipmentState.NotSet;
            currentShiftState = ShiftState.NotSet;
            string shiftdate = s.ScheduledDate.ToString("dd-MM-yyyy") + " / " + timeOfDay;
            ///
            // Creating vehicle nodes under shifts
            ///            foreach (ShipmentEntity sm in tempShipmentList)
            {                RadTreeNode shipmentNode = new RadTreeNode(sm.Vehicle_ID.ToString());
                shipmentNode.Value = sm.Vehicle_ID.ToString();
                if (sm.ShipmentState == ShipmentState.Ignored)
                {
                    sm.ShipmentState = ShipmentState.ReceivedFromAppWithError;
                }
                shipmentNode.ImageUrl = "~/images/States/" + sm.ShipmentState.ToString() + ".png";
                shipmentNode.Attributes.Add("NodeType", "Vehicle");
                shipmentNode.Attributes.Add("ShipmentType", sm.ShipmentState.ToString());
                shipmentNode.Attributes.Add("VehicleId", sm.Vehicle_ID.ToString());
                shipmentNode.Attributes.Add("ShiftIndex", sm.Shift_ID.ToString());
                //7363
                shipmentNode.Attributes.Add("ShiftDate", shiftdate);                if (!vehicleIdList.Contains(sm.Vehicle_ID))
                {
                    rootNode.Nodes.Add(shipmentNode);
                    vehicleIdList.Add(sm.Vehicle_ID);
                    //currentShipmentState = ShipmentState.NotSet;
                }                if (!(sm.ShipmentState.Equals(ShipmentState.NewShiftReady)) && !disableDelete)
                {
                    disableDelete = true;
                }                ///
                // Prioritising vehicle node status based on individual shipments
                ///
                String vehicleShipmentNodeType =
                    rootNode.Nodes.FindNodeByValue(sm.Vehicle_ID.ToString()).Attributes["ShipmentType"];
                if (vehicleShipmentNodeType != sm.ShipmentState.ToString())
                {
                    if (IsErrorHighPriority(sm.ShipmentState.ToString(), vehicleShipmentNodeType))
                    {
                        rootNode.Nodes.FindNodeByValue(sm.Vehicle_ID.ToString()).Remove();
                        rootNode.Nodes.Add(shipmentNode);
                    }
                }
                //adding code to bind new shipment node to tree view
                   
                List<ShipmentEntity> shipmentIDList = new List<ShipmentEntity>();                shipmentIDList = tempShipmentList.FindAll(sh => sh.Vehicle_ID == sm.Vehicle_ID);                foreach (ShipmentEntity sid in shipmentIDList)
                {                    RadTreeNode shipmentidnode = new RadTreeNode(sid.Shipment_ID.ToString());                    shipmentidnode.Value = sid.Shipment_ID.ToString();
                    shipmentidnode.Attributes.Add("NodeType", "Shipment");
                    shipmentidnode.Attributes.Add("ShipmentType", sid.ShipmentState.ToString());
                    shipmentidnode.Attributes.Add("VehicleId", sid.Vehicle_ID.ToString());
                    shipmentidnode.Attributes.Add("ShiftIndex", sid.Shift_ID.ToString());
                    shipmentidnode.Attributes.Add("ShipmentId", sid.Shipment_ID.ToString());
                    if (sid.ShipmentState == ShipmentState.Ignored)
                    {
                        sid.ShipmentState = ShipmentState.ReceivedFromAppWithError;
                    }
                    shipmentidnode.ImageUrl = "~/images/States/" + sid.ShipmentState.ToString() + ".png";
                    shipmentNode.Nodes.Add(shipmentidnode);                }               
            }
            ///
            // Adding vehicle nodes to shift nodes
            ///
            if (disableDelete)
            {
                rootNode.Attributes.Add("DisableDelete", "True");
            }
            String shipmentString = "";
            Boolean sendToGsap = false;
            Boolean sendToDev = false;
            Boolean manualSend = false;
            ShiftState tracker = new ShiftState();            //R2 1.11 GsapIdoc Interface
            //sendtoGsap will be available only for manual send
            HaulierSettingManager hsm = new HaulierSettingManager();            if (hsm.GetHaulierSettingByLocId(user.SelectedHaulierID) != null)
            {
            if (hsm.GetHaulierSettingByLocId(user.SelectedHaulierID).SendToGsapSetting == 2)
                { manualSend = true; }
            }            //6505
            List<RadTreeNode> vehiclenodecollection = new List<RadTreeNode>();
           
            foreach (RadTreeNode rtn in rootNode.Nodes)
            {
               
                shipmentString = rtn.Attributes["ShipmentType"].ToString();
                tracker = (ShiftState)Enum.Parse(typeof(ShiftState), shipmentString);
               
                if (currentShiftState == ShiftState.NotSet)
                {
                    currentShiftState = (ShiftState)Enum.Parse(typeof(ShiftState), shipmentString);
                }
                if (currentShiftState != tracker)
                {
                    currentShiftState = ShiftState.IncompleteShift;
                }
               
                if( shipmentString.Equals(ShipmentState.ReceivedFromAppNoError.ToString()) &&
                    !sendToGsap && user.UserType != "VW" && manualSend)
                {
                    rootNode.Attributes.Add("EnableSendToGsap", "True");
                    sendToGsap = true;
                }
                if (shipmentString.Equals(ShipmentState.NewShiftReady.ToString()) && !sendToDev)
                {
                    rootNode.Attributes.Add("EnableSendToDevice", "True");
                    sendToDev = true;
                }
                if (user.UserType == "VW")
                { rtn.Attributes.Add("EnableSendToDevice", "SHELLSUPPORT"); }                if (!user.ScreenLevelAccess.Contains("EL"))
                { rtn.Attributes.Add("EnableErrorLog", "False"); }                vehiclenodecollection.Add(rtn);
            }
            var q = from node in vehiclenodecollection
                    orderby node.Text ascending
                    select node;
            rootNode.Nodes.Clear();
            foreach (RadTreeNode nd in q)
            {
                rootNode.Nodes.Add(nd);
            }            s.Status = currentShiftState;            if (s.Status == ShiftState.ReceivedFromAppNoError && user.UserType != "VW" && manualSend)
            {
                rootNode.Attributes.Add("EnableSendToGsap", "True");
            }
            if (user.UserType == "VW")
            { rootNode.Attributes.Add("EnableSendToDevice", "SHELLSUPPORT"); }            //R2:1.34 user profile screen level access
            if (! user.ScreenLevelAccess.Contains("EL"))
            { rootNode.Attributes.Add("EnableErrorLog", "False"); }
           
            rootNode.Value = s.Shift_ID.ToString();
            rootNode.Attributes.Add("NodeType", "Shift");
            rootNode.Attributes.Add("ShiftId", s.Shift_ID.ToString());
            rootNode.ImageUrl = "~/images/States/" + s.Status.ToString() + ".png";            ShiftTreeView.Nodes.Add(rootNode);
        }        if (Session["haulierLocationFlag"] != null)
        {
            if (Session["haulierLocationFlag"].ToString() == "true")
            {
                //ShiftTreeView.Nodes.Clear();
                //ShiftTreeContextMenu.Items.Clear();
                Session["haulierLocationFlag"] = false;                List<ShipmentEntity> shipmentEntityCount = new List<ShipmentEntity>();
                ShipmentRadGrid.DataSource = shipmentEntityCount;
            }
        }
        else
        {
            Session["haulierLocationFlag"] = false;
        }        if (Session["haulierFlag"] != null)
        {
            if (Session["haulierFlag"].ToString() == "true")
            {
                Session["haulierLocationFlag"] = false;
                lbl_LoadingHeader.Text = string.Empty;
                lbl_DischargeHeader.Text = string.Empty;
                Session[_lastDischargeHeader] = string.Empty;
                Session[_lastLoadHeader] = string.Empty;                List<ShipmentEntity> shipmentEntCount = new List<ShipmentEntity>();
                ShipmentRadGrid.DataSource = shipmentEntCount;
            }
        }
        else
        {
            Session["haulierFlag"] = false;
        }
    }    protected Boolean IsErrorHighPriority(String gridVal, String treeVal)
    {        Int32 val1;
        Int32 val2;
        Priority.TryGetValue(gridVal, out val1);
        Priority.TryGetValue(treeVal, out val2);
        if (val1 > val2)
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    /// <summary>
    /// Set
    /// </summary>
    /// <param name="Key"></param>
    protected void StoreGridDataInSession(String Key)
    {
        switch (Key)
        {
            case "EntireShipment":
                {
                    if (Session[Key] == null && SessionManager.ApplicationUser.SelectedHaulierID != 0)
                    {
                        if (Session[Constants.SessionDataStoreKeys.EntireShift.ToString()] != null)
                        {
                            shiftList = (List<ShiftEntity>)Session[Constants.SessionDataStoreKeys.EntireShift.ToString()];
                            shipmentList = shipmentManager.GetAllShipmentsByShiftList(shiftList);
                            Session[Key] = shipmentList;
                        }
                        else
                        {
                            StoreGridDataInSession(Constants.SessionDataStoreKeys.EntireShift.ToString());
                            StoreGridDataInSession(Constants.SessionDataStoreKeys.EntireShipment.ToString());
                        }
                    }
                    else
                    {
                        shipmentList = (List<ShipmentEntity>)Session[Key];
                    }
                    ShipmentRadGrid.DataSource = shipmentList;
                }
                break;
            case "EntireShift":
                if (Session[Key] == null && SessionManager.ApplicationUser.SelectedHaulierID != 0)
                {
                    shiftList = shiftManager.GetShiftsByHaulier(SessionManager.ApplicationUser.SelectedHaulierID);
                    if (shiftList != null)
                    {
                        shiftList = shiftList.FindAll(s => (s.ScheduledDate.Date >= RadDate_ShiftFrom.SelectedDate
                                            && s.ScheduledDate.Date <= RadDate_ShiftTo.SelectedDate));
                    }
                    Session[Constants.SessionDataStoreKeys.EntireShift.ToString()] = shiftList;
                }
                else if (SessionManager.ApplicationUser.SelectedHaulierID == 0)
                {
                    return;
                }
                else
                {
                    shiftList = (List<ShiftEntity>)Session[Constants.SessionDataStoreKeys.EntireShift.ToString()];
                }
                break;        }
    }    protected void TranslatePage()
    {
        lblHeader.Text = MyGlobal.SDP_GUI_SCHEDULE_HEADER;        /// Added the code for defect : 5471
        lbl_ShipmentHeader.Text = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_WORKSCHED_LBL_SHIPMEMT + "</span>";
        lbl_LoadingHeader.Text = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_WORKSCHED_LBL_LOADING + "</span>";
        lbl_DischargeHeader.Text = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_WS_DISCHARGING + "</span>";
        //added for 1.06 R2
        lbl_ShipementForVehicle.Text = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_WORKSCHED_LBL_SHIFT + "</span>";
        //translate grid headers
        LoadingRadGrid.Columns[0].HeaderText = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_LOAD_CAPT_LOADID + "</span>";
        LoadingRadGrid.Columns[1].HeaderText = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_WORKSCHED_LBL_TERMINALID + "</span>";
        LoadingRadGrid.Columns[2].HeaderText = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_WORKSCHED_LBL_TERMINALNAME + "</span>";
        LoadingRadGrid.Columns[3].HeaderText = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_WORKSCHED_LBL_LOADSTART + "</span>";
        LoadingRadGrid.Columns[4].HeaderText = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_WORKSCHED_LBL_LOADEND + "</span>";        //added for 1.06 R2
        ShiftOverviewGrid.Columns[0].HeaderText = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_BALANCE_HEADER_PRODUCT + "</span>";
        ShiftOverviewGrid.Columns[1].HeaderText = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_BALANCE_HEADER_PRIOR + "</span>";
        ShiftOverviewGrid.Columns[2].HeaderText = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_BALANCE_HEADER_LOADED + "</span>";
        ShiftOverviewGrid.Columns[3].HeaderText = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_BALANCE_HEADER_DISCHARGE + "</span>";
        ShiftOverviewGrid.Columns[4].HeaderText = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_BALANCE_HEADER_LEFTONBOARD + "</span>";        ShipmentRadGrid.Columns[0].HeaderText = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_BALANCE_HEADER_PRODUCT + "</span>";
        ShipmentRadGrid.Columns[1].HeaderText = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_BALANCE_HEADER_PRIOR + "</span>";
        ShipmentRadGrid.Columns[2].HeaderText = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_BALANCE_HEADER_LOADED + "</span>";
        ShipmentRadGrid.Columns[3].HeaderText = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_BALANCE_HEADER_DISCHARGE + "</span>";
        ShipmentRadGrid.Columns[4].HeaderText = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_BALANCE_HEADER_LEFTONBOARD + "</span>";        DischargeRadGrid.Columns[0].HeaderText = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_WORKSCHED_LBL_DELINO + "</span>";
        DischargeRadGrid.Columns[1].HeaderText = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_WORKSCHED_LBL_SHIPTO + "</span>";
        DischargeRadGrid.Columns[2].HeaderText = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_DISCHARGE_LBL_SITENAME + "</span>";
        DischargeRadGrid.Columns[3].HeaderText = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_DISCHARGE_LBL_DSCHRGSRT + "</span>";
        DischargeRadGrid.Columns[4].HeaderText = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_DISCHARGE_LBL_DSCHGEND + "</span>";        btnAutoRefresh.Text = MyGlobal.SDP_GUI_WS_REFRESH_BUTTON;
        lblFromDate.Text = MyGlobal.SDP_GUI_WORKSCHED_LBL_FROMDATE;
        lblToDate.Text = MyGlobal.SDP_GUI_WORKSCHED_LBL_TODATE;        //ShipmentRadGrid.MasterTableView.DetailTables[0].Columns[0].HeaderText = MyGlobal.SDP_GUI_WORKSCHED_HEADER_ID;
        //ShipmentRadGrid.MasterTableView.DetailTables[0].Columns[1].HeaderText = MyGlobal.SDP_GUI_WORKSCHED_HEADER_TYPE.ToUpper();        LoadingRadGrid.MasterTableView.NoMasterRecordsText = MyGlobal.SDP_GUI_RADGRID_NO_RECORDS_FOUND;
        ShipmentRadGrid.MasterTableView.NoMasterRecordsText = MyGlobal.SDP_GUI_RADGRID_NO_RECORDS_FOUND;
        DischargeRadGrid.MasterTableView.NoMasterRecordsText = MyGlobal.SDP_GUI_RADGRID_NO_RECORDS_FOUND;        //added for 1.06 R2
        lbl_shiftStart.Text = MyGlobal.SDP_GUI_DISCHARGE_LBL_SHIFTSTART;
        lbl_shiftEnd.Text = MyGlobal.SDP_GUI_DISCHARGE_LBL_SHIFTEND;
        lbl_ShipmentStart.Text = MyGlobal.SDP_GUI_WS_SHIPMENT_STARTDATE;
        lbl_ShipmentEnd.Text = MyGlobal.SDP_GUI_WS_SHIPMENT_ENDDATE;
        lbl_ShipmentNo.Text = MyGlobal.SDP_GUI_WORKSCHED_LBL_SHIPMEMT;
    }    protected void ClearSelectedSession()
    {
        foreach (Constants.SessionDataStoreKeys e in Enum.GetValues(typeof(Constants.SessionDataStoreKeys)))
        {
            Session.Remove(e.ToString());
        }
        // Code commented for fixing of defect : 6815.
        //Session.Remove(_sesLastUpdated);
        Session.Remove(_lastShipmentSelect);
        Session.Remove(_lastDischargeSelect);
        Session.Remove(_lastLoadingSelect);
        Session.Remove(_sesLastVehicleSelect);
        //added for 1.06 R2
        Session.Remove(_lastDischargeSelect1);       
        Session.Remove(_lastLoadingSelect1);
    }
    #region CLIENT_EVENT_FUNCTIONS    protected void ReloadShiftPanel(object sender, EventArgs e)
    {
        ClearSelectedSession();
        StoreGridDataInSession(Constants.SessionDataStoreKeys.EntireShift.ToString());
        radAjaxManager.RaisePostBackEvent("UpdateShiftPanel");
    }    protected void radAjaxManager_OnAjaxRequest(object sender, AjaxRequestEventArgs e)
    {
       
        String calledBy = e.Argument.Split('/')[0];
        switch (calledBy)
        {
            case "selectedDateChanged":
                {
                    RefreshHeaders();
                    ClearSelectedSession();
                    StoreGridDataInSession(Constants.SessionDataStoreKeys.EntireShipment.ToString());
                    StoreGridDataInSession(Constants.SessionDataStoreKeys.EntireShift.ToString());
                    PopulateTreeNode();
                    break;
                }
            case "treeNodeSelected":
                {
                    //code modified for 1.06 R2
                    StoreGridDataInSession(Constants.SessionDataStoreKeys.EntireShipment.ToString());
                    //Int64 vehicleId = Int64.Parse(e.Argument.Split('/')[1]);
                    //Int64 shiftIndex = Int64.Parse(e.Argument.Split('/')[2]);
                    String shiftValue = ShiftTreeView.SelectedNode.ParentNode.Value.ToString();
                    String vehicleValue = ShiftTreeView.SelectedValue.ToString();
                    string shiftstart = ShiftTreeView.SelectedNode.ParentNode.Text.ToString();                   
                    List<BalanceEntity> balanceList = new List<BalanceEntity>();
                    Session[_lastShiftValue] = shiftValue;
                    Session[_lastVehicle] = vehicleValue;
                    //vehclelst = Session[_VehicleList].ToString();
                    vehclelst = null;
                    lbl_ShipementForVehicle.Text = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_WORKSCHED_LBL_SHIFT + "-" + shiftstart.ToString() + "-" + vehicleValue.ToString() + "</span>";
                    bool IsVehicleSelected = false;
                    balanceList = balanceManager.GetBalanceListByVehicleOnShift(Int64.Parse(shiftValue), Int64.Parse(vehicleValue), user.SelectedHaulierID);
                    Session[_lastSubmitType] = "Vehicle";
                    IsVehicleSelected = true;
                    if (balanceList.Count > 0)
                    {
                        //txt_shiftStartValue.Text = balanceList[0].ShiftStart.ToString();
                        //txt_shiftEndValue.Text = balanceList[0].ShiftEnd.ToString();
                        if (IsVehicleSelected)
                        {
                            txt_shiftStartValue.Text = (balanceList[0].ShiftStart == null)
                                                            ? MyGlobal.SDP_GUI_NOT_STARTED
                                                            : balanceList[0].ShiftStart <= DateTime.MinValue
                                                                ? MyGlobal.SDP_GUI_NOT_STARTED
                                                                : balanceList[0].ShiftStart.ToString();                            txt_shiftEndValue.Text = (balanceList[0].ShiftEnd == null)
                                                            ? MyGlobal.SDP_GUI_NOT_FINISHED
                                                            : balanceList[0].ShiftEnd <= DateTime.MinValue
                                                                ? MyGlobal.SDP_GUI_NOT_FINISHED
                                                                : balanceList[0].ShiftEnd.ToString();
                }
                        else
                {
                            txt_shiftStartValue.Text = "--";
                            txt_shiftEndValue.Text = "--";
                        }                        //BalanceRadGrid.MasterTableView.Columns[0].t
                        ShiftOverviewGrid.DataSource = balanceList;
                        Session[_lastBalanceResult] = balanceList;
                        GridGroupByExpression expression1 = GridGroupByExpression.Parse("ShipmentId [" + MyGlobal.SDP_GUI_BALANCE_CAPT_SHIPMENTID + "] Group By ActualSequence");
                        ShiftOverviewGrid.MasterTableView.GroupByExpressions.Add(expression1);
                        ShiftOverviewGrid.DataBind();
                            }
                    if (balanceList.Count == 0)
                        {
                        txt_shiftStartValue.Text = "";
                        txt_shiftEndValue.Text = "";
                        lbl_ShipementForVehicle.Text = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_WORKSCHED_LBL_SHIFT + "</span>";
                        ShiftOverviewGrid.DataSource = balanceList;                        GridGroupByExpression expression1 = GridGroupByExpression.Parse("ShipmentId [" + MyGlobal.SDP_GUI_BALANCE_CAPT_SHIPMENTID + "] Group By ActualSequence");
                        ShiftOverviewGrid.MasterTableView.GroupByExpressions.Add(expression1);
                        ShiftOverviewGrid.DataBind();                            }                    break;
                        }
            case "shipmentNodeSelected":
                {
                    StoreGridDataInSession(Constants.SessionDataStoreKeys.EntireShipment.ToString());
                    Int64 shipmentID = Int64.Parse(e.Argument.Split('/')[1]);
                    Int64 vehicleId = Int64.Parse(e.Argument.Split('/')[2]);                   
                    Session[_lastShipmentSelect] = shipmentID.ToString();
                    bool IsShipmenteSelected = false;
                    lbl_ShipmentHeader.Text = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_WORKSCHED_LBL_SHIPMEMT + " <" + shipmentID.ToString() + ">" + "</span>";
                    List<BalanceEntity> shipmentInstance;
                    shipmentInstance = balanceManager.GetBalanceEntityFromShipment(shipmentID, vehicleId);
                    IsShipmenteSelected = true;
                    if (shipmentInstance.Count > 0)
                        {
                        if (IsShipmenteSelected)
                        {
                            txt_ShipmentStartValue.Text = (shipmentInstance[0].ShipmentStart == null)
                                                            ? MyGlobal.SDP_GUI_NOT_STARTED
                                                            : shipmentInstance[0].ShipmentStart <= DateTime.MinValue
                                                                ? MyGlobal.SDP_GUI_NOT_STARTED
                                                                : shipmentInstance[0].ShipmentStart.ToString();
                       
                            txt_ShipmentEndValue.Text = (shipmentInstance[0].ShipmentEnd == null)
                                                            ? MyGlobal.SDP_GUI_NOT_FINISHED
                                                            : shipmentInstance[0].ShipmentEnd <= DateTime.MinValue
                                                                ? MyGlobal.SDP_GUI_NOT_FINISHED
                                                                : shipmentInstance[0].ShipmentEnd.ToString();
                            txt_ShipmentNo.Text = (shipmentInstance[0].ShipmentId == null)
                                                            ? MyGlobal.SDP_GUI_NOT_STARTED
                                                                : shipmentInstance[0].ShipmentId.ToString();                            }
                            else
                            {
                            txt_ShipmentStartValue.Text = "--";
                            txt_ShipmentEndValue.Text = "--";
                            txt_ShipmentNo.Text = "--";
                            }                        }
                    if (shipmentInstance.Count == 0)
                        {
                        txt_ShipmentStartValue.Text = "";
                        txt_ShipmentEndValue.Text = "";
                        txt_ShipmentNo.Text = "";
                        lbl_ShipmentHeader.Text = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_WORKSCHED_LBL_SHIPMEMT + "</span>";
                        }
                    loadingDetailWsList = new List<LoadingDetailExtraEntity>();
                    loadingDetailWsList = loadingDetailManager.GetLoadingDetailByShipmentId(shipmentID);
                    LoadingRadGrid.DataSource = loadingDetailWsList;
                    LoadingRadGrid.DataBind();
                    dischargeDetailWsList = new List<DischargeDetailExtraEntity>();
                    dischargeDetailWsList = dischargeDetailManager.GetDischargesByShipmentId(shipmentID);
                    DischargeRadGrid.DataSource = dischargeDetailWsList;
                    DischargeRadGrid.DataBind();                   
                    lbl_LoadingHeader.Text = MyGlobal.SDP_GUI_WORKSCHED_LBL_LOADING;
                    lbl_DischargeHeader.Text = MyGlobal.SDP_GUI_WS_DISCHARGING;                    Session.Remove(_lastShipmentSelect);
                    Session.Remove(_lastLoadingSelect);
                    Session.Remove(_lastDischargeSelect);
                    Session.Remove(_lastDischargeHeader);
                    Session.Remove(_lastLoadHeader);                    ShipmentRadGrid.DataSource = shipmentInstance;
                    ShipmentRadGrid.Rebind();                   
                    break;
                }
 
               
            case "sendToGsap":
                {                    ///
                    /// Check for vehicles inside shifts and send them!
                    ///                    Int64 vehicleId = Int64.Parse(e.Argument.Split('/')[1]);
                    Int64 shiftIndex = Int64.Parse(e.Argument.Split('/')[2]);                    Session[_sesSelShift] = ShiftTreeView.SelectedNode.Text;
                    // on clip to gsap
                    var entity = new FileExportImportEntity
                    {
                        State = FileLoaderState.ProcessToGsap,
                        Type = GsapFileType.Gsap025
                    };
                   
                    var manager = new GsapFileImportStateManager(entity);
                    manager.SetShiftForExport(shiftIndex);
                    manager.ProcessStateObject(entity);
                    Session[_025FilePath] = manager.retFilePath;
                    Session[_025FileName] = manager.retFileName;                    //R2 1.17 audit trail
                     List<ShipmentEntity> tempshipmentList = (List<ShipmentEntity>)Session["EntireShipment"];
                    tempshipmentList = tempshipmentList.FindAll(sh => sh.Shift_ID == shiftIndex)
                                                        .OrderBy(x => x.Vehicle_ID).ToList();
                    foreach(ShipmentEntity item in tempshipmentList)
                    {
                        auditLogManager.CreateLogOnSendToGSAP(user.UserID,int.Parse(user.SelectedHaulierID.ToString()),
                            item.Vehicle_ID, item.Shift_ID, item.Shipment_ID, 0, 0, 0, 0, item.ShipmentState, manager.retFileName);
                    }
                    ClearSelectedSession();
                    StoreGridDataInSession(Constants.SessionDataStoreKeys.EntireShipment.ToString());
                    PopulateTreeNode();
                    break;
                }
            case "sendToDevice":
                {
                    Int64 vehicleId = Int64.Parse(e.Argument.Split('/')[1]);
                    Int64 shiftIndex = Int64.Parse(e.Argument.Split('/')[2]);
                   
                    // -9999 indicates a shift node is clicked. Therefore no vehicle information
                    if (vehicleId == -9999)
                    {
                        jobManager.AsyncWorkCompleted += (s, ea) =>
                        {
                            if (ea.Entity.State == JobState.PENDING)
                                jobManager.ProcessStateObjectAsync(jobManager.ProcessedObject);
                        };
                        jobManager.SetJobData(shiftIndex);
                        jobManager.ProcessStateObject(jobManager.ProcessedObject);                        // Set shipment states to Sent (half moon)
                        List<ShipmentEntity> sentShipmentList = shipmentManager.GetAllShipmentsByShiftId(shiftIndex).FindAll(s => s.ShipmentState == ShipmentState.NewShiftReady);
                        foreach (ShipmentEntity se in sentShipmentList)
                        {
                            shipmentManager.UpdateShipmentState(se.Shipment_ID, ShipmentState.ShiftSent);
                        }
                        ClearSelectedSession();
                        StoreGridDataInSession(Constants.SessionDataStoreKeys.EntireShipment.ToString());
                        PopulateTreeNode();                        //if (chkBx_autoRefresh.Checked == true)
                        //{
                        //    PopulateTreeNode();
                        //}
                    }
                    else
                    {
                        jobManager.AsyncWorkCompleted += (s, ea) =>
                        {
                            if (ea.Entity.State == JobState.PENDING)
                                jobManager.ProcessStateObjectAsync(jobManager.ProcessedObject);
                        };
                        //jobManager.SetJobData(shiftIndex, SessionManager.ApplicationUser.SelectedHaulierID, vehicleId);
                        VehicleEntity objVehicleEntity = new VehicleEntity();
                        objVehicleEntity = jobManager.SetJobData(shiftIndex, SessionManager.ApplicationUser.SelectedHaulierID, vehicleId);
                        if (objVehicleEntity == null)
                        {
                            RadWindowManager1.RadAlert(MyGlobal.SDP_GUI_WS_HAULIER_DOES_NOT_EXISTS, 300, 120, null, null);
                        }
                       
                        jobManager.ProcessStateObject(jobManager.ProcessedObject);                        // Set shipment states to Sent (half moon)
                        List<ShipmentEntity> sentShipmentList = shipmentManager.GetShipmentByVehicleId(vehicleId).FindAll(s => s.ShipmentState == ShipmentState.NewShiftReady &&
                                                                                                                              s.Haulier_ID == SessionManager.ApplicationUser.SelectedHaulierID &&
                                                                                                                              s.Shift_ID == shiftIndex);
                        foreach (ShipmentEntity se in sentShipmentList)
                        {
                            shipmentManager.UpdateShipmentState(se.Shipment_ID, ShipmentState.ShiftSent);
                        }
                        ClearSelectedSession();
                        StoreGridDataInSession(Constants.SessionDataStoreKeys.EntireShipment.ToString());
                        PopulateTreeNode();
                        //if (chkBx_autoRefresh.Checked == true)
                        //{
                        //    PopulateTreeNode();
                        //}
                    }                    //defect:6019:tree view should remain open after data sent
                    RadTreeNode selnode = new RadTreeNode();
                    selnode = ShiftTreeView.FindNodeByText(vehicleId.ToString());                    if (selnode != null)
                    { selnode.Selected = true; }                    break;
                }
            //case "CheckForNewData":
            //    {  
            //        RefreshHeaders();
            //        if (chkBx_autoRefresh.Checked == false)
            //        {
            //            break;
            //        }
            //        if (Session[_sesLastUpdated] == null)
            //        {
            //            Session[_sesLastUpdated] = DateTime.UtcNow;
            //            break;
            //        }
            //        else
            //        {
            //            DateTime lastUpdated = (DateTime)Session[_sesLastUpdated];
            //            List<ShipmentEntity> temp = shipmentManager.GetLatestShipmentCreatedRange(lastUpdated, DateTime.UtcNow);
            //            temp.AddRange(shipmentManager.GetLatestShipmentUpdatedRange(lastUpdated, DateTime.UtcNow));
            //            temp.Sort((x, y) => y.DateOfShipment.CompareTo(x.DateOfShipment));
            //            temp = temp.FindAll(s => s.Haulier_ID == user.SelectedHaulierID);
            //            String shipmentContent = "";            //            if (temp.Count > 0)
            //            {
            //                UpdateShipmentSection(true);
            //                ClearSelectedSession();
            //                Session.Remove(_sesLastUpdated);
            //                StoreGridDataInSession(Constants.SessionDataStoreKeys.EntireShipment.ToString());
            //                Session[_sesLastUpdated] = DateTime.UtcNow;
            //                String updatetime = "";
            //                foreach (ShipmentEntity se in temp)
            //                {
            //                    if (se.LastUpdated < DateTime.UtcNow.AddDays(-30))
            //                    {
            //                        updatetime = "";
            //                    }
            //                    else
            //                    {
            //                        updatetime = se.LastUpdated.GetValueOrDefault().ToString();
            //                    }
            //                    shipmentContent += "<div class='shipmentEntity'>" +
            //                            MyGlobal.SDP_GUI_BALANCE_CAPT_SHIPMENTID + " " + se.Shipment_ID + "<br>" +
            //                            MyGlobal.SDP_GUI_SHIFTOVRVIEW_LBL_VEHICLEID  + " " + se.Vehicle_ID + "<br>" +
            //                            MyGlobal.SDP_GUI_WS_SHIPMENT_DATE + " " + se.DateOfShipment.ToShortDateString() + "<br>" +
            //                            MyGlobal.SDP_GUI_WS_CURRENT_STATE + " " + se.ShipmentState + "<br>" +
            //                            MyGlobal.SDP_GUI_WS_CREATED_TIME + " " + se.Created + "<br>" +
            //                            MyGlobal.SDP_GUI_WS_UPDATED_TIME + " " + updatetime + "<br>" +
            //                            "</div><br>";
            //                }
            //                PopulateTreeNode();
            //                //lblHistoryHolder.Text = shipmentContent + lblHistoryHolder.Text;
            //                break;
            //            }
            //        }
            //        break;
            //    }
            case "dropShift":
                {
                    Int64 shiftIndex = Int64.Parse(e.Argument.Split('/')[1]);
                    Int32 entriesDeleted = shiftManager.DeleteShiftDeep(shiftIndex);
                   
                    List<ShipmentEntity> tempshipmentList = (List<ShipmentEntity>)Session["EntireShipment"];
                    tempshipmentList = tempshipmentList.FindAll(sh => sh.Shift_ID == shiftIndex)
                                                        .OrderBy(x => x.Vehicle_ID).ToList();
                    if (entriesDeleted > 0)
                    {
                        RadWindowManager1.RadAlert(MyGlobal.SDP_GUI_WS_SHIFT_DELETED, 300, 120, MyGlobal.SDP_GUI_SUCCESSFUL, null);                        //R2 1.17 Audit Trail
                        foreach (ShipmentEntity item in tempshipmentList)
                        {
                            auditLogManager.CreateLogOnDeleteShift(user.UserID, user.SelectedHaulierID,
                                item.Vehicle_ID, item.Shift_ID,item.Shipment_ID);
                        }
                        ClearSelectedSession();
                        StoreGridDataInSession(Constants.SessionDataStoreKeys.EntireShipment.ToString());
                        PopulateTreeNode();
                    }
                    else
                    {
                        RadWindowManager1.RadAlert(MyGlobal.SDP_GUI_WS_SHIFT_NOT_EXIST_REFRESH, 300, 170, MyGlobal.SDP_GUI_SUCCESSFUL, null);
                    }
                    break;
                }
        }
    }    //code added for 1.05 R2
    protected void LoadingRadGrid_BatchEditCommand(object sender, GridBatchEditingEventArgs e)
    {
        //var loadingDal = new LoadingDal();
        //foreach (GridBatchEditingCommand command in e.Commands)
        //{
        //    if ((command.Type == GridBatchEditingCommandType.Insert))
        //    {
        //        Int64 shipmentID = Convert.ToInt64(ShiftTreeView.SelectedNode.Value);
        //        GridEditableItem editedItem = (GridEditableItem)e.Item;
        //        Hashtable newValues = new Hashtable();
        //        e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);
        //        Int64 plantId = Convert.ToInt64(newValues["Plant_ID"]);
        //        var loading = new LoadingEntity
        //        {
        //            Shipment_ID = shipmentID,
        //            Plant_ID = plantId,
        //        };
        //        loading.Loading_ID = loadingDal.CreateLoading(loading).Loading_ID;
        //    }
        //}
        //loadingDetailWsList = new List<LoadingDetailExtraEntity>();
        //loadingDetailWsList = loadingDetailManager.GetLoadingDetailByShipmentId(Convert.ToInt64(ShiftTreeView.SelectedNode.Value));
        //LoadingRadGrid.DataSource = loadingDetailWsList;
        //LoadingRadGrid.DataBind();    }    protected void LoadingRadGrid_UpdateCommand(object source, GridCommandEventArgs e)
    {
        if (e.CommandName == RadGrid.UpdateCommandName)
        {
            RadWindowManager1.RadConfirm(HTMLEncoder.Encode(MyGlobal.SDP_ALERT_WHILE_UPDATE_LOAD), "confirmCallBackFn", 400, 100, null, null);
        }
        var loadingDal = new LoadingDal();
       
        //GridEditableItem editedItem = (GridEditableItem)e.Item;
        Hashtable newValues = (e.CommandArgument as GridBatchEditingEventArgument).NewValues;
        Int64 plantId = Convert.ToInt64(newValues["Plant_ID"]);
        var loading = new LoadingEntity
        {
            Loading_ID=loadId,
            Plant_ID = plantId,
        };
        loading.Loading_ID = loadingDal.UpdateLoadingByLoadingID(loading).Loading_ID;
       
        loadingDetailWsList = new List<LoadingDetailExtraEntity>();
        loadingDetailWsList = loadingDetailManager.GetLoadingDetailByShipmentId(Convert.ToInt64(ShiftTreeView.SelectedNode.Value));
        LoadingRadGrid.DataSource = loadingDetailWsList;
        LoadingRadGrid.DataBind();//.Rebind();//.DataBind();
       
    }    protected void LoadingRadGrid_InsertCommand(object source, GridCommandEventArgs e)
    {
        if (e.CommandName == RadGrid.InitInsertCommandName)
        {
            RadWindowManager1.RadConfirm(HTMLEncoder.Encode(MyGlobal.SDP_ALERT_WHILE_ADD_NEW_LOAD), "confirmCallBackFn", 400, 100, null, null);
        }
        //RadWindowManager1.RadAlert("add new record", 330, 150, "new record", "callBackFn");
        var loadingDal = new LoadingDal();
        Int64 shipmentID = Convert.ToInt64(ShiftTreeView.SelectedNode.Value);
        //GridEditableItem editedItem = (GridEditableItem)e.Item;
        Hashtable newValues = (e.CommandArgument as GridBatchEditingEventArgument).NewValues;
        Int64 plantId = Convert.ToInt64(newValues["Plant_ID"]);
        var loading = new LoadingEntity
        {
            Shipment_ID = shipmentID,
            Plant_ID = plantId,
            Planned=false,
        };
        loading.Loading_ID = loadingDal.CreateLoading(loading).Loading_ID;        loadingDetailWsList = new List<LoadingDetailExtraEntity>();
        loadingDetailWsList = loadingDetailManager.GetLoadingDetailByShipmentId(Convert.ToInt64(ShiftTreeView.SelectedNode.Value));
        LoadingRadGrid.DataSource = loadingDetailWsList;
        LoadingRadGrid.DataBind();
            }
    protected void LoadingRadGrid_CancelCommand(object source, GridCommandEventArgs e)
    {
        //if (e.CommandName == RadGrid.CancelCommandName)
        //{
        //    e.Canceled = true;
        //    LoadingRadGrid.Rebind();
        //}
       
        //Int64 shipmentID = Convert.ToInt64(ShiftTreeView.SelectedNode.Value);
        //loadingDetailWsList = new List<LoadingDetailExtraEntity>();
        //loadingDetailWsList = loadingDetailManager.GetLoadingDetailByShipmentId(Convert.ToInt64(ShiftTreeView.SelectedNode.Value));
        //LoadingRadGrid.DataSource = loadingDetailWsList;
        //LoadingRadGrid.DataBind();
    }    protected void DischargeRadGrid_BatchEditCommand(object source, GridBatchEditingEventArgs e)
    {    }     protected void DischargeRadGrid_InsertCommand(object source, GridCommandEventArgs e)
     {
         if (e.CommandName == RadGrid.InitInsertCommandName)
         {
             RadWindowManager1.RadConfirm(HTMLEncoder.Encode(MyGlobal.SDP_ALERT_WHILE_ADD_NEW_LOAD), "confirmCallBackFn", 400, 100, null, null);
         }
         var DischargeDal = new DischargeDal();
         Int64 shipmentID = Convert.ToInt64(ShiftTreeView.SelectedNode.Value);
         //GridEditableItem editedItem = (GridEditableItem)e.Item;
         Hashtable newValues = (e.CommandArgument as GridBatchEditingEventArgument).NewValues;
         Int64 dischargeId = Convert.ToInt64(newValues["Discharge_ID"]);
         Int64 shipTo = Convert.ToInt64(newValues["Site_ID"]);
         DateTime? DischargeStartTime = DateTime.Now;
         DateTime? DischargeEndTime = DateTime.Now;
         var discharge = new DischargeEntity
         {
             Shipment_ID = shipmentID,            
             Site_ID = shipTo,
             Discharge_ID = dischargeId,
             Planned=false,
             Job_ID = new Guid(),
         };
         discharge.Discharge_ID = DischargeDal.CreateDischarge(discharge).Discharge_ID;
         dischargeDetailWsList = new List<DischargeDetailExtraEntity>();
         dischargeDetailWsList = dischargeDetailManager.GetDischargesByShipmentId(Convert.ToInt64(ShiftTreeView.SelectedNode.Value));
         DischargeRadGrid.DataSource = dischargeDetailWsList;
         DischargeRadGrid.DataBind();            
     }     protected void DischargeRadGrid_UpdateCommand(object source, GridCommandEventArgs e)
     {
         if (e.CommandName == RadGrid.UpdateCommandName)
         {
             RadWindowManager1.RadConfirm(HTMLEncoder.Encode(MyGlobal.SDP_ALERT_WHILE_UPDATE_LOAD), "confirmCallBackFn", 400, 100, null, null);
         }
       var DischargeDal = new DischargeDal();
       
        //GridEditableItem editedItem = (GridEditableItem)e.Item;
        Hashtable newValues = (e.CommandArgument as GridBatchEditingEventArgument).NewValues;
        Int64 dischargeId = Convert.ToInt64(newValues["Discharge_ID"]);
        Int64 shipTo = Convert.ToInt64(newValues["Site_ID"]);
        DateTime? DischargeStartTime = DateTime.Now;       
         var discharge = new DischargeEntity
         {
             Discharge_ID = dischargeId,
             Site_ID = shipTo,
             Job_ID = new Guid(),         };
         discharge.Discharge_ID = DischargeDal.UpdateDischargeByDischargeId(discharge).Discharge_ID;         dischargeDetailWsList = new List<DischargeDetailExtraEntity>();
         dischargeDetailWsList = dischargeDetailManager.GetDischargesByShipmentId(Convert.ToInt64(ShiftTreeView.SelectedNode.Value));
         DischargeRadGrid.DataSource = dischargeDetailWsList;
         DischargeRadGrid.DataBind();
     }     protected void CompartmentLevelLoadRadGrid_BatchEditCommand(object source, GridBatchEditingEventArgs e)
    {    }
    protected void CompartmentLevelLoadRadGrid_InsertCommand(object source, GridCommandEventArgs e)
     {     }
    protected void CompartmentLevelLoadRadGrid_UpdateCommand(object source, GridCommandEventArgs e)
    {    }
   
    //End of 1.05 R2    //code added for 1.37 R2
    public bool Between(int? DiffLoading, decimal Mintollerence, decimal Maxtollerence)
    {
        bool inclusive = false;
        return inclusive
            ? Mintollerence <= DiffLoading && DiffLoading <= Maxtollerence
            : Mintollerence < DiffLoading && DiffLoading < Maxtollerence;
    }
    protected void ShipmentRadGrid_ItemDataBound(object sender, GridItemEventArgs e)
    {
      
        if (e.Item is GridDataItem)
        {            GridDataItem dataItem = (GridDataItem)e.Item;
           
            foreach (GridBoundColumn column in ShipmentRadGrid.Columns)
            {
                if (column is GridEditableColumn && dataItem[column].Text == " ")               
                {
                    dataItem[column].CssClass = "missingdata";
                }
            }
            if (dataItem["PriorToLoad"].Text == "&nbsp;")
            {
                dataItem["PriorToLoad"].Text = "";
            }
            else  if (Convert.ToInt32(dataItem["PriorToLoad"].Text) != 0)
            {
                dataItem["PriorToLoad"].CssClass = "ErrorHighlight";
            }
            if (dataItem["LeftOnBoard"].Text == "&nbsp;")
            {
                dataItem["LeftOnBoard"].Text = "";
            }
            else if (Convert.ToInt32(dataItem["LeftOnBoard"].Text) > 0)
            {
                dataItem["LeftOnBoard"].CssClass = "ErrorHighlight";
        }        }    }    protected void CompartmentLevelLoadingRadGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        if (!Page.IsPostBack)
        {
            ClearSelectedSession();
            if (user.HaulierLocations.Count == 0)
            { return; }
            StoreGridDataInSession(Constants.SessionDataStoreKeys.EntireShipment.ToString());
            TranslatePage();
            PopulateTreeNode();
            /// Added the code for defect : 5471
            // ShipmentRadGrid.MasterTableView.GetColumn("Shipment_ID").HeaderText = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_SHIPMENT_ALL_VEHICLE + "</span>";
        }
        else
        {
            StoreGridDataInSession(Constants.SessionDataStoreKeys.EntireShipment.ToString());
        }
    }
    protected void ProductLevelLoadingRadGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        if (!Page.IsPostBack)
        {
            ClearSelectedSession();
            if (user.HaulierLocations.Count == 0)
            { return; }
            StoreGridDataInSession(Constants.SessionDataStoreKeys.EntireShipment.ToString());
            TranslatePage();
            PopulateTreeNode();
            /// Added the code for defect : 5471
            // ShipmentRadGrid.MasterTableView.GetColumn("Shipment_ID").HeaderText = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_SHIPMENT_ALL_VEHICLE + "</span>";
        }
        else
        {
            StoreGridDataInSession(Constants.SessionDataStoreKeys.EntireShipment.ToString());
        }
    }
   
    protected void CompartmentLevelLoadRadGrid_ItemDataBound(object sender, GridItemEventArgs e)
    {
        List<LoadingDetailExtraEntity> CompartmentTabListinstance = (List<LoadingDetailExtraEntity>)Session["_storeCompartmentLoadTable"];
        List<LoadingDetailExtraEntity> ProductTabListinstance = (List<LoadingDetailExtraEntity>)Session["_storeProductLoadTable"];
        HaulierSettingEntity haulierLocList = (HaulierSettingEntity)Session[_loadhaulierLoc];
        Decimal Maxtollerence = haulierLocList.PlannedVsActualLoadingHigh;
        Decimal Mintollerence = haulierLocList.PlannedVsActualLoadingLow;       
        if (e.Item is GridDataItem)
        {
            RadGrid cmpLoadGrid = sender as RadGrid;
            GridDataItem dataItem = (GridDataItem)e.Item;
            int ActualLoadQty = (dataItem["ActualLoadQty"].Text=="&nbsp;")?0:Convert.ToInt32(dataItem["ActualLoadQty"].Text);
            int PlannedLoadQty = (dataItem["PlannedLoadQty"].Text=="&nbsp;")?0:Convert.ToInt32(dataItem["PlannedLoadQty"].Text);
            bool blnColumnNull = false;            int cmpDiffLoading = ActualLoadQty - PlannedLoadQty; //Convert.ToInt32(dataItem["ActualLoadQty"].Text) - Convert.ToInt32(dataItem["PlannedLoadQty"].Text);            foreach (GridColumn column in cmpLoadGrid.Columns)
            {
                if (column is GridEditableColumn && dataItem[column].Text == "&nbsp;")
                {
                    dataItem[column].CssClass = "missingdata";                 
                    blnColumnNull = true;
                }
            }            if (dataItem["PriorToLoad"].Text == "&nbsp;")
            {
                dataItem["PriorToLoad"].Text = "";
            }
            else if (Convert.ToInt32(dataItem["PriorToLoad"].Text) != 0)
            {
                dataItem["PriorToLoad"].CssClass = "ErrorHighlight";
                //dataItem["PTL"].BackColor = System.Drawing.Color.Brown;
                //dataItem["PTL"].Font.Bold = true;
            }            if (dataItem["ActualLoadQty"].Text == "&nbsp;")
            {
                dataItem["ActualLoadQty"].Text = "";
            }
            // -100 < -101 && -101 > 100            //else if (blnColumnNull)
            //{
            //}
            else if (!Between(cmpDiffLoading, Mintollerence, Maxtollerence))
            {                //List<LoadingDetailExtraEntity> results = ProductTabListinstance.FindAll(CompartmentTabListinstance.Contains();
                //List<LoadingDetailExtraEntity> results = ProductTabListinstance.Where(p => CompartmentTabListinstance.Any(p2 => p2.ActualProductName == p.ActualProductName && p2.PlannedProductName == p.PlannedProductName)).ToList();
                Int32? ActualQuantity = 0;// = ProductTabListinstance[0].ActualQuantity
                Int32? PlannedQuantity = 0;
                foreach (LoadingDetailExtraEntity lst in ProductTabListinstance)
                {
                    if (lst.ActualProductName == dataItem["ActualLoadProd"].Text)
                    {
                        ActualQuantity = lst.ActualQuantity;
                        PlannedQuantity = lst.PlannedQuantity;
                    }                }                Int32? cmpDiffLoading1 = ActualQuantity - PlannedQuantity;
                if (Between(cmpDiffLoading1, Mintollerence, Maxtollerence))
                {
                    dataItem["ActualLoadQty"].CssClass = "CompartmentTolerenceError";//green
                                    }
                else
                {
                    dataItem["ActualLoadQty"].CssClass = "ProductTolerenceError";//magenta
                   
                }
            }
        }
       
    }
  
    protected void ProductLevelLoadRadGrid_ItemDataBound(object sender, GridItemEventArgs e)
    {
        List<LoadingDetailExtraEntity> CompartmentTabListinstance = (List<LoadingDetailExtraEntity>)Session["_storeCompartmentLoadTable"];
        List<LoadingDetailExtraEntity> ProductTabListinstance = (List<LoadingDetailExtraEntity>)Session["_storeProductLoadTable"];
        HaulierSettingEntity haulierLocList = (HaulierSettingEntity)Session[_loadhaulierLoc];        Decimal Maxtollerence = haulierLocList.PlannedVsActualLoadingHigh;
        Decimal Mintollerence = haulierLocList.PlannedVsActualLoadingLow;
       
        if (e.Item is GridDataItem)
        {
            bool IsTollerence = false;
            RadGrid prdLoadGrid = sender as RadGrid;
            GridDataItem dataItem = (GridDataItem)e.Item;
            int ActualLoadQty = (dataItem["ActualLoadQty"].Text == "&nbsp;") ? 0 : Convert.ToInt32(dataItem["ActualLoadQty"].Text);
            int PlannedLoadQty = (dataItem["PlannedLoadQty"].Text == "&nbsp;") ? 0 : Convert.ToInt32(dataItem["PlannedLoadQty"].Text);
            bool blnColumnNull = false;
            //int DiffLoading = Convert.ToInt32(dataItem["ActualLoadQty"].Text) - Convert.ToInt32(dataItem["PlannedLoadQty"].Text);
            int prdDiffLoading = ActualLoadQty - PlannedLoadQty;
            foreach (GridColumn column in prdLoadGrid.Columns)
            {
                if (column is GridEditableColumn && dataItem[column].Text == "&nbsp;")
                {
                    dataItem[column].CssClass = "missingdata";
                    blnColumnNull = true;
                }
            }
           
            if (dataItem["PriorToLoadQty"].Text == "&nbsp;")
            {
                dataItem["PriorToLoadQty"].Text = "";
            }
            else if (Convert.ToInt32(dataItem["PriorToLoadQty"].Text) != 0)
            {
                dataItem["PriorToLoadQty"].CssClass = "ErrorHighlight";
               
            }            if (dataItem["ActualLoadQty"].Text == "&nbsp;")
            {
                dataItem["ActualLoadQty"].Text = "";
            }
            //else if (blnColumnNull)
            //{
            //}            else if (!Between(prdDiffLoading, Mintollerence, Maxtollerence))
            {
                //List<LoadingDetailExtraEntity> results = ProductTabListinstance.FindAll(CompartmentTabListinstance.Contains();
                //List<LoadingDetailExtraEntity> results = CompartmentTabListinstance.Where(p => ProductTabListinstance.Any(p2 => p2.ActualProductName == p.ActualProductName && p2.PlannedProductName == p.PlannedProductName )).ToList();
                Int32? ActualQuantity = 0;// = ProductTabListinstance[0].ActualQuantity
                Int32? PlannedQuantity = 0;
                bool blnMegentaColor = false;
                foreach (LoadingDetailExtraEntity lst in CompartmentTabListinstance)
                {
                    if (lst.ActualProductName == dataItem["ActualLoadProd"].Text)
                    {
                        ActualQuantity = lst.ActualQuantity;
                        PlannedQuantity = lst.PlannedQuantity;
                    }
                    Int32? prdDiffLoading1 = ActualQuantity - PlannedQuantity;
                    //int DiffLoading1 = Convert.ToInt32(results[0].ActualQuantity - results[0].PlannedQuantity);
                    if (!blnMegentaColor)
                    {
                        if (!Between(prdDiffLoading1, Mintollerence, Maxtollerence))
                        {
                            blnMegentaColor = true;
                        }
                    }                }                //Int32? DiffLoading1 = ActualQuantity - PlannedQuantity;
                //int DiffLoading1 = Convert.ToInt32(results[0].ActualQuantity - results[0].PlannedQuantity);
                if (blnMegentaColor)
                {
                    dataItem["ActualLoadQty"].CssClass = "ProductTolerenceError";//megenta
                    //dataItem["ActualLoadQty"].CssClass = "ErrorHighlight";
                   
                }
                //else
                //{
                //    dataItem["ActualLoadQty"].CssClass = "ProductTolerenceError";//megenta
                //}
            }           
        }
       
    }
    protected void CompartmentLevelDischargeRadGrid_ItemDataBound(object sender, GridItemEventArgs e)
    {
        List<DischargeDetailExtraEntity> dischargeTabListinstance = (List<DischargeDetailExtraEntity>)Session["_storeCompartmentDischargeTable"];                  
        List<DischargeDetailExtraEntity> ProductTabinstance = (List<DischargeDetailExtraEntity>)Session["_storeProductDischargeTable"];
        HaulierSettingEntity haulierLocList = (HaulierSettingEntity)Session[_loadhaulierLoc];
        Decimal Maxtollerence = haulierLocList.PlannedVsActualDeliveryHigh;
        Decimal Mintollerence = haulierLocList.PlannedVsActualDeliveryLow;
        if (e.Item is GridDataItem)
        {
            RadGrid cmpDischargeGrid = sender as RadGrid;
            GridDataItem dataItem = (GridDataItem)e.Item;
            int ActualDischargeQty = (dataItem["ActualDischargeQty"].Text == "&nbsp;") ? 0 : Convert.ToInt32(dataItem["ActualDischargeQty"].Text);
            int PlannedDischargeQty = (dataItem["PlannedDischargeQty"].Text == "&nbsp;") ? 0 : Convert.ToInt32(dataItem["PlannedDischargeQty"].Text);
            bool blnColumnNull = false;            int cmpDiffDischarge = ActualDischargeQty - PlannedDischargeQty;
            //int DiffLoading = Convert.ToInt32(dataItem["ActualDischargeQty"].Text) - Convert.ToInt32(dataItem["PlannedDischargeQty"].Text);
            foreach (GridColumn column in cmpDischargeGrid.Columns)
            {
                if (column is GridEditableColumn && dataItem[column].Text == "&nbsp;")
                {
                    dataItem[column].CssClass = "missingdata";                 
                    blnColumnNull = true;
                }
            }
            if (dataItem["LeftOnBoard"].Text == "&nbsp;")
            {
                dataItem["LeftOnBoard"].Text = "";
            }
            else if (Convert.ToInt32(dataItem["LeftOnBoard"].Text) > 0)
            {
                dataItem["LeftOnBoard"].CssClass = "ErrorHighlight";
                //dataItem["LOB"].BackColor = System.Drawing.Color.Brown;
                //dataItem["LOB"].Font.Bold = true;
            }
            if (dataItem["ActualDischargeQty"].Text == "&nbsp;")
            {
                dataItem["ActualDischargeQty"].Text = "";
            }
            else if (!Between(cmpDiffDischarge, Mintollerence, Maxtollerence))
            {               
               // List<DischargeDetailExtraEntity> results = ProductTabinstance.Where(p => dischargeTabListinstance.Any(p2 => p2.ActualProductName == p.ActualProductName && p2.PlannedProductName == p.PlannedProductName)).ToList();
                //int DiffLoading1 = Convert.ToInt32(results[0].ActualQuantity - results[0].PlannedQuantity);                Int32? ActualQuantity = 0;// = ProductTabListinstance[0].ActualQuantity
                Int32? PlannedQuantity = 0;
                foreach (DischargeDetailExtraEntity lst in ProductTabinstance)
                {
                    if (lst.ActualProductName == dataItem["ActualDischargeProd"].Text)
                    {
                        ActualQuantity = lst.ActualQuantity;
                        PlannedQuantity = lst.PlannedQuantity;
                    }                }
                Int32? cmpDiffDischarge1 = ActualQuantity - PlannedQuantity;
                if (Between(cmpDiffDischarge1, Mintollerence, Maxtollerence))
                {
                    dataItem["ActualDischargeQty"].CssClass = "CompartmentTolerenceError";//green
                }
                else
                {
                    dataItem["ActualDischargeQty"].CssClass = "ProductTolerenceError";//magenta
                }              
            }        }
       
    }
    protected void ProductLevelDischargeRadGrid_ItemDataBound(object sender, GridItemEventArgs e)
    {
        List<DischargeDetailExtraEntity> dischargeTabListinstance = (List<DischargeDetailExtraEntity>)Session["_storeCompartmentDischargeTable"];
        List<DischargeDetailExtraEntity> ProductTabinstance = (List<DischargeDetailExtraEntity>)Session["_storeProductDischargeTable"];
        HaulierSettingEntity haulierLocList = (HaulierSettingEntity)Session[_loadhaulierLoc];
        Decimal Maxtollerence = haulierLocList.PlannedVsActualDeliveryHigh;
        Decimal Mintollerence = haulierLocList.PlannedVsActualDeliveryLow;
        if (e.Item is GridDataItem)
        {
            RadGrid prdDischargeGrid = sender as RadGrid;
            GridDataItem dataItem = (GridDataItem)e.Item;
            int ActualDischargeQty = (dataItem["ActualDischargeQty"].Text == "&nbsp;") ? 0 : Convert.ToInt32(dataItem["ActualDischargeQty"].Text);
            int PlannedDischargeQty = (dataItem["PlannedDischargeQty"].Text == "&nbsp;") ? 0 : Convert.ToInt32(dataItem["PlannedDischargeQty"].Text);
            bool blnColumnNull = false;
            int prdDiffDischarge = ActualDischargeQty - PlannedDischargeQty;
            //int DiffLoading = Convert.ToInt32(dataItem["ActualDischargeQty"].Text) - Convert.ToInt32(dataItem["PlannedDischargeQty"].Text);
            foreach (GridColumn column in prdDischargeGrid.Columns)
            {
                if (column is GridEditableColumn && dataItem[column].Text == "&nbsp;")
                {
                    dataItem[column].CssClass = "missingdata";
                    blnColumnNull = true;
                }
            }
            if (dataItem["LeftOnBoard"].Text == "&nbsp;")
            {
                dataItem["LeftOnBoard"].Text = "";
            }
            else if (Convert.ToInt32(dataItem["LeftOnBoard"].Text) > 0)
            {                dataItem["LeftOnBoard"].CssClass = "ErrorHighlight";
               
               
            }
            if (dataItem["ActualDischargeQty"].Text == "&nbsp;")
            {
                dataItem["ActualDischargeQty"].Text = "";
            }
            // -100 < -101 && -101 > 100
            else if (!Between(prdDiffDischarge, Mintollerence, Maxtollerence))
            {                //List<LoadingDetailExtraEntity> results = ProductTabListinstance.FindAll(CompartmentTabListinstance.Contains();
                //List<DischargeDetailExtraEntity> results =dischargeTabListinstance.Where(p => ProductTabinstance.Any(p2 => p2.ActualProductName == p.ActualProductName && p2.PlannedProductName == p.PlannedProductName)).ToList();
                Int32? ActualQuantity = 0;// = ProductTabListinstance[0].ActualQuantity
                Int32? PlannedQuantity = 0;
                bool blnMegentaColor = false;
                foreach (DischargeDetailExtraEntity lst in dischargeTabListinstance)
                {
                    if (lst.ActualProductName == dataItem["ActualDischargeProd"].Text)
                    {
                        ActualQuantity = lst.ActualQuantity;
                        PlannedQuantity = lst.PlannedQuantity;
                    }                }                Int32? prdDiffDischarge1 = ActualQuantity - PlannedQuantity;
                //int DiffLoading1 = Convert.ToInt32(results[0].ActualQuantity - results[0].PlannedQuantity);
                if (!blnMegentaColor)
                {
                    if (!Between(prdDiffDischarge1, Mintollerence, Maxtollerence))
                    {
                        blnMegentaColor = true;
                    }
                }
                if (blnMegentaColor)
                {
                    dataItem["ActualDischargeQty"].CssClass = "ProductTolerenceError";//megenta
                    //dataItem["ActualLoadQty"].CssClass = "ErrorHighlight";                }
                //if (Between(DiffLoading1, Mintollerence, Maxtollerence))
                //{
                //    //dataItem["ActualLoadQty"].CssClass = "ErrorHighlight";
                   
                //}
                //else
                //{
                //    dataItem["ActualDischargeQty"].CssClass = "ProductTolerenceError";//megenta
                //}
           
               
            }        }
       
    }
    //code added for 1.06r2
    protected void LoadingRadGrid_SelectedIndexChanged(object sender, EventArgs e)
    {
        GridDataItem item = (GridDataItem)LoadingRadGrid.SelectedItems[0];//get selected row
    }
    protected void LoadingRadGrid_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = (GridDataItem)e.Item;
            loadId = Convert.ToInt64(item["LoadId"].Text);
            Session[_lastLoadingSelect1] = loadId;
        }
        e.Canceled = false;
        //loadig compartmetnt load data
        List<LoadingDetailExtraEntity> CompartmentTabListinstance = new List<LoadingDetailExtraEntity>();
        CompartmentTabListinstance = loadingDetailManager.GetLoadingDetailWSListByLoadingId(loadId);
        Session["_storeCompartmentLoadTable"] = CompartmentTabListinstance;
                //loadig product level load data
        List<LoadingDetailExtraEntity> ProductTabListinstance = new List<LoadingDetailExtraEntity>();
        ProductTabListinstance = loadingDetailManager.GetLoadingDetailByLoadIdAtProductLevel(loadId);
        Session["_storeProductLoadTable"] = ProductTabListinstance;    }
    protected void DischargeRadGrid_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = (GridDataItem)e.Item;
            dischargeID = Convert.ToInt64(item["DeliveryNo"].Text);
            Session[_lastDischargeSelect1] = dischargeID;
        }
        e.Canceled = false;
        //loading compartment level discharge data
        List<DischargeDetailExtraEntity> dischargeTabListinstance = new List<DischargeDetailExtraEntity>();
        dischargeTabListinstance = dischargeDetailManager.GetDischargeDetailWSListByDischargeId(dischargeID);
        Session["_storeCompartmentDischargeTable"] = dischargeTabListinstance;        //loading compartment level discharge data
        List<DischargeDetailExtraEntity> ProductTabinstance = new List<DischargeDetailExtraEntity>();
        ProductTabinstance = dischargeDetailManager.GetDischargeDetailByDischargeIdAtProductlevel(dischargeID);
        Session["_storeProductDischargeTable"] = ProductTabinstance;    }
    protected void LoadTabStip_TabClick(object sender, RadTabStripEventArgs e)
    {
        //AddPageView(e.Tab.Text);
        e.Tab.PageView.Selected = true;
        string selectedtabindex = e.Tab.Text;
        Int64 shipmentID = Convert.ToInt64(ShiftTreeView.SelectedNode.Value);
        Int64 load = 0;
        load = Convert.ToInt64(Session[_lastLoadingSelect1].ToString());
        switch (selectedtabindex)
        {
            case "Details":
                {
                    RadPageView page = (RadPageView)e.Tab.PageView;
                    List<LoadingDetailExtraEntity> loadingDetails = new List<LoadingDetailExtraEntity>();
                    //loadingDetails = loadingDetailManager.GetLoadingDetailByShipmentId(shipmentID);
                    loadingDetails = loadingDetailManager.GetLoadingDetailWSListByLoadingId(load);
                    Label lblTerminalId = (Label)page.FindControl("lbl_TerminalIdValue");
                    Label lblTerminalName = (Label)page.FindControl("lbl_TerminalNameValue");
                    if (loadingDetails.Count > 0)
                    {
                       
                        lblTerminalId.Text = loadingDetails[0].Plant_ID.ToString();                       
                        lblTerminalName.Text = loadingDetails[0].TerminalName;
                    }
                    else
                    {
                        lblTerminalId.Text = MyGlobal.SDP_GUI_RADGRID_NO_RECORDS_FOUND;
                        lblTerminalName.Text = MyGlobal.SDP_GUI_RADGRID_NO_RECORDS_FOUND;
                    }
                    break;
                }
            case "Compartments":
                {
                    RadPageView page = (RadPageView)e.Tab.PageView;
                    RadGrid grdCompartment = (RadGrid)page.FindControl("CompartmentLevelLoadRadGrid");                    //List<LoadingDetailExtraEntity> CompartmentTabListinstance = new List<LoadingDetailExtraEntity>();
                    //CompartmentTabListinstance = loadingDetailManager.GetLoadingDetailWSListByLoadingId(load);
                    //Session["_storeCompartmentLoadTable"] = CompartmentTabListinstance;                    List<LoadingDetailExtraEntity> CompartmentTabListinstance = (List<LoadingDetailExtraEntity>)Session["_storeCompartmentLoadTable"];                    grdCompartment.DataSource = CompartmentTabListinstance;
                    grdCompartment.DataBind();                    //e.Tab.Controls.Add(grdLoad);
                    break;
                }
            case "Products":
                {
                    RadPageView page = (RadPageView)e.Tab.PageView;
                    RadGrid grdProduct = (RadGrid)page.FindControl("ProductLevelLoadRadGrid");
                    //List<LoadingDetailExtraEntity> ProductTabListinstance = new List<LoadingDetailExtraEntity>();
                    //ProductTabListinstance = loadingDetailManager.GetLoadingDetailByLoadIdAtProductLevel(load);
                    //Session["_storeProductLoadTable"] = ProductTabListinstance;                    List<LoadingDetailExtraEntity> ProductTabListinstance = (List<LoadingDetailExtraEntity>)Session["_storeProductLoadTable"];
                    grdProduct.DataSource = ProductTabListinstance;
                    grdProduct.DataBind();
                    break;
                }
        }
    }    protected void DischargeTabStip_TabClick(object sender, RadTabStripEventArgs e)
    {
        //AddPageView(e.Tab.Text);
        e.Tab.PageView.Selected = true;
        string selectedtabindex = e.Tab.Text;        Int64 shipmentID = Convert.ToInt64(ShiftTreeView.SelectedNode.Value);
        //Int64 load = 0;
        //load = Convert.ToInt64(Session[_lastLoadingSelect1].ToString());
        Int64 discharge = 0;
        discharge = Convert.ToInt64(Session[_lastDischargeSelect1].ToString());
        switch (selectedtabindex)
        {
            case "Details":
                {
                    RadPageView page = (RadPageView)e.Tab.PageView;
                    List<DischargeEntity> dischargeDetails = new List<DischargeEntity>();
                    dischargeDetails = dischargeManager.GetDischargeDetailsByDischargeId(discharge);//.GetDischargeByID(discharge);
                   
                    Label lblShipTo = (Label)page.FindControl("lbl_ShipToValue");
                    Label lblSiteName = (Label)page.FindControl("lbl_SiteNameValue");
                    Label lblAddress = (Label)page.FindControl("lbl_AddressValue");
                    Label lblSplInstructions = (Label)page.FindControl("lbl_SplInstructionValue");
                    Label lblPONumber = (Label)page.FindControl("lbl_PONumberValue");                    if (dischargeDetails.Count > 0)
                    {
                        lblShipTo.Text = dischargeDetails[0].Site_ID.ToString();
                        lblSiteName.Text = dischargeDetails[0].SiteName;
                        lblAddress.Text = dischargeDetails[0].SiteAddress + dischargeDetails[0].SiteName2;
                        lblSplInstructions.Text = dischargeDetails[0].DeliveryWindow;
                        lblPONumber.Text = dischargeDetails[0].PONumber.ToString();
                    }
                    else
                    {
                        lblShipTo.Text = MyGlobal.SDP_GUI_RADGRID_NO_RECORDS_FOUND;
                        lblSiteName.Text = MyGlobal.SDP_GUI_RADGRID_NO_RECORDS_FOUND;
                        lblAddress.Text = MyGlobal.SDP_GUI_RADGRID_NO_RECORDS_FOUND;
                        lblSplInstructions.Text = MyGlobal.SDP_GUI_RADGRID_NO_RECORDS_FOUND;
                        lblPONumber.Text = MyGlobal.SDP_GUI_RADGRID_NO_RECORDS_FOUND;
                    }
                    break;
                }
            case "Compartments":
                {
                    RadPageView page = (RadPageView)e.Tab.PageView;
                    RadGrid grdDisharge = (RadGrid)page.FindControl("CompartmentLevelDischargeRadGrid");                    //List<DischargeDetailExtraEntity> dischargeTabListinstance = new List<DischargeDetailExtraEntity>();
                    //dischargeTabListinstance = dischargeDetailManager.GetDischargeDetailWSListByDischargeId(discharge);                   
                    //Session["_storeCompartmentDischargeTable"] = dischargeTabListinstance;
                    List<DischargeDetailExtraEntity> dischargeTabListinstance = (List<DischargeDetailExtraEntity>)Session["_storeCompartmentDischargeTable"];
                    grdDisharge.DataSource = dischargeTabListinstance;
                    grdDisharge.DataBind();                   
                    break;
                }
            case "Products":
                {
                    RadPageView page = (RadPageView)e.Tab.PageView;
                    RadGrid grdDishargeProducts = (RadGrid)page.FindControl("ProductLevelDischargeRadGrid");
                    //List<DischargeDetailExtraEntity> ProductTabinstance = new List<DischargeDetailExtraEntity>();
                    //ProductTabinstance = dischargeDetailManager.GetDischargeDetailByDischargeIdAtProductlevel(discharge);
                    //Session["_storeProductDischargeTable"] = ProductTabinstance;
                    List<DischargeDetailExtraEntity> ProductTabinstance = (List<DischargeDetailExtraEntity>)Session["_storeProductDischargeTable"];
                    grdDishargeProducts.DataSource = ProductTabinstance;
                    grdDishargeProducts.DataBind();
                    break;
                }
        }
    }    protected void RefreshHeaders()
    {
        if (Session[_lastShipmentSelect] != null)
        {
            lbl_ShipmentHeader.Text = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_SHIPMNT_FOR_VEHICLE + " <" + Session[_lastShipmentSelect].ToString() + ">" + "</span>";        }
        if (Session[_lastVehicle] != null)
        {
            lbl_ShipementForVehicle.Text = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_WORKSCHED_LBL_SHIFT + "-" + Session[_lastVehicle].ToString() + "-" + Session[_lastVehicle].ToString() + "</span>";
        }
        if (Session[_sesLastVehicleSelect] != null)
        {
            lbl_ShipmentHeader.Text = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_SHIPMNT_FOR_VEHICLE + " <" + Session[_sesLastVehicleSelect].ToString() + ">" + "</span>";        }
        if (Session[_lastDischargeHeader] != null)
        {
            lbl_DischargeHeader.Text = Session[_lastDischargeHeader].ToString();
        }
        if (Session[_lastLoadHeader] != null)
        {
            lbl_LoadingHeader.Text = Session[_lastLoadHeader].ToString();
        }
    }
    protected void UpdateShipmentSection(Boolean changed)
    {
        updateCounter++;
        indexCounter.Text = updateCounter.ToString();
        Session["_sesUpdateCounter"] = indexCounter.Text.ConvertToInt32();
    }
    protected void ShipmentRadGrid_DetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
    {
        GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
        switch (e.DetailTableView.Name)
        {
            case "ShipmentType":
                Int32 selectedVehicleId = Int32.Parse(dataItem.GetDataKeyValue("Vehicle_ID").ToString());
                Int64 shipmentId = Int64.Parse(dataItem["Shipment_ID"].Text);
                e.DetailTableView.DataSource = gsm.GetAllShipmentTypes(shipmentId);
                break;
            case "ShipmentDetail":
                Int64 selectedTransferId = Int64.Parse(dataItem.GetDataKeyValue("Transfer_ID").ToString());
                String selectedTransferType = dataItem["TransferType"].Text;
                switch (selectedTransferType)
                {
                    case "Loading":
                        e.DetailTableView.DataSource = loadingDetailManager.GetLoadingDetailListByLoadingId(selectedTransferId);
                        break;
                    case "Discharge":
                        e.DetailTableView.DataSource = dischargeDetailManager.GetDischargeDetailListByDischargeId(selectedTransferId);
                        break;
                }
                break;
        }
    }    // Code added for fixing defect : 5906
    protected void LoadingRadGridFormat_OnItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = (GridDataItem)e.Item;
            if (item.DataItem.GetType() == typeof(LoadingDetailExtraEntity))
            {
                if (item["LoadId"].Text == "&nbsp;")
                {
                    item["LoadId"].Text = "";
                }
                // not required due to data being in correct format in the database
                //if (((Shell.DrivePartner.EntityObjects.LoadingDetailExtraEntity)(item.DataItem)).ActualMaterial_ID == DefaultConstant.DefaultProductCode)
                //{
                //    item["ActualLoadProd"].Text = "-";
                //    item["ActualLoadQty"].Text = "0";
                //}
            }
        }
    }
   
    // Code added for fixing defect : 5906
    protected void DsichargeRadGridFormat_OnItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = (GridDataItem)e.Item;
            if (item.DataItem.GetType() == typeof(DischargeDetailExtraEntity))
            {
                if (item["DeliveryNo"].Text == "&nbsp;")
                {
                    item["DeliveryNo"].Text = "";
                }
                if (((Shell.DrivePartner.EntityObjects.DischargeDetailExtraEntity)(item.DataItem)).ActualMaterial_ID == DefaultConstant.DefaultProductCode)
                {
                    // not required due to data being in correct format in the database
                    //item["ActualDischargeProd"].Text = "-";
                    //item["ActualDischargeQty"].Text = "0";
                    item["DischargeEnd"].Text = "-";
                }
            }
            else if (item.DataItem.GetType() == typeof(DischargeDetailExtraEntity))
            {
                if (item["DischargeEnd"].Text == "&nbsp;")
                {
                    item["DischargeEnd"].Text = "";
                }
            }
        }
    }
        /// <summary>
    /// Format Row on binding
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void FormatGrid_OnItemDataBound(object sender, GridItemEventArgs e)
    {
        List<ShipmentEntity> shipmentLst = new List<ShipmentEntity>();        if (e.Item is GridDataItem)
        {
            GridDataItem item = (GridDataItem)e.Item;
            if (item.DataItem.GetType() == typeof(ShipmentEntity))
            {
                item.SelectableMode = GridItemSelectableMode.ServerSide;
                //String shipmentState = item["ShipmentState"].Text;                String shipmentState = string.Empty;
                long shipmentId = Convert.ToInt64(item["Shipment_ID"].Text);
                if (shipmentList != null)
                {
                    shipmentLst = shipmentList.FindAll(sh => sh.Shipment_ID == shipmentId);
                }
                foreach (ShipmentEntity se in shipmentLst)
                {
                    shipmentState = se.ShipmentState.ToString();
                }                switch (shipmentState)
                {
                    case "ShiftSent":
                        break;
                    case "ReceivedFromAppNoError":
                        break;
                    case "ShiftReceivedByApp":
                        break;
                    case "DeliveryConfirmationSent":
                        break;
                    case "ReceivedFromAppWithError":
                        break;
                    case "ErrorShellData":
                        item.BackColor = System.Drawing.Color.FromArgb(232, 63, 80);
                        break;
                }
            }
            // Code added for fixing defect : 5906
            else if (item.DataItem.GetType() == typeof(LoadingDetailEntity))
            {
                if (item["ActualQuantity"].Text == "&nbsp;")
                {
                    item["ActualQuantity"].Text = "";
                }
            }
            // Code added for fixing defect : 5906
            else if (item.DataItem.GetType() == typeof(DischargeDetailEntity))
            {
                if (item["ActualQuantity"].Text == "&nbsp;")
                {
                    item["ActualQuantity"].Text = "";
                }
            }
            else if (item.DataItem.GetType() == typeof(DischargeDetailEntity))
            {
                if (item["ActualTankIndex"].Text == "&nbsp;")
                {
                    item["ActualTankIndex"].Text = "";
                }
            }        }
    }
    /// <summary>
    /// On ShipmentRadGrid Need Data Source
    /// If page is not postback Clear session, get latest data from database and store in session
    /// Populate tree nodes and update header table
    /// If it is post back get data from session
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void ShipmentRadGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        if (!Page.IsPostBack)
        {
            ClearSelectedSession();
            if (user.HaulierLocations.Count == 0)
            { return; }
            StoreGridDataInSession(Constants.SessionDataStoreKeys.EntireShipment.ToString());
            TranslatePage();
            PopulateTreeNode();
            /// Added the code for defect : 5471
            //ShipmentRadGrid.MasterTableView.GetColumn("Shipment_ID").HeaderText = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_SHIPMENT_ALL_VEHICLE + "</span>";
        }
        else
        {
            StoreGridDataInSession(Constants.SessionDataStoreKeys.EntireShipment.ToString());
        }    }
    protected void LoadingRadGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        if (!Page.IsPostBack)
        {
            ClearSelectedSession();
            if (user.HaulierLocations.Count == 0)
            { return; }
            StoreGridDataInSession(Constants.SessionDataStoreKeys.EntireShipment.ToString());
            TranslatePage();
            PopulateTreeNode();
            /// Added the code for defect : 5471
            // ShipmentRadGrid.MasterTableView.GetColumn("Shipment_ID").HeaderText = "<span style='font-weight: bold'>" + MyGlobal.SDP_GUI_SHIPMENT_ALL_VEHICLE + "</span>";
        }
        else
        {
            StoreGridDataInSession(Constants.SessionDataStoreKeys.EntireShipment.ToString());
        }    }
    /// <summary>
    /// Setting the User culture to the Page
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    private void SetUserCulture(ApplicationUserEntity User)
    {
        if (User == null)
        {
            Response.Redirect("../Default.aspx");
            return;
        }        try
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo(User.LanguageCode);
            Page.UICulture = User.LanguageCode;
            Page.Culture = User.LanguageCode;
        }
        catch (Exception) { }
    }
    #endregion    #region Events    /// <summary>
    /// Refresh the shift tree on Button Click
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnAutoRefresh_OnClick(object sender, EventArgs e)
    {
        if (Session[_sesLastUpdated] == null)
        {
            Session[_sesLastUpdated] = DateTime.UtcNow;
        }
        else
        {
            RefreshHeaders();            DateTime lastUpdated = (DateTime)Session[_sesLastUpdated];
            List<ShipmentEntity> temp = shipmentManager.GetLatestShipmentCreatedRange(lastUpdated, DateTime.UtcNow);
            temp.AddRange(shipmentManager.GetLatestShipmentUpdatedRange(lastUpdated, DateTime.UtcNow));
            temp.Sort((x, y) => y.DateOfShipment.CompareTo(x.DateOfShipment));
            temp = temp.FindAll(s => s.Haulier_ID == user.SelectedHaulierID);
            String shipmentContent = "";            if (temp.Count > 0)
            {
                UpdateShipmentSection(true);
                ClearSelectedSession();
                Session.Remove(_sesLastUpdated);
                StoreGridDataInSession(Constants.SessionDataStoreKeys.EntireShipment.ToString());
                Session[_sesLastUpdated] = DateTime.UtcNow;
                String updatetime = "";
                foreach (ShipmentEntity se in temp)
                {
                    if (se.LastUpdated < DateTime.UtcNow.AddDays(-30))
                    {
                        updatetime = "";
                    }
                    else
                    {
                        updatetime = se.LastUpdated.GetValueOrDefault().ToString();
                    }
                    shipmentContent += "<div class='shipmentEntity'>" +
                            MyGlobal.SDP_GUI_BALANCE_CAPT_SHIPMENTID + " " + se.Shipment_ID + "<br>" +
                            MyGlobal.SDP_GUI_SHIFTOVRVIEW_LBL_VEHICLEID + " " + se.Vehicle_ID + "<br>" +
                            MyGlobal.SDP_GUI_WS_SHIPMENT_DATE + " " + se.DateOfShipment.ToShortDateString() + "<br>" +
                            MyGlobal.SDP_GUI_WS_CURRENT_STATE + " " + se.ShipmentState + "<br>" +
                            MyGlobal.SDP_GUI_WS_CREATED_TIME + " " + se.Created + "<br>" +
                            MyGlobal.SDP_GUI_WS_UPDATED_TIME + " " + updatetime + "<br>" +
                            "</div><br>";
                }
                PopulateTreeNode();
            }
        }
    }    #endregion    /// <summary>
    /// translate grid filter menu items.
    /// </summary>
    /// <param name="radGrid"></param>
    protected void TranslateGridMenuItems(RadGrid radGrid)
    {
        GridFilterMenu menu = radGrid.FilterMenu;
        foreach (RadMenuItem item in menu.Items)
        {    //translate
            switch (item.Text)
            {
                case "Contains":
                    {
                        item.Text = MyGlobal.SDP_GUI_RADGRID_FILTER_MENU_CONTAINS;
                        break;
                    }
                case "DoesNotContain":
                    {
                        item.Text = MyGlobal.SDP_GUI_RADGRID_FILTER_MENU_DOESNOTCONTAIN;
                        break;
                    }
                case "StartsWith":
                    {
                        item.Text = MyGlobal.SDP_GUI_RADGRID_FILTER_MENU_STARTSWITH;
                        break;
                    }
                case "EndsWith":
                    {
                        item.Text = MyGlobal.SDP_GUI_RADGRID_FILTER_MENU_ENDSWITH;
                        break;
                    }
                case "EqualTo":
                    {
                        item.Text = MyGlobal.SDP_GUI_RADGRID_FILTER_MENU_EQUALTO;
                        break;
                    }
                case "NotEqualTo":
                    {
                        item.Text = MyGlobal.SDP_GUI_RADGRID_FILTER_MENU_NOTEQTO;
                        break;
                    }
                case "GreaterThan":
                    {
                        item.Text = MyGlobal.SDP_GUI_RADGRID_FILTER_MENU_GREATERTHAN;
                        break;
                    }
                case "LessThan":
                    {
                        item.Text = MyGlobal.SDP_GUI_RADGRID_FILTER_MENU_LESSTHAN;
                        break;
                    }
                case "GreaterThanOrEqualTo":
                    {
                        item.Text = MyGlobal.SDP_GUI_RADGRID_FILTER_MENU_GTEQTO;
                        break;
                    }
                case "LessThanOrEqualTo":
                    {
                        item.Text = MyGlobal.SDP_GUI_RADGRID_FILTER_MENU_LEEQTO;
                        break;
                    }
                case "Between":
                    {
                        item.Text = MyGlobal.SDP_GUI_RADGRID_FILTER_MENU_BETWEEN;
                        break;
                    }
                case "NotBetween":
                    {
                        item.Text = MyGlobal.SDP_GUI_RADGRID_FILTER_MENU_NOTBETWEEN;
                        break;
                    }
                case "IsEmpty":
                    {
                        item.Text = MyGlobal.SDP_GUI_RADGRID_FILTER_MENU_ISEMPTY;
                        break;
                    }
                case "NotIsEmpty":
                    {
                        item.Text = MyGlobal.SDP_GUI_RADGRID_FILTER_MENU_ISNOTEMPTY;
                        break;
                    }
                case "IsNull":
                    {
                        item.Text = MyGlobal.SDP_GUI_RADGRID_FILTER_MENU_ISNULL;
                        break;
                    }
                case "NotIsNull":
                    {
                        item.Text = MyGlobal.SDP_GUI_RADGRID_FILTER_MENU_NOTISNULL;
                        break;
                    }
                case "NoFilter":
                    {
                        item.Text = MyGlobal.SDP_GUI_RADGRID_FILTER_MENU_NOFILTER;
                        break;
                    }
            }
        }
    }}


Please share me the code asap.
Thanks in advance.

0
Angel Petrov
Telerik team
answered on 31 Oct 2014, 01:49 PM
Hello Sudhakar,

First I want to start by elaborating more on the type of binding the grids use. In the current setup it seems that some of the grids use advanced data-binding(assigning a data source in the NeedDataSource event) which is the preferable solution. Simple data-binding(calling .DataBind()) can be used only in scenarios where the data should be displayed. If a grid must allow data editing the logic should be modified in such a manner so that advanced data-binding is used. From that point of view it seems that the current configuration is correct.

As for modifying the records in the database in order to do so you would first need to extract the changes which the user had made. For that purpose you can use the OnBatchEditCommand handlers. For example if we want to obtain the changes for the CompartmentLevelLoadRadGrid grid we can execute the following logic.

C#:
protected void CompartmentLevelLoadRadGrid_BatchEditCommand(object source, GridBatchEditingEventArgs e)
    {   
         foreach (GridBatchEditingCommand command in e.Commands)
        {
            Hashtable newValues = command.NewValues;
            Hashtable oldValues = command.OldValues;
            string newPTL = newValues["PTL"].ToString();
            string oldPTL = oldValues["PTL"].ToString();
            string newActualProductName = newValues["ActualProductName"].ToString();
            string oldActualProductName = oldValues["ActualProductName"].ToString();
            .....
 
            if (command.Type == GridBatchEditingCommandType.Update)
            {
                //perform update
            }
            if (command.Type == GridBatchEditingCommandType.Insert)
            {
                //perform update
            }
            if (command.Type == GridBatchEditingCommandType.Delete)
            {
                //perform delete
            }
        }
    }
The same approach can be applied for the rest of the grid. The idea is to access the new and old collections and extract the values using the field name(example newValues["PTL"]).

Additionally I want to bring your attention to something which I noticed in the code. Some parts of the page are ajaxifyed by both a RadAjaxManager and RadAjaxPanel. Bear in mind that this is not supported and may break the update logic. In order to avoid problems of such types I advice on removing one of the mentioned controls and using only the other for ajaxifying the content.

Regards,
Angel Petrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Sudhakar
Top achievements
Rank 1
answered on 03 Nov 2014, 06:06 AM
Hi Angel,

I am getting the "Object reference not set to an instance of an object." error while inserting new record in the grid.
Because for a new record the old values collection are null values.
so, How to handle this situation here.

string newPTL = newValues["PTL"].ToString();
string oldPTL = oldValues["PTL"].ToString();-->Object reference not set to an instance of an object.

Regards,
Sudhakar.

​
0
Angel Petrov
Telerik team
answered on 06 Nov 2014, 07:14 AM
Hi Sudhakar,

Actually it is expected to have null values in the old values collection for the new records. In order to correct things please access only the new values collection for cases where an insert will be performed.

Regards,
Angel Petrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Sudhakar
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Sudhakar
Top achievements
Rank 1
Share this question
or