Solved

"foo" does not contain a definition for "controlBar"

Posted on 2013-01-30
5
677 Views
Last Modified: 2013-01-30
I copied some markup from another .ascx control (which had similar functionality to the new control I am writing) and I also copied and pasted in the designer stuff.

But still I get this error at compile time:

Error	433	'Reo.ContentControls.Tasks.RepairBidDetail' does not contain a definition for 'btnSubmit' and no extension method 'btnSubmit' accepting a first argument of type 'Reo.ContentControls.Tasks.RepairBidDetail' could be found (are you missing a using directive or an assembly reference?)	C:\R13\Reo\ContentControls\RepairBidDetail.ascx.cs	90	18	Reo

Open in new window





I am getting a whole host of these same messages.



Can this be resolved?


What is the reason the class has no knowledge of the control?


Tom
0
Comment
Question by:knowlton
  • 3
  • 2
5 Comments
 
LVL 41

Expert Comment

by:guru_sami
Comment Utility
Make sure you have a btnSubmit in your markup...
Can you share some code...
0
 
LVL 5

Author Comment

by:knowlton
Comment Utility
Yep, btnSubmit is there.


Here is the current markup:
<%@ Control Language="C#" AutoEventWireup="True" CodeBehind="RepairBidDetail.ascx.cs"
    Inherits="Reo.ContentControls.RepairBidDetail" ClassName="RepairBidDetail" %>
<%@ Register Src="~/ContentControls/AssetFrameNavigation.ascx" TagName="AssetFrameNavigation"
    TagPrefix="uc2" %>
<%@ Register Assembly="Framework" Namespace="Framework.UIControls" TagPrefix="cc1" %>
<%@ Register TagPrefix="uc1" TagName="DateCalendar" Src="~/Controls/DateCalendar.ascx" %>
<%@ Register Src="~/Controls/AssetDoc_Upload.ascx" TagName="AssetDoc_Upload" TagPrefix="uc2" %>
<%@ Register TagPrefix="uc1" TagName="PhotoBar" Src="~/Controls/PhotoBar.ascx" %>
<%@ Register Src="~/Controls/AssetTaskAppr.ascx" TagName="AssetTaskAppr" TagPrefix="uc2" %>
<%@ Register TagPrefix="uc2" TagName="BigLabel" Src="~/Controls/BigLabel.ascx" %>

<script type="text/javascript">
</script>
<div id="frame">
    <div id="frame_header">
        <uc2:AssetFrameNavigation ID="AssetFrameNavigation1" runat="server" />
        <!-- This is the frame main navigation tabs -->
        <div id="frame_title">
            <h1>
                <asp:Label ID="lblPageTitle" runat="server" Text="Repair Bid Detail" /></h1>
            <!-- Page title -->
        </div>
    </div>
    <div id="corpus">
        <!-- This is where the content of each page should go -->
        <div id="divInstructions" runat="server">
            <p>
                <b id="pInstructions" runat="server"></b>
            </p>
        </div>
        <div id="divTaskError" runat="server" visible="false">
            <h6>
                Form Errors</h6>
            <div id="errorPanel" class="warning list_item" runat="server">
            </div>
        </div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <h6>
                </h6>
                <table class="layout_table">
                    <tr>
                        <td>
                            <label>
                                Contractor Name:</label>
                        </td>
                        <td>
                            <asp:Label ID="LabelContractorName" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label>
                                Estimated Completion Days:</label>
                        </td>
                        <td>
                            <asp:Label ID="LabelEstimatedCompletionDays" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label>
                                Bid Total:</label>
                        </td>
                        <td>
                            <asp:Label ID="LabelBidTotal" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label>
                                Bid Status</label>
                        </td>
                        <td>
                            <%--<cc1:DdlLookup ID="ddlPropertyCondition" HeaderCode="Condition" AllowUnassigned="true"
                                runat="server">
                            </cc1:DdlLookup>--%>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label>
                                Bid Document</label>
                        </td>
                        <td>
                            <asp:HyperLink ID="hypBidDocument" runat="server" NavigateUrl="#" rel='shadowbox;width=900;height=600'>PDF</asp:HyperLink>
                        </td>
                    </tr>
                    <div class="Form">
                </table>
                <cc1:GridviewFormatted ID="gvRepair" runat="server" AllowSorting="True" AllowPaging="False"
                    ShowFooter="true" PageSize="15" AutoGenerateColumns="false" OnRowDataBound="rowDataBound">
                    <Columns>
                        <asp:TemplateField Visible="false">
                            <ItemTemplate>
                                <asp:Label ID="repairItemIDSID" runat="server"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Repair Item" ItemStyle-Width="100px" SortExpression="RepairItemID">
                            <ItemTemplate>
                                <cc1:DdlRprSubCategory ID="ddlItems" AllowUnassigned="true" Enabled="true" Width="150px"
                                    Style="display: inline;" runat="server">
                                </cc1:DdlRprSubCategory>
                                <asp:Label ID="lblItems" Width="150px" runat="server" Visible="false" />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Details" SortExpression="Details">
                            <ItemTemplate>
                                <%--                                   <uc2:BigLabel ID="lblDetails" runat="server" LabelWidth="100px" LabelHeight="15px" MessageText='<%# Eval("Details") %>'  />
                                   <asp:TextBox ID="txtDetails" runat="server" Width="100px" Visible="false"></asp:TextBox>--%>
                                <uc2:BigLabel ID="iconDetails" LabelWidth="0px" MessageText='<%# Eval("Details") %>'
                                    runat="server" Width="32px" Height="32px" />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Include" ItemStyle-Width="50px" SortExpression="Active">
                            <ItemTemplate>
                                <asp:CheckBox ID="chkActive" runat="server" />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Bid 1 Qty" SortExpression="Qty1" FooterText="Subtotals:">
                            <ItemTemplate>
                                <cc1:TxtInteger ID="txtQty1" Width="30px" runat="server" Style="display: inline;"></cc1:TxtInteger>&nbsp;
                                 <asp:Label ID="lblQty1" runat="server" Visible="false"></asp:Label>
                                <asp:Label ID="lblUnitDesc1" runat="server"></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderText="Bid 1 Amt" ItemStyle-Width="100px" SortExpression="Amt1">
                            <ItemTemplate>
                                <cc1:TxtCurrency ID="txtAmt1" Width="60" runat="server" DecimalDigits="2"></cc1:TxtCurrency>
                                <cc1:LblCurrency ID="lblAmt1" runat="server" Visible="false" DecimalDigits="2"></cc1:LblCurrency>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField>
                            <ItemTemplate>
                                <asp:Label ID="lblItemID" runat="server" Visible="false" />
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </cc1:GridviewFormatted>
                </div>
                <div class="Form">
                    <h6>
                        Other Contractor Recommended Repairs</h6>
                    <cc1:GridviewFormatted ID="gvRecommended" runat="server" AllowSorting="False" AllowPaging="False"
                        ShowFooter="true" AutoGenerateColumns="false" OnRowDataBound="rowDataBound">
                        <Columns>
                            <asp:TemplateField Visible="false">
                                <ItemTemplate>
                                    <asp:Label ID="repairItemIDSID" runat="server"></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Category" ItemStyle-Width="100px" SortExpression="RepairItemID">
                                <ItemTemplate>
                                    <cc1:DdlRprCategory ID="ddlRepairCategory" AllowUnassigned="true" Enabled="true"
                                        Width="150px" AutoPostBack="true" OnSelectedIndexChanged="ddlRepairCategory_SelectedIndexChanged"
                                        Style="display: inline;" runat="server">
                                    </cc1:DdlRprCategory>
                                    <asp:Label ID="lblRprCat" runat="server" Visible="false"></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Repair Item" ItemStyle-Width="150px" SortExpression="RepairItemID">
                                <ItemTemplate>
                                    <cc1:DdlRprSubCategory ID="ddlItems" AllowUnassigned="true" Enabled="true" Width="150px"
                                        Style="display: inline;" runat="server">
                                    </cc1:DdlRprSubCategory>
                                    <asp:Label ID="lblItems" runat="server" Width="150px" Visible="false" />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Details">
                                <ItemTemplate>
                                    <asp:TextBox ID="txtDetails" runat="server" Width="100px"></asp:TextBox>
                                    <uc2:BigLabel ID="lblDetails" runat="server" LabelWidth="100px" LabelHeight="15px"
                                        Visible="false" />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Include" ItemStyle-Width="50px" SortExpression="Active">
                                <ItemTemplate>
                                    <asp:CheckBox ID="chkActive" runat="server" />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Bid 1 Qty" SortExpression="Qty1" FooterText="Subtotals:">
                                <ItemTemplate>
                                    <cc1:TxtInteger ID="txtQty1" Width="30px" runat="server" Style="display: inline;"></cc1:TxtInteger>&nbsp;
                                     <asp:Label ID="lblQty1" runat="server" Visible="false"></asp:Label>
                                    <asp:Label ID="lblUnitDesc1" runat="server"></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Bid 1 Amt" ItemStyle-Width="100px" SortExpression="Amt1">
                                <ItemTemplate>
                                    <cc1:TxtCurrency ID="txtAmt1" Width="60" runat="server" DecimalDigits="2"></cc1:TxtCurrency>
                                    <cc1:LblCurrency ID="lblAmt1" runat="server" Visible="false" DecimalDigits="2"></cc1:LblCurrency>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:Label ID="lblItemID" runat="server" Visible="false" />
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </cc1:GridviewFormatted>
                    <div id="divRprAddlInst">
                        <table width="100%">
                            <tr>
                                <td>
                                    <label>
                                        Additional Repair Instructions</label>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <cc1:TxtString ID="txtAddlInst" runat="server" Rows="10" TextMode="MultiLine" 
                                        Width="95%" />
                                </td>
                            </tr>
                        </table>
                        <table id="tblInstructionsDoc" runat="server">
                            <tr>
                                <td style="vertical-align: top;">
                                    <label>
                                        Additional Instructions Documentation:</label>
                                </td>
                                <td>
                                    <uc2:AssetDoc_Upload ID="uplAddlInst" Description="Repair Bid Instructions" runat="server"
                                        DocumentCategoryCode="DocCatRpr" ShowDelete="false" />
                                </td>
                            </tr>
                        </table>
                    </div>
                    <h6>Upload "Before" Photos</h6>
                    <table id="tblAddPhotos" runat="server" style="width:400px;">
                        <tr>
                            <td></td>
                            <td id="tdAddPhotos" runat="server">
                                <span class="button" id="spnLnkAddPhotos" runat="server">
                                    <asp:HyperLink ID="lnkAddPhotos" runat="server" 
                                        NavigateUrl="#"
                                        rel="shadowbox;height=600;width=1024" title="Add Photos" Text="Add Photos">
                                    </asp:HyperLink>                          
                                </span>
                            </td>
                        </tr>
                    </table>
                    <%--<uc1:PhotoBar ID="photoBar1" runat="server" />  --%>        
                    <uc1:PhotoBar ID="photoBar1" runat="server" />          
                </div>
                
            </ContentTemplate>
            <Triggers>
                <asp:PostBackTrigger ControlID="cmdSubmit" />
                <asp:PostBackTrigger ControlID="btnApprove" />
            </Triggers>
        </asp:UpdatePanel>



         <div id="divSave" class="float_left" runat="server">
            <table>
                <tr>
                    <td>
                        <span id="spnSaveBtn" class="button" runat="server">
                            <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" />
                        </span>
                    </td>
                    <td>
                        <span id="spnSubmitBtn" class="button" runat="server">
                            <asp:Button ID="btnSubmit" runat="server" Text="Save & Submit" OnClick="btnSubmit_Click"/>
                        </span>
                    </td>
                </tr>
            </table>
        </div>

        <div class="extender">
        </div>
    </div>
    <div id="footer">
    </div>
