private void StepSelectSectionsProcessGrid()
        {
            ProjectAddSectionsTDS dataSet = new ProjectAddSectionsTDS();
            dataSet.ProjectAddSectionsSearch.Merge(projectAddSectionsSearch, true);
            ProjectAddSectionsSearch model = new ProjectAddSectionsSearch(dataSet);

            // update rows
            if (Session["projectAddSectionsSearchDummy"] == null)
            {
                foreach (GridViewRow row in grdProjectAddSectionsSearch.Rows)
                {
                    string sectionId = ((Label)row.FindControl("lblSectionID")).Text.Trim();
                    bool selected = ((CheckBox)row.FindControl("cbxSelected")).Checked;

                    bool rehabAssessment = ((CheckBox)row.FindControl("cbxRehabAssessmentPrevWork")).Checked;
                    bool fullLengthLining = ((CheckBox)row.FindControl("cbxFullLengthLiningPrevWork")).Checked;
                    bool pointRepairs = ((CheckBox)row.FindControl("cbxPointRepairsPrevWork")).Checked;
                    bool junctionLining = ((CheckBox)row.FindControl("cbxJunctionLiningPrevWork")).Checked;

                    bool rehabAssessmentPrevWork = ((CheckBox)row.FindControl("cbxRehabAssessmentPrevWorkReadOnly")).Checked;
                    bool fullLengthLiningPrevWork = ((CheckBox)row.FindControl("cbxFullLengthLiningPrevWorkReadOnly")).Checked;
                    bool pointRepairsPrevWork = ((CheckBox)row.FindControl("cbxPointRepairsPrevWorkReadOnly")).Checked;
                    bool junctionLiningPrevWork = ((CheckBox)row.FindControl("cbxJunctionLiningPrevWorkReadOnly")).Checked;

                    model.UpdateBySectionId(sectionId, rehabAssessment, fullLengthLining, pointRepairs, junctionLining, selected, rehabAssessmentPrevWork, fullLengthLiningPrevWork, pointRepairsPrevWork, junctionLiningPrevWork);
                }

                model.Table.AcceptChanges();

                projectAddSectionsSearch = (ProjectAddSectionsTDS.ProjectAddSectionsSearchDataTable)model.Table;
                Session["projectAddSectionsSearch"] = projectAddSectionsSearch;
            }
        }
        private void StepSelectForIntermediateSectionsProcessGrid()
        {
            ProjectAddSectionsTDS dataSet = new ProjectAddSectionsTDS();
            dataSet.ProjectAddSectionsSearch.Merge(projectAddSectionsSearch, true);
            ProjectAddSectionsSearch model = new ProjectAddSectionsSearch(dataSet);

            // update rows
            if (Session["projectAddSectionsSearchDummy"] == null)
            {
                foreach (GridViewRow row in grdSelectForIntermediateSectionsSearch.Rows)
                {
                    string sectionId = ((Label)row.FindControl("lblSectionID_")).Text.Trim();
                    bool selected = ((CheckBox)row.FindControl("cbxSelected_")).Checked;

                    model.UpdateBySectionId(sectionId, false, false, false, false, selected, false, false, false, false);
                }

                model.Table.AcceptChanges();

                projectAddSectionsSearch = (ProjectAddSectionsTDS.ProjectAddSectionsSearchDataTable)model.Table;
                Session["projectAddSectionsSearch"] = projectAddSectionsSearch;
            }
        }
        private bool StepSearchSectionsNext()
        {
            // Get where clause and order by clasue
            string whereClause = GetWhereClause();
            string orderByClause = GetOderByClause();

            // Search
            ProjectAddSectionsTDS dataSet = new ProjectAddSectionsTDS();
            dataSet.ProjectAddSectionsSearch.Merge(projectAddSectionsSearch, true);
            ProjectAddSectionsSearch model = new ProjectAddSectionsSearch(dataSet);

            model.Load(whereClause, orderByClause);

            // Review Previous Work
            int projectId = Int32.Parse(hdfProjectId.Value);
            int companyId = Int32.Parse(hdfCompanyId.Value);

            model.UpdatePreviousWorks(projectId, companyId);

            // Store tables
            projectAddSectionsSearch = (ProjectAddSectionsTDS.ProjectAddSectionsSearchDataTable) model.Table;
            Session["projectAddSectionsSearch"] = projectAddSectionsSearch;

            return true;
        }
        private bool StepSelectForIntermediateSectionsNext()
        {
            ProjectAddSectionsTDS dataSet = new ProjectAddSectionsTDS();
            dataSet.ProjectAddSectionsSearch.Merge(projectAddSectionsSearch, true);
            ProjectAddSectionsSearch model = new ProjectAddSectionsSearch(dataSet);

            if (model.Table.Rows.Count > 0)
            {
                Page.Validate("selectForIntermediateSection");
                if (Page.IsValid)
                {
                    StepSelectForIntermediateSectionsProcessGrid();

                    if (Session["projectAddSectionsSearchDummy"] == null)
                    {
                        foreach (GridViewRow row in grdSelectForIntermediateSectionsSearch.Rows)
                        {
                            string sectionId = ((Label)row.FindControl("lblSectionID_")).Text.Trim();
                            bool selected = ((CheckBox)row.FindControl("cbxSelected_")).Checked;
                            if (selected)
                            {
                                hdfPrimarySectionId.Value = sectionId;
                            }
                        }
                    }
                    return true;
                }
                else
                {
                    return false;
                }
            }

            return false;
        }
        private bool StepSearchIntermediateSectionsNext()
        {
            // Get where clause and order by clause
            string whereClause = GetIntermediateWhereClause();

            string orderByClause = GetIntermediateOderByClause();

            // Search
            ProjectAddSectionsTDS dataSet = new ProjectAddSectionsTDS();
            dataSet.ProjectAddSectionsSearch.Merge(projectAddSectionsSearch, true);
            ProjectAddSectionsSearch model = new ProjectAddSectionsSearch(dataSet);

            model.Load(whereClause, orderByClause);

            // Store tables
            projectAddSectionsSearch = (ProjectAddSectionsTDS.ProjectAddSectionsSearchDataTable)model.Table;
            Session["projectAddSectionsSearch"] = projectAddSectionsSearch;

            return true;
        }