/// <summary>
        /// UpdateForProcess
        /// </summary>
        /// <param name="companyId">companyId</param>
        public void UpdateForReport(int companyId)
        {
            SectionGateway sectionGateway = new SectionGateway();
            JlinerGateway jlinerGateway = new JlinerGateway(sectionGateway.Data);
            Jliner jliner = new Jliner(sectionGateway.Data);

            sectionGateway.ClearBeforeFill = false;
            jlinerGateway.ClearBeforeFill = false;

            SectionTDS.LFS_JUNCTION_LINER2Row lfsJunctionLiner2Row;

            foreach (JlinertoBuildReportTDS.JLinersToBuildRow jLinersToBuildRow in ((JlinertoBuildReportTDS.JLinersToBuildDataTable)Table))
            {
                // Load sections
                try
                {
                    sectionGateway.GetRow(jLinersToBuildRow.ID);
                }
                catch
                {
                    sectionGateway.LoadById(jLinersToBuildRow.ID, companyId);
                }

                // Load laterals
                try
                {
                    lfsJunctionLiner2Row = (SectionTDS.LFS_JUNCTION_LINER2Row) jlinerGateway.GetRow(jLinersToBuildRow.ID, jLinersToBuildRow.RefID);
                }
                catch
                {
                    jlinerGateway.LoadByIdCompanyId(jLinersToBuildRow.ID, companyId);
                    lfsJunctionLiner2Row = (SectionTDS.LFS_JUNCTION_LINER2Row) jlinerGateway.GetRow(jLinersToBuildRow.ID, jLinersToBuildRow.RefID);
                }

                // Update InProcess
                lfsJunctionLiner2Row.InProcess = DateTime.Now;
                lfsJunctionLiner2Row.BuildRebuild++;
            }

            //Update
            try
            {
                sectionGateway.Update();
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
        /// <summary>
        /// Save to Section and Jliner rows
        /// </summary>
        /// <param name="sectionTDS">sectionTDS</param>
        public void Save(SectionTDS sectionTDS)
        {
            FlatSectionJlinerTDS flatSectionJlinerChanges = (FlatSectionJlinerTDS)Data.GetChanges();
            if (flatSectionJlinerChanges.FlatSectionJliner.Rows.Count > 0)
            {
                SectionGateway sectionGateway = new SectionGateway(sectionTDS);
                LiquiForce.LFSLive.BL.CWP.Section.Section section = new LiquiForce.LFSLive.BL.CWP.Section.Section(sectionTDS);
                JlinerGateway jlinerGateway = new JlinerGateway(sectionTDS);
                Jliner jliner = new Jliner(sectionTDS);
                JlinerCommentGateway jlinerCommentGateway = new JlinerCommentGateway(sectionTDS);
                JlinerComments jlinerComments = new JlinerComments(jlinerCommentGateway.Data);
                JlinerHistoryGateway jlinerHistoryGateway = new JlinerHistoryGateway(sectionTDS);
                JlinerHistory jlinerHistory = new JlinerHistory(jlinerHistoryGateway.Data);

                sectionGateway.ClearBeforeFill = false;
                jlinerGateway.ClearBeforeFill = false;
                jlinerCommentGateway.ClearBeforeFill = false;
                jlinerHistoryGateway.ClearBeforeFill = false;

                foreach (FlatSectionJlinerTDS.FlatSectionJlinerRow flatSectionJlinerRow in (FlatSectionJlinerTDS.FlatSectionJlinerDataTable)flatSectionJlinerChanges.FlatSectionJliner)
                {
                    // Load section and jliner
                    // ... Load section
                    try
                    {
                        //... Search section row
                        sectionGateway.GetRow(flatSectionJlinerRow.ID);
                    }
                    catch
                    {
                        //... Load section and section's jliners
                        sectionGateway.LoadById(flatSectionJlinerRow.ID, flatSectionJlinerRow.COMPANY_ID);
                        jlinerGateway.LoadByIdCompanyId(flatSectionJlinerRow.ID, flatSectionJlinerRow.COMPANY_ID);
                        jlinerCommentGateway.LoadById(flatSectionJlinerRow.ID, flatSectionJlinerRow.COMPANY_ID);
                        jlinerHistoryGateway.LoadById(flatSectionJlinerRow.ID, flatSectionJlinerRow.COMPANY_ID);
                    }

                    // Update

                    // ... Update jliner
                    string address = ""; if (!flatSectionJlinerRow.IsNull("Address")) address = flatSectionJlinerRow.Address;
                    DateTime? pipeLocated = null; if (!flatSectionJlinerRow.IsNull("PipeLocated")) pipeLocated = flatSectionJlinerRow.PipeLocated;
                    DateTime? servicesLocated = null; if (!flatSectionJlinerRow.IsNull("ServicesLocated")) servicesLocated = flatSectionJlinerRow.ServicesLocated;
                    DateTime? coInstalled = null; if (!flatSectionJlinerRow.IsNull("CoInstalled")) coInstalled = flatSectionJlinerRow.CoInstalled;
                    DateTime? backfilledConcrete = null; if (!flatSectionJlinerRow.IsNull("BackfilledConcrete")) backfilledConcrete = flatSectionJlinerRow.BackfilledConcrete;
                    DateTime? backfilledSoil = null; if (!flatSectionJlinerRow.IsNull("BackfilledSoil")) backfilledSoil = flatSectionJlinerRow.BackfilledSoil;
                    DateTime? grouted = null; if (!flatSectionJlinerRow.IsNull("Grouted")) grouted = flatSectionJlinerRow.Grouted;
                    DateTime? cored = null; if (!flatSectionJlinerRow.IsNull("Cored")) cored = flatSectionJlinerRow.Cored;
                    DateTime? prepped = null; if (!flatSectionJlinerRow.IsNull("Prepped")) prepped = flatSectionJlinerRow.Prepped;
                    DateTime? measured = null; if (!flatSectionJlinerRow.IsNull("Measured")) measured = flatSectionJlinerRow.Measured;
                    string linerSize = ""; if (!flatSectionJlinerRow.IsNull("LinerSize")) linerSize = flatSectionJlinerRow.LinerSize;
                    DateTime? inProcess = null; if (!flatSectionJlinerRow.IsNull("Inprocess")) inProcess = flatSectionJlinerRow.InProcess;
                    DateTime? inStock = null; if (!flatSectionJlinerRow.IsNull("InStock")) inStock = flatSectionJlinerRow.InStock;
                    DateTime? delivered = null; if (!flatSectionJlinerRow.IsNull("Delivered")) delivered = flatSectionJlinerRow.Delivered;
                    DateTime? preVideo = null; if (!flatSectionJlinerRow.IsNull("PreVideo")) preVideo = flatSectionJlinerRow.PreVideo;
                    DateTime? linerInstalled = null; if (!flatSectionJlinerRow.IsNull("LinerInstalled")) linerInstalled = flatSectionJlinerRow.LinerInstalled;
                    DateTime? finalVideo = null; if (!flatSectionJlinerRow.IsNull("FinalVideo")) finalVideo = flatSectionJlinerRow.FinalVideo;
                    double? distanceFromUSMH = null; if (!flatSectionJlinerRow.IsNull("DistanceFromUSMH")) distanceFromUSMH = flatSectionJlinerRow.DistanceFromUSMH;
                    double? distanceFromDSMH = null; if (!flatSectionJlinerRow.IsNull("DistanceFromDSMH")) distanceFromDSMH = flatSectionJlinerRow.DistanceFromDSMH;
                    string history = ""; if (!flatSectionJlinerRow.IsNull("History")) history = flatSectionJlinerRow.History;
                    string map = "";
                    string issue = flatSectionJlinerRow.Issue;
                    decimal? cost = null; if (!flatSectionJlinerRow.IsNull("Cost")) cost = flatSectionJlinerRow.Cost;
                    bool deleted = flatSectionJlinerRow.Deleted;

                    // ... Delete all comments and history for a jliner
                    if (deleted)
                    {
                        jlinerComments.DeleteAllCommentsForAJliner(flatSectionJlinerRow.ID, flatSectionJlinerRow.RefID, flatSectionJlinerRow.COMPANY_ID);
                        jlinerHistory.DeleteAllHistoryForAJliner(flatSectionJlinerRow.ID, flatSectionJlinerRow.RefID, flatSectionJlinerRow.COMPANY_ID);
                    }

                    DateTime? videoInspection = null; if (!flatSectionJlinerRow.IsNull("VideoInspection")) videoInspection = flatSectionJlinerRow.VideoInspection;
                    bool coRequired = flatSectionJlinerRow.CoRequired;
                    bool pitRequired = flatSectionJlinerRow.PitRequired;
                    string coPitLocation = ""; if (!flatSectionJlinerRow.IsNull("CoPitLocation")) coPitLocation = flatSectionJlinerRow.CoPitLocation;
                    bool postContractDigRequired = flatSectionJlinerRow.PostContractDigRequired;
                    DateTime? coCutDown = null; if (!flatSectionJlinerRow.IsNull("CoCutDown")) coCutDown = flatSectionJlinerRow.CoCutDown;
                    DateTime? finalRestoration = null; if (!flatSectionJlinerRow.IsNull("FinalRestoration")) finalRestoration = flatSectionJlinerRow.FinalRestoration;
                    string clientLateralId = ""; if (!flatSectionJlinerRow.IsNull("ClientLateralID")) clientLateralId = flatSectionJlinerRow.ClientLateralID;
                    string videoLengthToPropertyLine = ""; if (!flatSectionJlinerRow.IsNull("VideoLengthToPropertyLine")) videoLengthToPropertyLine = flatSectionJlinerRow.VideoLengthToPropertyLine;
                    bool liningThruCo = flatSectionJlinerRow.LiningThruCo;
                    string hamiltonInspectionNumber = ""; if (!flatSectionJlinerRow.IsNull("HamiltonInspectionNumber")) hamiltonInspectionNumber = flatSectionJlinerRow.HamiltonInspectionNumber;
                    DateTime? noticeDelivered = null; if (!flatSectionJlinerRow.IsNull("NoticeDelivered")) noticeDelivered = flatSectionJlinerRow.NoticeDelivered;

                    jliner.Update(flatSectionJlinerRow.ID, flatSectionJlinerRow.RefID, flatSectionJlinerRow.COMPANY_ID, flatSectionJlinerRow.DetailID, address, pipeLocated, servicesLocated, coInstalled, backfilledConcrete, backfilledSoil, grouted, cored, prepped, measured, linerSize, inProcess, inStock, delivered, preVideo, linerInstalled, finalVideo, distanceFromUSMH, distanceFromDSMH,map, issue, cost, deleted, videoInspection, coRequired, pitRequired, coPitLocation, postContractDigRequired, coCutDown, finalRestoration, clientLateralId, videoLengthToPropertyLine, liningThruCo, hamiltonInspectionNumber, noticeDelivered);

                    // ... Update section
                    section.UpdateJliners(flatSectionJlinerRow.ID, flatSectionJlinerRow.COMPANY_ID);
                }
            }
        }
        /// <summary>
        /// Update - JLiner
        /// </summary>
        public void Update()
        {
            JlinerGateway jlinerGateway = new JlinerGateway(Data);
            JlinerCommentGateway jlinerCommentGateway = new JlinerCommentGateway(Data);

            DataTable sectionChanges = Table.GetChanges();
            DataTable jlinerChanges = jlinerGateway.Table.GetChanges();
            DataTable jlinerCommentChanges = jlinerCommentGateway.Table.GetChanges();

            if ((sectionChanges == null) && (jlinerChanges == null) && (jlinerCommentChanges == null)) return;

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

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

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

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

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

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

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

                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();
            }
        }
        /// <summary>
        /// Save a JL Work
        /// </summary>
        /// <param name="originalId">originalId</param>
        /// <param name="projectId">projectId</param>
        /// <param name="section_assetId">section_assetId</param>
        /// <param name="numLats">numLats</param>
        /// <param name="notLinedYet">notLinedYet</param>
        /// <param name="allMeasured">allMeasured</param>
        /// <param name="issueWithLaterals">issueWithLaterals</param>
        /// <param name="notMeasuredYet">notMeasuredYet</param>
        /// <param name="notDeliveredYet">notDeliveredYet</param>
        /// <param name="countryId">countryId</param>
        /// <param name="provinceId">provinceId</param>
        /// <param name="countyId">countyId</param>
        /// <param name="cityId">cityId</param>
        /// <param name="companyId">companyId</param>
        private void SaveJLWork(Guid originalId, int section_assetId, int numLats, int notLinedYet, bool allMeasured, string issueWithLaterals, int notMeasuredYet, int notDeliveredYet, int projectId, Int64? countryId, Int64? provinceId, Int64? countyId, Int64? cityId, int companyId)
        {
            // Insert Junction Lining Section
            WorkJunctionLiningSection workJunctionLiningSection = new WorkJunctionLiningSection(null);
            int sectionWorkId = workJunctionLiningSection.InsertDirect(projectId, section_assetId, null, numLats, notLinedYet, allMeasured, issueWithLaterals, notMeasuredYet, notDeliveredYet, false, companyId, "", "", "", "", false, "", 0);

            // Insert Junction Lining Laterals
            SectionTDS sectionTDS = new SectionTDS();

            SectionGateway sectionGateway = new SectionGateway(sectionTDS);
            sectionGateway.LoadById(originalId, companyId);

            JlinerGateway jlinerGateway = new JlinerGateway(sectionTDS);
            jlinerGateway.LoadByIdCompanyId(originalId, companyId);

            foreach (SectionTDS.LFS_JUNCTION_LINER2Row row in (SectionTDS.LFS_JUNCTION_LINER2DataTable)jlinerGateway.Table)
            {
                string lateralID = ""; if (!row.IsDetailIDNull()) lateralID = row.DetailID;
                string address = ""; if (!row.IsAddressNull()) address = row.Address;
                string distanceFromUSMH = ""; if (!row.IsDistanceFromUSMHNull()) distanceFromUSMH = row.DistanceFromUSMH.ToString();
                string distanceFromDSMH = ""; if (!row.IsDistanceFromDSMHNull()) distanceFromDSMH = row.DistanceFromDSMH.ToString();
                DateTime? pipeLocated = null; if (!row.IsPipeLocatedNull()) pipeLocated = row.PipeLocated;
                DateTime? servicesLocated = null; if (!row.IsServicesLocatedNull()) servicesLocated = row.ServicesLocated;
                DateTime? coInstalled = null; if (!row.IsCoInstalledNull()) coInstalled = row.CoInstalled;
                DateTime? backfilledConcrete = null; if (!row.IsBackfilledConcreteNull()) backfilledConcrete = row.BackfilledConcrete;
                DateTime? backfilledSoil = null; if (!row.IsBackfilledSoilNull()) backfilledSoil = row.BackfilledSoil;
                DateTime? grouted = null; if (!row.IsGroutedNull()) grouted = row.Grouted;
                DateTime? cored = null; if (!row.IsCoredNull()) cored = row.Cored;
                DateTime? prepped = null; if (!row.IsPreppedNull()) prepped = row.Prepped;
                DateTime? measured = null; if (!row.IsMeasuredNull()) measured = row.Measured;
                string linerSize = ""; if (!row.IsLinerSizeNull()) linerSize = row.LinerSize;
                DateTime? inProcess = null; if (!row.IsInProcessNull()) inProcess = row.InProcess;
                DateTime? inStock = null; if (!row.IsInStockNull()) inStock = row.InStock;
                DateTime? delivered = null; if (!row.IsDeliveredNull()) delivered = row.Delivered;
                int? buildRebuid = null; if (!row.IsBuildRebuildNull()) buildRebuid = row.BuildRebuild;
                DateTime? preVideo = null; if (!row.IsPreVideoNull()) preVideo = row.PreVideo;
                DateTime? linerInstalled = null; if (!row.IsLinerInstalledNull()) linerInstalled = row.LinerInstalled;
                DateTime? finalVideo = null; if (!row.IsFinalVideoNull()) finalVideo = row.FinalVideo;
                string map = ""; if (!row.IsMapNull()) map = row.Map;
                decimal? cost = null; if (!row.IsCostNull()) cost = row.Cost;
                DateTime? videoInspection = null; if (!row.IsVideoInspectionNull()) videoInspection = row.VideoInspection;
                bool coRequired = row.CoRequired;
                bool pitRequired = row.PitRequired;
                string coPitLocation = ""; if (!row.IsCoPitLocationNull()) coPitLocation = row.CoPitLocation;
                bool postContractDigRequired = row.PostContractDigRequired;
                string comments = ""; if (!row.IsCommentsNull()) comments = row.Comments;
                string history = ""; if (!row.IsHistoryNull()) history = row.History;
                DateTime? coCutDown = null; if (!row.IsCoCutDownNull()) coCutDown = row.CoCutDown;
                DateTime? finalRestoration = null; if (!row.IsFinalRestorationNull()) finalRestoration = row.FinalRestoration;
                string clientLateralId = ""; if (!row.IsClientLateralIDNull()) clientLateralId = row.ClientLateralID;
                string videoLengthToPropertyLine = ""; if (!row.IsVideoLengthToPropertyLineNull()) videoLengthToPropertyLine = row.VideoLengthToPropertyLine;
                bool liningThruCo = row.LiningThruCo;
                DateTime? noticeDelivered = null; if (!row.IsNoticeDeliveredNull()) noticeDelivered = row.NoticeDelivered;
                string hamiltonInspectionNumber = ""; if (!row.IsHamiltonInspectionNumberNull()) hamiltonInspectionNumber = row.HamiltonInspectionNumber;
                bool dyeTestReq = row.DyeTestReq;
                DateTime? dyeTestComplete = null; if (!row.IsDyeTestCompleteNull()) dyeTestComplete = row.DyeTestComplete;

                // Fields only presents in new Junction lining
                string flange = "";
                string gasket = "";
                string connectionType = "";
                string depthOfLocated = "";
                bool digRequiredPriorToLining = false;
                DateTime? digRequiredPriorToLiningCompleted = null;
                bool digRequiredAfterLining = false;
                DateTime? digRequiredAfterLiningCompleted = null;
                bool outOfScope = false;
                bool holdClientIssue = false;
                DateTime? holdClientIssueResolved  = null;
                bool holdLFSIssue = false;
                DateTime? holdLFSIssueResolved = null;
                bool requiresRoboticPrep = false;
                DateTime? requiresRoboticPrepCompleted = null;

                ProjectGateway projectGateway = new ProjectGateway();
                projectGateway.LoadByProjectId(projectId);
                int clientId = projectGateway.GetClientID(projectId);

                // Insert into LFS Asset Lateral
                LfsAssetSewerLateral lfsAssetSewerLateral = new LfsAssetSewerLateral(null);
                int lateralAssetId = lfsAssetSewerLateral.InsertDirect(countryId, provinceId, countyId, cityId, section_assetId, address, lateralID, "", "", "", "", "Live", "", distanceFromUSMH, distanceFromDSMH, "", false, companyId, connectionType);

                // Insert into LFS Asset Lateral Client
                LfsAssetSewerLateralClient lfsAssetSewerLateralClient = new LfsAssetSewerLateralClient(null);
                lfsAssetSewerLateralClient.InsertDirect(lateralAssetId, clientId, clientLateralId, false, companyId);

                // Insert into Work Junction Lining Lateral
                WorkJunctionLiningLateral workJunctionLiningLateral = new WorkJunctionLiningLateral(null);
                int workLateral = workJunctionLiningLateral.InsertDirect(projectId, lateralAssetId, sectionWorkId, pipeLocated, servicesLocated, coInstalled, backfilledConcrete, backfilledSoil, grouted, cored, prepped, measured, linerSize, inProcess, inStock, delivered, buildRebuid, preVideo, linerInstalled, finalVideo, cost, videoInspection, coRequired, pitRequired, coPitLocation, postContractDigRequired, coCutDown, finalRestoration, false, companyId, comments, history, videoLengthToPropertyLine, liningThruCo, noticeDelivered, hamiltonInspectionNumber, flange, gasket, depthOfLocated, digRequiredPriorToLining, digRequiredPriorToLiningCompleted, digRequiredAfterLining, digRequiredAfterLiningCompleted, outOfScope, holdClientIssue, holdClientIssueResolved, holdLFSIssue, holdLFSIssueResolved, requiresRoboticPrep, requiresRoboticPrepCompleted, "", "", dyeTestReq, dyeTestComplete, "");

                // Insert into Work Comments
                JlinerCommentGateway jlinerCommentGateway = new JlinerCommentGateway(sectionTDS);
                jlinerCommentGateway.LoadByIdRefId(originalId, row.RefID, companyId);

                foreach (SectionTDS.LFS_JUNCTION_LINER2_COMMENTRow rowComment in (SectionTDS.LFS_JUNCTION_LINER2_COMMENTDataTable)jlinerCommentGateway.Table)
                {
                    int loginId = rowComment.LoginID;
                    DateTime dateTime_ = rowComment.DateTime_;
                    string comment = rowComment.Comment;

                    WorkCommentsGateway workCommentsGateway = new WorkCommentsGateway();
                    workCommentsGateway.LoadByWorkIdWorkType(workLateral, companyId, "Junction Lining Lateral");
                    WorkComments workComments = new WorkComments(workCommentsGateway.Data);
                    workComments.Insert(workLateral, 0, "Junction Lining Lateral", "Bulk Upload Comments", loginId, dateTime_, comment, null, false, companyId, false, "Junction Lining");

                    // Update Comments
                    workCommentsGateway.Update();
                }

                // Insert into Work History
                JlinerHistoryGateway jlinerHistoryGateway = new JlinerHistoryGateway(sectionTDS);
                jlinerHistoryGateway.LoadByIdRefId(originalId, row.RefID, companyId);

                foreach (SectionTDS.LFS_JUNCTION_LINER2_HISTORYRow rowHistory in (SectionTDS.LFS_JUNCTION_LINER2_HISTORYDataTable)jlinerHistoryGateway.Table)
                {
                    int loginId = rowHistory.LoginID;
                    DateTime dateTime_H = rowHistory.DateTime_;
                    string history_ = rowHistory.History;

                    WorkHistoryGateway workHistoryGateway = new WorkHistoryGateway();
                    workHistoryGateway.LoadByWorkIdWorkType(workLateral, companyId, "Junction Lining Lateral");
                    WorkHistory workHistory = new WorkHistory(workHistoryGateway.Data);
                    workHistory.Insert(workLateral, 0, "Junction Lining Lateral", "Bulk Upload History", loginId, dateTime_H, history_, null, false, companyId, false, "Junction Lining");

                    // Update History
                    workHistoryGateway.Update();
                }
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!(Convert.ToBoolean(Session["sgLFS_APP_VIEW"]) && Convert.ToBoolean(Session["sgLFS_APP_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["client"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in flat_section_jliner_edit.aspx");
                }

                // Tag page
                hdfCurrentClient.Value = (string)Request.QueryString["client"];
                hdfLoginId.Value = Convert.ToInt32(Session["loginID"]).ToString();
                hdfId.Value = Convert.ToString(Request.QueryString["rowId"]);
                hdfRefId.Value = Convert.ToString(Request.QueryString["rowRefId"]);
                hdfCompanyId.Value = Convert.ToString(Request.QueryString["rowCompanyId"]);
                hdfAdminPermission.Value = Convert.ToBoolean(Session["sgLFS_APP_ADMIN"]).ToString();
                hdfUpdate.Value = "yes";

                // Prepare initial data
                Session.Remove("commentsDummy");

                // ... Names for UserList
                int companyId = Int32.Parse(hdfCompanyId.Value);

                LoginGateway loginGateway = new LoginGateway();
                loginGateway.LoadByLoginId(Convert.ToInt32(hdfLoginId.Value), companyId);
                hdfCreatedBy.Value = loginGateway.GetLastName(Convert.ToInt32(hdfLoginId.Value), companyId) + " " + loginGateway.GetFirstName(Convert.ToInt32(hdfLoginId.Value), companyId);
                hdfCreationDateTime.Value = DateTime.Now.ToString();

                // If comming from
                // ... flat_section_jliner_summary.aspx
                if (Request.QueryString["source_page"] == "flat_section_jliner_summary.aspx" || Request.QueryString["source_page"] == "flat_section_jliner_edit.aspx")
                {
                    StoreNavigatorState();
                    ViewState["update"] = Request.QueryString["update"];
                    Session["rowFocus"] = Convert.ToInt32(Request.QueryString["rowFocus"].ToString());

                    // ... Load comments to edit
                    sectionTDS = new SectionTDS();
                    flatSectionJlinerTDS = (FlatSectionJlinerTDS)Session["flatSectionJlinerTDS"];

                    SectionGateway sectionGateway = new SectionGateway(sectionTDS);
                    sectionGateway.LoadById(new Guid(hdfId.Value), Convert.ToInt32(hdfCompanyId.Value));

                    JlinerGateway jlinerGateway = new JlinerGateway(sectionTDS);
                    jlinerGateway.LoadByIdCompanyIdRefId(new Guid(hdfId.Value), Convert.ToInt32(hdfCompanyId.Value), Convert.ToInt32(hdfRefId.Value));

                    FlatSectionJlinerJuntionLiner2CommentGateway flatSectionJlinerJuntionLiner2CommentGateway = new FlatSectionJlinerJuntionLiner2CommentGateway(flatSectionJlinerTDS);
                    flatSectionJlinerJuntionLiner2CommentGateway.LoadAllByIdRefId(new Guid(hdfId.Value), Convert.ToInt32(hdfRefId.Value), Convert.ToInt32(hdfCompanyId.Value));

                    FlatSectionJlinerJuntionLiner2Comment flatSectionJlinerJuntionLiner2Comment = new FlatSectionJlinerJuntionLiner2Comment(flatSectionJlinerJuntionLiner2CommentGateway.Data);
                    flatSectionJlinerJuntionLiner2Comment.UpdateForProcess();

                    // ... Load history for transfers
                    FlatSectionJlinerJuntionLiner2HistoryGateway flatSectionJlinerJuntionLiner2HistoryGateway = new FlatSectionJlinerJuntionLiner2HistoryGateway(flatSectionJlinerTDS);
                    flatSectionJlinerJuntionLiner2HistoryGateway.LoadAllByIdRefId(new Guid(hdfId.Value), Convert.ToInt32(hdfRefId.Value), Convert.ToInt32(hdfCompanyId.Value));

                    // ... Store datasets
                    Session["sectionTDS"] = sectionTDS;
                    Session["flatSectionJlinerTDS"] = flatSectionJlinerTDS;
                    comments = flatSectionJlinerTDS.JuntionLiner2Comment;
                    Session["comments"] = comments;
                }
            }
            else
            {
                // Restore datasets
                sectionTDS = (SectionTDS)Session["sectionTDS"];
                flatSectionJlinerTDS = (FlatSectionJlinerTDS)Session["flatSectionJlinerTDS"];
                Session["flatSectionJlinerTDS"] = flatSectionJlinerTDS;
                comments = flatSectionJlinerTDS.JuntionLiner2Comment;
                Session["comments"] = comments;
            }
        }
Example #6
0
 /// <summary>
 /// DeleteDirect
 /// </summary>
 /// <param name="id">id</param>
 /// <param name="refId">refId</param>
 /// <param name="companyId">companyId</param>                
 public void DeleteDirect(Guid id, int refId, int companyId)
 {
     JlinerGateway jlinerGateway = new JlinerGateway(null);
     jlinerGateway.Delete(id, refId, companyId);
 }
Example #7
0
 /// <summary>
 /// Update direct
 /// </summary>
 /// <param name="originalId">originalId</param>
 /// <param name="originalRefId">originalRefId</param>
 /// <param name="originalCompanyId">originalCompanyId</param>
 /// <param name="originalDetailId">originalDetailId</param>
 /// <param name="originalAddress">originalAddress</param>
 /// <param name="originalPipeLocated">originalPipeLocated</param>
 /// <param name="originalServicesLocated">originalServicesLocated</param>
 /// <param name="originalCoInstalled">originalCoInstalled</param>
 /// <param name="originalBackfilledConcrete">originalBackfilledConcrete</param>
 /// <param name="originalBackfilledSoil">originalBackfilledSoil</param>
 /// <param name="originalGrouted">originalGrouted</param>
 /// <param name="originalCored">originalCored</param>
 /// <param name="originalPrepped">originalPrepped</param>
 /// <param name="originalMeasured">originalMeasured</param>
 /// <param name="originalLinerSize">originalLinerSize</param>
 /// <param name="originalInProcess">originalInProcess</param>
 /// <param name="originalInStock">originalInStock</param>
 /// <param name="originalDelivered">originalDelivered</param>
 /// <param name="originalBuildRebuild">originalBuildRebuild</param>
 /// <param name="originalPreVideo">originalPreVideo</param>        
 /// <param name="originalLinerInstalled">originalLinerInstalled</param>
 /// <param name="originalFinalVideo">originalFinalVideo</param>
 /// <param name="originalDistanceFromUSMH">originalDistanceFromUSMH</param>
 /// <param name="originalDistanceFromDSMH">originalDistanceFromDSMH</param>
 /// <param name="originalMap">originalMap</param>
 /// <param name="originalIssue">originalIssue</param>
 /// <param name="originalCost">originalCost</param>
 /// <param name="originalDeleted">originalDeleted</param>
 /// <param name="originalVideoInspection">originalVideoInspection</param>
 /// <param name="originalCoRequired">originalCoRequired</param>
 /// <param name="originalPitRequired">originalPitRequired</param>
 /// <param name="originalCoPitLocation">originalCoPitLocation</param>
 /// <param name="originalPostContractDigRequired">originalPostContractDigRequired</param>
 /// <param name="originalComments">originalComments</param>
 /// <param name="originalHistory">originalHistory</param>
 /// <param name="originalCoCutDown">originalCoCutDown</param>
 /// <param name="originalFinalRestoration">originalFinalRestoration</param>
 /// <param name="originalClientLateralID">originalClientLateralID</param>
 /// <param name="originalVideoLengthToPropertyLine">originalVideoLengthToPropertyLine</param>
 /// <param name="originalLiningThruCo">originalLiningThruCo</param>
 /// <param name="originalHamiltonInspectionNumber">originalHamiltonInspectionNumber</param>
 /// <param name="originalNoticeDelivered">originalNoticeDelivered</param>
 ///
 /// <param name="newId">newId</param>
 /// <param name="newRefId">newRefId</param>
 /// <param name="newCompanyId">newCompanyId</param>
 /// <param name="newDetailId">newDetailId</param>
 /// <param name="newAddress">newAddress</param>
 /// <param name="newPipeLocated">newPipeLocated</param>
 /// <param name="newServicesLocated">newServicesLocated</param>
 /// <param name="newCoInstalled">newCoInstalled</param>
 /// <param name="newBackfilledConcrete">newBackfilledConcrete</param>
 /// <param name="newBackfilledSoil">newBackfilledSoil</param>
 /// <param name="newGrouted">newGrouted</param>
 /// <param name="newCored">newCored</param>
 /// <param name="newPrepped">newPrepped</param>
 /// <param name="newMeasured">newMeasured</param>
 /// <param name="newLinerSize">newLinerSize</param>
 /// <param name="newInProcess">newInProcess</param>
 /// <param name="newInStock">newInStock</param>
 /// <param name="newDelivered">newDelivered</param>
 /// <param name="newBuildRebuild">newBuildRebuild</param>
 /// <param name="newPreVideo">newPreVideo</param>        
 /// <param name="newLinerInstalled">newLinerInstalled</param>
 /// <param name="newFinalVideo">newFinalVideo</param>
 /// <param name="newDistanceFromUSMH">newDistanceFromUSMH</param>
 /// <param name="newDistanceFromDSMH">newDistanceFromDSMH</param>
 /// <param name="newMap">newMap</param>
 /// <param name="newIssue">newIssue</param>
 /// <param name="newCost">newCost</param>
 /// <param name="newDeleted">newDeleted</param>        
 /// <param name="newVideoInspection">newVideoInspection</param>
 /// <param name="newCoRequired">newCoRequired</param>
 /// <param name="newPitRequired">newPitRequired</param>
 /// <param name="newCoPitLocation">newCoPitLocation</param>
 /// <param name="newPostContractDigRequired">newPostContractDigRequired</param>
 /// <param name="newComments">newComments</param>
 /// <param name="newHistory">newHistory</param>
 /// <param name="newCoCutDown">newCoCutDown</param>
 /// <param name="newFinalRestoration">newFinalRestoration</param>
 /// <param name="newClientLateralID">newClientLateralID</param>
 /// <param name="newVideoLengthToPropertyLine">newVideoLengthToPropertyLine</param>
 /// <param name="newLiningThruCo">newLiningThruCo</param>
 /// <param name="newHamiltonInspectionNumber">newHamiltonInspectionNumber</param>
 /// <param name="newNoticeDelivered">newNoticeDelivered</param>
 public void UpdateDirect(Guid originalId, int originalRefId, int originalCompanyId, string originalDetailId, string originalAddress, DateTime? originalPipeLocated, DateTime? originalServicesLocated, DateTime? originalCoInstalled, DateTime? originalBackfilledConcrete, DateTime? originalBackfilledSoil, DateTime? originalGrouted, DateTime? originalCored, DateTime? originalPrepped, DateTime? originalMeasured, string originalLinerSize, DateTime? originalInProcess, DateTime? originalInStock, DateTime? originalDelivered, int? originalBuildRebuild, DateTime? originalPreVideo, DateTime? originalLinerInstalled, DateTime? originalFinalVideo, double? originalDistanceFromUSMH, double? originalDistanceFromDSMH, string originalMap, string originalIssue, decimal? originalCost, bool originalDeleted, DateTime? originalVideoInspection, bool originalCoRequired, bool originalPitRequired, string originalCoPitLocation, bool originalPostContractDigRequired, string originalComments, string originalHistory, DateTime? originalCoCutDown, DateTime? originalFinalRestoration, string originalClientLateralID, string originalVideoLengthToPropertyLine, bool originalLiningThruCo, string originalHamiltonInspectionNumber, DateTime? originalNoticeDelivered, Guid newId, int newRefId, int newCompanyId, string newDetailId, string newAddress, DateTime? newPipeLocated, DateTime? newServicesLocated, DateTime? newCoInstalled, DateTime? newBackfilledConcrete, DateTime? newBackfilledSoil, DateTime? newGrouted, DateTime? newCored, DateTime? newPrepped, DateTime? newMeasured, string newLinerSize, DateTime? newInProcess, DateTime? newInStock, DateTime? newDelivered, int? newBuildRebuild, DateTime? newPreVideo, DateTime? newLinerInstalled, DateTime? newFinalVideo, double? newDistanceFromUSMH, double? newDistanceFromDSMH, string newMap, string newIssue, decimal? newCost, bool newDeleted, DateTime? newVideoInspection, bool newCoRequired, bool newPitRequired, string newCoPitLocation, bool newPostContractDigRequired, string newComments, string newHistory, DateTime? newCoCutDown, DateTime? newFinalRestoration, string newClientLateralID, string newVideoLengthToPropertyLine, bool newLiningThruCo, string newHamiltonInspectionNumber, DateTime? newNoticeDelivered)
 {
     JlinerGateway jlinerGateway = new JlinerGateway(null);
     jlinerGateway.Update(originalId, originalRefId, originalCompanyId, originalDetailId, originalAddress, originalPipeLocated, originalServicesLocated, originalCoInstalled, originalBackfilledConcrete, originalBackfilledSoil, originalGrouted, originalCored, originalPrepped, originalMeasured, originalLinerSize, originalInProcess, originalInStock, originalDelivered, originalBuildRebuild, originalPreVideo, originalLinerInstalled, originalFinalVideo, originalDistanceFromUSMH, originalDistanceFromDSMH, originalMap, originalIssue,  originalCost, originalDeleted, originalVideoInspection, originalCoRequired, originalPitRequired, originalCoPitLocation, originalPostContractDigRequired, originalComments, originalHistory, originalCoCutDown, originalFinalRestoration, originalClientLateralID, originalVideoLengthToPropertyLine, originalLiningThruCo, originalHamiltonInspectionNumber, originalNoticeDelivered, newId, newRefId, newCompanyId, newDetailId, newAddress, newPipeLocated, newServicesLocated, newCoInstalled, newBackfilledConcrete, newBackfilledSoil, newGrouted, newCored, newPrepped, newMeasured, newLinerSize, newInProcess, newInStock, newDelivered, newBuildRebuild, newPreVideo, newLinerInstalled, newFinalVideo, newDistanceFromUSMH, newDistanceFromDSMH, newMap, newIssue, newCost, newDeleted, newVideoInspection, newCoRequired, newPitRequired, newCoPitLocation, newPostContractDigRequired, newComments, newHistory, newCoCutDown, newFinalRestoration, newClientLateralID, newVideoLengthToPropertyLine, newLiningThruCo, newHamiltonInspectionNumber, newNoticeDelivered);
 }
Example #8
0
 /// <summary>
 /// Insert direct
 /// </summary>
 /// <param name="id">id</param>
 /// <param name="refId">refId</param>
 /// <param name="companyId">companyId</param>
 /// <param name="detailId">detailId</param>
 /// <param name="address">address</param>
 /// <param name="pipeLocated">pipeLocated</param>
 /// <param name="servicesLocated">servicesLocated</param>
 /// <param name="coInstalled">coInstalled</param>
 /// <param name="backfilledConcrete">backfilledConcrete</param>
 /// <param name="backfilledSoil">backfilledSoil</param>
 /// <param name="grouted">grouted</param>
 /// <param name="cored">cored</param>
 /// <param name="prepped">prepped</param>
 /// <param name="measured">measured</param>
 /// <param name="linerSize">linerSize</param>
 /// <param name="inProcess">inProcess</param>
 /// <param name="inStock">inStock</param>
 /// <param name="delivered">delivered</param>
 /// <param name="buildRebuild">buildRebuild</param>
 /// <param name="preVideo">preVideo</param>        
 /// <param name="linerInstalled">linerInstalled</param>
 /// <param name="finalVideo">finalVideo</param>
 /// <param name="distanceFromUSMH">distanceFromUSMH</param>
 /// <param name="distanceFromDSMH">distanceFromDSMH</param>
 /// <param name="map">map</param>
 /// <param name="issue">issue</param>
 /// <param name="cost">cost</param>
 /// <param name="deleted">deleted</param>
 /// <param name="videoInspection">videoInspection</param>
 /// <param name="coRequired">coRequired</param>
 /// <param name="pitRequired">pitRequired</param>
 /// <param name="coPitLocation">coPitLocation</param>
 /// <param name="postContractDigRequired">postContractDigRequired</param>
 /// <param name="comments">comments</param>
 /// <param name="history">history</param>
 /// <param name="coCutDown">coCutDown</param>
 /// <param name="finalRestoration">finalRestoration</param>
 /// <param name="clientLateralID">clientLateralID</param>
 /// <param name="videoLengthToPropertyLine">videoLengthToPropertyLine</param>
 /// <param name="liningThruCo">liningThruCo</param>
 /// <param name="hamiltonInspectionNumber">hamiltonInspectionNumber</param>
 /// <param name="noticeDelivered">noticeDelivered</param>                
 public void InsertDirect(Guid id, int refId, int companyId, string detailId, string address, DateTime? pipeLocated, DateTime? servicesLocated, DateTime? coInstalled, DateTime? backfilledConcrete, DateTime? backfilledSoil, DateTime? grouted, DateTime? cored, DateTime? prepped, DateTime? measured, string linerSize, DateTime? inProcess, DateTime? inStock, DateTime? delivered, int? buildRebuild, DateTime? preVideo, DateTime? linerInstalled, DateTime? finalVideo, double? distanceFromUSMH, double? distanceFromDSMH, string map, string issue, decimal? cost, bool deleted, DateTime? videoInspection, bool coRequired, bool pitRequired, string coPitLocation, bool postContractDigRequired, string comments, string history, DateTime? coCutDown, DateTime? finalRestoration, string clientLateralID, string videoLengthToPropertyLine, bool liningThruCo, string hamiltonInspectionNumber, DateTime? noticeDelivered)
 {
     JlinerGateway jlinerGateway = new JlinerGateway(null);
     jlinerGateway.Insert(id, refId, companyId, detailId, address, pipeLocated, servicesLocated, coInstalled, backfilledConcrete, backfilledSoil, grouted, cored, prepped, measured, linerSize, inProcess, inStock, delivered, buildRebuild, preVideo, linerInstalled, finalVideo, distanceFromUSMH, distanceFromDSMH, map, issue, cost, deleted, videoInspection, coRequired, pitRequired, coPitLocation, postContractDigRequired, comments, history, coCutDown, finalRestoration, clientLateralID, videoLengthToPropertyLine, liningThruCo, hamiltonInspectionNumber, noticeDelivered);
 }