</div>
<div id="end_cap">
</div>

Open in new window



Here is the current code-behind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Text;
using System.IO;

using Models;
using Framework.Utilities;
using Framework.Business;
using Framework.UIControls;
using Framework.UIControls.Base;
using Reo.Controls;


namespace Reo.ContentControls.Tasks
{
    public partial class RepairBidDetail : Reo.Base.BaseTask
    {

        protected int RepairBidFormID;
        protected int RepairBidFormSID;
        protected int FormAssetTaskID;
        protected int FormAssetTaskSID;

        protected int requiredBidNumber;

        protected bool allowPhotoDelete;

        protected bool bid1Active = true;
        protected bool bid2Active = true;
        protected bool bid3Active = true;
        protected bool bid4Active = true;
        protected bool bidFSActive = true;

        protected bool bid4Visible = false;
        protected bool bid4Edit = false;

        protected bool FSBidOnly = false;
        protected bool oneBidOnly = false;

        protected RepairBidForm_GetResult repairBidFormData;
        protected List<RepairBidItems_GetResult> repairItemData;
        protected AssetTaskInfo_GetResult taskInfo;
        protected List<RepairBid_GetResult> repairBidData;
        protected List<RepairUnit_GetResult> repairUnitData;
        protected List<PoolBidLimit_SelectResult> bidLimits;
        protected List<AssetDoc_GetResult> assetDocData;

        protected List<PhotoDocs_GetResult> photos;

        protected RepairBid_GetResult bid1;
        protected RepairBid_GetResult bid2;
        protected RepairBid_GetResult bid3;
        protected RepairBid_GetResult bid4;
        protected RepairBid_GetResult bidFS;
        protected RepairBid_GetResult approvedBid;

        protected string bid1IDSID = "";
        protected string bid2IDSID = "";
        protected string bid3IDSID = "";
        protected string bid4IDSID = "";
        protected string bidFSIDSID = "";

        protected List<RepairBidItems_GetResult> recommendedBidsItems;
        protected List<RepairBidItems_GetResult> normalBidsItems;


        #region -- Page_Load --
        protected void Page_Load(object sender, EventArgs e)
        {
            photoBar1.DisableAutoPopulate = true;
            GetAssetTaskInfo();

            if (taskInfo.Code == "RVWRPRBD")
            {
                SetReviewFields();
            }

            if (!IsPostBack)
            {
                SetFormData();
            }
            SetVisibleFields();
            DisplayPhotos();            
            this.btnSubmit.OnClientClick = "HideButton('" + this.spnSubmitBtn.ClientID + "');";

        }
        #endregion

        #region -- GetAssetTaskInfo --
        protected void GetAssetTaskInfo()
        {
            if (Request.QueryString["AssetTaskID"] != null)
            {
                //string atIdSid = Request.QueryString["AssetTaskID"];
                //AssetTaskID = Helper.SplitKey(atIdSid).PrimaryID;
                //AssetTaskSID = Helper.SplitKey(atIdSid).ServerID;

                LoadData();

                Task_AuthorizeUser auth = TaskMaster.AuthorizeUser(taskInfo);
                if (!auth.CanEnterTask)
                {
                    TaskError(2);
                }

                if (!auth.CanCompleteTask)
                {
                    this.divSave.Visible = false;
                    Helper.DisableControls(this);
                    allowPhotoDelete = false;
                }
                else
                {
                    allowPhotoDelete = true;
                }

                this.lblPageTitle.Text = taskInfo.Description;

                if (!string.IsNullOrEmpty(taskInfo.Instructions))
                {
                    this.pInstructions.InnerText = taskInfo.Instructions;
                }
            }
            else
            {
                TaskError(1);
            }

        }
        protected void TaskError(int code)
        {
            // code 1 = Unable to find task data
            // code 2 = Not authorized to enter task
            //string assetIDSID = "";

            //if (AssetID != 0 && AssetSID != 0)
            //{
            //    assetIDSID = AssetID + "-" + AssetSID;
            //}

            //else if (Request.QueryString["AssetID"] != null)
            //{
            //    assetIDSID = (Request.QueryString["AssetID"]);
            //}

            NavigationManager.NavigateToTaskErrorPage(AssetIdSid, code);
        }


        #endregion

        #region -- LoadData --

        protected void LoadData()
        {
            GetData();

            // Test if FS Bid is required and not present (should not happen)
            if (string.IsNullOrEmpty(bidFSIDSID) && (repairBidFormData.BidsFrom == LookUp.Find("RBFS").LookupID || repairBidFormData.BidsFrom == LookUp.Find("RBBOTH").LookupID))
            {
                using (RepairBidDataContext dc = new RepairBidDataContext())
                {
                    dc.RepairBid_Insert(RepairBidFormID, RepairBidFormSID, LookUp.Find("PRESRPRFS").LookupID);
                }
                GetData();
            }

            approvedBid = repairBidData.Find(item => item.RepairBidID == repairBidFormData.ApprovedRepairBidID &&
                item.RepairBidSID == repairBidFormData.ApprovedRepairBidSID);


            normalBidsItems = repairItemData.FindAll(item => item.IsContractorRecommended == false);
            recommendedBidsItems = repairItemData.FindAll(item => item.IsContractorRecommended == true);


            this.uploadBid1.AssetID = AssetID;
            this.uploadBid1.AssetSID = AssetSID;
            this.uploadBid1.AssetTaskID = FormAssetTaskID;
            this.uploadBid1.AssetTaskSID = FormAssetTaskSID;
            this.uploadBid2.AssetID = AssetID;
            this.uploadBid2.AssetSID = AssetSID;
            this.uploadBid2.AssetTaskID = FormAssetTaskID;
            this.uploadBid2.AssetTaskSID = FormAssetTaskSID;
            this.uploadBid3.AssetID = AssetID;
            this.uploadBid3.AssetSID = AssetSID;
            this.uploadBid3.AssetTaskID = FormAssetTaskID;
            this.uploadBid3.AssetTaskSID = FormAssetTaskSID;
            this.uploadBid4.AssetID = AssetID;
            this.uploadBid4.AssetSID = AssetSID;
            this.uploadBid4.AssetTaskID = FormAssetTaskID;
            this.uploadBid4.AssetTaskSID = FormAssetTaskSID;
            this.uploadBidFS.AssetID = AssetID;
            this.uploadBidFS.AssetSID = AssetSID;
            this.uploadBidFS.AssetTaskID = FormAssetTaskID;
            this.uploadBidFS.AssetTaskSID = FormAssetTaskSID;

            this.uplAddlInst.AssetTaskID = FormAssetTaskID;
            this.uplAddlInst.AssetTaskSID = FormAssetTaskSID;

            this.uploadBid1.bindDocuments();
            this.uploadBid2.bindDocuments();
            this.uploadBid3.bindDocuments();
            this.uploadBid4.bindDocuments();
            this.uploadBidFS.bindDocuments();

            this.uplAddlInst.bindDocuments();
            if (!this.uplAddlInst.HasDocs)
            {
                this.tblInstructionsDoc.Visible = false;
            }

            SetPhotoUrl();

            CalculateTotals();
            CalcRequiredBids();



        }

        protected void GetData()
        {
            using (RepairBidDataContext dc = new RepairBidDataContext())
            {
                IMultipleResults results = dc.RepairBidForm_GetResults(AssetTaskID, AssetTaskSID);
                repairBidFormData = results.GetResult<RepairBidForm_GetResult>().FirstOrDefault<RepairBidForm_GetResult>();
                taskInfo = results.GetResult<AssetTaskInfo_GetResult>().FirstOrDefault<AssetTaskInfo_GetResult>();
                repairItemData = results.GetResult<RepairBidItems_GetResult>().ToList<RepairBidItems_GetResult>();
                repairBidData = results.GetResult<RepairBid_GetResult>().ToList<RepairBid_GetResult>();
                repairUnitData = results.GetResult<RepairUnit_GetResult>().ToList<RepairUnit_GetResult>();
                bidLimits = results.GetResult<PoolBidLimit_SelectResult>().ToList<PoolBidLimit_SelectResult>();
                assetDocData = results.GetResult<AssetDoc_GetResult>().ToList<AssetDoc_GetResult>();

                if (repairBidFormData == null || taskInfo == null)
                {
                    TaskError(1);
                }

                //AssetID = taskInfo.AssetID;
                //AssetSID = taskInfo.AssetSID;

                RepairBidFormID = repairBidFormData.RepairBidFormID;
                RepairBidFormSID = repairBidFormData.RepairBidFormSID;

                FormAssetTaskID = repairBidFormData.FormAssetTaskID;
                FormAssetTaskSID = repairBidFormData.FormAssetTaskSID;

                bid1 = repairBidData.Find(item => item.PresTypeID == Framework.Business.LookUp.Find("PresRpr1").LookupID);
                bid2 = repairBidData.Find(item => item.PresTypeID == Framework.Business.LookUp.Find("PresRpr2").LookupID);
                bid3 = repairBidData.Find(item => item.PresTypeID == Framework.Business.LookUp.Find("PresRpr3").LookupID);
                bid4 = repairBidData.Find(item => item.PresTypeID == Framework.Business.LookUp.Find("PresRpr4").LookupID);
                bidFS = repairBidData.Find(item => item.PresTypeID == Framework.Business.LookUp.Find("PresRprFS").LookupID);

                if (bid1 != null)
                {
                    bid1IDSID = bid1.RepairBidID.ToString() + "-" + bid1.RepairBidSID.ToString();
                }
                if (bid2 != null)
                {
                    bid2IDSID = bid2.RepairBidID.ToString() + "-" + bid2.RepairBidSID.ToString();
                }
                if (bid3 != null)
                {
                    bid3IDSID = bid3.RepairBidID.ToString() + "-" + bid3.RepairBidSID.ToString();
                }

                if (bid4 != null)
                {
                    bid4IDSID = bid4.RepairBidID.ToString() + "-" + bid4.RepairBidSID.ToString();
                }

                if (bidFS != null)
                {
                    bidFSIDSID = bidFS.RepairBidID.ToString() + "-" + bidFS.RepairBidSID.ToString();
                }

                if (taskInfo.Code == "ORPRBID_FS" || taskInfo.Code == "OMPRB_FS")
                {
                    FSBidOnly = true;
                }

                else
                {
                    // Only one bid required if  bid is provided by Both FS Co. and Listing Agent
                    if (LookUp.Find(repairBidFormData.BidsFrom).LookupCode == "RBBOTH")
                    {
                        oneBidOnly = true;
                    }
                }
            }
        }

