private void SectionsReinstatePostVideoProcessGrid()
        {
            TeamProjectTime2Section model = new TeamProjectTime2Section(teamProjectTime2TDS);

            // Update rows
            foreach (GridViewRow row in grdSectionsReinstatePostVideo.Rows)
            {
                string sectionId = grdSectionsReinstatePostVideo.DataKeys[row.RowIndex].Values["SectionID"].ToString();
                string flowOrderId = ((Label)row.FindControl("lblFlowOrderID")).Text;
                bool selected = ((CheckBox)row.FindControl("cbxSelected")).Checked;
                bool completed = ((CheckBox)row.FindControl("cbxCompleted")).Checked;
                int percentageOpened = Convert.ToInt32(((Label)row.FindControl("lblPercentageOpened")).Text);
                int percentageBrushed = Convert.ToInt32(((Label)row.FindControl("lblPercentageBrushed")).Text);
                DateTime? postVideo = Convert.ToDateTime(((Label)row.FindControl("lblPostVideo")).Text);

                if (selected)
                {
                    model.Update2(sectionId, completed, postVideo, selected, percentageOpened, percentageBrushed);
                }
            }

            model.Table.AcceptChanges();

            teamProjectTimeSection = (TeamProjectTime2TDS.LFS_TEAM_PROJECT_TIME_SECTIONDataTable)model.Table;
            Session["teamProjectTimeSection"] = teamProjectTimeSection;
            Session["teamProjectTime2TDS"] = teamProjectTime2TDS;
        }
        private void ManholesRehabPrepProcessGrid()
        {
            TeamProjectTime2Section modelSection = new TeamProjectTime2Section(teamProjectTime2TDS);
            TeamProjectTime2SectionMH model = new TeamProjectTime2SectionMH(teamProjectTime2TDS);

            // Update rows
            foreach (GridViewRow row in grdManholesRehabPrep.Rows)
            {
                int assetId = Convert.ToInt32(grdManholesRehabPrep.DataKeys[row.RowIndex].Values["AssetID"].ToString());
                bool selected = ((CheckBox)row.FindControl("cbxSelected")).Checked;

                if (selected)
                {
                    DateTime prepDate = Convert.ToDateTime(((Label)row.FindControl("lblPrepDate")).Text);

                    model.Update(assetId, prepDate, selected);
                }
            }

            model.Table.AcceptChanges();

            teamProjectTimeSectionMH = (TeamProjectTime2TDS.LFS_TEAM_PROJECT_TIME_SECTION_MHDataTable)model.Table;
            Session["teamProjectTimeSection"] = teamProjectTimeSection;
            Session["teamProjectTime2TDS"] = teamProjectTime2TDS;
        }
        private void SectionsPrepAndMeasureProcessGrid()
        {
            TeamProjectTime2Section model = new TeamProjectTime2Section(teamProjectTime2TDS);

            // Update rows
            foreach (GridViewRow row in grdSections.Rows)
            {
                string sectionId = grdSections.DataKeys[row.RowIndex].Values["SectionID"].ToString();
                string flowOrderId = ((Label)row.FindControl("lblFlowOrderID")).Text;
                bool selected = ((CheckBox)row.FindControl("cbxSelected")).Checked;
                bool completed = ((CheckBox)row.FindControl("cbxCompleted")).Checked;
                DateTime? prepDate = Convert.ToDateTime(((Label)row.FindControl("lblPrepDate")).Text);

                if (selected)
                {
                    if (completed)
                    {
                        if (prepDate != tkrdpDate_.SelectedDate.Value)
                        {
                            prepDate = tkrdpDate_.SelectedDate.Value;
                        }
                    }

                    model.Update(sectionId, completed, prepDate, selected);
                }
            }

            model.Table.AcceptChanges();

            teamProjectTimeSection = (TeamProjectTime2TDS.LFS_TEAM_PROJECT_TIME_SECTIONDataTable)model.Table;
            Session["teamProjectTimeSection"] = teamProjectTimeSection;
            Session["teamProjectTime2TDS"] = teamProjectTime2TDS;
        }
        protected void ddlFunction_SelectedIndexChanged(object sender, EventArgs e)
        {
            pnlFullLengthInstall.Visible = false;
            pnlFullLengthPrepMeasure.Visible = false;
            pnlFullLengthReinstatePostVideo.Visible = false;
            pnlSectionsManholesRehabPrep.Visible = false;
            pnlSectionsManholesRehabSpray.Visible = false;

            if (ddlTypeOfWork.SelectedValue == "Full Length")
            {
                TeamProjectTime2Section model = new TeamProjectTime2Section(teamProjectTime2TDS);

                switch (ddlFunction.SelectedValue)
                {
                    case "Install":
                        pnlFullLengthInstall.Visible = true;

                        model.LoadForFllInstall(Int32.Parse(ddlProject.SelectedValue), "Full Length Lining", tkrdpDate_.SelectedDate.Value);

                        // Store tables
                        teamProjectTimeSection = (TeamProjectTime2TDS.LFS_TEAM_PROJECT_TIME_SECTIONDataTable)model.Table;
                        Session["teamProjectTimeSection"] = teamProjectTimeSection;
                        Session["teamProjectTime2TDS"] = teamProjectTime2TDS;
                        grdSectionsInstall.DataBind();
                        break;

                    case "Prep & Measure":
                        pnlFullLengthPrepMeasure.Visible = true;

                        model.LoadForFllPrepAndMeasure(Int32.Parse(ddlProject.SelectedValue), "Full Length Lining", tkrdpDate_.SelectedDate.Value);

                        // Store tables
                        teamProjectTimeSection = (TeamProjectTime2TDS.LFS_TEAM_PROJECT_TIME_SECTIONDataTable)model.Table;
                        Session["teamProjectTimeSection"] = teamProjectTimeSection;
                        Session["teamProjectTime2TDS"] = teamProjectTime2TDS;
                        grdSections.DataBind();
                        break;

                    case "Reinstate & Post Video":
                        pnlFullLengthReinstatePostVideo.Visible = true;

                        model.LoadForFllReinstatePostVideo(Int32.Parse(ddlProject.SelectedValue), "Full Length Lining", tkrdpDate_.SelectedDate.Value);

                        // Store tables
                        teamProjectTimeSection = (TeamProjectTime2TDS.LFS_TEAM_PROJECT_TIME_SECTIONDataTable)model.Table;
                        Session["teamProjectTimeSection"] = teamProjectTimeSection;
                        Session["teamProjectTime2TDS"] = teamProjectTime2TDS;
                        grdSectionsReinstatePostVideo.DataBind();
                        break;
                }
            }
            else
            {
                if (ddlTypeOfWork.SelectedValue == "MH Rehab")
                {
                    TeamProjectTime2SectionMH model = new TeamProjectTime2SectionMH(teamProjectTime2TDS);
                    model.LoadByProjectIdAndUpdateDate(Convert.ToInt32(ddlProject.SelectedValue), tkrdpDate_.SelectedDate.Value, Convert.ToInt32(hdfCompanyId.Value));

                    // Store tables
                    teamProjectTimeSectionMH = (TeamProjectTime2TDS.LFS_TEAM_PROJECT_TIME_SECTION_MHDataTable)model.Table;
                    Session["teamProjectTimeSectionMH"] = teamProjectTimeSectionMH;
                    Session["teamProjectTime2TDS"] = teamProjectTime2TDS;
                    Session.Remove("teamProjectTimeSectionMHDummy");

                    switch (ddlFunction.SelectedValue)
                    {
                        case "Prep":
                            pnlSectionsManholesRehabPrep.Visible = true;
                            grdManholesRehabPrep.DataBind();
                            break;

                        case "Spray":
                            pnlSectionsManholesRehabSpray.Visible = true;
                            grdManholesRehabSpray.DataBind();
                            break;
                    }
                }
            }

            upnlFullLengthInstall.Update();
            upnlFullLengthPrepMeasure.Update();
            upnlFullLengthReinstatePostVideo.Update();
            upnlManholesRehabPrep.Update();
            upnlManholesRehabSpray.Update();
        }