<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" EnableEventValidation="false" CodeBehind="Spray_Workarea_Company.aspx.cs" Inherits="VMT.Spray_Workarea_Company" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .auto-style2 {
            width: 100%;
            padding: 3px;
        }
        
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphJavaScriptContentPlaceHolder" runat="server">
    <script type="text/javascript">
        <%--   function ddl_Bunit_Click() {
            var currentValue = document.getElementById("<%=ddl_Bunit.ClientID%>");
            var previousValue = document.getElementById("<%=hdfBU.ClientID%>");
            var listBox = document.getElementById("<%=lst_selWorkArea.ClientID%>");
            if (listBox.options.length > 0) {
                var cmt = confirm('You have selected Work Area, Do you still want to cancel the Work Area and Customer Mapping Operation?');
                if (cmt == true) {
                    document.getElementById("<%=hdfBU.ClientID%>").value = currentValue;
                    return true;
                }
                else {
                    document.getElementById("<%=ddl_Bunit.ClientID%>").value = previousValue;
                    return false;
                }
            }
            return true;
        }

        function ddl_Year_Click() {
            var currentValue = document.getElementById("<%=ddl_Year.ClientID%>");
            var previousValue = document.getElementById("<%=hdfYR.ClientID%>");
            var listBox = document.getElementById("<%=lst_selWorkArea.ClientID%>");
            if (listBox.options.length > 0) {
                var cmt = confirm('You have selected Work Area, Do you still want to cancel the Work Area and Customer Mapping Operation?');
                if (cmt == true) {
                    document.getElementById("<%=hdfYR.ClientID%>").value = currentValue;
                    return true;
                }
                else {
                    document.getElementById("<%=ddl_Year.ClientID%>").value = previousValue;
                    return false;
                }
            }
            return true;
        }

        function ddl_eventcode_Click() {
            var currentValue = document.getElementById("<%=ddl_eventcode.ClientID%>");
            var previousValue = document.getElementById("<%=hdfEC.ClientID%>");
            var listBox = document.getElementById("<%=lst_selWorkArea.ClientID%>");
            if (listBox.options.length > 0) {
                var cmt = confirm('You have selected Work Area, Do you still want to cancel the Work Area and Customer Mapping Operation?');
                if (cmt == true) {
                    document.getElementById("<%=hdfEC.ClientID%>").value = currentValue;
                    return true;
                }
                else {
                    document.getElementById("<%=ddl_eventcode.ClientID%>").value = previousValue;
                    return false;
                }
            }
            return true;
        }--%>
        function ConfirmDelete(workstatusid) {
            var cmt = '';
            
            if (workstatusid == 4 || workstatusid == 10) {
                cmt = confirm('Project is in contractor open status and delete will remove the chemicals and assigned lines and change the status of the project back to Ready.Do you want to continue?');
            }
            else {
                cmt = confirm('Delete will remove the chemicals and assigned lines and change the status of the project back to Ready.Do you want to continue?');
            }
            if (cmt == true) {
                    return true;
                }
                else {
                    return false;
                }
        }
    </script>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="cphPageTitleContentPlaceHolder" runat="server">
     <div id="CssPageTitle">
        <h1>
            Assign Spray Project/Event to Company
        </h1>
    </div>
    <div id="SubPageTitle">
        <!-- OPTIONAL SUB PAGE TITLE -->
        <asp:HiddenField ID="hdfBU" runat="server" />
        <asp:HiddenField ID="hdfYR" runat="server" />
        <asp:HiddenField ID="hdfEC" runat="server" />
    </div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="cphMainContentPlaceHolder" runat="server">
     <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
 <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                    <ContentTemplate>
                         <div id="loaderdiv">
    <asp:updateprogress id="UpdateProgress1" runat="server" associatedupdatepanelid="UpdatePanel2" dynamiclayout="true">
                        <progresstemplate>

                           <img src="resource_gallery/graphics/loader.gif" class="ajax-loader">

                        </progresstemplate>
                    </asp:updateprogress>

                    </div>