        #endregion

        #region -- DisplayPhotos --
        protected void DisplayPhotos()
        {
            using (PhotoDocsDataContext dc1 = new PhotoDocsDataContext())
            {
                photos = dc1.PhotoDocs_Get(AssetID, AssetSID, RepairBidFormID, RepairBidFormSID,
                    LookUp.Find("PicKeyRpr").LookupID, LookUp.Find("PicRprBfor").LookupID, null, null, FormAssetTaskID, FormAssetTaskSID)
                    .ToList<PhotoDocs_GetResult>();
            }
            if (photos.Count == 0)
            {
                this.photoBar1.Visible = false;
            }
            else
            {
                photoBar1.AllowDelete = allowPhotoDelete;
                photoBar1.Visible = true;
                photoBar1.AlreadyBound = true;
                photoBar1.BindRepeater(photos);
            }
        }
        #endregion

        #region -- SetPhotoUrl --

        protected void SetPhotoUrl()
        {
            //PhotoUpload URL
            StringBuilder sp = new StringBuilder();
            sp.Append("~/Sbox.aspx?MenuID=" + NavigationManager.GetMenuID("UplPhoto"));
            sp.Append("&AssetID=" + AssetID + "-" + AssetSID);
            sp.Append("&AssetTaskID=" + FormAssetTaskID + "-" + FormAssetTaskSID);
            sp.Append("&KeyTypeID=" + LookUp.Find("PicKeyRpr").LookupID);
            sp.Append("&PhotoTypeID=" + LookUp.Find("PicRprBfor").LookupID);
            sp.Append("&KeyID=" + RepairBidFormID + "-" + RepairBidFormSID);
            sp.Append("&Popup=true");

            lnkAddPhotos.NavigateUrl = sp.ToString();
        }

        #endregion
        #region -- SetFormData --
        protected void SetFormData()
        {
            if (bid1 != null)
            {
                txtContractorName1.Text = bid1.BidCompany;
                txtRprEstCompletionDays1.SaveValue = bid1.RprEstCompletionDays;
                ddlBid1Status.LookupID = bid1.StatusID;
            }

            if (bid2 != null)
            {
                txtContractorName2.Text = bid2.BidCompany;
                txtRprEstCompletionDays2.SaveValue = bid2.RprEstCompletionDays;
                ddlBid2Status.LookupID = bid2.StatusID;

            }

            if (bid3 != null)
            {
                txtContractorName3.Text = bid3.BidCompany;
                txtRprEstCompletionDays3.SaveValue = bid3.RprEstCompletionDays;
                ddlBid3Status.LookupID = bid3.StatusID;

            }

            if (bid4 != null)
            {
                txtContractorName4.Text = bid4.BidCompany;
                txtRprEstCompletionDays4.SaveValue = bid4.RprEstCompletionDays;
                ddlBid4Status.LookupID = bid4.StatusID;
            }

            if (bidFS != null)
            {
                txtContractorNameFS.Text = bidFS.BidCompany;
                txtRprEstCompletionDaysFS.SaveValue = bidFS.RprEstCompletionDays;
                ddlBidFSStatus.LookupID = bidFS.StatusID;
            }

            this.gvRepairBids.DataSource = bidLimits;
            this.gvRepairBids.DataBind();

            FillItemGrids();

            this.txtAddlInst.Text = repairBidFormData.RprAdditionalComment;

            this.lblReqBy.LookupID = repairBidFormData.RentalRepairReqBy;
            this.lblEmergencyRepair.DisplayValue = repairBidFormData.RentalEmergencyRepair;

        }
        #endregion

        #region -- FillItemGrids --
        protected void FillItemGrids()
        {
            this.gvRepair.DataSource = normalBidsItems;
            this.gvRepair.DataBind();

            this.gvRecommended.DataSource = recommendedBidsItems;
            this.gvRecommended.DataBind();

            this.gvRepair.Columns[12].Visible = bid4Visible;
            this.gvRepair.Columns[13].Visible = bid4Visible;
            this.gvRecommended.Columns[13].Visible = bid4Visible;
            this.gvRecommended.Columns[14].Visible = bid4Visible;

            CalculateTotals();
            CalcRequiredBids();
        }
        #endregion

        #region -- SetVisibleFields --
        protected void SetVisibleFields()
        {
            if (taskInfo.Code == "RVWRPRBD")
            {
                this.txtContractorName1.ReadOnly = true;
                this.txtContractorName2.ReadOnly = true;
                this.txtContractorName3.ReadOnly = true;

                this.txtRprEstCompletionDays1.ReadOnly = true;
                this.txtRprEstCompletionDays2.ReadOnly = true;
                this.txtRprEstCompletionDays3.ReadOnly = true;
                this.txtRprEstCompletionDaysFS.ReadOnly = true;

                // hide unused bids
                bid1Active = (!string.IsNullOrEmpty(bid1.BidCompany));
                bid2Active = (!string.IsNullOrEmpty(bid2.BidCompany));
                bid3Active = (!string.IsNullOrEmpty(bid3.BidCompany));
                bidFSActive = (repairBidFormData.BidsFrom == LookUp.Find("RBFS").LookupID || repairBidFormData.BidsFrom == LookUp.Find("RBBOTH").LookupID);

                this.tdBid1Hdr.Visible = bid1Active;
                this.tdBid1Name.Visible = bid1Active;
                this.tdBid1Days.Visible = bid1Active;
                this.tdBid1Status.Visible = bid1Active;
                this.tdBid1Total.Visible = bid1Active;

                this.tdBid2Hdr.Visible = bid2Active;
                this.tdBid2Name.Visible = bid2Active;
                this.tdBid2Days.Visible = bid2Active;
                this.tdBid2Status.Visible = bid2Active;
                this.tdBid2Total.Visible = bid2Active;

                this.tdBid3Hdr.Visible = bid3Active;
                this.tdBid3Name.Visible = bid3Active;
                this.tdBid3Days.Visible = bid3Active;
                this.tdBid3Status.Visible = bid3Active;
                this.tdBid3Total.Visible = bid3Active;

                this.tdBidFSHdr.Visible = bidFSActive;
                this.tdBidFSName.Visible = bidFSActive;
                this.tdBidFSDays.Visible = bidFSActive;
                this.tdBidFSStatus.Visible = bidFSActive;
                this.tdBidFSTotal.Visible = bidFSActive;

                this.gvRepair.Columns[4].Visible = bid1Active;
                this.gvRepair.Columns[5].Visible = bid1Active;
                this.gvRepair.Columns[6].Visible = bid2Active;
                this.gvRepair.Columns[7].Visible = bid2Active;
                this.gvRepair.Columns[8].Visible = bid3Active;
                this.gvRepair.Columns[9].Visible = bid3Active;
                this.gvRepair.Columns[10].Visible = bidFSActive;
                this.gvRepair.Columns[11].Visible = bidFSActive;


                this.gvRecommended.Columns[5].Visible = bid1Active;
                this.gvRecommended.Columns[6].Visible = bid1Active;
                this.gvRecommended.Columns[7].Visible = bid2Active;
                this.gvRecommended.Columns[8].Visible = bid2Active;
                this.gvRecommended.Columns[9].Visible = bid3Active;
                this.gvRecommended.Columns[10].Visible = bid3Active;
                this.gvRecommended.Columns[11].Visible = bidFSActive;
                this.gvRecommended.Columns[12].Visible = bidFSActive;


                this.trBidStatus.Visible = true;
                if (string.IsNullOrEmpty(this.txtContractorName1.Text) || this.lblGrandTotal1.DisplayValue == 0)
                {
                    this.ddlBid1Status.Enabled = false;
                }
                if (string.IsNullOrEmpty(this.txtContractorName2.Text) || this.lblGrandTotal2.DisplayValue == 0)
                {
                    this.ddlBid2Status.Enabled = false;
                }
                if (string.IsNullOrEmpty(this.txtContractorName3.Text) || this.lblGrandTotal3.DisplayValue == 0)
                {
                    this.ddlBid3Status.Enabled = false;
                }

                if (!bidFSActive)
                {
                    this.ddlBidFSStatus.Enabled = false;
                }

                this.lnkAddRec.Visible = bid4Edit;

                this.tdAddPhotos.Visible = false;
                allowPhotoDelete = false;

                if (taskInfo.StatusID == LookUp.Find("AstTskPendAprvl").LookupID)
                {
                    this.tblAddPhotos.Visible = false;
                    allowPhotoDelete = false;
                }

                this.uploadBid1.ShowDelete = false;
                this.uploadBid2.ShowDelete = false;
                this.uploadBid3.ShowDelete = false;
                this.uploadBidFS.ShowDelete = false;
                this.uploadBid4.ShowDelete = bid4Visible;

                if (this.uploadBid1.Documents == null || this.uploadBid1.Documents.Count == 0)
                {
                    this.trBid1.Visible = false;
                }
                if (this.uploadBid2.Documents == null || this.uploadBid2.Documents.Count == 0)
                {
                    this.trBid2.Visible = false;
                }
                if (this.uploadBid3.Documents == null || this.uploadBid3.Documents.Count == 0)
                {
                    this.trBid3.Visible = false;
                }
                if (this.uploadBidFS.Documents == null || this.uploadBidFS.Documents.Count == 0)
                {
                    this.trBidFS.Visible = false;
                }
                this.trBid4.Visible = bid4Visible;


                // if all bids are denied, show prompt to require new bids or not
                int apprCount = 0;
                if (this.ddlBid1Status.Enabled && this.ddlBid1Status.LookupCode != "PRESDENY") apprCount++;
                if (this.ddlBid2Status.Enabled && this.ddlBid2Status.LookupCode != "PRESDENY") apprCount++;
                if (this.ddlBid3Status.Enabled && this.ddlBid3Status.LookupCode != "PRESDENY") apprCount++;
                if (this.ddlBidFSStatus.Enabled && this.ddlBidFSStatus.LookupCode != "PRESDENY") apprCount++;
                if (bid4Visible && this.ddlBid4Status.Enabled && this.lblGrandTotal4.DisplayValue > 0 &&
                    this.ddlBid4Status.LookupCode != "PRESDENY") apprCount++;

                this.trNewBids.Visible = (apprCount == 0);
                Show_HideBidVerification(apprCount > 0);
            }
            else // Obtain Repair Bids task
            {
                this.trBidStatus.Visible = false;
                Show_HideBid4(false);
                Show_HideBidVerification(false);

                if (FSBidOnly || oneBidOnly)
                {
                    this.divRepairBids.Visible = false;

                    bid1Active = !FSBidOnly;
                    bid2Active = false;
                    bid3Active = false;
                    bidFSActive = FSBidOnly;

                    this.tdBid1Hdr.Visible = !FSBidOnly;
                    this.tdBid1Name.Visible = !FSBidOnly;
                    this.tdBid1Days.Visible = !FSBidOnly;
                    this.tdBid1Status.Visible = !FSBidOnly;
                    this.tdBid1Total.Visible = !FSBidOnly;

                    this.tdBid2Hdr.Visible = false;
                    this.tdBid2Name.Visible = false;
                    this.tdBid2Days.Visible = false;
                    this.tdBid2Status.Visible = false;
                    this.tdBid2Total.Visible = false;

                    this.tdBid3Hdr.Visible = false;
                    this.tdBid3Name.Visible = false;
                    this.tdBid3Days.Visible = false;
                    this.tdBid3Status.Visible = false;
                    this.tdBid3Total.Visible = false;

                    this.tdBidFSHdr.Visible = FSBidOnly;
                    this.tdBidFSName.Visible = FSBidOnly;
                    this.tdBidFSDays.Visible = FSBidOnly;
                    this.tdBidFSStatus.Visible = FSBidOnly;
                    this.tdBidFSTotal.Visible = FSBidOnly;

                    this.gvRepair.Columns[4].Visible = !FSBidOnly;
                    this.gvRepair.Columns[5].Visible = !FSBidOnly;
                    this.gvRepair.Columns[6].Visible = false;
                    this.gvRepair.Columns[7].Visible = false;
                    this.gvRepair.Columns[8].Visible = false;
                    this.gvRepair.Columns[9].Visible = false;
                    this.gvRepair.Columns[10].Visible = FSBidOnly;
                    this.gvRepair.Columns[11].Visible = FSBidOnly;


                    this.gvRecommended.Columns[5].Visible = !FSBidOnly;
                    this.gvRecommended.Columns[6].Visible = !FSBidOnly;
                    this.gvRecommended.Columns[7].Visible = false;
                    this.gvRecommended.Columns[8].Visible = false;
                    this.gvRecommended.Columns[9].Visible = false;
                    this.gvRecommended.Columns[10].Visible = false;
                    this.gvRecommended.Columns[11].Visible = FSBidOnly;
                    this.gvRecommended.Columns[12].Visible = FSBidOnly;

                    this.trBid1.Visible = !FSBidOnly;
                    this.trBid2.Visible = false;
                    this.trBid3.Visible = false;
                    this.trBidFS.Visible = FSBidOnly;

                }
            }

            this.trRental.Visible = repairBidFormData.RentalRepairReqBy.HasValue;
        }

