private void LoadCostingUpdates()
        {
            // Data for Costing Updates tab
            ProjectCostingUpdatesGateway projectCostingUpdatesGateway = new ProjectCostingUpdatesGateway(projectTDS);

            if (projectCostingUpdatesGateway.Table.Rows.Count > 0)
            {
                int projectId = int.Parse(hdfProjectId.Value);
                decimal costsIncurredToDate = 0M;
                decimal invoicedToDate = 0M;
                decimal actualGrossMarginToDate = 0M;

                //if (projectCostingUpdatesGateway.GetExtrasToDate(int.Parse(hdfProjectId.Value)).HasValue) tbxExtrasToDate.Text = ((decimal)projectCostingUpdatesGateway.GetExtrasToDate(int.Parse(hdfProjectId.Value))).ToString("n2");
                //if (projectCostingUpdatesGateway.GetCostToComplete(int.Parse(hdfProjectId.Value)).HasValue) tbxCostToComplete.Text = ((decimal)projectCostingUpdatesGateway.GetCostToComplete(int.Parse(hdfProjectId.Value))).ToString("n2");
                //if (projectCostingUpdatesGateway.GetOriginalProfitEstimated(int.Parse(hdfProjectId.Value)).HasValue) tbxOriginalProfitEstimated.Text = ((decimal)projectCostingUpdatesGateway.GetOriginalProfitEstimated(int.Parse(hdfProjectId.Value))).ToString("n2");

                if (projectCostingUpdatesGateway.GetCostsIncurred(projectId).HasValue)
                {
                    costsIncurredToDate = (decimal)projectCostingUpdatesGateway.GetCostsIncurred(projectId);
                    tbxCostsIncurredToDate.Text = costsIncurredToDate.ToString("n2");
                }
                else
                {
                    tbxCostsIncurredToDate.Text = "0";
                }

                if (projectCostingUpdatesGateway.GetInvoicedToDate(projectId).HasValue)
                {
                    invoicedToDate = (decimal)projectCostingUpdatesGateway.GetInvoicedToDate(projectId);
                    tbxInvoicedToDate.Text = invoicedToDate.ToString("n2");
                }
                else
                {
                    tbxInvoicedToDate.Text = "0";
                }

                if (invoicedToDate != 0)
                {
                    actualGrossMarginToDate = ((invoicedToDate - costsIncurredToDate) / invoicedToDate) * 100;
                }

                tbxActualGrossMarginToDate.Text = actualGrossMarginToDate.ToString("n2");
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!(Convert.ToBoolean(Session["sgLFS_PROJECTS_VIEW"]) && Convert.ToBoolean(Session["sgLFS_PROJECTS_EDIT"])))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "You are not authorized to view this page. Contact your system administrator.");
                }

                // Validate query string
                if (((string)Request.QueryString["source_page"] == null) || ((string)Request.QueryString["project_id"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in project_edit.aspx");
                }

                // Tag page
                hdfCompanyId.Value = Session["companyID"].ToString();
                hdfProjectId.Value = Request.QueryString["project_id"];
                hdfLoginId.Value = Convert.ToInt32(Session["loginID"]).ToString();
                hdfDataChanged.Value = Request.QueryString["data_changed"];
                hdfDataChangedMessage.Value = "Changes made to this project will not be saved.";

                // Prepare initial data
                Session.Remove("projectNotesDummy");
                Session.Remove("projectServicesDummy");
                Session.Remove("projectTypeOfWorkFunctionClassificationDummy");
                Session.Remove("projectJobClassClassificationDummy");
                Session.Remove("projectBudgetDummy");
                Session.Remove("subcontractorsBudgetDummy");
                Session.Remove("hotelsBudgetDummy");
                Session.Remove("bondingsBudgetDummy");
                Session.Remove("insurancesBudgetDummy");
                Session.Remove("otherCostsBudgetDummy");

                Session["fairWage"] = "None";

                // ... Set initial tab
                if ((string)Session["dialogOpenedProjects"] != "1")
                {
                    hdfActiveTab.Value = Request.QueryString["active_tab"];
                }
                else
                {
                    hdfActiveTab.Value = (string)Session["activeTabProjects"];
                }

                // ... For Library
                if (Session["lfsLibraryTDS"] != null)
                {
                    libraryTDS = (LibraryTDS)Session["lfsLibraryTDS"];
                }
                else
                {
                    libraryTDS = new LibraryTDS();
                }

                // If coming from
                // ... projects2.aspx or project_add.aspx
                if (Request.QueryString["source_page"] == "projects2.aspx" || Request.QueryString["source_page"] == "project_add.aspx")
                {
                    // Store Navigator State, Update control and Origin
                    StoreNavigatorState();
                    ViewState["update"] = "no";
                    ViewState["origin"] = "navigator";

                    // Get Project Id
                    int projectId = int.Parse(hdfProjectId.Value);

                    // ... Attachment control
                    if (Session["fromAttachment"] != null)
                    {
                        if (Session["fromAttachment"].ToString() == "yes")
                        {
                            // Restore dataset
                            projectTDS = (ProjectTDS)Session["lfsProjectTDS"];
                            projectNavigatorTDS = (ProjectNavigatorTDS)Session["projectNavigatorTDS"];
                            projectNotes = (ProjectNavigatorTDS.ProjectNotesDataTable)Session["projectNotes"];
                            projectServices = (ProjectNavigatorTDS.ProjectServiceDataTable)Session["projectServices"];
                            projectJobClassClassification = (ProjectNavigatorTDS.LFS_PROJECT_JOB_CLASS_TYPE_RATEDataTable)Session["projectJobClassClassification"];
                            projectTypeOfWorkFunctionClassification = (ProjectNavigatorTDS.LFS_PROJECT_WORK_FUNCTION_FAIR_WAGEDataTable)Session["projectTypeOfWorkFunctionClassification"];
                            projectBudget = (ProjectNavigatorTDS.ProjectWorkFunctionBudgetDataTable)Session["projectBudget"];
                            unitsBudget = (ProjectNavigatorTDS.ProjectUnitsBudgetDataTable)Session["unitsBudget"];
                            materialsBudget = (ProjectNavigatorTDS.ProjectMaterialsBudgetDataTable)Session["materialsBudget"];
                            subcontractorsBudget = (ProjectNavigatorTDS.ProjectSubcontractorsBudgetDataTable)Session["subcontractorsBudget"];
                            hotelsBudget = (ProjectNavigatorTDS.ProjectHotelsBudgetDataTable)Session["hotelsBudget"];
                            bondingsBudget = (ProjectNavigatorTDS.ProjectBondingsBudgetDataTable)Session["bondingsBudget"];
                            insurancesBudget = (ProjectNavigatorTDS.ProjectInsurancesBudgetDataTable)Session["insurancesBudget"];
                            otherCostsBudget = (ProjectNavigatorTDS.ProjectOtherCostsBudgetDataTable)Session["otherCostsBudget"];
                        }

                        Session.Remove("fromAttachment");
                    }
                    else
                    {
                        // Get dataset
                        projectTDS = new ProjectTDS();
                        projectNavigatorTDS = new ProjectNavigatorTDS();
                        projectNotes = new ProjectNavigatorTDS.ProjectNotesDataTable();
                        projectServices = new ProjectNavigatorTDS.ProjectServiceDataTable();
                        projectTypeOfWorkFunctionClassification = new ProjectNavigatorTDS.LFS_PROJECT_WORK_FUNCTION_FAIR_WAGEDataTable();
                        projectJobClassClassification = new ProjectNavigatorTDS.LFS_PROJECT_JOB_CLASS_TYPE_RATEDataTable();
                        projectBudget = new ProjectNavigatorTDS.ProjectWorkFunctionBudgetDataTable();
                        unitsBudget = new ProjectNavigatorTDS.ProjectUnitsBudgetDataTable();
                        materialsBudget = new ProjectNavigatorTDS.ProjectMaterialsBudgetDataTable();
                        subcontractorsBudget = new ProjectNavigatorTDS.ProjectSubcontractorsBudgetDataTable();
                        hotelsBudget = new ProjectNavigatorTDS.ProjectHotelsBudgetDataTable();
                        bondingsBudget = new ProjectNavigatorTDS.ProjectBondingsBudgetDataTable();
                        insurancesBudget = new ProjectNavigatorTDS.ProjectInsurancesBudgetDataTable();
                        otherCostsBudget = new ProjectNavigatorTDS.ProjectOtherCostsBudgetDataTable();

                        // Get General Data
                        ProjectGateway projectGatewayForLoad = new ProjectGateway(projectTDS);
                        projectGatewayForLoad.LoadByProjectId(projectId);

                        // Get job info
                        ProjectJobInfoGateway projectJobInfoGateway = new ProjectJobInfoGateway(projectNavigatorTDS);
                        projectJobInfoGateway.LoadAllByProjectId(projectId);

                        // Get Sale/Billing/Pricing
                        ProjectSaleBillingPricingGateway projectSaleBillingPricingGatewayForLoad = new ProjectSaleBillingPricingGateway(projectTDS);
                        projectSaleBillingPricingGatewayForLoad.LoadAllByProjectId(projectId);

                        // ... Get Sale/Billing/Pricing - Services
                        ProjectNavigatorProjectService projectNavigatorProjectService = new ProjectNavigatorProjectService(projectNavigatorTDS);
                        projectNavigatorProjectService.LoadAllByProjectId(projectId);
                        projectNavigatorProjectService.UpdateForLoad();

                        // Get Costing Updates
                        ProjectCostingUpdatesGateway projectCostingUpdatesGatewayForLoad = new ProjectCostingUpdatesGateway(projectTDS);
                        projectCostingUpdatesGatewayForLoad.LoadByProjectId(projectId);

                        // Get Project Terms
                        ProjectTermsPOGateway projectTermsPOGatewayForLoad = new ProjectTermsPOGateway(projectTDS);
                        projectTermsPOGatewayForLoad.LoadByProjectId(projectId);

                        // Get Technical
                        ProjectTechnicalGateway projectTechnicalGatewayForLoad = new ProjectTechnicalGateway(projectTDS);
                        projectTechnicalGatewayForLoad.LoadByProjectId(projectId);

                        // Get Engineer Subcontractors
                        ProjectEngineerSubcontractorsGateway projectEngineerSubcontractorsGatewayForLoad = new ProjectEngineerSubcontractorsGateway(projectTDS);
                        projectEngineerSubcontractorsGatewayForLoad.LoadAllByProjectId(projectId);

                        // ... Get Subcontractors
                        ProjectSubcontractorGateway projectSubcontractorGatewayForLoad = new ProjectSubcontractorGateway(projectTDS);
                        projectSubcontractorGatewayForLoad.LoadAllByProjectId(projectId);

                        // Cost Exceptions
                        // ... Get Type Of Work & Function Classification
                        ProjectNavigatorProjectWorkFunctionFairWage projectNavigatorProjectWorkFunctionFairWage = new ProjectNavigatorProjectWorkFunctionFairWage(projectNavigatorTDS);
                        projectNavigatorProjectWorkFunctionFairWage.LoadAllByProjectId(projectId);

                        // ... Get Job Class Classification
                        ProjectNavigatorProjectJobClassTypeRate projectNavigatorProjectJobClassTypeRate = new ProjectNavigatorProjectJobClassTypeRate(projectNavigatorTDS);
                        projectNavigatorProjectJobClassTypeRate.LoadAllByProjectId(projectId);

                        // Get Budget
                        ProjectNavigatorProjectWorkFunctionBudget projectNavigatorProjectWorkFunctionBudget = new ProjectNavigatorProjectWorkFunctionBudget(projectNavigatorTDS);
                        projectNavigatorProjectWorkFunctionBudget.LoadAllByProjectId(projectId);

                        // Get Units Budget
                        ProjectNavigatorProjectUnitsBudget projectNavigatorProjectUnitsBudget = new ProjectNavigatorProjectUnitsBudget(projectNavigatorTDS);
                        projectNavigatorProjectUnitsBudget.LoadAllByProjectId(projectId);

                        // Get Materials Budget
                        ProjectNavigatorProjectMaterialsBudget projectNavigatorProjectMaterialsBudget = new ProjectNavigatorProjectMaterialsBudget(projectNavigatorTDS);
                        projectNavigatorProjectMaterialsBudget.LoadAllByProjectId(projectId);

                        // Get Subcontractors Budget
                        ProjectNavigatorProjectSubcontractorsBudget projectNavigatorProjectSubcontractorsBudget = new ProjectNavigatorProjectSubcontractorsBudget(projectNavigatorTDS);
                        projectNavigatorProjectSubcontractorsBudget.LoadAllByProjectId(projectId);

                        // Get Hotels Budget
                        ProjectNavigatorProjectHotelsBudget projectNavigatorProjectHotelsBudget = new ProjectNavigatorProjectHotelsBudget(projectNavigatorTDS);
                        projectNavigatorProjectHotelsBudget.LoadAllByProjectId(projectId);

                        // Get Bondings Budget
                        ProjectNavigatorProjectBondingsBudget projectNavigatorProjectBondingsBudget = new ProjectNavigatorProjectBondingsBudget(projectNavigatorTDS);
                        projectNavigatorProjectBondingsBudget.LoadAllByProjectId(projectId);

                        // Get Insurances Budget
                        ProjectNavigatorProjectInsurancesBudget projectNavigatorProjectInsurancesBudget = new ProjectNavigatorProjectInsurancesBudget(projectNavigatorTDS);
                        projectNavigatorProjectInsurancesBudget.LoadAllByProjectId(projectId);

                        // Get Other Costs Budget
                        ProjectNavigatorProjectOtherCostsBudget projectNavigatorProjectOtherCostsBudget = new ProjectNavigatorProjectOtherCostsBudget(projectNavigatorTDS);
                        projectNavigatorProjectOtherCostsBudget.LoadAllByProjectId(projectId);

                        // Get Notes
                        ProjectNavigatorProjectNotes projectNavigatorProjectNotes = new ProjectNavigatorProjectNotes(projectNavigatorTDS);
                        projectNavigatorProjectNotes.LoadAllByProjectId(projectId);

                        // Store dataset
                        Session["lfsProjectTDS"] = projectTDS;
                        Session["projectNavigatorTDS"] = projectNavigatorTDS;
                        Session["projectNotes"] = projectNavigatorTDS.ProjectNotes;
                        Session["projectServices"] = projectNavigatorTDS.ProjectService;
                        Session["projectTypeOfWorkFunctionClassification"] = projectNavigatorTDS.LFS_PROJECT_WORK_FUNCTION_FAIR_WAGE;
                        Session["projectJobClassClassification"] = projectNavigatorTDS.LFS_PROJECT_JOB_CLASS_TYPE_RATE;
                        Session["projectBudget"] = projectNavigatorTDS.ProjectWorkFunctionBudget;
                        Session["unitsBudget"] = projectNavigatorTDS.ProjectUnitsBudget;
                        Session["materialsBudget"] = projectNavigatorTDS.ProjectMaterialsBudget;
                        Session["subcontractorsBudget"] = projectNavigatorTDS.ProjectSubcontractorsBudget;
                        Session["hotelsBudget"] = projectNavigatorTDS.ProjectHotelsBudget;
                        Session["bondingsBudget"] = projectNavigatorTDS.ProjectBondingsBudget;
                        Session["insurancesBudget"] = projectNavigatorTDS.ProjectInsurancesBudget;
                        Session["otherCostsBudget"] = projectNavigatorTDS.ProjectOtherCostsBudget;
                    }

                    //grdNotes.DataBind();
                    //grdServices.DataBind();
                    grdTypeOfWorkFunctionClassification.DataBind();
                    grdJobClassClassification.DataBind();
                    grdBudget.DataBind();
                    /*grdSubcontractorsBudget.DataBind();
                    grdHotelsBudget.DataBind();
                    grdBondingsBudget.DataBind();
                    grdInsurancesBudget.DataBind();*/
                    grdOtherCostsBudget.DataBind();
                }

                // ... project_summary.aspx or project_edit.aspx
                if ((Request.QueryString["source_page"] == "project_summary.aspx") || (Request.QueryString["source_page"] == "project_edit.aspx") || (Request.QueryString["source_page"] == "lm"))
                {
                    // Store Navigator State, update control and origin
                    StoreNavigatorState();
                    ViewState["update"] = Request.QueryString["update"];
                    ViewState["origin"] = Request.QueryString["origin"]; //summary

                    // Restore dataset
                    projectTDS = (ProjectTDS)Session["lfsProjectTDS"];
                    projectNavigatorTDS = (ProjectNavigatorTDS)Session["projectNavigatorTDS"];
                    projectNotes = (ProjectNavigatorTDS.ProjectNotesDataTable)Session["projectNotes"];
                    projectServices = (ProjectNavigatorTDS.ProjectServiceDataTable)Session["projectServices"];
                    projectJobClassClassification = (ProjectNavigatorTDS.LFS_PROJECT_JOB_CLASS_TYPE_RATEDataTable)Session["projectJobClassClassification"];
                    projectTypeOfWorkFunctionClassification = (ProjectNavigatorTDS.LFS_PROJECT_WORK_FUNCTION_FAIR_WAGEDataTable)Session["projectTypeOfWorkFunctionClassification"];
                    projectBudget = (ProjectNavigatorTDS.ProjectWorkFunctionBudgetDataTable)Session["projectBudget"];
                    unitsBudget = (ProjectNavigatorTDS.ProjectUnitsBudgetDataTable)Session["unitsBudget"];
                    materialsBudget = (ProjectNavigatorTDS.ProjectMaterialsBudgetDataTable)Session["materialsBudget"];
                    subcontractorsBudget = (ProjectNavigatorTDS.ProjectSubcontractorsBudgetDataTable)Session["subcontractorsBudget"];
                    hotelsBudget = (ProjectNavigatorTDS.ProjectHotelsBudgetDataTable)Session["hotelsBudget"];
                    bondingsBudget = (ProjectNavigatorTDS.ProjectBondingsBudgetDataTable)Session["bondingsBudget"];
                    insurancesBudget = (ProjectNavigatorTDS.ProjectInsurancesBudgetDataTable)Session["insurancesBudget"];
                    otherCostsBudget = (ProjectNavigatorTDS.ProjectOtherCostsBudgetDataTable)Session["otherCostsBudget"];

                    // Get Project Id
                    int projectId = int.Parse(hdfProjectId.Value);

                    if (ViewState["update"].ToString().Trim() == "yes")
                    {
                        // Get General Data
                        ProjectGateway projectGatewayForLoad = new ProjectGateway(projectTDS);
                        projectGatewayForLoad.LoadByProjectId(projectId);

                        // Get job info
                        ProjectJobInfoGateway projectJobInfoGateway = new ProjectJobInfoGateway(projectNavigatorTDS);
                        projectJobInfoGateway.LoadAllByProjectId(projectId);

                        // Get Sale/Billing/Pricing
                        ProjectSaleBillingPricingGateway projectSaleBillingPricingGatewayForLoad = new ProjectSaleBillingPricingGateway(projectTDS);
                        projectSaleBillingPricingGatewayForLoad.LoadAllByProjectId(projectId);

                        // ... Get Sale/Billing/Pricing - Services
                        ProjectNavigatorProjectService projectNavigatorProjectService = new ProjectNavigatorProjectService(projectNavigatorTDS);
                        projectNavigatorProjectService.LoadAllByProjectId(projectId);
                        projectNavigatorProjectService.UpdateForLoad();

                        // Get Costing Updates
                        ProjectCostingUpdatesGateway projectCostingUpdatesGatewayForLoad = new ProjectCostingUpdatesGateway(projectTDS);
                        projectCostingUpdatesGatewayForLoad.LoadByProjectId(projectId);

                        // Get Project Terms
                        ProjectTermsPOGateway projectTermsPOGatewayForLoad = new ProjectTermsPOGateway(projectTDS);
                        projectTermsPOGatewayForLoad.LoadByProjectId(projectId);

                        // Get Technical
                        ProjectTechnicalGateway projectTechnicalGatewayForLoad = new ProjectTechnicalGateway(projectTDS);
                        projectTechnicalGatewayForLoad.LoadByProjectId(projectId);

                        // Get Engineer Subcontractors
                        ProjectEngineerSubcontractorsGateway projectEngineerSubcontractorsGatewayForLoad = new ProjectEngineerSubcontractorsGateway(projectTDS);
                        projectEngineerSubcontractorsGatewayForLoad.LoadAllByProjectId(projectId);

                        // ... Get Subcontractors
                        ProjectSubcontractorGateway projectSubcontractorGatewayForLoad = new ProjectSubcontractorGateway(projectTDS);
                        projectSubcontractorGatewayForLoad.LoadAllByProjectId(projectId);

                        // Cost Exceptions
                        // ... Get Type Of Work & Function Classification
                        ProjectNavigatorProjectWorkFunctionFairWage projectNavigatorProjectWorkFunctionFairWage = new ProjectNavigatorProjectWorkFunctionFairWage(projectNavigatorTDS);
                        projectNavigatorProjectWorkFunctionFairWage.LoadAllByProjectId(projectId);

                        // ... Get Job Class Classification
                        ProjectNavigatorProjectJobClassTypeRate projectNavigatorProjectJobClassTypeRate = new ProjectNavigatorProjectJobClassTypeRate(projectNavigatorTDS);
                        projectNavigatorProjectJobClassTypeRate.LoadAllByProjectId(projectId);

                        // Get Budget
                        ProjectNavigatorProjectWorkFunctionBudget projectNavigatorProjectWorkFunctionBudget = new ProjectNavigatorProjectWorkFunctionBudget(projectNavigatorTDS);
                        projectNavigatorProjectWorkFunctionBudget.LoadAllByProjectId(projectId);

                        // Get Units Budget
                        ProjectNavigatorProjectUnitsBudget projectNavigatorProjectUnitsBudget = new ProjectNavigatorProjectUnitsBudget(projectNavigatorTDS);
                        projectNavigatorProjectUnitsBudget.LoadAllByProjectId(projectId);

                        // Get Materials Budget
                        ProjectNavigatorProjectMaterialsBudget projectNavigatorProjectMaterialsBudget = new ProjectNavigatorProjectMaterialsBudget(projectNavigatorTDS);
                        projectNavigatorProjectMaterialsBudget.LoadAllByProjectId(projectId);

                        // Get Subcontractors Budget
                        ProjectNavigatorProjectSubcontractorsBudget projectNavigatorProjectSubcontractorsBudget = new ProjectNavigatorProjectSubcontractorsBudget(projectNavigatorTDS);
                        projectNavigatorProjectSubcontractorsBudget.LoadAllByProjectId(projectId);

                        // Get Hotels Budget
                        ProjectNavigatorProjectHotelsBudget projectNavigatorProjectHotelsBudget = new ProjectNavigatorProjectHotelsBudget(projectNavigatorTDS);
                        projectNavigatorProjectHotelsBudget.LoadAllByProjectId(projectId);

                        // Get Bondings Budget
                        ProjectNavigatorProjectBondingsBudget projectNavigatorProjectBondingsBudget = new ProjectNavigatorProjectBondingsBudget(projectNavigatorTDS);
                        projectNavigatorProjectBondingsBudget.LoadAllByProjectId(projectId);

                        // Get Insurances Budget
                        ProjectNavigatorProjectInsurancesBudget projectNavigatorProjectInsurancesBudget = new ProjectNavigatorProjectInsurancesBudget(projectNavigatorTDS);
                        projectNavigatorProjectInsurancesBudget.LoadAllByProjectId(projectId);

                        // Get Other Costs Budget
                        ProjectNavigatorProjectOtherCostsBudget projectNavigatorProjectOtherCostsBudget = new ProjectNavigatorProjectOtherCostsBudget(projectNavigatorTDS);
                        projectNavigatorProjectOtherCostsBudget.LoadAllByProjectId(projectId);

                        // Get Notes
                        ProjectNavigatorProjectNotes projectNavigatorProjectNotes = new ProjectNavigatorProjectNotes(projectNavigatorTDS);
                        projectNavigatorProjectNotes.LoadAllByProjectId(projectId);

                        //grdNotes.DataBind();
                        //grdServices.DataBind();
                        grdTypeOfWorkFunctionClassification.DataBind();
                        grdJobClassClassification.DataBind();
                        grdBudget.DataBind();
                        /*grdSubcontractorsBudget.DataBind();
                        grdHotelsBudget.DataBind();
                        grdBondingsBudget.DataBind();
                        grdInsurancesBudget.DataBind();*/
                        grdOtherCostsBudget.DataBind();

                        // Store dataset
                        Session["lfsProjectTDS"] = projectTDS;
                        Session["projectNavigatorTDS"] = projectNavigatorTDS;
                        Session["projectNotes"] = projectNavigatorTDS.ProjectNotes;
                        Session["projectServices"] = projectNavigatorTDS.ProjectService;
                        Session["projectTypeOfWorkFunctionClassification"] = projectNavigatorTDS.LFS_PROJECT_WORK_FUNCTION_FAIR_WAGE;
                        Session["projectJobClassClassification"] = projectNavigatorTDS.LFS_PROJECT_JOB_CLASS_TYPE_RATE;
                        Session["projectBudget"] = projectNavigatorTDS.ProjectWorkFunctionBudget;
                        Session["unitsBudget"] = projectNavigatorTDS.ProjectUnitsBudget;
                        Session["materialsBudget"] = projectNavigatorTDS.ProjectMaterialsBudget;
                        Session["subcontractorsBudget"] = projectNavigatorTDS.ProjectSubcontractorsBudget;
                        Session["hotelsBudget"] = projectNavigatorTDS.ProjectHotelsBudget;
                        Session["bondingsBudget"] = projectNavigatorTDS.ProjectBondingsBudget;
                        Session["insurancesBudget"] = projectNavigatorTDS.ProjectInsurancesBudget;
                        Session["otherCostsBudget"] = projectNavigatorTDS.ProjectOtherCostsBudget;
                    }
                }

                // Data for current project
                ProjectGateway projectGateway = new ProjectGateway(projectTDS);

                // ... for project
                int currentProjectId = Int32.Parse(hdfProjectId.Value.ToString());
                string name = projectGateway.GetName(currentProjectId);
                if (name.Length > 23) name = name.Substring(0, 20) + "...";
                lblTitleProjectName.Text = name + " (" + projectGateway.GetProjectNumber(currentProjectId) + ")";

                // ... for client
                int companyId = Int32.Parse(hdfCompanyId.Value);
                int currentClientId = projectGateway.GetClientID(Int32.Parse(hdfProjectId.Value.ToString()));
                CompaniesGateway companiesGateway = new CompaniesGateway();
                companiesGateway.LoadAllByCompaniesId(currentClientId, companyId);
                lblTitleClientName.Text = "Client: " + companiesGateway.GetName(currentClientId);

                // Load Data
                LoadData();

                // Store Dataset
                Session["lfsProjectTDS"] = projectTDS;

                //// ... For total cost at services
                //ProjectNavigatorProjectService projectNavigatorProjectServiceForCost = new ProjectNavigatorProjectService(projectNavigatorTDS);
                //tbxTotalCost.Text = Decimal.Round(projectNavigatorProjectServiceForCost.GetTotalCost(), 2).ToString();
            }
            else
            {
                // Restore dataset
                projectTDS = (ProjectTDS)Session["lfsProjectTDS"];
                projectNavigatorTDS = (ProjectNavigatorTDS)Session["projectNavigatorTDS"];
                projectNotes = (ProjectNavigatorTDS.ProjectNotesDataTable)Session["projectNotes"];
                projectServices = (ProjectNavigatorTDS.ProjectServiceDataTable)Session["projectServices"];
                projectJobClassClassification = (ProjectNavigatorTDS.LFS_PROJECT_JOB_CLASS_TYPE_RATEDataTable)Session["projectJobClassClassification"];
                projectTypeOfWorkFunctionClassification = (ProjectNavigatorTDS.LFS_PROJECT_WORK_FUNCTION_FAIR_WAGEDataTable)Session["projectTypeOfWorkFunctionClassification"];
                projectBudget = (ProjectNavigatorTDS.ProjectWorkFunctionBudgetDataTable)Session["projectBudget"];
                unitsBudget = (ProjectNavigatorTDS.ProjectUnitsBudgetDataTable)Session["unitsBudget"];
                materialsBudget = (ProjectNavigatorTDS.ProjectMaterialsBudgetDataTable)Session["materialsBudget"];
                subcontractorsBudget = (ProjectNavigatorTDS.ProjectSubcontractorsBudgetDataTable)Session["subcontractorsBudget"];
                hotelsBudget = (ProjectNavigatorTDS.ProjectHotelsBudgetDataTable)Session["hotelsBudget"];
                bondingsBudget = (ProjectNavigatorTDS.ProjectBondingsBudgetDataTable)Session["bondingsBudget"];
                insurancesBudget = (ProjectNavigatorTDS.ProjectInsurancesBudgetDataTable)Session["insurancesBudget"];
                otherCostsBudget = (ProjectNavigatorTDS.ProjectOtherCostsBudgetDataTable)Session["otherCostsBudget"];

                tbxProjectNumber.DataBind();

                if (Session["lfsLibraryTDS"] != null)
                {
                    libraryTDS = (LibraryTDS)Session["lfsLibraryTDS"];
                }
                else
                {
                    libraryTDS = new LibraryTDS();
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Update4 - Duplicate proposal
        /// </summary>
        public void Update4()
        {
            ProjectCostingUpdatesGateway projectCostingUpdatesGateway = new ProjectCostingUpdatesGateway(Data);
            ProjectEngineerSubcontractorsGateway projectEngineerSubcontractorsGateway = new ProjectEngineerSubcontractorsGateway(Data);
            ProjectHistoryGateway projectHistoryGateway = new ProjectHistoryGateway(Data);
            ProjectNotesGateway projectNotesGateway = new ProjectNotesGateway(Data);
            ProjectSaleBillingPricingGateway projectSaleBillingPricingGateway = new ProjectSaleBillingPricingGateway(Data);
            ProjectServiceGateway projectServiceGateway = new ProjectServiceGateway(Data);
            ProjectSubcontractorGateway projectSubcontractorGateway = new ProjectSubcontractorGateway(Data);
            ProjectTechnicalGateway projectTechnicalGateway = new ProjectTechnicalGateway(Data);
            ProjectTermsPOGateway projectTermsPOGateway = new ProjectTermsPOGateway(Data);

            DataTable projectChanges = Table.GetChanges();
            DataTable projectCostingUpdatesChanges = projectCostingUpdatesGateway.Table.GetChanges();
            DataTable projectEngineerSubcontractorsChanges = projectEngineerSubcontractorsGateway.Table.GetChanges();
            DataTable projectHistoryChanges = projectHistoryGateway.Table.GetChanges();
            DataTable projectNotesChanges = projectNotesGateway.Table.GetChanges();
            DataTable projectSaleBillingPricingChanges = projectSaleBillingPricingGateway.Table.GetChanges();
            DataTable projectServiceChanges = projectServiceGateway.Table.GetChanges();
            DataTable projectSubcontractorChanges = projectSubcontractorGateway.Table.GetChanges();
            DataTable projectTechnicalChanges = projectTechnicalGateway.Table.GetChanges();
            DataTable projectTermsPOChanges = projectTermsPOGateway.Table.GetChanges();

            if ((projectChanges == null) && (projectCostingUpdatesChanges == null) && (projectEngineerSubcontractorsChanges == null) && (projectHistoryChanges == null) && (projectNotesChanges == null) && (projectSaleBillingPricingChanges == null) && (projectServiceChanges == null) && (projectSubcontractorChanges == null) && (projectTechnicalChanges == null) && (projectTermsPOChanges == null)) return;

            try
            {
                DB.Open();
                DB.BeginTransaction();

                Adapter.InsertCommand.Transaction = DB.Transaction;
                Adapter.UpdateCommand.Transaction = DB.Transaction;
                Adapter.DeleteCommand.Transaction = DB.Transaction;

                projectCostingUpdatesGateway.Adapter.InsertCommand.Transaction = DB.Transaction;
                projectCostingUpdatesGateway.Adapter.UpdateCommand.Transaction = DB.Transaction;
                projectCostingUpdatesGateway.Adapter.DeleteCommand.Transaction = DB.Transaction;

                projectEngineerSubcontractorsGateway.Adapter.InsertCommand.Transaction = DB.Transaction;
                projectEngineerSubcontractorsGateway.Adapter.UpdateCommand.Transaction = DB.Transaction;
                projectEngineerSubcontractorsGateway.Adapter.DeleteCommand.Transaction = DB.Transaction;

                projectHistoryGateway.Adapter.InsertCommand.Transaction = DB.Transaction;
                projectHistoryGateway.Adapter.UpdateCommand.Transaction = DB.Transaction;
                projectHistoryGateway.Adapter.DeleteCommand.Transaction = DB.Transaction;

                projectNotesGateway.Adapter.InsertCommand.Transaction = DB.Transaction;
                projectNotesGateway.Adapter.UpdateCommand.Transaction = DB.Transaction;
                projectNotesGateway.Adapter.DeleteCommand.Transaction = DB.Transaction;

                projectSaleBillingPricingGateway.Adapter.InsertCommand.Transaction = DB.Transaction;
                projectSaleBillingPricingGateway.Adapter.UpdateCommand.Transaction = DB.Transaction;
                projectSaleBillingPricingGateway.Adapter.DeleteCommand.Transaction = DB.Transaction;

                projectServiceGateway.Adapter.InsertCommand.Transaction = DB.Transaction;
                projectServiceGateway.Adapter.UpdateCommand.Transaction = DB.Transaction;
                projectServiceGateway.Adapter.DeleteCommand.Transaction = DB.Transaction;

                projectSubcontractorGateway.Adapter.InsertCommand.Transaction = DB.Transaction;
                projectSubcontractorGateway.Adapter.UpdateCommand.Transaction = DB.Transaction;
                projectSubcontractorGateway.Adapter.DeleteCommand.Transaction = DB.Transaction;

                projectTechnicalGateway.Adapter.InsertCommand.Transaction = DB.Transaction;
                projectTechnicalGateway.Adapter.UpdateCommand.Transaction = DB.Transaction;
                projectTechnicalGateway.Adapter.DeleteCommand.Transaction = DB.Transaction;

                projectTermsPOGateway.Adapter.InsertCommand.Transaction = DB.Transaction;
                projectTermsPOGateway.Adapter.UpdateCommand.Transaction = DB.Transaction;
                projectTermsPOGateway.Adapter.DeleteCommand.Transaction = DB.Transaction;

                if ((projectChanges != null) && (projectChanges.Rows.Count > 0))
                {
                    Adapter.Update(projectChanges);

                    int newProjectId = DB.GetIdentCurrent("LFS_PROJECT", DB.Transaction);

                    //Getting projectId for History table
                    ProjectTDS.LFS_PROJECT_HISTORYRow rowHistory = ((ProjectTDS.LFS_PROJECT_HISTORYDataTable)projectHistoryGateway.Table).FindByProjectIDRefID(0, 1);
                    rowHistory.ProjectID = newProjectId;
                    projectHistoryChanges = projectHistoryGateway.Table.GetChanges();

                    //Getting projectId for Costing Updates table
                    if (projectCostingUpdatesGateway.Table.Rows.Count > 0)
                    {
                        ProjectTDS.LFS_PROJECT_COSTING_UPDATESRow rowProjectCosting = ((ProjectTDS.LFS_PROJECT_COSTING_UPDATESDataTable)projectCostingUpdatesGateway.Table).FindByProjectID(0);
                        rowProjectCosting.ProjectID = newProjectId;
                        projectCostingUpdatesChanges = projectCostingUpdatesGateway.Table.GetChanges();
                    }

                    //Getting projectId for Engineer Subcontractors table
                    if (projectEngineerSubcontractorsGateway.Table.Rows.Count > 0)
                    {
                        ProjectTDS.LFS_PROJECT_ENGINEER_SUBCONTRACTORSRow rowEngineerSubcontractors = ((ProjectTDS.LFS_PROJECT_ENGINEER_SUBCONTRACTORSDataTable)projectEngineerSubcontractorsGateway.Table).FindByProjectID(0);
                        rowEngineerSubcontractors.ProjectID = newProjectId;
                        projectEngineerSubcontractorsChanges = projectEngineerSubcontractorsGateway.Table.GetChanges();
                    }

                    //Getting projectId for Notes table
                    foreach (ProjectTDS.LFS_PROJECT_NOTERow rowNotes in (ProjectTDS.LFS_PROJECT_NOTEDataTable)projectNotesGateway.Table)
                    {
                        if (rowNotes.ProjectID == 0)
                        {
                            rowNotes.ProjectID = newProjectId;
                        }
                    }
                    projectNotesChanges = projectNotesGateway.Table.GetChanges();

                    //Getting projectId for SaleBillingPricing
                    if (projectSaleBillingPricingGateway.Table.Rows.Count > 0)
                    {
                        ProjectTDS.LFS_PROJECT_SALE_BILLING_PRICINGRow rowSaleBillingPricing = ((ProjectTDS.LFS_PROJECT_SALE_BILLING_PRICINGDataTable)projectSaleBillingPricingGateway.Table).FindByProjectID(0);
                        rowSaleBillingPricing.ProjectID = newProjectId;
                        projectSaleBillingPricingChanges = projectSaleBillingPricingGateway.Table.GetChanges();
                    }

                    //Getting projectId for Subcontractors
                    foreach (ProjectTDS.LFS_PROJECT_SUBCONTRACTORRow rowSubcontractor in (ProjectTDS.LFS_PROJECT_SUBCONTRACTORDataTable)projectSubcontractorGateway.Table)
                    {
                        if (rowSubcontractor.ProjectID == 0)
                        {
                            rowSubcontractor.ProjectID = newProjectId;
                        }
                    }
                    projectSubcontractorChanges = projectSubcontractorGateway.Table.GetChanges();

                    //Getting projectId for Services
                    foreach (ProjectTDS.LFS_PROJECT_SERVICERow rowService in (ProjectTDS.LFS_PROJECT_SERVICEDataTable)projectServiceGateway.Table)
                    {
                        if (rowService.ProjectID == 0)
                        {
                            rowService.ProjectID = newProjectId;
                        }
                    }
                    projectServiceChanges = projectServiceGateway.Table.GetChanges();

                    //Getting projectId for Technical
                    if (projectTechnicalGateway.Table.Rows.Count > 0)
                    {
                        ProjectTDS.LFS_PROJECT_TECHNICALRow rowTechnical = ((ProjectTDS.LFS_PROJECT_TECHNICALDataTable)projectTechnicalGateway.Table).FindByProjectID(0);
                        rowTechnical.ProjectID = newProjectId;
                        projectTechnicalChanges = projectTechnicalGateway.Table.GetChanges();
                    }

                    //Getting projectId for Terms
                    if (projectTermsPOGateway.Table.Rows.Count > 0)
                    {
                        ProjectTDS.LFS_PROJECT_TERMSRow rowTerms = ((ProjectTDS.LFS_PROJECT_TERMSDataTable)projectTermsPOGateway.Table).FindByProjectID(0);
                        rowTerms.ProjectID = newProjectId;
                        projectTermsPOChanges = projectTermsPOGateway.Table.GetChanges();
                    }
                }

                if ((projectCostingUpdatesChanges != null) && (projectCostingUpdatesChanges.Rows.Count > 0))
                {
                    projectCostingUpdatesGateway.Adapter.Update(projectCostingUpdatesChanges);
                }

                if ((projectEngineerSubcontractorsChanges != null) && (projectEngineerSubcontractorsChanges.Rows.Count > 0))
                {
                    projectEngineerSubcontractorsGateway.Adapter.Update(projectEngineerSubcontractorsChanges);
                }

                if ((projectHistoryChanges != null) && (projectHistoryChanges.Rows.Count > 0))
                {
                    projectHistoryGateway.Adapter.Update(projectHistoryChanges);
                }

                if ((projectNotesChanges != null) && (projectNotesChanges.Rows.Count > 0))
                {
                    projectNotesGateway.Adapter.Update(projectNotesChanges);
                }

                if ((projectSaleBillingPricingChanges != null) && (projectSaleBillingPricingChanges.Rows.Count > 0))
                {
                    projectSaleBillingPricingGateway.Adapter.Update(projectSaleBillingPricingChanges);
                }

                if ((projectServiceChanges != null) && (projectServiceChanges.Rows.Count > 0))
                {
                    projectServiceGateway.Adapter.Update(projectServiceChanges);
                }

                if ((projectSubcontractorChanges != null) && (projectSubcontractorChanges.Rows.Count > 0))
                {
                    projectSubcontractorGateway.Adapter.Update(projectSubcontractorChanges);
                }

                if ((projectTechnicalChanges != null) && (projectTechnicalChanges.Rows.Count > 0))
                {
                    projectTechnicalGateway.Adapter.Update(projectTechnicalChanges);
                }

                if ((projectTermsPOChanges != null) && (projectTermsPOChanges.Rows.Count > 0))
                {
                    projectTermsPOGateway.Adapter.Update(projectTermsPOChanges);
                }

                DB.CommitTransaction();
            }

            catch (DBConcurrencyException dBConcurrencyException)
            {
                DB.RollbackTransaction();
                throw new Exception("Concurrency error: Another user already updated the data you are working on.  Your operation has been cancelled.", dBConcurrencyException);
            }

            catch (SqlException sqlException)
            {
                DB.RollbackTransaction();
                byte severityLevel = sqlException.Class;
                if (severityLevel <= 16)
                {
                    throw new Exception("Low severity error. Your operation has been cancelled.  SQL Error " + severityLevel + ".");
                }
                if ((severityLevel >= 17) && (severityLevel <= 19))
                {
                    throw new Exception("Mid severity error. Your operation has been cancelled.  SQL Error " + severityLevel + ".");
                }
                if (severityLevel >= 20)
                {
                    throw new Exception("High severity error. Your operation has been cancelled.  SQL Error " + severityLevel + ".");
                }
            }

            catch (Exception e)
            {
                DB.RollbackTransaction();
                throw new Exception("Unknow error. Your operation has been cancelled.", e);
            }

            finally
            {
                DB.Close();
            }
        }
        private void InsertProjectCostingUpdates(int originalProjectId)
        {
            // ... Data for current project
            ProjectCostingUpdatesGateway projectCostingUpdatesGateway = new ProjectCostingUpdatesGateway(projectTDS);
            projectCostingUpdatesGateway.LoadByProjectId(originalProjectId);

            if (projectCostingUpdatesGateway.Table.Rows.Count > 0)
            {
                // ... Definition of general variables
                decimal? extrasToDate = null; if (projectCostingUpdatesGateway.GetExtrasToDate(originalProjectId).HasValue) extrasToDate = (decimal)projectCostingUpdatesGateway.GetExtrasToDate(originalProjectId);
                decimal? costsIncurred = null; if (projectCostingUpdatesGateway.GetCostsIncurred(originalProjectId).HasValue) costsIncurred = (decimal)projectCostingUpdatesGateway.GetCostsIncurred(originalProjectId);
                decimal? costToComplete = null; if (projectCostingUpdatesGateway.GetCostToComplete(originalProjectId).HasValue) costToComplete = (decimal)projectCostingUpdatesGateway.GetCostToComplete(originalProjectId);
                decimal? originalProfitEstimated = null; if (projectCostingUpdatesGateway.GetOriginalProfitEstimated(originalProjectId).HasValue) originalProfitEstimated = (decimal)projectCostingUpdatesGateway.GetOriginalProfitEstimated(originalProjectId);
                decimal? invoicedToDate = null; if (projectCostingUpdatesGateway.GetInvoicedToDate(originalProjectId).HasValue) invoicedToDate = (decimal)projectCostingUpdatesGateway.GetInvoicedToDate(originalProjectId);

                // ... Insert Costing Updates
                ProjectCostingUpdates projectCostingUpdates = new ProjectCostingUpdates(projectTDS);
                projectCostingUpdates.Insert(0, extrasToDate, costsIncurred, costToComplete, originalProfitEstimated, invoicedToDate, Int32.Parse(hdfCompanyId.Value.Trim()));
            }
        }
Пример #5
0
        /// <summary>
        /// Update3 - Update all project
        /// </summary>
        public void Update3()
        {
            ProjectCostingUpdatesGateway projectCostingUpdatesGateway = new ProjectCostingUpdatesGateway(Data);
            ProjectEngineerSubcontractorsGateway projectEngineerSubcontractorsGateway = new ProjectEngineerSubcontractorsGateway(Data);
            ProjectHistoryGateway projectHistoryGateway = new ProjectHistoryGateway(Data);
            ProjectSaleBillingPricingGateway projectSaleBillingPricingGateway = new ProjectSaleBillingPricingGateway(Data);
            ProjectSubcontractorGateway projectSubcontractorGateway = new ProjectSubcontractorGateway(Data);
            ProjectTechnicalGateway projectTechnicalGateway = new ProjectTechnicalGateway(Data);
            ProjectTermsPOGateway projectTermsPOGateway = new ProjectTermsPOGateway(Data);

            DataTable projectChanges = Table.GetChanges();
            DataTable projectCostingUpdatesChanges = projectCostingUpdatesGateway.Table.GetChanges();
            DataTable projectEngineerSubcontractorsChanges = projectEngineerSubcontractorsGateway.Table.GetChanges();
            DataTable projectHistoryChanges = projectHistoryGateway.Table.GetChanges();
            DataTable projectSaleBillingPricingChanges = projectSaleBillingPricingGateway.Table.GetChanges();
            DataTable projectSubcontractorChanges = projectSubcontractorGateway.Table.GetChanges();
            DataTable projectTechnicalChanges = projectTechnicalGateway.Table.GetChanges();
            DataTable projectTermsPOChanges = projectTermsPOGateway.Table.GetChanges();

            if ((projectChanges == null) && (projectCostingUpdatesChanges == null) && (projectEngineerSubcontractorsChanges == null) && (projectHistoryChanges == null)  && (projectSaleBillingPricingChanges == null) && (projectSubcontractorChanges == null) && (projectTechnicalChanges == null) && (projectTermsPOChanges == null)) return;

            try
            {
                DB.Open();
                DB.BeginTransaction();

                Adapter.InsertCommand.Transaction = DB.Transaction;
                Adapter.UpdateCommand.Transaction = DB.Transaction;
                Adapter.DeleteCommand.Transaction = DB.Transaction;

                projectCostingUpdatesGateway.Adapter.InsertCommand.Transaction = DB.Transaction;
                projectCostingUpdatesGateway.Adapter.UpdateCommand.Transaction = DB.Transaction;
                projectCostingUpdatesGateway.Adapter.DeleteCommand.Transaction = DB.Transaction;

                projectEngineerSubcontractorsGateway.Adapter.InsertCommand.Transaction = DB.Transaction;
                projectEngineerSubcontractorsGateway.Adapter.UpdateCommand.Transaction = DB.Transaction;
                projectEngineerSubcontractorsGateway.Adapter.DeleteCommand.Transaction = DB.Transaction;

                projectHistoryGateway.Adapter.InsertCommand.Transaction = DB.Transaction;
                projectHistoryGateway.Adapter.UpdateCommand.Transaction = DB.Transaction;
                projectHistoryGateway.Adapter.DeleteCommand.Transaction = DB.Transaction;

                projectSaleBillingPricingGateway.Adapter.InsertCommand.Transaction = DB.Transaction;
                projectSaleBillingPricingGateway.Adapter.UpdateCommand.Transaction = DB.Transaction;
                projectSaleBillingPricingGateway.Adapter.DeleteCommand.Transaction = DB.Transaction;

                projectSubcontractorGateway.Adapter.InsertCommand.Transaction = DB.Transaction;
                projectSubcontractorGateway.Adapter.UpdateCommand.Transaction = DB.Transaction;
                projectSubcontractorGateway.Adapter.DeleteCommand.Transaction = DB.Transaction;

                projectTechnicalGateway.Adapter.InsertCommand.Transaction = DB.Transaction;
                projectTechnicalGateway.Adapter.UpdateCommand.Transaction = DB.Transaction;
                projectTechnicalGateway.Adapter.DeleteCommand.Transaction = DB.Transaction;

                projectTermsPOGateway.Adapter.InsertCommand.Transaction = DB.Transaction;
                projectTermsPOGateway.Adapter.UpdateCommand.Transaction = DB.Transaction;
                projectTermsPOGateway.Adapter.DeleteCommand.Transaction = DB.Transaction;

                if ((projectChanges != null) && (projectChanges.Rows.Count > 0))
                {
                    Adapter.Update(projectChanges);
                }

                if ((projectCostingUpdatesChanges != null) && (projectCostingUpdatesChanges.Rows.Count > 0))
                {
                    projectCostingUpdatesGateway.Adapter.Update(projectCostingUpdatesChanges);
                }

                if ((projectEngineerSubcontractorsChanges != null) && (projectEngineerSubcontractorsChanges.Rows.Count > 0))
                {
                    projectEngineerSubcontractorsGateway.Adapter.Update(projectEngineerSubcontractorsChanges);
                }

                if ((projectHistoryChanges != null) && (projectHistoryChanges.Rows.Count > 0))
                {
                    projectHistoryGateway.Adapter.Update(projectHistoryChanges);
                }

                if ((projectSaleBillingPricingChanges != null) && (projectSaleBillingPricingChanges.Rows.Count > 0))
                {
                    projectSaleBillingPricingGateway.Adapter.Update(projectSaleBillingPricingChanges);
                }

                if ((projectSubcontractorChanges != null) && (projectSubcontractorChanges.Rows.Count > 0))
                {
                    projectSubcontractorGateway.Adapter.Update(projectSubcontractorChanges);
                }

                if ((projectTechnicalChanges != null) && (projectTechnicalChanges.Rows.Count > 0))
                {
                    projectTechnicalGateway.Adapter.Update(projectTechnicalChanges);
                }

                if ((projectTermsPOChanges != null) && (projectTermsPOChanges.Rows.Count > 0))
                {
                    projectTermsPOGateway.Adapter.Update(projectTermsPOChanges);
                }

                DB.CommitTransaction();
            }

            catch (DBConcurrencyException dBConcurrencyException)
            {
                DB.RollbackTransaction();
                throw new Exception("Concurrency error: Another user already updated the data you are working on.  Your operation has been cancelled.", dBConcurrencyException);
            }

            catch (SqlException sqlException)
            {
                DB.RollbackTransaction();
                byte severityLevel = sqlException.Class;
                if (severityLevel <= 16)
                {
                    throw new Exception("Low severity error. Your operation has been cancelled.  SQL Error " + severityLevel + ".");
                }
                if ((severityLevel >= 17) && (severityLevel <= 19))
                {
                    throw new Exception("Mid severity error. Your operation has been cancelled.  SQL Error " + severityLevel + ".");
                }
                if (severityLevel >= 20)
                {
                    throw new Exception("High severity error. Your operation has been cancelled.  SQL Error " + severityLevel + ".");
                }
            }

            catch (Exception e)
            {
                DB.RollbackTransaction();
                throw new Exception("Unknow error. Your operation has been cancelled.", e);
            }

            finally
            {
                DB.Close();
            }
        }