<%--<div style="text-align:right;"><strong>&#8249;&#8249;</strong> <a href="Assignments.aspx">Back</a></div>--%>
                        <div style="text-align:right;"><a href="default.aspx">Home</a> <strong>&#8249;&#8249;</strong> <a href="Assignments.aspx">Assignment</a> <strong>&#8249;&#8249;</strong> Assign Spray Project to Company</div>

                        <div style="text-align:left; width: 100%;">
                             <fieldset class="masterform">
                                <legend>Project/Event Treatment/Re-treatment</legend> 
                                <div style=" width: 100%; height:35px; ">


		                            <table class="auto-style2">
                                        <tr>
                                            <td class="auto-style3">
                                                <asp:RadioButton ID="rbt_open" runat="server" GroupName="inspect" AutoPostBack="True" OnCheckedChanged="rbt_open_CheckedChanged" /> <strong>Spray Treatment</strong></td>
                                            <td class="auto-style3">
                                                <asp:RadioButton ID="rbt_close" runat="server" GroupName="inspect" AutoPostBack="True" OnCheckedChanged="rbt_close_CheckedChanged"/>&nbsp; <strong>Spray Re-treatment</strong>
                                            </td>
                                        </tr>
                                    </table>


		                       </div>
       	                       </fieldset>
                        </div>

 <div style="text-align:left; width: 100%;">
                            <fieldset class="masterform">
                                <legend>Select Project/Event</legend>
                                <div style=" width: 100%; height:40px; ">
                                    <table class="auto-style2">
                                        <tr>
                                            <td style="width: 21%"><strong>Business Unit</strong></td>
                                            <td style="width: 21%"><strong>Work Year</strong></td>
                                            
                                            <td style="width: 21%"><strong>Project/Event</strong></td>
                                            <td style="width: 21%"><strong>Company</strong></td>
                                            <td style="width: 16%" rowspan="2"><asp:Button ID="btn_add1" runat="server" CssClass="FormButton" Text="Apply" OnClick="btn_add1_Click" />
                                                <asp:HiddenField ID="hdn_role" runat="server" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="width: 21%">
                                                <asp:DropDownList ID="ddl_Bunit" runat="server" AutoPostBack="True" OnDataBound="ddl_Bunit_DataBound" OnSelectedIndexChanged="ddl_Bunit_SelectedIndexChanged">
                                                </asp:DropDownList>
                                            </td>
                                            <td style="width: 21%">
                                                <asp:DropDownList ID="ddl_Year" runat="server" AutoPostBack="True" OnDataBound="ddl_Year_DataBound" OnSelectedIndexChanged="ddl_Year_SelectedIndexChanged">
                                                </asp:DropDownList>
                                            </td>
                                            <td style="width: 21%">
                                                <asp:DropDownList ID="ddl_eventcode" runat="server" AutoPostBack="True" OnDataBound="ddl_eventcode_DataBound" OnSelectedIndexChanged="ddl_eventcode_SelectedIndexChanged">
                                                </asp:DropDownList>
                                            </td>
                                            <td style="width: 21%">
                                                <asp:DropDownList ID="ddl_Company" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddl_Company_SelectedIndexChanged" OnDataBound="ddl_Company_DataBound"></asp:DropDownList>
                                            </td>
                                        </tr>
                                        </table>
                                     </div>
                            </fieldset></div>
                                                <div style="text-align:left; width: 100%;">
                            <fieldset class="masterform">
                                <legend>Spray Project Contractor Assignment</legend>
                              
                                <div style=" width: 100%; height:200px; overflow-y: scroll;"><br />
                                    <asp:GridView ID="gdv_WA_Company" runat="server" HeaderStyle-CssClass="FixedHeader"  BorderColor="#014567" CellPadding="3"  AutoGenerateColumns="False" OnRowDeleting="gdv_WA_Company_RowDeleting" OnRowCreated="gdv_WA_Company_RowCreated">
                                        <AlternatingRowStyle BackColor="#E9EFF2" />
                                        <Columns>
                                            <asp:TemplateField HeaderText="PROJECT/EVENT" HeaderStyle-Width="381px" ItemStyle-Width="380px">
                                                
                                                <ItemTemplate>
                                                    <asp:HiddenField ID="hdn_EVENT_CODE_ID" runat="server" Value='<%# Eval("EVENT_CODE_ID") %>'> </asp:HiddenField>
                                                    <%--<a href='LocateSprayWA_Map.aspx?EVENT_CODE_ID=<%# Eval("EVENT_CODE_ID") %>&nm=<%# Eval("EVENT_CODE") %>' target="_blank">   <asp:Label ID="Label2" runat="server" Text='<%# Bind("EVENT_CODE") %>'></asp:Label> </a>--%>
                                                    <a href='<%=System.Configuration.ConfigurationManager.AppSettings["VMSWorkLink"]%>?bu=0&ec=<%# Eval("EVENT_CODE_ID") %>&wa=0&yr=0' target="_blank"> <asp:Label ID="Label2s" runat="server" Text='<%# Bind("EVENT_CODE") %>'></asp:Label> </a>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                          <%--  <asp:TemplateField HeaderText="SECTION/WA"  HeaderStyle-Width="221px" ItemStyle-Width="220px">
                                               
                                                <ItemTemplate>
                                                    <a href='LocateWA_Map.aspx?WORK_AREA_ID=<%# Eval("WORK_AREA_ID") %>&nm=<%# Eval("WORK_AREA")%>'  target="_blank">   <asp:Label ID="Label1" runat="server" Text='<%# Bind("WORK_AREA") %>'></asp:Label></a>
                                                </ItemTemplate>
                                            </asp:TemplateField>--%>
                                            <asp:BoundField DataField="COMPANY_NAME" HeaderText="COMPANY"  HeaderStyle-Width="281px" ItemStyle-Width="280px" />
                                            <asp:TemplateField ShowHeader="False" HeaderText="DELETE" HeaderStyle-Width="130px" ItemStyle-Width="130px">
                                                <ItemTemplate>
                                                    <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Delete" OnClientClick='<%# string.Format("return ConfirmDelete({0});", Eval("work_status_id")) %>'><img src="resource_gallery/graphics/icon_delete.png" /></asp:LinkButton>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <%--<asp:TemplateField>
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("WORK_AREA_ID") %>'></asp:TextBox>
                                                </EditItemTemplate>
                                                <ItemTemplate>
                                               <asp:Label ID="lbl_WORK_AREA_ID" runat="server" Text='<%# Bind("WORK_AREA_ID") %>'></asp:Label> 
                                                </ItemTemplate>
                                            </asp:TemplateField>--%>
                                            <asp:TemplateField>
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("COMPANY_ID") %>'></asp:TextBox>
                                                </EditItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="lbl_COMPANY_ID" runat="server" Text='<%# Bind("COMPANY_ID") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                        </Columns>
                                        <HeaderStyle BackColor="#98C8DE" Font-Bold="True" />
                                        <SelectedRowStyle BackColor="#FFE98F" />
                                    </asp:GridView>


                                </div>
                                
                                   
                            </fieldset></div>
                        