        protected void SetReviewFields()
        {
            if (taskInfo.StatusID == LookUp.Find("AstTskPendAprvl").LookupID)
            {
                if (!string.IsNullOrEmpty(bid4.BidCompany)) // did AM enter an additional bid?
                {
                    // Yes, show Bid4 but don't allow edit
                    bid4Edit = false;
                    Show_HideBid4(true);
                }
                else
                {
                    // No, don't show Bid 4
                    Show_HideBid4(false);
                }
            }
            else // AM is reviewing bids submitted by agent -- Allow AM to enter additional bid
            {
                bid4Edit = true;
                Show_HideBid4(true);
            }

            gvRecommended.Columns[1].Visible = false;

            Show_HideBidVerification(true);

        }

        protected void Show_HideBid4(bool show)
        {
            this.tdBid4Hdr.Visible = show;
            this.tdBid4Name.Visible = show;
            this.tdBid4Days.Visible = show;
            this.tdBid4Status.Visible = show;
            this.tdBid4Total.Visible = show;
            this.trBid4.Visible = show;
            if (show)
            {
                this.txtContractorName4.ReadOnly = !bid4Edit;
                this.txtRprEstCompletionDays4.ReadOnly = !bid4Edit;
            }
            bid4Visible = show;
        }


        protected void Show_HideBidVerification(bool show)
        {
            bid1Active = (!string.IsNullOrEmpty(bid1.BidCompany));
            bid2Active = (!string.IsNullOrEmpty(bid2.BidCompany));
            bid3Active = (!string.IsNullOrEmpty(bid3.BidCompany));
            bid4Active = false;

            if (taskInfo.StatusID == LookUp.Find("AstTskPendAprvl").LookupID)
            {
                bid4Active = (bid4Visible && !string.IsNullOrEmpty(bid4.BidCompany));
            }
            else
            {
                bid4Active = bid4Visible;
            }
        }

        #endregion

        #region -- CalcRequiredBids --
        private void CalcRequiredBids()
        {
            // This calculation does not involve Bid 4, since it will not be present for Obtain Repair Bids task
            decimal minBidAmount = 0;

            decimal bid1Total;
            decimal bid2Total;
            decimal bid3Total;

            bid1Total = (this.lblGrandTotal1.DisplayValue != null ? (decimal)this.lblGrandTotal1.DisplayValue : 0);
            bid2Total = (this.lblGrandTotal2.DisplayValue != null ? (decimal)this.lblGrandTotal2.DisplayValue : 0);
            bid3Total = (this.lblGrandTotal3.DisplayValue != null ? (decimal)this.lblGrandTotal3.DisplayValue : 0);

            minBidAmount = bid1Total;
            if (bid2Total > 0 && bid2Total < minBidAmount) minBidAmount = bid2Total;
            if (bid3Total > 0 && bid3Total < minBidAmount) minBidAmount = bid3Total;



            if (minBidAmount == 0 || FSBidOnly || oneBidOnly)
            {
                requiredBidNumber = 1;
            }
            else
            {


                foreach (PoolBidLimit_SelectResult bidLimit in bidLimits)
                {
                    if (minBidAmount >= bidLimit.MinAmt && minBidAmount <= bidLimit.MaxAmt)
                    {
                        requiredBidNumber = (int)bidLimit.BidNumber;
                        break;
                    }
                }

                if (requiredBidNumber == 0)
                {
                    requiredBidNumber = 1;
                }
            }

        }


        #endregion

        #region -- CalculateTotals --
        private void CalculateTotals()
        {
            List<RepairBidItems_GetResult> normalRepairItems = repairItemData.FindAll(item => item.IsContractorRecommended == false);
            List<RepairBidItems_GetResult> recommendedRepairItems = repairItemData.FindAll(item => item.IsContractorRecommended == true);

            int firstAmtIndex = 5;

            GridViewRow footer = gvRepair.FooterRow;
            GridViewRow recFooter = gvRecommended.FooterRow;
            LblCurrency lblSubTotal = new LblCurrency();
            lblSubTotal.DecimalDigits = 2;

            for (int bidNumber = 1; bidNumber <= 5; bidNumber++)
            {
                int bidNumberZeroIndex = bidNumber - 1;

                string presCode = string.Empty;
                string grandTotLbl = string.Empty;
                switch (bidNumber)
                {
                    case 1:
                        presCode = "PresRpr1";
                        grandTotLbl = "lblGrandTotal1";
                        break;
                    case 2:
                        presCode = "PresRpr2";
                        grandTotLbl = "lblGrandTotal2";
                        break;
                    case 3:
                        presCode = "PresRpr3";
                        grandTotLbl = "lblGrandTotal3";
                        break;
                    case 4:
                        presCode = "PresRprFS";
                        grandTotLbl = "lblGrandTotalFS";
                        break;
                    case 5:
                        presCode = "PresRpr4";
                        grandTotLbl = "lblGrandTotal4";
                        break;
                }

                RepairBid_GetResult currentBid = repairBidData.Find(bid => bid.PresTypeID == Framework.Business.LookUp.Find(presCode).LookupID);

                if (currentBid != null)
                {
                    if (gvRepair.FooterRow != null)
                    {
                        LblCurrency subTotal = new LblCurrency();
                        subTotal.DecimalDigits = 2;
                        subTotal.DisplayValue = repairUnitData.FindAll(unit => unit.RepairBidID == currentBid.RepairBidID
                            && unit.RepairBidSID == currentBid.RepairBidSID
                            && normalRepairItems.Exists(item => item.RepairItemID == unit.RepairItemID
                                && item.RepairItemSID == unit.RepairItemSID && item.Active)).Sum(total => total.Amt);
                        int cellIndex = firstAmtIndex + (bidNumberZeroIndex * 2);
                        if (subTotal.DisplayValue == 0) subTotal.DisplayValue = null;
                        footer.Cells[cellIndex].Controls.Clear();
                        footer.Cells[cellIndex].Controls.Add(subTotal);
                    }

                    if (gvRecommended.FooterRow != null)
                    {
                        LblCurrency recSubTotal = new LblCurrency();
                        recSubTotal.DecimalDigits = 2;
                        recSubTotal.DisplayValue = repairUnitData.FindAll(unit => unit.RepairBidID == currentBid.RepairBidID
                            && unit.RepairBidSID == currentBid.RepairBidSID
                            && recommendedRepairItems.Exists(item => item.RepairItemID == unit.RepairItemID
                                && item.RepairItemSID == unit.RepairItemSID && item.Active)).Sum(total => total.Amt);
                        if (recSubTotal.DisplayValue == 0) recSubTotal.DisplayValue = null;
                        int cellIndex = firstAmtIndex + 1 + (bidNumberZeroIndex * 2);
                        recFooter.Cells[cellIndex].Controls.Clear();
                        recFooter.Cells[cellIndex].Controls.Add(recSubTotal);
                    }

                    decimal? grandTotal = repairUnitData.FindAll(unit => unit.RepairBidID == currentBid.RepairBidID
                        && unit.RepairBidSID == currentBid.RepairBidSID
                        && repairItemData.Exists(item => item.RepairItemID == unit.RepairItemID
                            && item.RepairItemSID == unit.RepairItemSID && item.Active)).Sum(total => total.Amt);
                    LblCurrency lblGrandTotal = (LblCurrency)FindControl(grandTotLbl);
                    lblGrandTotal.DisplayValue = grandTotal.Value;
                    if (lblGrandTotal.DisplayValue == 0) lblGrandTotal.DisplayValue = null;
                }
            }
        }

