<%@ Page Title="" Language="C#" MasterPageFile="~/Site1.Master" AutoEventWireup="true" CodeBehind="SprayCycleManagement.aspx.cs" Inherits="VMT.SprayCycleManagement" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    
   <script type="text/javascript">
       function Confirm() {
           //debugger;
           //if (document.getElementById('<%= hdnRetainWkID.ClientID %>').value == 1) {
           // if (confirm('Are you sure to retain the rate?'))
           // document.getElementById('<%= hdnConfirmvalue.ClientID %>').value = 1;
           //else
           //     document.getElementById('<%= hdnConfirmvalue.ClientID %>').value = 0;
           // }

       }

    </script>
    
    <style type="text/css">
        .auto-style2 {
            height: 18px;
        }
    </style>
    
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphJavaScriptContentPlaceHolder" runat="server">
    <script type="text/javascript">

        function CallMethod() {
            var strMessage;

            var NewSysAssnYear = document.getElementById("<%=ddlSysAssnYear.ClientID %>");
           var NewCycleYear = document.getElementById("<%=ddlCycleYear.ClientID %>");
            var NewCycle = document.getElementById("<%=ddlCycle.ClientID %>");
            var NewChangeReason = document.getElementById("<%=ddlChangeReson.ClientID %>");


            //radio button value

            //var inputs = list.getElementsByTagName("input");
            var selected;
            var movecycle;
            var radiovalue;
            //for (var i = 0; i < inputs.length; i++) {
            //    if (inputs[i].checked) {
            //        selected = inputs[i];
            //        break;
            //    }
            //}
            //if (selected) {
            //    movecycle = selected.innerHTML;
            //    radiovalue = selected.value;
            //    //alert("radio - " + radiovalue);
            //}

            // display value obtained
            var NewFuTrimYrTarget = document.getElementById("<%=txtFuTrimYrTarget.ClientID %>");
           var NewFuFuTrimYrTarget = document.getElementById("<%=txtFuFuTrimYrTarget.ClientID %>");

            var NewSysAssnYearText = NewSysAssnYear.options[NewSysAssnYear.selectedIndex].text;
            var NewCycleYearText = NewCycleYear.options[NewCycleYear.selectedIndex].text;
            var NewCycleText = NewCycle.options[NewCycle.selectedIndex].text;
            var NewChangeReasonText = NewChangeReason.options[NewChangeReason.selectedIndex].text;
            
            var CurSysAssnYear = document.getElementById("<%=lblSysAssnYear.ClientID %>").innerHTML;
           var CurCycleYear = document.getElementById("<%=lblCycleYear.ClientID %>").innerHTML;
            var CurCycle = document.getElementById("<%=lblCycle.ClientID %>").innerHTML;
            var CurChangeReason = document.getElementById("<%=lblChangeReson.ClientID %>").innerHTML;
            

            strMessage = "Do you want to make this change ?";
            var ddlCycleYear = document.getElementById("<%=ddlSysAssnYear.ClientID %>");
            var ddlWorkYear = document.getElementById("<%=ddlCycleYear.ClientID %>");

            var intNewCycleYear = parseInt(ddlCycleYear.options[ddlCycleYear.selectedIndex].text);
            var intNewWorkYear = parseInt(ddlWorkYear.options[ddlWorkYear.selectedIndex].text);

            if ((parseInt(CurSysAssnYear) !== intNewCycleYear) || (parseInt(CurCycleYear) !== intNewWorkYear) || (parseInt(NewCycleText) !== parseInt(CurCycle))) {
                if (NewChangeReasonText == CurChangeReason) {
                    alert('Specify change reason');
                    document.getElementById('<%= hfConfirmMsg.ClientID %>').value = "CR";
                    return;
                }
            }

            if ((intNewWorkYear - intNewCycleYear) > 1) {
                strMessage = "Work year and Cycle year has more than one year of diffrence, Do you want to make this change ?";
            }

            if (typeof strMessage !== "undefined") {
                var confirm_value = document.createElement("INPUT");
                confirm_value.type = "hidden";
                confirm_value.name = "confirm_value";
                confirm_value.value = "";
                var cmt = confirm(strMessage);
                if (cmt == true) {
                    // confirm_value.value = "Yes";
                    document.getElementById('<%= hfConfirmMsg.ClientID %>').value = "Yes";
                }
                else {
                    //confirm_value.value = "No";
                    document.getElementById('<%= hfConfirmMsg.ClientID %>').value = "No";
                }
                //document.forms[0].appendChild(confirm_value);
            }

            //alert(CurSysAssnYear + "-" + NewSysAssnYearText);
            //if (CurSysAssnYear !== NewSysAssnYearText) {
            //    alert("Hi");
            //}
            //else {
            //    alert("hello");
            //}


            //if (radiovalue == "Y") {
            //if (CurSysAssnYear !== NewSysAssnYearText && CurCycleYear !== NewCycleYearText && CurCycle !== NewCycleText) {
            //    strMessage = "Scheduled Work has been moved to " + NewSysAssnYearText +
            //          " Projected work has been moved to " + NewCycleYearText +
            //          " Cycle changed to " + NewCycleText +
            //          ", and future trim dates are changing permanently.";
            //}
            //else if (CurSysAssnYear !== NewSysAssnYearText && CurCycleYear !== NewCycleYearText){
            //    strMessage = "Scheduled Work has been moved to " + NewSysAssnYearText +
            //          " Projected work has been moved to " + NewCycleYearText +
            //          ", and future trim dates are changing permanently.";
            //}
            //else if (CurSysAssnYear !== NewSysAssnYearText && CurCycle !== NewCycleText) {
            //    strMessage = "Scheduled Work has been moved to " + NewSysAssnYearText +
            //           " Cycle changed to " + NewCycleText +
            //           ", and future trim dates are changing permanently.";
            //}
            //else if (CurCycleYear !== NewCycleYearText && CurCycle !== NewCycleText) {
            //    strMessage = " Projected work has been moved to " + NewCycleYearText +
            //          " Cycle changed to " + NewCycleText +
            //          ", and future trim dates are changing permanently.";
            //}
            //else if (CurSysAssnYear !== NewSysAssnYearText) {
            //    strMessage = "Scheduled Work has been moved to " + NewSysAssnYearText +
            //     ", and future trim dates are changing permanently.";
            //}
            //else if (CurCycleYear !== NewCycleYearText) {
            //    strMessage = "Projected work has been moved to " + NewCycleYearText + ", and future trim dates are changing permanently.";
            //}
            //else if (CurCycle !== NewCycleText) {
            //    strMessage = " Cycle will be changed to " + NewCycleText + ", and cause the future trim dates to be impacted.";
            //}
            //strMessage = "Do you want to make this change ?";
            //}

            //if (radiovalue == "N") {
            //if (CurSysAssnYear !== NewSysAssnYearText && CurCycleYear !== NewCycleYearText && CurCycle !== NewCycleText) {
            //    strMessage = "  Change the scheduled work to be done in " + NewSysAssnYearText +
            //     ". Change the projected work to be done in " + NewCycleYearText + ". Future dates change. " +
            //     " Cycle will be changed to " + NewCycleText + ", and cause the future trim dates to be impacted.";
            //}
            //else if (CurSysAssnYear !== NewSysAssnYearText && CurCycleYear !== NewCycleYearText) {
            //    strMessage = "  Change the scheduled work to be done in " + NewSysAssnYearText +
            //     ". Change the projected work to be done in " + NewCycleYearText + ". Future dates change. ";
            //}
            //else if (CurSysAssnYear !== NewSysAssnYearText && CurCycle !== NewCycleText) {
            //    strMessage = "  Change the scheduled work to be done in " + NewSysAssnYearText +
            //    " Cycle will be changed to " + NewCycleText + ", and cause the future trim dates to be impacted.";
            //}
            //else if (CurCycleYear !== NewCycleYearText && CurCycle !== NewCycleText) {
            //    strMessage = "Change the projected work to be done in " + NewCycleYearText + ".  Future dates change. " +
            //     " Cycle will be changed to " + NewCycleText + ", and cause the future trim dates to be impacted.";
            //}
            //else if (CurSysAssnYear !== NewSysAssnYearText) {
            //    strMessage = "  Change the scheduled work to be done in " + NewSysAssnYearText + ", and keep the future trim dates the same.";
            //}
            //else if (CurCycleYear !== NewCycleYearText) {
            //    strMessage = "Change the projected work to be done in " + NewCycleYearText + ". Future dates change.";
            //}
            //else if (CurCycle !== NewCycleText) {
            //    strMessage = " Cycle will be changed to " + NewCycleText + ", and cause the future trim dates to be impacted.";
            //}
            //strMessage = "Do you want to make this change ?";
            //}



        }


    </script>
    
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="cphPageTitleContentPlaceHolder" runat="server">
    <div id="CssPageTitle">
        <h1>
            Spray Cycle Management
        </h1>
    </div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="cphMainContentPlaceHolder" runat="server">
    
      <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"></asp:ScriptManager>
      <asp:UpdatePanel ID="UpdatePanel2" runat="server">
          
          <ContentTemplate>
              <div style="text-align:right;"><a href="default.aspx">Home</a> <strong>&#8249;&#8249;</strong> <a href="Analysis.aspx">Analysis</a> <strong>&#8249;&#8249;</strong>Spray Cycle Management</div>
                        <div >
             <fieldset class="masterform">
                <legend>Move Cycle</legend> 
                <div style=" width: 90%; height:80px; ">
                    <table>
                        <tr>
                            <td> Business Unit:
                            </td>
                            <td>
                                <asp:HiddenField ID="hfConfirmMsg" runat="server" />
                                <asp:HiddenField ID="hdnConfirmvalue" runat="server" />
                                <asp:HiddenField ID="hdn_role" runat="server" />
                                <asp:HiddenField ID="hdnRetainWkID" runat="server" />
                                <asp:DropDownList ID="ddlBUnit" runat="server" OnSelectedIndexChanged="ddlBUnit_SelectedIndexChanged" AutoPostBack="true" OnDataBound="ddlBUnit_DataBound">
                                </asp:DropDownList>
                            </td>
                        </tr>
                        <tr>
                            <td>Cycle Year:
                            </td>
                            <td>
                                <asp:DropDownList ID="ddlYear" runat="server" OnSelectedIndexChanged="ddlYear_SelectedIndexChanged" AutoPostBack="true" OnDataBound="ddlYear_DataBound">
                                </asp:DropDownList>
                            <td/>
                        </tr>
                        <%--<tr>
                            <td> Work Year:
                            </td>
                            <td>
                                <asp:DropDownList ID="ddlWorkYear" runat="server" OnSelectedIndexChanged="ddlWorkYear_SelectedIndexChanged" AutoPostBack="true"
                                     OnDataBound="ddlWorkYear_DataBound">
                                </asp:DropDownList>
                            <td/>
                        </tr>--%>
                        <tr>
                            <td> Project/Event:
                                </td>
                            <td style="color:red;">
                                <asp:DropDownList ID="ddlEventCode" runat="server" OnSelectedIndexChanged="ddlEventCode_SelectedIndexChanged" AutoPostBack="true">  
                                </asp:DropDownList>
                                * Cycle Management is allowed on status Ready.
                            </td>
                        </tr>
                      <%--   <tr runat="server" visible="false">
                            <td> Section/WA:
                                </td>
                            <td>
                                <asp:DropDownList ID="ddlWorkArea" runat="server" Width="250px" disabled="disabled"
                                     OnSelectedIndexChanged="ddlWorkArea_SelectedIndexChanged" AutoPostBack="true" OnDataBound="ddlWorkArea_DataBound">
                                </asp:DropDownList>
                            </td>
                       </tr>
                       <tr>
                             <td > <asp:Button ID="btnGo" runat="server" Text="Go" OnClick="btn_go_Click"  CssClass="FormButton"/></td> 
                        </tr>--%>
                        </table>
                        </div> 
             </fieldset>

                </div>
                <div>
                    <fieldset>
                    <legend>Changing Scheduled Cycle Information</legend> 
                <div style=" width: 98%; height:240px; ">
                    <%--<table >
                        <tr>
                            <td>
                               
                            </td>--%>

                             <table style=" width: 100%; " border="0" cellpadding="2">
                        <tr>
                            <td> </td>
                            <td>
                                <b>Current Spray Value</b></td>
                            <td>
                               <b> <strong>Updated Value</b></strong></td>
                            <td>
                               <b> <strong>Trim Value</b></strong></td>
                            
                       </tr>
                         <tr>
                                <td class="auto-style2">Previous Trim Date: </td>
                                <td class="auto-style2">
                                    <asp:Label ID="lblPrevTrimDt" runat="server"></asp:Label>
                                </td>
                                <td class="auto-style2">
                                    &nbsp;
                                </td>
                                 <td class="auto-style2">
                                    <asp:Label ID="lblSprayPrevTrimDt" runat="server"></asp:Label>
                                </td>
                            </tr>
                                 <tr>
                                     <td>Cycle Year: </td>
                                     <td>
                                         <asp:Label ID="lblSysAssnYear" runat="server"></asp:Label>
                                     </td>
                                     <td>
                                         <asp:DropDownList ID="ddlSysAssnYear" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlSysAssnYear_SelectedIndexChanged">
                                         </asp:DropDownList>
                                     </td>
                                     <td>
                                         <asp:Label ID="lblSpraySysAssnYear" runat="server"></asp:Label>
                                     </td>
                                 </tr>
                         <%--<tr style="display: none;">--%>
                        <tr>
                            <td> Work Year:
                                </td>
                             <td>
                                 <asp:Label ID="lblCycleYear" runat="server"></asp:Label>
                             </td>
                            <td>
                                <asp:DropDownList ID="ddlCycleYear" runat="server" OnSelectedIndexChanged="ddlCycleYear_SelectedIndexChanged" AutoPostBack="true">
                                </asp:DropDownList>
                            </td>
                            <td>
                                 <asp:Label ID="lblSprayCycleYear" runat="server"></asp:Label>
                             </td>

                       </tr>
                        <tr>
                            <td> Cycle:
                                </td>
                            <td>
                                <asp:Label ID="lblCycle" runat="server"></asp:Label>
                            </td>
                            <td>
                                <asp:DropDownList ID="ddlCycle" runat="server" OnSelectedIndexChanged="ddlCycle_SelectedIndexChanged" AutoPostBack="true">
                                </asp:DropDownList>
                            </td>
                            <td>
                                <asp:Label ID="lblSprayCycle" runat="server"></asp:Label>
                            </td>
                       </tr>

    
                        <tr>
                            <td> Change Reason:
                                </td>
                            <td>
                                <asp:Label ID="lblChangeReson" runat="server"></asp:Label>
                            </td>
                            <td>
                                <asp:DropDownList ID="ddlChangeReson" runat="server" >
                                </asp:DropDownList>
                            </td>
                            <td>
                                <asp:Label ID="lblSprayChangeReson" runat="server"></asp:Label>
                            </td>
                       </tr>

                         <tr>
                            <%--<td> Update Projected Year:--%>
                                </td>
                           <%-- <td>
                                <asp:CheckBox ID="chkMvCycle" runat="server" OnCheckedChanged="chkMvCycle_CheckedChanged" AutoPostBack="true">
                                </asp:CheckBox>
                            </td>--%>
                            <%-- <td>
                                 <asp:Label ID="lblmovecycle" runat="server"></asp:Label>
                             </td>--%>
                            
                                <%--<asp:RadioButton ID="rdoOneTime" Text="One-Time"  runat="server"  OnCheckedChanged="chkMvCycle_CheckedChanged" GroupName="movecycle" AutoPostBack="true">
                                </asp:RadioButton>--%>
                             <%-- <td>
                                 <asp:RadioButtonList ID="rblMvCycle" runat="server" OnSelectedIndexChanged="chkMvCycle_CheckedChanged" AutoPostBack="true" RepeatDirection="Horizontal" Width="200px">
                                     <asp:ListItem Text=" One-Time" Value="N"></asp:ListItem>
                                     <asp:ListItem Text=" Permanent" Value="Y" Selected="True"></asp:ListItem>
                                 </asp:RadioButtonList>
                            </td>--%>
                              <%-- <td>
                              <asp:RadioButton ID="rdoPermanent" Text="Permanent"  runat="server" OnCheckedChanged="chkMvCycle_CheckedChanged" GroupName="movecycle" AutoPostBack="true">
                                </asp:RadioButton>
                            </td>--%>
                       </tr>
                        <tr>
                            <td>Future Trim Year Target:
                                </td>
                            <td>
                                <asp:Label ID="lblFuTrimYrTarget" runat="server"></asp:Label>
                            </td>
                            <td>                                
                                <asp:TextBox ID="txtFuTrimYrTarget" runat="server" ReadOnly="true" >
                                </asp:TextBox>
                            </td>
                            <td>
                                <asp:Label ID="lblSprayFuTrimYrTarget" runat="server"></asp:Label>
                            </td>
                       </tr>
                        <tr>
                            <td>Future Future Trim Year Target:
                                </td>
                            <td>
                                <asp:Label ID="lblFuFuTrimYrTarget" runat="server"></asp:Label>
                            </td>
                            <td>
                                <asp:TextBox ID="txtFuFuTrimYrTarget" runat="server" ReadOnly="true" >
                                </asp:TextBox>
                            </td>
                            <td>
                                <asp:Label ID="lblSprayFuFuTrimYrTarget" runat="server"></asp:Label>
                            </td>
                       </tr>
                        

                        <tr>
                             <td > <asp:Button ID="btnUpdate" runat="server" Text="Submit"  Visible="false" onclientclick="javascript:CallMethod();" OnClick="btnUpdate_Click"  CssClass="FormButton"/></td> 
                             <td>&nbsp;<asp:HiddenField ID="hfWorkStatusId" runat="server" />
                             </td>
                        </tr>
                        </table>
                            <%--<td>
                            </td>
                        </tr>
                    </table>--%>
                    
                   
                </fieldset>

                </div>    
                    

              </div>
                    <br />
                     

                           
                    </ContentTemplate>
     </asp:UpdatePanel>
</asp:Content>