<%--<div style="text-align:left; width: 100%;">
                            <fieldset class="masterform">
                                <legend>Assign Section/WA to Spray Contractor</legend>
                                <div style=" width: 100%; height:140px; ">

                                    <table class="auto-style2">
                                       
                                        <tr>
                                            <td style="width: 20%"><strong>Section/WA</strong></td>
                                            <td style="width: 8%">&nbsp;</td>
                                            <td style="width: 20%"><strong>Selected Section/WA</strong></td>
                                            <td style="width: 4%">&nbsp;</td>
                                            <td style="width: 20%"><strong>Company</strong></td>
                                            <td style="width: 8%">&nbsp;</td>
                                            <td style="width: 20%"><strong>Selected Company</strong></td>
                                        </tr>
                                        <tr>
                                            <td style="width: 20%">
                                                <asp:ListBox ID="lst_WorkArea" runat="server" Rows="6"></asp:ListBox>
                                            </td>
                                            <td style="width: 8%; text-align: center;"> <asp:Button ID="btn_addWA" runat="server" CssClass="FormButton" Text="&gt;&gt;" OnClick="btn_addWA_Click" />
                                                <br />
                                                <br />
                                                <asp:Button ID="btn_remWA" runat="server" CssClass="FormButton" Text="&lt;&lt;" OnClick="btn_remWA_Click" /></td>
                                            <td style="width: 20%">
                                                <asp:ListBox ID="lst_selWorkArea" runat="server" Rows="6"></asp:ListBox>
                                            </td>
                                            <td style="width: 4%">&nbsp;</td>
                                            <td style="width: 20%">
                                                <asp:ListBox ID="lst_Company" runat="server" Rows="6"></asp:ListBox>
                                            </td>
                                            <td style="width: 8%; text-align: center;">  <asp:Button ID="btn_addComp" runat="server" CssClass="FormButton" Text="&gt;&gt;" OnClick="btn_addComp_Click" />
                                                <br />
                                                <br />
                                                <asp:Button ID="btn_remComp" runat="server" CssClass="FormButton" Text="&lt;&lt;" OnClick="btn_remComp_Click" /></td>
                                            <td style="width: 20%">
                                                <asp:ListBox ID="lst_selCompany" runat="server" Rows="6"></asp:ListBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td style="width: 20%">&nbsp;</td>
                                            <td style="width: 8%">&nbsp;</td>
                                            <td style="width: 20%">&nbsp;</td>
                                            <td style="width: 4%">&nbsp;</td>
                                            <td style="width: 20%">&nbsp;</td>
                                            <td style="width: 8%">&nbsp;</td>
                                            <td style="width: 20%"></td>
                                        </tr>
                                        </table>
                                    
                                </div>
                            </fieldset></div>--%>
<div style="text-align:left; width: 100%;">
                            </div>
                        <div style="text-align:left; width: 100%;">
                            <fieldset class="masterform">
                              <legend>Navigate to</legend>
                                <div style=" width: 100%; height:40px; ">
                                    
                                    <table class="auto-style2">
                                        <tr>
                                           <td style="width: 40%" rowspan="2">
                                                    <asp:Button ID="btnAddRate" runat="server" CssClass="FormButton" OnClick="btnAddRate_Click" Text="Chemical Assignment" />
                                                    </td>
                                            <td style="width: 10%"><%--To Assign Rates for all WorkArea associated with selected Project and Year, Click Assign.--%></td>
                                           
                                            

                                            <td style="width: 20%" rowspan="2">
                                               
                                                <asp:Button ID="btn_expExcel" runat="server" CssClass="FormButton" Text="Export to Excel" OnClick="btn_expExcel_Click" />
                                            </td>
                                             <td style="width: 30%" rowspan="2">
                                                 &nbsp;</td>
                                        </tr>
                                        
                                    </table>
                                    
                                </div>
                            </fieldset></div>
</ContentTemplate>
            </asp:UpdatePanel>
</asp:Content>