        private void addRecommendedRepairItem()
        {
            RepairBidItems_GetResult newItem = new RepairBidItems_GetResult()
            {
                IsContractorRecommended = true,
                RepairItemID = 0,
                RepairItemSID = 0,
                ItemID = 0,
                Active = true
            };

            if (repairItemData == null)
            {
                LoadData();
            }

            List<RepairBidItems_GetResult> recommendedRepairItems = repairItemData.FindAll(item => item.IsContractorRecommended == true);
            recommendedRepairItems.Insert(0, newItem);
            gvRecommended.DataSource = recommendedRepairItems;
            gvRecommended.EditIndex = 0;
            gvRecommended.DataBind();
        }


        #endregion


        #region -- ValidData --
        protected bool ValidData()
        {
            bool valid = true;

            decimal bid1Total;
            decimal bid2Total;
            decimal bid3Total;
            decimal bid4Total;
            decimal bidFSTotal;

            bid1Total = (this.lblGrandTotal1.DisplayValue != null ? (decimal)this.lblGrandTotal1.DisplayValue : 0);
            bid2Total = (this.lblGrandTotal2.DisplayValue != null ? (decimal)this.lblGrandTotal2.DisplayValue : 0);
            bid3Total = (this.lblGrandTotal3.DisplayValue != null ? (decimal)this.lblGrandTotal3.DisplayValue : 0);
            bid4Total = (bid4Visible && this.lblGrandTotal4.DisplayValue != null ? (decimal)this.lblGrandTotal4.DisplayValue : 0);
            bidFSTotal = (FSBidOnly && this.lblGrandTotalFS.DisplayValue != null ? (decimal)this.lblGrandTotalFS.DisplayValue : 0);

            bid1Active = bid1Total > 0;
            bid2Active = bid2Total > 0;
            bid3Active = bid3Total > 0;
            bid4Active = bid4Total > 0;
            bidFSActive = bidFSTotal > 0;




            // turn off all previously indicated errors
            this.divTaskError.Visible = false;
            //this.myControl.CssClass = "";

            StringBuilder sb = new StringBuilder();
            sb.AppendLine("Please correct the following errors:<ol>");

            if (taskInfo.Code != "RVWRPRBD") // Not Review Repair Bids
            {


                int bidcount = 0;
                if (bid1Total > 0) bidcount++;
                if (bid2Total > 0) bidcount++;
                if (bid3Total > 0) bidcount++;
                if (bidFSTotal > 0) bidcount++;
                // bid 4 not included in this calc because it will be added by AM after bids are entered by agent




                if (bidcount < requiredBidNumber)
                {
                    valid = false;
                    sb.AppendLine("<li>You must enter at least " + requiredBidNumber + " bid(s)</li>");
                }

                if (bid1Active && string.IsNullOrEmpty(this.txtContractorName1.Text))
                {
                    valid = false;
                    sb.AppendLine("<li>Bid # 1 has amounts entered, but no contractor name</li>");
                }

                if (bid2Active && string.IsNullOrEmpty(this.txtContractorName2.Text))
                {
                    valid = false;
                    sb.AppendLine("<li>Bid # 2 has amounts entered, but no contractor name</li>");
                }

                if (bid3Active && string.IsNullOrEmpty(this.txtContractorName3.Text))
                {
                    valid = false;
                    sb.AppendLine("<li>Bid # 3 has amounts entered, but no contractor name</li>");
                }

                if (bid1Active && string.IsNullOrEmpty(this.txtRprEstCompletionDays1.Text))
                {
                    valid = false;
                    sb.AppendLine("<li>Bid # 1 has amounts entered, but no estimated completion days</li>");
                }

                if (bid2Active && string.IsNullOrEmpty(this.txtRprEstCompletionDays2.Text))
                {
                    valid = false;
                    sb.AppendLine("<li>Bid # 2 has amounts entered, but no estimated completion days</li>");
                }

                if (bid3Active && string.IsNullOrEmpty(this.txtRprEstCompletionDays3.Text))
                {
                    valid = false;
                    sb.AppendLine("<li>Bid # 3 has amounts entered, but no estimated completion days</li>");
                }

                if (bidFSActive && string.IsNullOrEmpty(this.txtRprEstCompletionDaysFS.Text))
                {
                    valid = false;
                    sb.AppendLine("<li>Field Services bid has amounts entered, but no estimated completion days</li>");
                }

                if (photos.Count < 2)
                {
                    valid = false;
                    sb.AppendLine("<li>You must upload at least 2 photos</li>");
                }

                if (bid1Active && (this.uploadBid1.Documents == null || this.uploadBid1.Documents.Count == 0))
                {
                    valid = false;
                    sb.AppendLine("<li>Please upload documents for bid # 1</li>");
                }

                if (bid2Active && (this.uploadBid2.Documents == null || this.uploadBid2.Documents.Count == 0))
                {
                    valid = false;
                    sb.AppendLine("<li>Please upload documents for bid # 2</li>");
                }

                if (bid3Active && (this.uploadBid3.Documents == null || this.uploadBid3.Documents.Count == 0))
                {
                    valid = false;
                    sb.AppendLine("<li>Please upload documents for bid # 3</li>");
                }

                if (bidFSActive && (this.uploadBidFS.Documents == null || this.uploadBidFS.Documents.Count == 0))
                {
                    valid = false;
                    sb.AppendLine("<li>Please upload documents for Field Services Bid</li>");
                }

            }
            else // Review Repair Bids
            {
                if (this.ddlBid1Status.Enabled)
                {
                    if (this.ddlBid1Status.LookupID == null)
                    {
                        valid = false;
                        sb.AppendLine("<li>Bid # 1 status not selected</li>");
                    }
                }

                if (this.ddlBid2Status.Enabled)
                {
                    if (this.ddlBid2Status.LookupID == null)
                    {
                        valid = false;
                        sb.AppendLine("<li>Bid # 2 status not selected</li>");
                    }
                }

                if (this.ddlBid3Status.Enabled)
                {
                    if (this.ddlBid3Status.LookupID == null)
                    {
                        valid = false;
                        sb.AppendLine("<li>Bid # 3 status not selected</li>");
                    }
                }

                if (bid4Active && this.ddlBid4Status.Enabled)
                {
                    if (this.ddlBid4Status.LookupID == null)
                    {
                        valid = false;
                        sb.AppendLine("<li>Additional Bid status not selected</li>");
                    }
                }

                if (bidFSActive && this.ddlBidFSStatus.Enabled)
                {
                    if (this.ddlBidFSStatus.LookupID == null)
                    {
                        valid = false;
                        sb.AppendLine("<li>Field Services Bid status not selected</li>");
                    }
                }

                int apprCount = 0;
                if (this.ddlBid1Status.LookupCode == "PRESAPPR") apprCount++;
                if (this.ddlBid2Status.LookupCode == "PRESAPPR") apprCount++;
                if (this.ddlBid3Status.LookupCode == "PRESAPPR") apprCount++;
                if (this.ddlBid4Status.LookupCode == "PRESAPPR") apprCount++;
                if (this.ddlBidFSStatus.LookupCode == "PRESAPPR") apprCount++;

                if (apprCount > 1)
                {
                    valid = false;
                    sb.AppendLine("<li>You cannot select more than 1 bid to be approved</li>");
                }

                if (bid4Active && string.IsNullOrEmpty(this.txtContractorName4.Text))
                {
                    valid = false;
                    sb.AppendLine("<li>Additional Bid has amounts entered, but no contractor name</li>");
                }

                if (bid4Active && string.IsNullOrEmpty(this.txtRprEstCompletionDays4.Text))
                {
                    valid = false;
                    sb.AppendLine("<li>Additional Bid has amounts entered, but no estimated completion days</li>");
                }
            }

            if (!valid)
            {
                sb.AppendLine("</ol>");
                this.divTaskError.Visible = true;
                this.errorPanel.InnerHtml = sb.ToString();
            }

            return valid;
        }
        #endregion

