private void PostPageChanges()
        {
            // Insert subcontractors
            ProjectSubcontractor projectSubcontractor = new ProjectSubcontractor(projectTDS);

            int refId = projectSubcontractor.GetNewRefId();
            int subcontractorId = int.Parse(ddlSubcontractorId.SelectedValue);
            bool writtenQuote = cbxSubcontractorWrittenQuote.Checked;
            bool surveyedSite = cbxSubcontractorSurveyedSite.Checked;
            bool workedBefore = cbxSubcontractorWorkedBefore.Checked;
            string role = tbxSubcontractorRole.Text.Trim();
            bool agreement = cbxSubcontractorAgreement.Checked;
            string issues = tbxSubcontractorIssues.Text.Trim();
            bool purchaseOrder = cbxSubcontractorPurchaseOrder.Checked;
            bool insuranceCertificate = cbxSubcontractorInsuranceCertificate.Checked;
            bool wsib = cbxSubcontractorWSIB.Checked;
            string molForm1000 = ddlSubcontractorMOLForm1000.SelectedValue;
            int royalties = int.Parse(tbxRoyalties.Text.Trim());

            projectSubcontractor.Insert(int.Parse(hdfProjectId.Value), refId, subcontractorId, writtenQuote, surveyedSite, workedBefore, role, agreement, issues, purchaseOrder, insuranceCertificate, wsib, molForm1000, false, Int32.Parse(hdfCompanyId.Value.Trim()), royalties);
        }
        private void InsertProjectSubcontractor(int originalProjectId)
        {
            // ... Data for current project
            ProjectTDS projectTDSTemp = new ProjectTDS();
            ProjectSubcontractorGateway projectSubcontractorGatewayTemp = new ProjectSubcontractorGateway(projectTDSTemp);
            projectSubcontractorGatewayTemp.LoadAllByProjectId(originalProjectId);

            ProjectSubcontractorGateway projectSubcontractorGateway = new ProjectSubcontractorGateway(projectTDS);
            projectSubcontractorGateway.LoadAllByProjectId(originalProjectId);

            // ... Definition of general variables
            ProjectSubcontractor projectSubcontractor = new ProjectSubcontractor(projectTDS);

            int refId;
            int subcontractorId;
            bool writtenQuote;
            bool surveyedSite;
            bool workedBefore;
            string role;
            bool agreement;
            string issues;
            bool purchaseOrder;
            bool insuranceCertificate;
            bool wsib;
            string molForm1000;
            bool deleted;
            int? royalties;

            foreach (ProjectTDS.LFS_PROJECT_SUBCONTRACTORRow row in projectTDSTemp.Tables["LFS_PROJECT_SUBCONTRACTOR"].Rows)
            {
                refId = row.RefID;
                subcontractorId = row.SubcontractorID;
                writtenQuote = row.WrittenQuote;
                surveyedSite = row.SurveyedSite;
                workedBefore = row.WorkedBefore;
                try { role = row.Role; }
                catch { role = ""; }
                agreement = row.Agreement;
                try { issues = row.Issues; }
                catch { issues = ""; }
                purchaseOrder = row.PurchaseOrder;
                insuranceCertificate = row.InsuranceCertificate;
                wsib = row.WSIB;
                try { molForm1000 = row.MOLForm1000; }
                catch { molForm1000 = ""; }
                deleted = row.Deleted;
                try {royalties = row.Royalties;}
                catch { royalties = null; }

                // ... Insert Subcontractors
                projectSubcontractor.Insert(0, refId, subcontractorId, writtenQuote, surveyedSite, workedBefore, role, agreement, issues, purchaseOrder, insuranceCertificate, wsib, molForm1000, deleted, Int32.Parse(hdfCompanyId.Value.Trim()), royalties);
            }
        }