        #region -- SaveForm --
        protected void SaveForm()
        {
            UpdateBidTotals();

            // Update auditlog

            bid1.BidCompany = this.txtContractorName1.Text;
            bid1.RprEstCompletionDays = this.txtRprEstCompletionDays1.SaveValue;
            bid1.StatusID = this.ddlBid1Status.LookupID;
            //Audit.AuditLog(bid1, "Asset", AssetID + "-" + AssetSID, UserID + "-" + UserSID);
            AuditTaskData(bid1, "Asset");

            bid2.BidCompany = this.txtContractorName2.Text;
            bid2.RprEstCompletionDays = this.txtRprEstCompletionDays2.SaveValue;
            bid2.StatusID = this.ddlBid2Status.LookupID;
            //Audit.AuditLog(bid2, "Asset", AssetID + "-" + AssetSID, UserID + "-" + UserSID);
            AuditTaskData(bid2, "Asset");

            bid3.BidCompany = this.txtContractorName3.Text;
            bid3.RprEstCompletionDays = this.txtRprEstCompletionDays3.SaveValue;
            bid3.StatusID = this.ddlBid3Status.LookupID;
            //Audit.AuditLog(bid3, "Asset", AssetID + "-" + AssetSID, UserID + "-" + UserSID);
            AuditTaskData(bid3, "Asset");

            if (bid4Visible && bid4 != null)
            {
                bid4.BidCompany = this.txtContractorName4.Text;
                bid4.RprEstCompletionDays = this.txtRprEstCompletionDays4.SaveValue;
                bid4.StatusID = this.ddlBid4Status.LookupID;
                //Audit.AuditLog(bid4, "Asset", AssetID + "-" + AssetSID, UserID + "-" + UserSID);
                AuditTaskData(bid4, "Asset");
            }

            if (bidFSActive && bidFS != null)
            {
                bidFS.RprEstCompletionDays = this.txtRprEstCompletionDaysFS.SaveValue;
                bidFS.StatusID = this.ddlBidFSStatus.LookupID;
                AuditTaskData(bidFS, "Asset");
            }

            int? bidDocID1 = null;
            int? bidDocSID1 = null;
            int? bidDocID2 = null;
            int? bidDocSID2 = null;
            int? bidDocID3 = null;
            int? bidDocSID3 = null;
            int? bidDocID4 = null;
            int? bidDocSID4 = null;
            int? bidDocIDFS = null;
            int? bidDocSIDFS = null;

            if (this.uploadBid1.Documents != null && this.uploadBid1.Documents.Count > 0)
            {
                bidDocID1 = this.uploadBid1.Documents[0].DocumentID;
                bidDocSID1 = this.uploadBid1.Documents[0].DocumentSID;
            }
            if (this.uploadBid2.Documents != null && this.uploadBid2.Documents.Count > 0)
            {
                bidDocID2 = this.uploadBid2.Documents[0].DocumentID;
                bidDocSID2 = this.uploadBid2.Documents[0].DocumentSID;
            }
            if (this.uploadBid3.Documents != null && this.uploadBid3.Documents.Count > 0)
            {
                bidDocID3 = this.uploadBid3.Documents[0].DocumentID;
                bidDocSID3 = this.uploadBid3.Documents[0].DocumentSID;
            }
            if (this.uploadBid4.Documents != null && this.uploadBid4.Documents.Count > 0)
            {
                bidDocID4 = this.uploadBid4.Documents[0].DocumentID;
                bidDocSID4 = this.uploadBid4.Documents[0].DocumentSID;
            }
            if (this.uploadBidFS.Documents != null && this.uploadBidFS.Documents.Count > 0)
            {
                bidDocIDFS = this.uploadBidFS.Documents[0].DocumentID;
                bidDocSIDFS = this.uploadBidFS.Documents[0].DocumentSID;
            }



            using (RepairBidDataContext dc = new RepairBidDataContext())
            {
                dc.RepairBid_Update(bid1.RepairBidID, bid1.RepairBidSID, this.txtContractorName1.Text,
                    this.ddlBid1Status.LookupID, bidDocID1, bidDocSID1, this.txtRprEstCompletionDays1.SaveValue);

                dc.RepairBid_Update(bid2.RepairBidID, bid2.RepairBidSID, this.txtContractorName2.Text,
                    this.ddlBid2Status.LookupID, bidDocID2, bidDocSID2, this.txtRprEstCompletionDays2.SaveValue);

                dc.RepairBid_Update(bid3.RepairBidID, bid3.RepairBidSID, this.txtContractorName3.Text,
                    this.ddlBid3Status.LookupID, bidDocID3, bidDocSID3, this.txtRprEstCompletionDays3.SaveValue);

                dc.RepairBid_Update(bid4.RepairBidID, bid4.RepairBidSID, this.txtContractorName4.Text,
                    this.ddlBid4Status.LookupID, bidDocID4, bidDocSID4, this.txtRprEstCompletionDays4.SaveValue);

                if (bidFS != null)
                {
                    dc.RepairBid_Update(bidFS.RepairBidID, bidFS.RepairBidSID, this.txtContractorNameFS.Text,
                        this.ddlBidFSStatus.LookupID, bidDocIDFS, bidDocSIDFS, this.txtRprEstCompletionDaysFS.SaveValue);
                }
                dc.RepairBidInstructions_Update(RepairBidFormID, RepairBidFormSID, repairBidFormData.RprAdditionalCommentID,
                    repairBidFormData.RprAdditionalCommentSID, this.txtAddlInst.Text, AssetID, AssetSID, UserID, UserSID);

            }

        }
        #endregion

        #region -- UpdateBidTotals --
        protected void UpdateBidTotals()
        {
            UpdateBidTotals(this.gvRepair);
            UpdateBidTotals(this.gvRecommended);
        }

        protected void UpdateBidTotals(GridView gv)
        {
            GridViewRow r;

            for (int index = 0; index < gv.Rows.Count; index++)
            {
                int RepairItemID = 0;
                int RepairItemSID = 0;

                int? ItemID;

                bool ContractorRecommended = (gv.ID == "gvRecommended");

                r = gv.Rows[index];
                Label RepairItemIDSID = (Label)r.FindControl("RepairItemIDSID");
                DdlRprSubCategory ddlItems = (DdlRprSubCategory)r.FindControl("ddlItems");

                ItemID = ddlItems.SubRepairCategoryID;
                CheckBox chkActive = (CheckBox)r.FindControl("chkActive");

                TextBox txtDetails = (TextBox)r.FindControl("txtDetails");

                if (RepairItemIDSID.Text == "0-0") // new item
                {
                    if (ddlItems.SubRepairCategoryID != null)
                    {
                        using (RepairBidDataContext dc = new RepairBidDataContext())
                        {
                            RepairBidItem_InsertResult newItem =
                                dc.RepairBidItem_Insert(RepairBidFormID, RepairBidFormSID, ItemID, ContractorRecommended, txtDetails.Text, UserID, UserSID)
                                .FirstOrDefault<RepairBidItem_InsertResult>();
                            RepairItemID = (int)newItem.RepairItemID;
                            RepairItemSID = (int)newItem.RepairItemSID;
                            RepairItemIDSID.Text = RepairItemID + "-" + RepairItemSID;

                        }
                    }

                }
                else // existing item
                {
                    RepairItemID = Helper.SplitKey(RepairItemIDSID.Text).PrimaryID;
                    RepairItemSID = Helper.SplitKey(RepairItemIDSID.Text).ServerID;

                    using (RepairBidDataContext dc = new RepairBidDataContext())
                    {
                        dc.RepairBidItem_Update(RepairItemID, RepairItemSID, ItemID, ContractorRecommended, chkActive.Checked);
                    }
                }

                LoadData();

                if (RepairItemID != 0)
                {
                    RepairUnit_GetResult unit1 = repairUnitData.Find(item => item.RepairItemID == RepairItemID
                        && item.RepairItemSID == RepairItemSID
                        && item.RepairBidID == bid1.RepairBidID
                        && item.RepairBidSID == bid1.RepairBidSID);

                    RepairUnit_GetResult unit2 = repairUnitData.Find(item => item.RepairItemID == RepairItemID
                        && item.RepairItemSID == RepairItemSID
                        && item.RepairBidID == bid2.RepairBidID
                        && item.RepairBidSID == bid2.RepairBidSID);

                    RepairUnit_GetResult unit3 = repairUnitData.Find(item => item.RepairItemID == RepairItemID
                        && item.RepairItemSID == RepairItemSID
                        && item.RepairBidID == bid3.RepairBidID
                        && item.RepairBidSID == bid3.RepairBidSID);

                    RepairUnit_GetResult unit4 = repairUnitData.Find(item => item.RepairItemID == RepairItemID
                        && item.RepairItemSID == RepairItemSID
                        && item.RepairBidID == bid4.RepairBidID
                        && item.RepairBidSID == bid4.RepairBidSID);

                    RepairUnit_GetResult unitFS = null;

                    if (bidFS != null)
                    {
                        unitFS = repairUnitData.Find(item => item.RepairItemID == RepairItemID
                            && item.RepairItemSID == RepairItemSID
                            && item.RepairBidID == bidFS.RepairBidID
                            && item.RepairBidSID == bidFS.RepairBidSID);
                    }

                    TxtInteger txtQty1 = (TxtInteger)r.FindControl("txtQty1");
                    TxtCurrency txtAmt1 = (TxtCurrency)r.FindControl("txtAmt1");
                    TxtInteger txtQty2 = (TxtInteger)r.FindControl("txtQty2");
                    TxtCurrency txtAmt2 = (TxtCurrency)r.FindControl("txtAmt2");
                    TxtInteger txtQty3 = (TxtInteger)r.FindControl("txtQty3");
                    TxtCurrency txtAmt3 = (TxtCurrency)r.FindControl("txtAmt3");
                    TxtInteger txtQty4 = (TxtInteger)r.FindControl("txtQty4");
                    TxtCurrency txtAmt4 = (TxtCurrency)r.FindControl("txtAmt4");
                    TxtInteger txtQtyFS = (TxtInteger)r.FindControl("txtQtyFS");
                    TxtCurrency txtAmtFS = (TxtCurrency)r.FindControl("txtAmtFS");

                    using (RepairBidDataContext dc = new RepairBidDataContext())
                    {
                        dc.RepairUnit_Update(unit1.RepairUnitID, unit1.RepairUnitSID, txtQty1.SaveValue, txtAmt1.SaveValue);
                        dc.RepairUnit_Update(unit2.RepairUnitID, unit2.RepairUnitSID, txtQty2.SaveValue, txtAmt2.SaveValue);
                        dc.RepairUnit_Update(unit3.RepairUnitID, unit3.RepairUnitSID, txtQty3.SaveValue, txtAmt3.SaveValue);
                        dc.RepairUnit_Update(unit4.RepairUnitID, unit4.RepairUnitSID, txtQty4.SaveValue, txtAmt4.SaveValue);
                        if (bidFS != null)
                        {
                            dc.RepairUnit_Update(unitFS.RepairUnitID, unitFS.RepairUnitSID, txtQtyFS.SaveValue, txtAmtFS.SaveValue);
                        }
                    }

                }

            }
            LoadData();
        }


        #endregion

        #region SetFinalApproval
        protected void SetFinalApproval()
        {
            GetData();
            approvedBid = repairBidData.Find(item => item.RepairBidID == repairBidFormData.ApprovedRepairBidID &&
                item.RepairBidSID == repairBidFormData.ApprovedRepairBidSID);
            if (approvedBid != null)
            {
                approvedBid.IsFinalApproval = true;
                AuditTaskData(approvedBid, "Asset");

                using (RepairBidDataContext dc = new RepairBidDataContext())
                {
                    dc.RepairBid_FinalApproval_Update(approvedBid.RepairBidID, approvedBid.RepairBidSID);
                }

                //Send Email
                using (EmailDataContext dc = new EmailDataContext())
                {
                    var items = dc.Email_Detail_Get(this.AssetID, this.AssetSID, "RVWRPRBD", "EvntBeginRpr").ToList<Email_Detail_GetResult>();
                    foreach (Email_Detail_GetResult item in items)
                    {
                        Email.SendAndSave(item.ToEmail, null, item.Subject, item.Message, this.User.Email, null, this.AssetID, this.AssetSID, LookUp.Find("CmtCatRpr").LookupID, this.AssetTaskID, this.AssetTaskSID);
                    }
                }
            }


        }
        #endregion

        #region -- ClickEvents --
        protected void btnSave_Click(object sender, EventArgs e)
        {
            SaveForm();
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string approvalCode = "";
            SaveForm();
            if (ValidData())
            {
                if (taskInfo.Code == "RVWRPRBD")
                {
                    int apprCount = 0;
                    if (this.ddlBid1Status.LookupCode == "PRESAPPR") apprCount++;
                    if (this.ddlBid2Status.LookupCode == "PRESAPPR") apprCount++;
                    if (this.ddlBid3Status.LookupCode == "PRESAPPR") apprCount++;
                    if (this.ddlBid4Status.LookupCode == "PRESAPPR") apprCount++;
                    if (this.ddlBidFSStatus.LookupCode == "PRESAPPR") apprCount++;

                    if (apprCount == 0) // All bids denied
                    {
                        using (RepairBidDataContext dc = new RepairBidDataContext())
                        {
                            dc.RepairBids_Remove(RepairBidFormID, RepairBidFormSID, AssetTaskID, AssetTaskSID, FormAssetTaskID, FormAssetTaskSID,
                                this.ddlNewBids.SaveValue);
                        }
                        approvalCode = "DENIED";
                    }
                    else
                    {
                        approvalCode = "APPROVED";
                    }
                }

                if (taskInfo.StatusID == LookUp.Find("AstTskPendAprvl").LookupID)
                {
                    //pass approvalCode to TaskCompleted method
                    KeepTaskWindowOpen = true;
                    TaskResults tresult;
                    tresult = CompleteTask(divTaskError, errorPanel, approvalCode: approvalCode, primaryID: RepairBidFormID, primarySID: RepairBidFormSID);
                    if (tresult.IsComplete && AssetTask.Code == "RVWRPRBD" && approvalCode == "APPROVED")
                    {
                        SetFinalApproval();

                    }
                    CloseTask();

                }
                else
                {
                    // call TaskCompleted without approvalCode
                    CompleteTask(divTaskError, errorPanel, primaryID: RepairBidFormID, primarySID: RepairBidFormSID);
                }

            }

        }

        protected void UpdateTotals(object sender, EventArgs e)
        {
            //WebControl ctl = (WebControl)sender;
            UpdateBidTotals();

            //WebControl nextCtl;
            //switch (ctl.ID)
            //{
            //    case "chkActive":
            //        nextCtl = (WebControl)ctl.Parent.Parent.FindControl("txtQty1");
            //        break;
            //    case "txtAmt1":
            //        nextCtl = (WebControl)ctl.Parent.Parent.FindControl("txtQty2");
            //        break;
            //    case "txtAmt2":
            //        nextCtl = (WebControl)ctl.Parent.Parent.FindControl("txtQty3");
            //        break;
            //    default:
            //        nextCtl = ctl;
            //        break;
            //}
            //nextCtl.Focus();

            //// set focus to next control

        }


        protected void lnkAddRec_Click(object sender, EventArgs e)
        {
            UpdateBidTotals();
            addRecommendedRepairItem();
        }

        protected void btnCalc_Click(object sender, EventArgs e)
        {
            UpdateBidTotals();
        }

        #endregion

        #region -- GridView events --
        protected void gvRepairBids_RowDataBound(object sender, System.Web.UI.WebControls.GridViewRowEventArgs e)
        {
            if (e.Row.RowType == System.Web.UI.WebControls.DataControlRowType.DataRow)
            {
                PoolBidLimit_SelectResult bidLimit = (PoolBidLimit_SelectResult)e.Row.DataItem;
                Label lblBidRange = (Label)e.Row.FindControl("lblBidRange");
                decimal minAmt = bidLimit.MinAmt == null ? 0 : (decimal)bidLimit.MinAmt;
                decimal maxAmt = bidLimit.MaxAmt == null ? 0 : (decimal)bidLimit.MaxAmt;
                lblBidRange.Text = minAmt.ToString("C") + " to " + maxAmt.ToString("C");
                Label lblBidsRequired = (Label)e.Row.FindControl("lblBidsRequired");
                lblBidsRequired.Text = bidLimit.BidNumber.ToString();
            }
        }
        protected void rowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                string unitDesc = String.Empty;
                string itemDesc = String.Empty;

                RepairBidItems_GetResult dataItem = ((RepairBidItems_GetResult)e.Row.DataItem);

                Label repairItemIDSID = (Label)e.Row.FindControl("repairItemIDSID");
                repairItemIDSID.Text = dataItem.RepairItemID.ToString() + "-" + dataItem.RepairItemSID.ToString();

                Label lblItemID = (Label)e.Row.FindControl("lblItemID");
                lblItemID.Text = dataItem.ItemID.ToString();

                if (dataItem.ItemID.HasValue && dataItem.ItemID.Value != 0)
                {
                    var repairList = Repair.RepairCategoryList;
                    var repairItem = repairList.Find(i => i.RepairSubCategoryID == dataItem.ItemID);

                    if (repairItem != null)
                    {
                        itemDesc = repairItem.ItemDescription;
                        unitDesc = repairItem.UnitsDescription;
                    }
                }

                Label lblItems = (Label)e.Row.FindControl("lblItems");
                DdlRprSubCategory ddlItems = ((DdlRprSubCategory)e.Row.FindControl("ddlItems"));
                DdlRprCategory ddlCategory = ((DdlRprCategory)e.Row.FindControl("ddlRepairCategory"));
                Label lblRprCat = (Label)e.Row.FindControl("lblRprCat");


                if (ddlCategory != null)
                {
                    if (dataItem.RepairCategoryID.HasValue)
                    {
                        ddlCategory.ReportCategoryID = dataItem.RepairCategoryID;
                    }

                    if (e.Row.RowIndex == 0)
                    {
                        ddlCategory.Visible = true;
                        if (ddlCategory.ReportCategoryID.HasValue)
                        {
                            ddlItems.RepairCategoryID = ddlCategory.ReportCategoryID.Value;
                            ddlItems.PopulateDropDown();
                        }
                    }
                    else
                    {
                        lblRprCat.Visible = true;
                        ddlCategory.Visible = false;
                        lblRprCat.Text = dataItem.RepairCategory;
                    }
                }

                CheckBox chkActive = (CheckBox)e.Row.FindControl("chkActive");
                chkActive.Checked = dataItem.Active;

                Label lblUnitDesc1 = (Label)e.Row.FindControl("lblUnitDesc1");
                TxtInteger txtQty1 = (TxtInteger)e.Row.FindControl("txtQty1");
                TxtCurrency txtAmt1 = (TxtCurrency)e.Row.FindControl("txtAmt1");
                Label lblQty1 = (Label)e.Row.FindControl("lblQty1");
                LblCurrency lblAmt1 = (LblCurrency)e.Row.FindControl("lblAmt1");

                Label lblUnitDesc2 = (Label)e.Row.FindControl("lblUnitDesc2");
                TxtInteger txtQty2 = (TxtInteger)e.Row.FindControl("txtQty2");
                TxtCurrency txtAmt2 = (TxtCurrency)e.Row.FindControl("txtAmt2");
                Label lblQty2 = (Label)e.Row.FindControl("lblQty2");
                LblCurrency lblAmt2 = (LblCurrency)e.Row.FindControl("lblAmt2");

                Label lblUnitDesc3 = (Label)e.Row.FindControl("lblUnitDesc3");
                TxtInteger txtQty3 = (TxtInteger)e.Row.FindControl("txtQty3");
                TxtCurrency txtAmt3 = (TxtCurrency)e.Row.FindControl("txtAmt3");
                Label lblQty3 = (Label)e.Row.FindControl("lblQty3");
                LblCurrency lblAmt3 = (LblCurrency)e.Row.FindControl("lblAmt3");

                Label lblUnitDesc4 = (Label)e.Row.FindControl("lblUnitDesc4");
                TxtInteger txtQty4 = (TxtInteger)e.Row.FindControl("txtQty4");
                TxtCurrency txtAmt4 = (TxtCurrency)e.Row.FindControl("txtAmt4");
                Label lblQty4 = (Label)e.Row.FindControl("lblQty4");
                LblCurrency lblAmt4 = (LblCurrency)e.Row.FindControl("lblAmt4");

                Label lblUnitDescFS = (Label)e.Row.FindControl("lblUnitDescFS");
                TxtInteger txtQtyFS = (TxtInteger)e.Row.FindControl("txtQtyFS");
                TxtCurrency txtAmtFS = (TxtCurrency)e.Row.FindControl("txtAmtFS");
                Label lblQtyFS = (Label)e.Row.FindControl("lblQtyFS");
                LblCurrency lblAmtFS = (LblCurrency)e.Row.FindControl("lblAmtFS");


                // BigLabel lblDetails = (BigLabel)e.Row.FindControl("lblDetails");
                //TextBox txtDetails = (TextBox)e.Row.FindControl("txtDetails");

                BigLabel iconDetails = (BigLabel)e.Row.FindControl("iconDetails");

                //lblDetails.MessageText = dataItem.Details;
                //txtDetails.Text = dataItem.Details;

                iconDetails.MessageText = dataItem.Details;

                lblUnitDesc1.Text = "EA"; // default
                lblUnitDesc2.Text = "EA";
                lblUnitDesc3.Text = "EA";
                lblUnitDesc4.Text = "EA";
                lblUnitDescFS.Text = "EA";

                if (taskInfo.Code == "RVWRPRBD")  // review mode
                {
                    ddlItems.SubRepairCategoryID = dataItem.ItemID;
                    lblItems.Text = itemDesc;
                    lblItems.Visible = true;
                    ddlItems.Visible = false;
                    chkActive.Enabled = true;
                    txtQty1.Visible = false;
                    lblQty1.Visible = true;
                    txtAmt1.Visible = false;
                    lblAmt1.Visible = true;
                    txtQty2.Visible = false;
                    lblQty2.Visible = true;
                    txtAmt2.Visible = false;
                    lblAmt2.Visible = true;
                    txtQty3.Visible = false;
                    lblQty3.Visible = true;
                    txtAmt3.Visible = false;
                    lblAmt3.Visible = true;
                    txtQtyFS.Visible = false;
                    lblQtyFS.Visible = true;
                    txtAmtFS.Visible = false;
                    lblAmtFS.Visible = true;

                    //lblDetails.Visible = true;
                    //txtDetails.Visible = false;

                    iconDetails.Visible = true;


                }
                else
                {
                    ddlItems.SubRepairCategoryID = dataItem.ItemID;
                    lblItems.Text = itemDesc;
                    if (!dataItem.IsContractorRecommended)
                    {
                        ddlItems.Visible = false;
                        lblItems.Visible = true;
                    }
                    chkActive.Enabled = true;
                    txtQty1.Visible = true;
                    lblQty1.Visible = false;
                    txtAmt1.Visible = true;
                    lblAmt1.Visible = false;
                    txtQty2.Visible = true;
                    lblQty2.Visible = false;
                    txtAmt2.Visible = true;
                    lblAmt2.Visible = false;
                    txtQty3.Visible = true;
                    lblQty3.Visible = false;
                    txtAmt3.Visible = true;
                    lblAmt3.Visible = false;
                    txtQtyFS.Visible = true;
                    lblQtyFS.Visible = false;
                    txtAmtFS.Visible = true;
                    lblAmtFS.Visible = false;
                    //lblDetails.Visible = false;
                    //txtDetails.Visible = true;

                    iconDetails.Visible = true;
                }
                if (bid4Visible)
                {
                    txtQty4.Visible = bid4Edit;
                    lblQty4.Visible = !bid4Edit;
                    txtAmt4.Visible = bid4Edit;
                    lblAmt4.Visible = !bid4Edit;
                }
                else
                {
                    txtQty4.Visible = false;
                    lblQty4.Visible = false;
                    lblUnitDesc4.Visible = false;
                    txtAmt4.Visible = false;
                    lblAmt4.Visible = false;
                }


                if (bid1IDSID.Length != 0)
                {
                    CompositeKey key = new CompositeKey(bid1IDSID);
                    RepairUnit_GetResult unit = repairUnitData.Find(item => item.RepairBidID == key.PrimaryID &&
                        item.RepairBidSID == key.ServerID &&
                        item.RepairItemID == dataItem.RepairItemID &&
                        item.RepairItemSID == dataItem.RepairItemSID);


                    if (unit != null)
                    {

                        lblUnitDesc1.Text = unitDesc;

                        if (unit.Qty != null)
                        {
                            txtQty1.SaveValue = unit.Qty;
                            lblQty1.Text = unit.Qty.Value.ToString();
                        }

                        if (unit.Amt != null)
                        {
                            txtAmt1.SaveValue = unit.Amt;
                            lblAmt1.Text = String.Format("{0:C}", unit.Amt.Value);
                        }

                    }
                }

                if (bid2IDSID.Length != 0)
                {
                    CompositeKey key = new CompositeKey(bid2IDSID);
                    RepairUnit_GetResult unit = repairUnitData.Find(item => item.RepairBidID == key.PrimaryID &&
                        item.RepairBidSID == key.ServerID &&
                        item.RepairItemID == dataItem.RepairItemID &&
                        item.RepairItemSID == dataItem.RepairItemSID);

                    if (unit != null)
                    {

                        lblUnitDesc2.Text = unitDesc;

                        if (unit.Qty != null)
                        {
                            txtQty2.SaveValue = unit.Qty;
                            lblQty2.Text = unit.Qty.Value.ToString();
                        }

                        if (unit.Amt != null)
                        {
                            txtAmt2.SaveValue = unit.Amt;
                            lblAmt2.Text = String.Format("{0:C}", unit.Amt.Value);
                        }

                    }

                }

                if (bid3IDSID.Length != 0)
                {
                    CompositeKey key = new CompositeKey(bid3IDSID);
                    RepairUnit_GetResult unit = repairUnitData.Find(item => item.RepairBidID == key.PrimaryID &&
                        item.RepairBidSID == key.ServerID &&
                        item.RepairItemID == dataItem.RepairItemID &&
                        item.RepairItemSID == dataItem.RepairItemSID);

                    if (unit != null)
                    {

                        lblUnitDesc3.Text = unitDesc;

                        if (unit.Qty != null)
                        {
                            txtQty3.SaveValue = unit.Qty;
                            lblQty3.Text = unit.Qty.Value.ToString();
                        }

                        if (unit.Amt != null)
                        {
                            txtAmt3.SaveValue = unit.Amt;
                            lblAmt3.Text = String.Format("{0:C}", unit.Amt.Value);
                        }

                    }
                }

                if (bid4IDSID.Length != 0)
                {
                    CompositeKey key = new CompositeKey(bid4IDSID);
                    RepairUnit_GetResult unit = repairUnitData.Find(item => item.RepairBidID == key.PrimaryID &&
                        item.RepairBidSID == key.ServerID &&
                        item.RepairItemID == dataItem.RepairItemID &&
                        item.RepairItemSID == dataItem.RepairItemSID);

                    if (unit != null)
                    {

                        lblUnitDesc4.Text = unitDesc;

                        if (unit.Qty != null)
                        {
                            txtQty4.SaveValue = unit.Qty;
                            lblQty4.Text = unit.Qty.Value.ToString();
                        }

                        if (unit.Amt != null)
                        {
                            txtAmt4.SaveValue = unit.Amt;
                            lblAmt4.Text = String.Format("{0:C}", unit.Amt.Value);
                        }

                    }
                }

                if (bidFSIDSID.Length != 0)
                {
                    CompositeKey key = new CompositeKey(bidFSIDSID);
                    RepairUnit_GetResult unit = repairUnitData.Find(item => item.RepairBidID == key.PrimaryID &&
                        item.RepairBidSID == key.ServerID &&
                        item.RepairItemID == dataItem.RepairItemID &&
                        item.RepairItemSID == dataItem.RepairItemSID);

                    if (unit != null)
                    {

                        lblUnitDescFS.Text = unitDesc;

                        if (unit.Qty != null)
                        {
                            txtQtyFS.SaveValue = unit.Qty;
                            lblQtyFS.Text = unit.Qty.Value.ToString();
                        }

                        if (unit.Amt != null)
                        {
                            txtAmtFS.SaveValue = unit.Amt;
                            lblAmtFS.Text = String.Format("{0:C}", unit.Amt.Value);
                        }

                    }
                }

            }
        }

        protected void ddlRepairCategory_SelectedIndexChanged(object sender, EventArgs e)
        {
            var ddlRepairCategory = (DdlRprCategory)gvRecommended.Rows[0].FindControl("ddlRepairCategory");
            var ddlItems = (DdlRprSubCategory)gvRecommended.Rows[0].FindControl("ddlItems");
            ddlItems.RepairCategoryID = ddlRepairCategory.ReportCategoryID;
            ddlItems.PopulateDropDown();
        }


        #endregion


    }
}

Open in new window




And the designer.cs file:
//------------------------------------------------------------------------------
// <auto-generated>
//     This code was generated by a tool.
//
//     Changes to this file may cause incorrect behavior and will be lost if
//     the code is regenerated. 
// </auto-generated>
//------------------------------------------------------------------------------

namespace Reo.ContentControls {
    
    
    public partial class RepairBidDetail {
        
        /// <summary>
        /// AssetFrameNavigation1 control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::Reo.ContentControls.frameMainNavigation AssetFrameNavigation1;
        
        /// <summary>
        /// lblPageTitle control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.Label lblPageTitle;
        
        /// <summary>
        /// divInstructions control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.HtmlControls.HtmlGenericControl divInstructions;
        
        /// <summary>
        /// pInstructions control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.HtmlControls.HtmlGenericControl pInstructions;
        
        /// <summary>
        /// divTaskError control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.HtmlControls.HtmlGenericControl divTaskError;
        
        /// <summary>
        /// errorPanel control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.HtmlControls.HtmlGenericControl errorPanel;
        
        /// <summary>
        /// UpdatePanel1 control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.UpdatePanel UpdatePanel1;
        
        /// <summary>
        /// LabelContractorName control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.Label LabelContractorName;
        
        /// <summary>
        /// LabelEstimatedCompletionDays control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.Label LabelEstimatedCompletionDays;
        
        /// <summary>
        /// LabelBidTotal control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.Label LabelBidTotal;
        
        /// <summary>
        /// hypBidDocument control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.HyperLink hypBidDocument;
        
        /// <summary>
        /// gvRepair control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::Framework.UIControls.GridviewFormatted gvRepair;
        
        /// <summary>
        /// gvRecommended control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::Framework.UIControls.GridviewFormatted gvRecommended;
        
        /// <summary>
        /// txtAddlInst control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::Framework.UIControls.TxtString txtAddlInst;
        
        /// <summary>
        /// tblInstructionsDoc control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.HtmlControls.HtmlTable tblInstructionsDoc;
        
        /// <summary>
        /// uplAddlInst control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::Reo.Controls.AssetDoc_Upload uplAddlInst;
        
        /// <summary>
        /// tblAddPhotos control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.HtmlControls.HtmlTable tblAddPhotos;
        
        /// <summary>
        /// tdAddPhotos control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.HtmlControls.HtmlTableCell tdAddPhotos;
        
        /// <summary>
        /// spnLnkAddPhotos control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.HtmlControls.HtmlGenericControl spnLnkAddPhotos;
        
        /// <summary>
        /// lnkAddPhotos control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.HyperLink lnkAddPhotos;
        
        /// <summary>
        /// photoBar1 control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::Reo.Controls.PhotoBar photoBar1;
        
        /// <summary>
        /// divSave control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.HtmlControls.HtmlGenericControl divSave;
        
        /// <summary>
        /// spnSaveBtn control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.HtmlControls.HtmlGenericControl spnSaveBtn;
        
        /// <summary>
        /// btnSave control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.Button btnSave;
        
        /// <summary>
        /// spnSubmitBtn control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.HtmlControls.HtmlGenericControl spnSubmitBtn;
        
        /// <summary>
        /// btnSubmit control.
        /// </summary>
        /// <remarks>
        /// Auto-generated field.
        /// To modify move field declaration from designer file to code-behind file.
        /// </remarks>
        protected global::System.Web.UI.WebControls.Button btnSubmit;
    }
}

Open in new window

0
 
LVL 41

Accepted Solution

by:
guru_sami earned 500 total points
Comment Utility
Wow...that's quite a bit of code...
Can you try to add some new random control to your markup and recompile.
You should not add stuff to your .designer.cs manually. It's an auto generated file and should pick up the changes.
0
 
LVL 5

Author Comment

by:knowlton
Comment Utility
Okay...some of the errors are legitimate.

Give me a few minutes to sort them out.


But I suspect some of the other problems will still remain...
0
 
LVL 5

Author Comment

by:knowlton
Comment Utility
All cleared up now.

Thanks!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now