コード例 #1
0
        private void Save2()
        {
            //Save changes without validate

            // Save data
            int companyId = Int32.Parse(hdfCompanyId.Value);
            int assetId = Int32.Parse(hdfAssetId.Value);
            int workId = Int32.Parse(hdfWorkId.Value);
            int currentProjectId = Int32.Parse(hdfCurrentProjectId.Value.ToString());

            // Get Manhole information
            // ... ManholeRehabilitationManholeDetails data
            string newAddress = ""; if (tbxStreet.Text != "") newAddress = tbxStreet.Text.Trim();
            string newLatitude = ""; if (tbxLatitude.Text != "") newLatitude = tbxLatitude.Text.Trim();
            string newLongitude = ""; if (tbxLongitude.Text != "") newLongitude = tbxLongitude.Text.Trim();
            string newShape = ""; if (ddlShape.SelectedValue != "") newShape = ddlShape.SelectedValue;
            int? newConditionRating = null; if (ddlConditioningRating.SelectedValue != "-1") newConditionRating = int.Parse(ddlConditioningRating.SelectedValue);
            int? newMaterialId = null; if (ddlMaterial.SelectedValue != "-1") newMaterialId = int.Parse(ddlMaterial.SelectedValue);
            string newMaterialDescription = ""; if (ddlMaterial.Text != "") newMaterialDescription = ddlMaterial.Text;
            string newLocation = ""; if (ddlLocation.SelectedValue != "") newLocation = ddlLocation.SelectedValue;

            string newTopDiameter = "";
            string newTopDepth = "";
            string newTopFloor = "";
            string newTopCeiling = "";
            string newTopBenching = "";
            string newDownDiameter = "";
            string newDownDepth = "";
            string newDownFloor = "";
            string newDownCeiling = "";
            string newDownBenching = "";
            string newRectangle1LongSide = "";
            string newRectangle1ShortSide = "";
            string newRectangle2LongSide = "";
            string newRectangle2ShortSide = "";
            string newTopSurfaceArea = "";
            string newDownSurfaceArea = "";
            int? newManholeRugs = null;
            string newTotalDepth = "";
            string newTotalSurfaceArea = "";

            // ... Structure Details
            if (newShape == "Round")
            {
                if (tbxRehabilitationDataChimneyDiameter.Text != "") newTopDiameter = tbxRehabilitationDataChimneyDiameter.Text.Trim();
                if (tbxRehabilitationDataChimneyDepth.Text != "") newTopDepth = tbxRehabilitationDataChimneyDepth.Text.Trim();
                if (tbxRehabilitationDataChimneyFloor.Text != "") newTopFloor = tbxRehabilitationDataChimneyFloor.Text.Trim();
                if (tbxRehabilitationDataChimneyCeiling.Text != "") newTopCeiling = tbxRehabilitationDataChimneyCeiling.Text.Trim();
                if (tbxRehabilitationDataChimneyBenching.Text != "") newTopBenching = tbxRehabilitationDataChimneyBenching.Text.Trim();
                if (tbxRehabilitationDataChimneySurfaceArea.Text != "") newTopSurfaceArea = tbxRehabilitationDataChimneySurfaceArea.Text.Trim();

                if (tbxRehabilitationDataBarrelDiameter.Text != "") newDownDiameter = tbxRehabilitationDataBarrelDiameter.Text.Trim();
                if (tbxRehabilitationDataBarrelDepth.Text != "") newDownDepth = tbxRehabilitationDataBarrelDepth.Text.Trim();
                if (tbxRehabilitationDataBarrelFloor.Text != "") newDownFloor = tbxRehabilitationDataBarrelFloor.Text.Trim();
                if (tbxRehabilitationDataBarrelCeiling.Text != "") newDownCeiling = tbxRehabilitationDataBarrelCeiling.Text.Trim();
                if (tbxRehabilitationDataBarrelBenching.Text != "") newDownBenching = tbxRehabilitationDataBarrelBenching.Text.Trim();
                if (tbxRehabilitationDataBarrelSurfaceArea.Text != "") newDownSurfaceArea = tbxRehabilitationDataBarrelSurfaceArea.Text.Trim();

                if (ddlRehabilitationDataRoundManholeRugs.SelectedValue != "-1") newManholeRugs = int.Parse(ddlRehabilitationDataRoundManholeRugs.SelectedValue);
                if (tbxRehabilitationDataRoundTotalDepth.Text != "") newTotalDepth = tbxRehabilitationDataRoundTotalDepth.Text.Trim();
                if (tbxRehabilitationDataRoundTotalSurfaceArea.Text != "") newTotalSurfaceArea = tbxRehabilitationDataRoundTotalSurfaceArea.Text.Trim();
            }

            if (newShape == "Rectangular")
            {
                if (tbxRehabilitationDataRectangle1LongSide.Text != "") newRectangle1LongSide = tbxRehabilitationDataRectangle1LongSide.Text.Trim();
                if (tbxRehabilitationDataRectangle1ShortSide.Text != "") newRectangle1ShortSide = tbxRehabilitationDataRectangle1ShortSide.Text.Trim();
                if (tbxRehabilitationDataRectangle1Depth.Text != "") newTopDepth = tbxRehabilitationDataRectangle1Depth.Text.Trim();
                if (tbxRehabilitationDataRectangle1Floor.Text != "") newTopFloor = tbxRehabilitationDataRectangle1Floor.Text.Trim();
                if (tbxRehabilitationDataRectangle1Ceiling.Text != "") newTopCeiling = tbxRehabilitationDataRectangle1Ceiling.Text.Trim();
                if (tbxRehabilitationDataRectangle1Benching.Text != "") newTopBenching = tbxRehabilitationDataRectangle1Benching.Text.Trim();
                if (tbxRehabilitationDataRectangle1SurfaceArea.Text != "") newTopSurfaceArea = tbxRehabilitationDataRectangle1SurfaceArea.Text.Trim();

                if (tbxRehabilitationDataRectangle2LongSide.Text != "") newRectangle2LongSide = tbxRehabilitationDataRectangle2LongSide.Text.Trim();
                if (tbxRehabilitationDataRectangle2ShortSide.Text != "") newRectangle2ShortSide = tbxRehabilitationDataRectangle2ShortSide.Text.Trim();
                if (tbxRehabilitationDataRectangle2Depth.Text != "") newDownDepth = tbxRehabilitationDataRectangle2Depth.Text.Trim();
                if (tbxRehabilitationDataRectangle2Floor.Text != "") newDownFloor = tbxRehabilitationDataRectangle2Floor.Text.Trim();
                if (tbxRehabilitationDataRectangle2Ceiling.Text != "") newDownCeiling = tbxRehabilitationDataRectangle2Ceiling.Text.Trim();
                if (tbxRehabilitationDataRectangle2Benching.Text != "") newDownBenching = tbxRehabilitationDataRectangle2Benching.Text.Trim();
                if (tbxRehabilitationDataRectangle2SurfaceArea.Text != "") newDownSurfaceArea = tbxRehabilitationDataRectangle2SurfaceArea.Text.Trim();

                if (ddlRehabilitationDataRectangularManholeRugs.SelectedValue != "-1") newManholeRugs = int.Parse(ddlRehabilitationDataRectangularManholeRugs.SelectedValue);
                if (tbxRehabilitationDataRectangularTotalDepth.Text != "") newTotalDepth = tbxRehabilitationDataRectangularTotalDepth.Text.Trim();
                if (tbxRehabilitationDataRectangularTotalSurfaceArea.Text != "") newTotalSurfaceArea = tbxRehabilitationDataRectangularTotalSurfaceArea.Text.Trim();
            }

            if (newShape == "Mixed")
            {
                if (tbxRehabilitationDataRoundDiameter.Text != "") newTopDiameter = tbxRehabilitationDataRoundDiameter.Text.Trim();
                if (tbxRehabilitationDataRoundDepth.Text != "") newTopDepth = tbxRehabilitationDataRoundDepth.Text.Trim();
                if (tbxRehabilitationDataRoundFloor.Text != "") newTopFloor = tbxRehabilitationDataRoundFloor.Text.Trim();
                if (tbxRehabilitationDataRoundCeiling.Text != "") newTopCeiling = tbxRehabilitationDataRoundCeiling.Text.Trim();
                if (tbxRehabilitationDataRoundBenching.Text != "") newTopBenching = tbxRehabilitationDataRoundBenching.Text.Trim();
                if (tbxRehabilitationDataRoundSurfaceArea.Text != "") newTopSurfaceArea = tbxRehabilitationDataRoundSurfaceArea.Text.Trim();

                if (tbxRehabilitationDataRectangleLongSide.Text != "") newRectangle2LongSide = tbxRehabilitationDataRectangleLongSide.Text.Trim();
                if (tbxRehabilitationDataRectangleShortSide.Text != "") newRectangle2ShortSide = tbxRehabilitationDataRectangleShortSide.Text.Trim();
                if (tbxRehabilitationDataRectangleDepth.Text != "") newDownDepth = tbxRehabilitationDataRectangleDepth.Text.Trim();
                if (tbxRehabilitationDataRectangleFloor.Text != "") newDownFloor = tbxRehabilitationDataRectangleFloor.Text.Trim();
                if (tbxRehabilitationDataRectangleCeiling.Text != "") newDownCeiling = tbxRehabilitationDataRectangleCeiling.Text.Trim();
                if (tbxRehabilitationDataRectangleBenching.Text != "") newDownBenching = tbxRehabilitationDataRectangleBenching.Text.Trim();
                if (tbxRehabilitationDataRectangleSufaceArea.Text != "") newDownSurfaceArea = tbxRehabilitationDataRectangleSufaceArea.Text.Trim();

                if (ddlRehabilitationDataMixManholeRugs.SelectedValue != "-1") newManholeRugs = int.Parse(ddlRehabilitationDataRectangularManholeRugs.SelectedValue);
                if (tbxRehabilitationDataRectangularTotalDepth.Text != "") newTotalDepth = tbxRehabilitationDataRectangularTotalDepth.Text.Trim();
                if (tbxRehabilitationDataRectangularTotalSurfaceArea.Text != "") newTotalSurfaceArea = tbxRehabilitationDataRectangularTotalSurfaceArea.Text.Trim();
            }

            if (newShape == "Other")
            {
                if (tbxRehabilitationDataOtherStructure.Text != "") newTotalSurfaceArea = tbxRehabilitationDataOtherStructure.Text.Trim();
            }

            // Update manhole details
            ManholeRehabilitationManholeDetails manholeRehabilitationManholeDetails = new ManholeRehabilitationManholeDetails(manholeRehabilitationTDS);
            manholeRehabilitationManholeDetails.Update(assetId, newLongitude, newLatitude, newAddress, newShape, newLocation, newMaterialId, newTopDiameter, newTopDepth, newTopFloor, newTopCeiling, newTopBenching, newDownDiameter, newDownDepth, newDownFloor, newDownCeiling, newDownBenching, newRectangle1LongSide, newRectangle1ShortSide, newRectangle2LongSide, newRectangle2ShortSide, newTopSurfaceArea, newDownSurfaceArea, newManholeRugs, newTotalDepth, newTotalSurfaceArea, newConditionRating, newMaterialDescription);

            // Get manhole work inforamtion
            DateTime? newPreppedDate = null; if (tkrdpRehabilitationPreppedDate.SelectedDate.HasValue) newPreppedDate = (DateTime)tkrdpRehabilitationPreppedDate.SelectedDate;
            DateTime? newSprayedDate = null; if (tkrdpRehabilitationSprayedDate.SelectedDate.HasValue) newSprayedDate = (DateTime)tkrdpRehabilitationSprayedDate.SelectedDate;

            int newBatchId = Int32.Parse(ddlRehabilitationBatchDate.SelectedValue);///TODO MH
            MrBatchVerificationGateway mrBatchVerificationGateway = new MrBatchVerificationGateway();
            mrBatchVerificationGateway.LoadByBatchId(newBatchId, companyId);
            DateTime newBatchDate = mrBatchVerificationGateway.GetDate(newBatchId);

            hdfBatchId.Value = newBatchId.ToString();

            // ... Update work details
            ManholeRehabilitationWorkDetails manholeRehabilitationWorkDetails = new ManholeRehabilitationWorkDetails(manholeRehabilitationTDS);
            manholeRehabilitationWorkDetails.Update(workId, newPreppedDate, newSprayedDate, newBatchId, newBatchDate, companyId);

            // Store datasets
            Session["manholeRehabilitationTDS"] = manholeRehabilitationTDS;

            ViewState["update"] = "no";
        }
コード例 #2
0
        private int UpdateDatabase()
        {
            // Get ids & location
            int projectId = Int32.Parse(hdfCurrentProjectId.Value.Trim());
            ProjectGateway projectGateway = new ProjectGateway();
            projectGateway.LoadByProjectId(projectId);

            Int64? countryId = null;
            Int64? provinceId = null;
            Int64? countyId = null;
            Int64? cityId = null;

            if (projectGateway.Table.Rows.Count > 0)
            {
                // ... Get ids
                try
                {//TODO MH
                    countryId = projectGateway.GetCountryID(projectId);
                }
                catch
                {
                }
                if (projectGateway.GetProvinceID(projectId).HasValue) provinceId = (Int64)projectGateway.GetProvinceID(projectId);
                if (projectGateway.GetCountyID(projectId).HasValue) countyId = (Int64)projectGateway.GetCountyID(projectId);
                if (projectGateway.GetCityID(projectId).HasValue) cityId = (Int64)projectGateway.GetCityID(projectId);
            }

            string workType = hdfWorkType.Value.Trim();
            int companyId = Int32.Parse(hdfCompanyId.Value);
            int workId = Int32.Parse(hdfWorkId.Value);
            int assetId = Int32.Parse(hdfAssetId.Value);
            bool inProject = bool.Parse(hdfInProject.Value);

            DB.Open();
            DB.BeginTransaction();
            try
            {
                // Save section details
                ManholeRehabilitationManholeDetails manholeRehabilitationManholeDetails = new ManholeRehabilitationManholeDetails(manholeRehabilitationTDS);
                manholeRehabilitationManholeDetails.Save(countryId, provinceId, countyId, cityId, projectId, companyId);

                // Save work details
                ManholeRehabilitationWorkDetails fullLengthLiningWorkDetails = new ManholeRehabilitationWorkDetails(manholeRehabilitationTDS);
                workId = fullLengthLiningWorkDetails.Save(countryId, provinceId, countyId, cityId, projectId, assetId, companyId, inProject);

                DB.CommitTransaction();

                // Store datasets
                manholeRehabilitationTDS.AcceptChanges();
                Session["manholeRehabilitationTDS"] = manholeRehabilitationTDS;
            }
            catch (Exception ex)
            {
                DB.RollbackTransaction();

                string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' '));
                Response.Redirect(url);
            }

            return workId;
        }
コード例 #3
0
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            bool isFromTabClick = false;

            if (!IsPostBack)
            {
                if (!isFromTabClick)
                {
                    // Security check
                    if (!(Convert.ToBoolean(Session["sgLFS_CWP_MANHOLEREHABILITATION_VIEW"]) && Convert.ToBoolean(Session["sgLFS_CWP_MANHOLEREHABILITATION_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_id"] == null) || ((string)Request.QueryString["project_id"] == null) || ((string)Request.QueryString["asset_id"] == null) || ((string)Request.QueryString["active_tab"] == null) || ((string)Request.QueryString["in_project"] == null))
                    {
                        Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in mr_edit.aspx");
                    }

                    // Tag Page
                    TagPage();

                    // If coming from
                    int companyId = Int32.Parse(hdfCompanyId.Value.Trim());
                    int currentProjectId = Int32.Parse(hdfCurrentProjectId.Value.ToString());
                    int assetId = Int32.Parse(hdfAssetId.Value.Trim());
                    int workId = Int32.Parse(hdfWorkId.Value.Trim());
                    string workType = hdfWorkType.Value;
                    lblNotLastBatch.Visible = false;

                    // ... mr_navigator2.aspx
                    if (Request.QueryString["source_page"] == "mr_navigator2.aspx")
                    {
                        StoreNavigatorState();
                        ViewState["update"] = "no";

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

                            manholeRehabilitationTDS = new ManholeRehabilitationTDS();

                            ManholeRehabilitationManholeDetails manholeRehabilitationManholeDetails = new ManholeRehabilitationManholeDetails(manholeRehabilitationTDS);
                            manholeRehabilitationManholeDetails.LoadByAssetId(assetId, companyId);

                            ManholeRehabilitationWorkDetails fullLengthLiningWorkDetails = new ManholeRehabilitationWorkDetails(manholeRehabilitationTDS);
                            fullLengthLiningWorkDetails.LoadByWorkIdAssetId(workId, assetId, companyId);
                        }
                        else
                        {
                            hdfActiveTab.Value = (string)Session["activeTabMr"];

                            // Restore datasets
                            manholeRehabilitationTDS = (ManholeRehabilitationTDS)Session["manholeRehabilitationTDS"];
                        }

                        // ... Store dataset
                        Session["manholeRehabilitationTDS"] = manholeRehabilitationTDS;
                    }

                    // ... mr_summary.aspx or mr_edit.aspx
                    if ((Request.QueryString["source_page"] == "mr_summary.aspx") || (Request.QueryString["source_page"] == "mr_edit.aspx"))
                    {
                        StoreNavigatorState();
                        ViewState["update"] = Request.QueryString["update"];

                        // ... Restore dataset
                        manholeRehabilitationTDS = (ManholeRehabilitationTDS)Session["manholeRehabilitationTDS"];

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

                        if (ViewState["update"].ToString().Trim() == "yes")
                        {
                            ManholeRehabilitationManholeDetails manholeRehabilitationManholeDetails = new ManholeRehabilitationManholeDetails(manholeRehabilitationTDS);
                            manholeRehabilitationManholeDetails.LoadByAssetId(assetId, companyId);

                            ManholeRehabilitationWorkDetails fullLengthLiningWorkDetails = new ManholeRehabilitationWorkDetails(manholeRehabilitationTDS);
                            fullLengthLiningWorkDetails.LoadByWorkIdAssetId(workId, assetId, companyId);

                            // ... Store dataset
                            Session["manholeRehabilitationTDS"] = manholeRehabilitationTDS;
                        }
                    }

                    // Set initial data
                    int activeTab = Int32.Parse(hdfActiveTab.Value);
                    tcMrDetails.ActiveTabIndex = activeTab;
                    lblBatchDateRequired.Visible = false;

                    if ((hdfCurrentClientId.Value != "0") && (hdfCurrentProjectId.Value != "0"))
                    {
                        // ... for client
                        int currentClientId = Int32.Parse(hdfCurrentClientId.Value.ToString());
                        CompaniesGateway companiesGateway = new CompaniesGateway();
                        companiesGateway.LoadByCompaniesId(currentClientId, companyId);
                        lblTitleClientName.Text = "Client: " + companiesGateway.GetName(currentClientId);

                        // ... for project
                        ProjectGateway projectGateway = new ProjectGateway();
                        projectGateway.LoadByProjectId(currentProjectId);
                        string name = projectGateway.GetName(currentProjectId);
                        if (name.Length > 23) name = name.Substring(0, 20) + "...";
                        lblTitleProjectName.Text = " > Project: " + name + " (" + projectGateway.GetProjectNumber(currentProjectId) + ") > Selected Manhole";
                    }
                    else
                    {
                        lblTitleClientName.Text = "";
                        lblTitleProjectName.Text = "";
                    }

                    // ... For batch dates
                    WorkManholeRehabilitationBatchList workManholeRehabilitationBatchList = new WorkManholeRehabilitationBatchList();
                    workManholeRehabilitationBatchList.LoadAndAddItem(-1, "(Select a batch)", companyId);
                    ddlRehabilitationBatchDate.DataSource = workManholeRehabilitationBatchList.Table;
                    ddlRehabilitationBatchDate.DataValueField = "BatchID";
                    ddlRehabilitationBatchDate.DataTextField = "Description";
                    ddlRehabilitationBatchDate.DataBind();

                    // ... ... Data for current manhole rehabilitation work
                    LoadManholeRehabilitationData(currentProjectId, assetId, companyId);

                    // ... ... Make panels visible
                    ShapeStructure();

                    // Databind
                    Page.DataBind();

                    // For usmh, dsmh autocomplete
                    string provinceId_ = "0"; if (hdfProvinceId.Value != "") provinceId_ = hdfProvinceId.Value;
                    string countyId_ = "0"; if (hdfCountyId.Value != "") countyId_ = hdfCountyId.Value;
                    string cityId_ = "0"; if (hdfCityId.Value != "") cityId_ = hdfCityId.Value;
                }
            }
            else
            {
                // Restore datasets
                manholeRehabilitationTDS = (ManholeRehabilitationTDS)Session["manholeRehabilitationTDS"];

                // Set initial tab
                int activeTab = Int32.Parse(hdfActiveTab.Value);
                tcMrDetails.ActiveTabIndex = activeTab;
            }
        }
コード例 #4
0
        private void Save()
        {
            // Validate data
            bool validData = true;

            validData = ValidatePage();

            if (validData)
            {
                // Save data
                int companyId = Int32.Parse(hdfCompanyId.Value);
                int assetId = Int32.Parse(hdfAssetId.Value);
                int workId = Int32.Parse(hdfWorkId.Value);
                int currentProjectId = Int32.Parse(hdfCurrentProjectId.Value.ToString());

                // Get Manhole information
                // ... ManholeRehabilitationManholeDetails data
                string newAddress = ""; if (tbxStreet.Text != "") newAddress = tbxStreet.Text.Trim();
                string newLatitude = ""; if (tbxLatitude.Text != "") newLatitude = tbxLatitude.Text.Trim();
                string newLongitude = ""; if (tbxLongitude.Text != "") newLongitude = tbxLongitude.Text.Trim();
                string newShape = ""; if (ddlShape.SelectedValue != "") newShape = ddlShape.SelectedValue;
                int? newConditionRating = null; if (ddlConditioningRating.SelectedValue != "-1") newConditionRating = int.Parse(ddlConditioningRating.SelectedValue);
                int? newMaterialId = null; if (ddlMaterial.SelectedValue != "-1") newMaterialId = int.Parse(ddlMaterial.SelectedValue);
                string newMaterialDescription = ""; if (ddlMaterial.SelectedValue != "") newMaterialDescription = ddlMaterial.Text;
                string newLocation = ""; if (ddlLocation.SelectedValue != "") newLocation = ddlLocation.SelectedValue;

                string newTopDiameter = "";
                string newTopDepth = "";
                string newTopFloor = "";
                string newTopCeiling = "";
                string newTopBenching = "";
                string newDownDiameter = "";
                string newDownDepth = "";
                string newDownFloor = "";
                string newDownCeiling = "";
                string newDownBenching = "";
                string newRectangle1LongSide = "";
                string newRectangle1ShortSide = "";
                string newRectangle2LongSide = "";
                string newRectangle2ShortSide = "";
                string newTopSurfaceArea = "";
                string newDownSurfaceArea = "";
                int? newManholeRugs = null;
                string newTotalDepth = "";
                string newTotalSurfaceArea = "";

                // ... Structure Details
                if (newShape == "Round")
                {
                    if (tbxRehabilitationDataChimneyDiameter.Text != "") newTopDiameter = tbxRehabilitationDataChimneyDiameter.Text.Trim();
                    if (tbxRehabilitationDataChimneyDepth.Text != "") newTopDepth = tbxRehabilitationDataChimneyDepth.Text.Trim();
                    if (tbxRehabilitationDataChimneyFloor.Text != "") newTopFloor = tbxRehabilitationDataChimneyFloor.Text.Trim();
                    if (tbxRehabilitationDataChimneyCeiling.Text != "") newTopCeiling = tbxRehabilitationDataChimneyCeiling.Text.Trim();
                    if (tbxRehabilitationDataChimneyBenching.Text != "") newTopBenching = tbxRehabilitationDataChimneyBenching.Text.Trim();
                    if (tbxRehabilitationDataChimneySurfaceArea.Text != "") newTopSurfaceArea = tbxRehabilitationDataChimneySurfaceArea.Text.Trim();

                    if (tbxRehabilitationDataBarrelDiameter.Text != "") newDownDiameter = tbxRehabilitationDataBarrelDiameter.Text.Trim();
                    if (tbxRehabilitationDataBarrelDepth.Text != "") newDownDepth = tbxRehabilitationDataBarrelDepth.Text.Trim();
                    if (tbxRehabilitationDataBarrelFloor.Text != "") newDownFloor = tbxRehabilitationDataBarrelFloor.Text.Trim();
                    if (tbxRehabilitationDataBarrelCeiling.Text != "") newDownCeiling = tbxRehabilitationDataBarrelCeiling.Text.Trim();
                    if (tbxRehabilitationDataBarrelBenching.Text != "") newDownBenching = tbxRehabilitationDataBarrelBenching.Text.Trim();
                    if (tbxRehabilitationDataBarrelSurfaceArea.Text !="") newDownSurfaceArea = tbxRehabilitationDataBarrelSurfaceArea.Text.Trim();

                    if (ddlRehabilitationDataRoundManholeRugs.SelectedValue != "-1")  newManholeRugs = int.Parse( ddlRehabilitationDataRoundManholeRugs.SelectedValue);
                    if (tbxRehabilitationDataRoundTotalDepth.Text != "") newTotalDepth = tbxRehabilitationDataRoundTotalDepth.Text.Trim();
                    if (tbxRehabilitationDataRoundTotalSurfaceArea.Text !="") newTotalSurfaceArea = tbxRehabilitationDataRoundTotalSurfaceArea.Text.Trim();
                }

                if (newShape == "Rectangular")
                {
                    if (tbxRehabilitationDataRectangle1LongSide.Text != "") newRectangle1LongSide = tbxRehabilitationDataRectangle1LongSide.Text.Trim();
                    if (tbxRehabilitationDataRectangle1ShortSide.Text != "") newRectangle1ShortSide = tbxRehabilitationDataRectangle1ShortSide.Text.Trim();
                    if (tbxRehabilitationDataRectangle1Depth.Text !="") newTopDepth = tbxRehabilitationDataRectangle1Depth.Text.Trim();
                    if (tbxRehabilitationDataRectangle1Floor.Text !="") newTopFloor = tbxRehabilitationDataRectangle1Floor.Text.Trim();
                    if (tbxRehabilitationDataRectangle1Ceiling.Text !="") newTopCeiling = tbxRehabilitationDataRectangle1Ceiling.Text.Trim();
                    if (tbxRehabilitationDataRectangle1Benching.Text !="")newTopBenching = tbxRehabilitationDataRectangle1Benching.Text.Trim();
                    if (tbxRehabilitationDataRectangle1SurfaceArea.Text != "")  newTopSurfaceArea = tbxRehabilitationDataRectangle1SurfaceArea.Text.Trim();

                    if (tbxRehabilitationDataRectangle2LongSide.Text != "") newRectangle2LongSide = tbxRehabilitationDataRectangle2LongSide.Text.Trim();
                    if (tbxRehabilitationDataRectangle2ShortSide.Text != "") newRectangle2ShortSide = tbxRehabilitationDataRectangle2ShortSide.Text.Trim();
                    if (tbxRehabilitationDataRectangle2Depth.Text !="") newDownDepth = tbxRehabilitationDataRectangle2Depth.Text.Trim();
                    if (tbxRehabilitationDataRectangle2Floor.Text !="") newDownFloor = tbxRehabilitationDataRectangle2Floor.Text.Trim();
                    if (tbxRehabilitationDataRectangle2Ceiling.Text !="") newDownCeiling = tbxRehabilitationDataRectangle2Ceiling.Text.Trim();
                    if (tbxRehabilitationDataRectangle2Benching.Text != "") newDownBenching = tbxRehabilitationDataRectangle2Benching.Text.Trim();
                    if (tbxRehabilitationDataRectangle2SurfaceArea.Text != "")  newDownSurfaceArea = tbxRehabilitationDataRectangle2SurfaceArea.Text.Trim();

                    if (ddlRehabilitationDataRectangularManholeRugs.SelectedValue != "-1")  newManholeRugs = int.Parse( ddlRehabilitationDataRectangularManholeRugs.SelectedValue);
                    if (tbxRehabilitationDataRectangularTotalDepth.Text != "") newTotalDepth = tbxRehabilitationDataRectangularTotalDepth.Text.Trim();
                    if (tbxRehabilitationDataRectangularTotalSurfaceArea.Text !="") newTotalSurfaceArea = tbxRehabilitationDataRectangularTotalSurfaceArea.Text.Trim();
                 }

                if (newShape == "Mixed")
                {
                    if (tbxRehabilitationDataRoundDiameter.Text != "") newTopDiameter = tbxRehabilitationDataRoundDiameter.Text.Trim();
                    if (tbxRehabilitationDataRoundDepth.Text != "") newTopDepth = tbxRehabilitationDataRoundDepth.Text.Trim();
                    if (tbxRehabilitationDataRoundFloor.Text != "") newTopFloor = tbxRehabilitationDataRoundFloor.Text.Trim();
                    if (tbxRehabilitationDataRoundCeiling.Text != "") newTopCeiling = tbxRehabilitationDataRoundCeiling.Text.Trim();
                    if (tbxRehabilitationDataRoundBenching.Text != "") newTopBenching = tbxRehabilitationDataRoundBenching.Text.Trim();
                    if (tbxRehabilitationDataRoundSurfaceArea.Text != "") newTopSurfaceArea = tbxRehabilitationDataRoundSurfaceArea.Text.Trim();

                    if (tbxRehabilitationDataRectangleLongSide.Text != "") newRectangle2LongSide = tbxRehabilitationDataRectangleLongSide.Text.Trim();
                    if (tbxRehabilitationDataRectangleShortSide.Text != "") newRectangle2ShortSide = tbxRehabilitationDataRectangleShortSide.Text.Trim();
                    if (tbxRehabilitationDataRectangleDepth.Text != "") newDownDepth = tbxRehabilitationDataRectangleDepth.Text.Trim();
                    if (tbxRehabilitationDataRectangleFloor.Text != "") newDownFloor = tbxRehabilitationDataRectangleFloor.Text.Trim();
                    if (tbxRehabilitationDataRectangleCeiling.Text != "") newDownCeiling = tbxRehabilitationDataRectangleCeiling.Text.Trim();
                    if (tbxRehabilitationDataRectangleBenching.Text != "") newDownBenching = tbxRehabilitationDataRectangleBenching.Text.Trim();
                    if (tbxRehabilitationDataRectangleSufaceArea.Text != "") newDownSurfaceArea = tbxRehabilitationDataRectangleSufaceArea.Text.Trim();

                    if (ddlRehabilitationDataMixManholeRugs.SelectedValue != "-1") newManholeRugs = int.Parse(ddlRehabilitationDataMixManholeRugs.SelectedValue);
                    if (tbxRehabilitationDataMixedTotalDepth.Text != "") newTotalDepth = tbxRehabilitationDataMixedTotalDepth.Text.Trim();
                    if (tbxRehabilitationDataMixedTotalSurfaceArea.Text != "") newTotalSurfaceArea = tbxRehabilitationDataMixedTotalSurfaceArea.Text.Trim();
                 }

                if (newShape == "Other")
                {
                    if (tbxRehabilitationDataOtherStructure.Text !="") newTotalSurfaceArea = tbxRehabilitationDataOtherStructure.Text.Trim();
                }

                // Update manhole details
                ManholeRehabilitationManholeDetails manholeRehabilitationManholeDetails = new ManholeRehabilitationManholeDetails(manholeRehabilitationTDS);
                manholeRehabilitationManholeDetails.Update(assetId, newLongitude, newLatitude, newAddress, newShape, newLocation, newMaterialId, newTopDiameter, newTopDepth, newTopFloor, newTopCeiling, newTopBenching, newDownDiameter, newDownDepth, newDownFloor, newDownCeiling, newDownBenching, newRectangle1LongSide, newRectangle1ShortSide, newRectangle2LongSide, newRectangle2ShortSide, newTopSurfaceArea, newDownSurfaceArea, newManholeRugs, newTotalDepth, newTotalSurfaceArea, newConditionRating, newMaterialDescription);

                // Get manhole work inforamtion
                DateTime? newPreppedDate = null; if (tkrdpRehabilitationPreppedDate.SelectedDate.HasValue) newPreppedDate = (DateTime)tkrdpRehabilitationPreppedDate.SelectedDate;
                DateTime? newSprayedDate = null; if (tkrdpRehabilitationSprayedDate.SelectedDate.HasValue) newSprayedDate = (DateTime)tkrdpRehabilitationSprayedDate.SelectedDate;

                int newBatchId = Int32.Parse(ddlRehabilitationBatchDate.SelectedValue);//TODO MH
                MrBatchVerificationGateway mrBatchVerificationGateway = new MrBatchVerificationGateway();
                mrBatchVerificationGateway.LoadByBatchId(newBatchId, companyId);
                DateTime newBatchDate = mrBatchVerificationGateway.GetDate(newBatchId);

                hdfBatchId.Value = newBatchId.ToString();

                // ... Update work details
                ManholeRehabilitationWorkDetails manholeRehabilitationWorkDetails = new ManholeRehabilitationWorkDetails(manholeRehabilitationTDS);
                manholeRehabilitationWorkDetails.Update(workId, newPreppedDate, newSprayedDate, newBatchId , newBatchDate, companyId);

                // Store datasets
                Session["manholeRehabilitationTDS"] = manholeRehabilitationTDS;

                // Update database
                UpdateDatabase();

                ViewState["update"] = "yes";

                // Redirect
                string url = "";
                if (Request.QueryString["source_page"] == "mr_navigator2.aspx")
                {
                    url = "./mr_navigator2.aspx?source_page=mr_edit.aspx&client_id=" + hdfCurrentClientId.Value + "&project_id=" + hdfCurrentProjectId.Value + "&in_project=" + hdfInProject.Value + GetNavigatorState() + "&update=yes";
                }

                if (Request.QueryString["source_page"] == "mr_summary.aspx")
                {
                    string activeTab = hdfActiveTab.Value;
                    url = "./mr_summary.aspx?source_page=mr_edit.aspx&client_id=" + hdfCurrentClientId.Value + "&project_id=" + hdfCurrentProjectId.Value + "&asset_id=" + hdfAssetId.Value + "&in_project=" + hdfInProject.Value + "&active_tab=" + activeTab + GetNavigatorState() + "&update=yes";
                }
                Response.Redirect(url);
            }
        }
コード例 #5
0
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!(Convert.ToBoolean(Session["sgLFS_CWP_MANHOLEREHABILITATION_VIEW"]) && Convert.ToBoolean(Session["sgLFS_CWP_MANHOLEREHABILITATION_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_id"] == null) || ((string)Request.QueryString["project_id"] == null) || ((string)Request.QueryString["asset_id"] == null) || ((string)Request.QueryString["active_tab"] == null) || ((string)Request.QueryString["in_project"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in mr_summary.aspx");
                }

                // Tag Page
                TagPage();

                // If comming from
                int companyId = Int32.Parse(hdfCompanyId.Value.Trim());
                int currentProjectId = Int32.Parse(hdfCurrentProjectId.Value.ToString());
                int assetId = Int32.Parse(hdfAssetId.Value.Trim());
                string workType = hdfWorkType.Value;
                int workId = Int32.Parse(hdfWorkId.Value);

                // ... mr_navigator2.aspx
                if (Request.QueryString["source_page"] == "mr_navigator2.aspx")
                {
                    StoreNavigatorState();
                    ViewState["update"] = "no";

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

                        manholeRehabilitationTDS = new ManholeRehabilitationTDS();

                        ManholeRehabilitationManholeDetails manholeRehabilitationManholeDetails = new ManholeRehabilitationManholeDetails(manholeRehabilitationTDS);
                        manholeRehabilitationManholeDetails.LoadByAssetId(assetId, companyId);

                        ManholeRehabilitationWorkDetails fullLengthLiningWorkDetails = new ManholeRehabilitationWorkDetails(manholeRehabilitationTDS);
                        fullLengthLiningWorkDetails.LoadByWorkIdAssetId(workId, assetId, companyId);
                    }
                    else
                    {
                        hdfActiveTab.Value = (string)Session["activeTabMr"];

                        // Restore datasets
                        manholeRehabilitationTDS = (ManholeRehabilitationTDS)Session["manholeRehabilitationTDS"];
                    }

                    tcMrDetails.ActiveTabIndex = Int32.Parse(hdfActiveTab.Value);

                    // Store dataset
                    Session["manholeRehabilitationTDS"] = manholeRehabilitationTDS;
                }

                // ... mr_delete.aspx or mr_edit.aspx
                if ((Request.QueryString["source_page"] == "mr_delete.aspx") || (Request.QueryString["source_page"] == "mr_edit.aspx"))
                {
                    StoreNavigatorState();
                    ViewState["update"] = Request.QueryString["update"];

                    // Restore dataset
                    manholeRehabilitationTDS = new ManholeRehabilitationTDS();

                    ManholeRehabilitationManholeDetails manholeRehabilitationManholeDetails = new ManholeRehabilitationManholeDetails(manholeRehabilitationTDS);
                    manholeRehabilitationManholeDetails.LoadByAssetId(assetId, companyId);

                    ManholeRehabilitationWorkDetails fullLengthLiningWorkDetails = new ManholeRehabilitationWorkDetails(manholeRehabilitationTDS);
                    fullLengthLiningWorkDetails.LoadByWorkIdAssetId(workId, assetId, companyId);

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

                    tcMrDetails.ActiveTabIndex = Int32.Parse(hdfActiveTab.Value);
                }

                // Prepare initial data
                if ((hdfCurrentClientId.Value != "0") && (hdfCurrentProjectId.Value != "0"))
                {
                    // ... for client
                    int currentClientId = Int32.Parse(hdfCurrentClientId.Value.ToString());
                    CompaniesGateway companiesGateway = new CompaniesGateway();
                    companiesGateway.LoadByCompaniesId(currentClientId, companyId);
                    lblTitleClientName.Text = "Client: " + companiesGateway.GetName(currentClientId);

                    // ... for project
                    ProjectGateway projectGateway = new ProjectGateway();
                    projectGateway.LoadByProjectId(currentProjectId);
                    string name = projectGateway.GetName(currentProjectId);
                    if (name.Length > 23) name = name.Substring(0, 20) + "...";
                    lblTitleProjectName.Text = " > Project: " + name + " (" + projectGateway.GetProjectNumber(currentProjectId) + ") ";
                }
                else
                {
                    lblTitleClientName.Text = "";
                    lblTitleProjectName.Text = "";
                }

                // ... Data for current full length lining work
                LoadManholeRehabilitationData(currentProjectId, assetId, companyId);

                // Databind
                Page.DataBind();
            }
            else
            {
                // Restore datasets
                manholeRehabilitationTDS = (ManholeRehabilitationTDS)Session["manholeRehabilitationTDS"];

                // Set initial tab
                int activeTab = Int32.Parse(hdfActiveTab.Value);
                tcMrDetails.ActiveTabIndex = activeTab;

                // Load summary for inversionfield cure record
                int companyId =Int32.Parse(hdfCompanyId.Value);
                int workId = Int32.Parse(hdfWorkId.Value);
            }
        }
コード例 #6
0
        // ////////////////////////////////////////////////////////////////////////
        // EVENTS
        //
        protected void Page_Load(object sender, EventArgs e)
        {
            // Register client scripts
            this.RegisterClientScripts();

            if (!IsPostBack)
            {
                // Security check
                if (!(Convert.ToBoolean(Session["sgLFS_CWP_MANHOLEREHABILITATION_VIEW"]) && Convert.ToBoolean(Session["sgLFS_CWP_MANHOLEREHABILITATION_DELETE"])))
                {
                    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_id"] == null) || ((string)Request.QueryString["project_id"] == null) || ((string)Request.QueryString["asset_id"] == null) || ((string)Request.QueryString["in_project"] == null))
                {
                    Response.Redirect("./../../error_page.aspx?error=" + "Invalid query string in mr_delete.aspx");
                }

                // Tag Page
                TagPage();

                // Prepare initial data
                // ... for client
                int currentClientId = Int32.Parse(hdfCurrentClientId.Value.ToString());
                int companyId = Int32.Parse(hdfCompanyId.Value);

                CompaniesGateway companiesGateway = new CompaniesGateway();
                companiesGateway.LoadByCompaniesId(currentClientId, companyId);
                lblTitleClientName.Text = "Client: " + companiesGateway.GetName(currentClientId);

                // ... for project
                int currentProjectId = Int32.Parse(hdfCurrentProjectId.Value.ToString());
                ProjectGateway projectGateway = new ProjectGateway();
                projectGateway.LoadByProjectId(currentProjectId);
                string name = projectGateway.GetName(currentProjectId);
                if (name.Length > 23) name = name.Substring(0, 20) + "...";
                lblTitleProjectName.Text = " > Project: " + name + " (" + projectGateway.GetProjectNumber(currentProjectId) + ") > Selected Section";

                // If coming from
                // ... mr_navigator2.aspx
                if (Request.QueryString["source_page"] == "mr_navigator2.aspx")
                {
                    StoreNavigatorState();
                    ViewState["update"] = "no";

                    manholeRehabilitationTDS = new ManholeRehabilitationTDS();

                    int workId = Int32.Parse(hdfWorkId.Value);
                    int assetId = Int32.Parse(hdfAssetId.Value);

                    ManholeRehabilitationManholeDetails manholeRehabilitationManholeDetails = new ManholeRehabilitationManholeDetails(manholeRehabilitationTDS);
                    manholeRehabilitationManholeDetails.LoadByAssetId(assetId, companyId);

                    ManholeRehabilitationWorkDetails manholeRehabilitationWorkDetails = new ManholeRehabilitationWorkDetails(manholeRehabilitationTDS);
                    manholeRehabilitationWorkDetails.LoadByWorkIdAssetId(workId, assetId, companyId);

                    // Store dataset
                    Session["manholeRehabilitationTDS"] = manholeRehabilitationTDS;
                }

                // ... mr_summary.aspx
                if (Request.QueryString["source_page"] == "mr_summary.aspx")
                {
                    StoreNavigatorState();
                    ViewState["update"] = Request.QueryString["update"];

                    // Restore dataset
                    manholeRehabilitationTDS = (ManholeRehabilitationTDS)Session["manholeRehabilitationTDS"];
                }
            }
            else
            {
                // Restore datasets
                manholeRehabilitationTDS = (ManholeRehabilitationTDS)Session["manholeRehabilitationTDS"];
            }
        }
コード例 #7
0
        private void UpdateDatabase()
        {
            // Get ids
            int workId = Int32.Parse(hdfWorkId.Value);
            int assetId = Int32.Parse(hdfAssetId.Value);
            int companyId = Int32.Parse(hdfCompanyId.Value);

            // Delete
            DB.Open();
            DB.BeginTransaction();
            try
            {
                LfsAssetSewerMH lfsAssetSewerMH = new LfsAssetSewerMH();
                lfsAssetSewerMH.DeleteDirect(assetId, companyId);

                ManholeRehabilitationWorkDetails manholeRehabilitationWorkDetails = new ManholeRehabilitationWorkDetails(manholeRehabilitationTDS);
                manholeRehabilitationWorkDetails.DeleteDirect(workId, companyId);

                DB.CommitTransaction();

                // Store datasets
                Session["manholeRehabilitationTDS"] = manholeRehabilitationTDS;
            }
            catch (Exception ex)
            {
                DB.RollbackTransaction();

                string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' '));
                Response.Redirect(url);
            }
        }
コード例 #8
0
        private void UpdateDatabase()
        {
            DB.Open();
            DB.BeginTransaction();
            try
            {
                int companyId = Int32.Parse(hdfCompanyId.Value);

                // Update comments
                ManholeRehabilitationCommentDetails manholeRehabilitationCommentDetails = new ManholeRehabilitationCommentDetails(manholeRehabilitationTDS);
                manholeRehabilitationCommentDetails.Save(companyId);

                // Update works
                workUpdate();

                // Update section
                int workId = Int32.Parse(hdfWorkId.Value.Trim());
                ManholeRehabilitationWorkDetails fullLengthLiningWorkDetails = new ManholeRehabilitationWorkDetails(manholeRehabilitationTDS);
                fullLengthLiningWorkDetails.UpdateCommentsForSummaryEdit(workId, companyId);

                // Store datasets
                Session["manholeRehabilitationTDS"] = manholeRehabilitationTDS;

                DB.CommitTransaction();
            }
            catch (Exception ex)
            {
                DB.RollbackTransaction();

                string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' '));
                Response.Redirect(url);
            }
        }
コード例 #9
0
        private void UpdateDatabase()
        {
            try
            {
                TeamProjectTime2Gateway teamProjectTime2Gateway = new TeamProjectTime2Gateway(teamProjectTime2TDSToSave);
                teamProjectTime2Gateway.Update(projectTime2TDS);

                teamProjectTime2TDSToSave.AcceptChanges();
                teamProjectTime2TDS.AcceptChanges();
                projectTime2TDS.AcceptChanges();
                Session["teamProjectTime2TDS"] = teamProjectTime2TDS;
            }
            catch (Exception ex)
            {
                string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' '));
                Response.Redirect(url);
            }

            DB.Open();
            DB.BeginTransaction();
            try
            {
                if (ddlTypeOfWork.SelectedValue == "MH Rehab")
                {
                    int companyId = Int32.Parse(hdfCompanyId.Value);

                    // Get ids & location
                    int projectId = Int32.Parse(ddlProject.SelectedValue);
                    ProjectGateway projectGateway = new ProjectGateway();
                    projectGateway.LoadByProjectId(projectId);

                    Int64 countryId = projectGateway.GetCountryID(projectId);
                    Int64? provinceId = null; if (projectGateway.GetProvinceID(projectId).HasValue) provinceId = (Int64)projectGateway.GetProvinceID(projectId);
                    Int64? countyId = null; if (projectGateway.GetCountyID(projectId).HasValue) countyId = (Int64)projectGateway.GetCountyID(projectId);
                    Int64? cityId = null; if (projectGateway.GetCityID(projectId).HasValue) cityId = (Int64)projectGateway.GetCityID(projectId);

                    manholeRehabilitationTDS = new ManholeRehabilitationTDS();
                    ManholeRehabilitationWorkDetails manholeRehabilitationWorkDetails = new ManholeRehabilitationWorkDetails(manholeRehabilitationTDS);
                    ManholeRehabilitationWorkDetailsGateway manholeRehabilitationWorkDetailsGateway = new ManholeRehabilitationWorkDetailsGateway(manholeRehabilitationTDS);

                    switch (ddlFunction.SelectedValue)
                    {
                        case "Prep":
                            foreach (GridViewRow row in grdManholesRehabPrep.Rows)
                            {
                                bool selected = ((CheckBox)row.FindControl("cbxSelected")).Checked;
                                DateTime? prepDate = Convert.ToDateTime(((Label)row.FindControl("lblPrepDate")).Text);

                                if (selected)
                                {
                                    int assetId = Convert.ToInt32(grdManholesRehabPrep.DataKeys[row.RowIndex].Values["AssetID"].ToString());
                                    int workId = 0;

                                    workId = GetWorkId(Int32.Parse(ddlProject.SelectedValue), assetId, "Manhole Rehabilitation", companyId);

                                    manholeRehabilitationWorkDetails.LoadByWorkIdAssetId(workId, assetId, Int32.Parse(hdfCompanyId.Value));

                                    if (manholeRehabilitationWorkDetailsGateway.Table.Rows.Count > 0)
                                    {
                                        int? batchId = manholeRehabilitationWorkDetailsGateway.GetBatchID(workId);
                                        manholeRehabilitationWorkDetails.Update(workId, prepDate, manholeRehabilitationWorkDetailsGateway.GetSprayedDate(workId), batchId, manholeRehabilitationWorkDetailsGateway.GetDate(workId).Value, companyId);
                                    }
                                    else
                                    {
                                        manholeRehabilitationWorkDetails.Update(workId, prepDate, null, null, DateTime.Now, companyId);
                                    }

                                    manholeRehabilitationWorkDetails.Save2(countryId, provinceId, countyId, cityId, projectId, assetId, companyId, true);
                                }
                            }
                            break;

                        case "Spray":
                            foreach (GridViewRow row in grdManholesRehabSpray.Rows)
                            {
                                bool selected = ((CheckBox)row.FindControl("cbxSelected")).Checked;
                                DateTime? sprayDate = Convert.ToDateTime(((Label)row.FindControl("lblSprayDate")).Text);

                                if (selected)
                                {
                                    int assetId = Convert.ToInt32(grdManholesRehabSpray.DataKeys[row.RowIndex].Values["AssetID"].ToString());
                                    int workId = 0;

                                    workId = GetWorkId(Int32.Parse(ddlProject.SelectedValue), assetId, "Manhole Rehabilitation", companyId);

                                    manholeRehabilitationWorkDetails.LoadByWorkIdAssetId(workId, assetId, Int32.Parse(hdfCompanyId.Value));

                                    if (manholeRehabilitationWorkDetailsGateway.Table.Rows.Count > 0)
                                    {
                                        int? batchId = manholeRehabilitationWorkDetailsGateway.GetBatchID(workId);
                                        manholeRehabilitationWorkDetails.Update(workId, manholeRehabilitationWorkDetailsGateway.GetPreppedDate(workId), sprayDate, batchId, manholeRehabilitationWorkDetailsGateway.GetDate(workId).Value, companyId);
                                    }
                                    else
                                    {
                                        manholeRehabilitationWorkDetails.Update(workId, null, sprayDate, null, DateTime.Now, companyId);
                                    }

                                    manholeRehabilitationWorkDetails.Save2(countryId, provinceId, countyId, cityId, projectId, assetId, companyId, true);
                                }
                            }
                            break;
                    }

                    DB.CommitTransaction();

                    // Store datasets
                    manholeRehabilitationTDS.AcceptChanges();
                }
                else
                {
                    if (ddlTypeOfWork.SelectedValue == "Full Length")
                    {
                        fullLengthLiningTDS = new FullLengthLiningTDS();
                        AssetSewerSectionGateway aass = new AssetSewerSectionGateway();
                        FullLengthLiningWorkDetails fullLengthLiningWorkDetails = new FullLengthLiningWorkDetails(fullLengthLiningTDS);
                        FullLengthLiningWorkDetailsGateway fullLengthLiningWorkDetailsGateway = new FullLengthLiningWorkDetailsGateway(fullLengthLiningTDS);

                        int assetId = 0;
                        int workId = 0;

                        // Get ids & location
                        int projectId = Int32.Parse(ddlProject.SelectedValue);
                        ProjectGateway projectGateway = new ProjectGateway();
                        projectGateway.LoadByProjectId(projectId);

                        Int64 countryId = projectGateway.GetCountryID(projectId);
                        Int64? provinceId = null; if (projectGateway.GetProvinceID(projectId).HasValue) provinceId = (Int64)projectGateway.GetProvinceID(projectId);
                        Int64? countyId = null; if (projectGateway.GetCountyID(projectId).HasValue) countyId = (Int64)projectGateway.GetCountyID(projectId);
                        Int64? cityId = null; if (projectGateway.GetCityID(projectId).HasValue) cityId = (Int64)projectGateway.GetCityID(projectId);

                        int companyId = Int32.Parse(hdfCompanyId.Value);

                        switch (ddlFunction.SelectedValue)
                        {
                            case "Install":
                                foreach (GridViewRow row in grdSectionsInstall.Rows)
                                {
                                    bool selected = ((CheckBox)row.FindControl("cbxSelected")).Checked;
                                    DateTime? installDate = Convert.ToDateTime(((Label)row.FindControl("lblInstallDate")).Text);

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

                                        string sectionId = grdSectionsInstall.DataKeys[row.RowIndex].Values["SectionID"].ToString();
                                        aass.LoadBySectionId(sectionId, companyId);
                                        assetId = aass.GetAssetID(sectionId);
                                        workId = GetWorkId(Int32.Parse(ddlProject.SelectedValue), assetId, "Full Length Lining", companyId);

                                        fullLengthLiningWorkDetails.LoadByWorkIdAssetId(workId, assetId, Int32.Parse(hdfCompanyId.Value));
                                        fullLengthLiningWorkDetails.Update(workId, fullLengthLiningWorkDetailsGateway.GetP1Date(workId), fullLengthLiningWorkDetailsGateway.GetP1Completed(workId), installDate, fullLengthLiningWorkDetailsGateway.GetFinalVideoDate(workId));
                                        fullLengthLiningWorkDetails.Save(countryId, provinceId, countyId, cityId, projectId, assetId, companyId, false, false);
                                    }
                                }
                                break;

                            case "Prep & Measure":
                                foreach (GridViewRow row in grdSections.Rows)
                                {
                                    bool selected = ((CheckBox)row.FindControl("cbxSelected")).Checked;
                                    bool completed = ((CheckBox)row.FindControl("cbxCompleted")).Checked;
                                    DateTime? prepDate = Convert.ToDateTime(((Label)row.FindControl("lblPrepDate")).Text);

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

                                        string sectionId = grdSections.DataKeys[row.RowIndex].Values["SectionID"].ToString();
                                        aass.LoadBySectionId(sectionId, companyId);
                                        assetId = aass.GetAssetID(sectionId);
                                        workId = GetWorkId(Int32.Parse(ddlProject.SelectedValue), assetId, "Full Length Lining", companyId);

                                        fullLengthLiningWorkDetails.LoadByWorkIdAssetId(workId, assetId, Int32.Parse(hdfCompanyId.Value));
                                        fullLengthLiningWorkDetails.Update(workId, prepDate, completed, fullLengthLiningWorkDetailsGateway.GetInstallDate(workId), fullLengthLiningWorkDetailsGateway.GetFinalVideoDate(workId));
                                        fullLengthLiningWorkDetails.Save(countryId, provinceId, countyId, cityId, projectId, assetId, companyId, false, false);
                                    }
                                }
                                break;

                            case "Reinstate & Post Video":
                                FullLengthLiningLateralDetails fullLengthLiningLateralDetails = new FullLengthLiningLateralDetails(fullLengthLiningTDS);
                                FullLengthLiningLateralDetailsGateway fullLengthLiningLateralDetailsGateway = new FullLengthLiningLateralDetailsGateway(fullLengthLiningTDS);

                                foreach (GridViewRow row in grdSectionsReinstatePostVideo.Rows)
                                {
                                    bool selected = ((CheckBox)row.FindControl("cbxSelected")).Checked;
                                    bool completed = ((CheckBox)row.FindControl("cbxCompleted")).Checked;
                                    DateTime? postVideo = Convert.ToDateTime(((Label)row.FindControl("lblPostVideo")).Text);
                                    string sectionId = grdSectionsReinstatePostVideo.DataKeys[row.RowIndex].Values["SectionID"].ToString();

                                    aass.LoadBySectionId(sectionId, companyId);
                                    assetId = aass.GetAssetID(sectionId);
                                    workId = GetWorkId(Int32.Parse(ddlProject.SelectedValue), assetId, "Full Length Lining", companyId);

                                    if (selected)
                                    {
                                        if (completed)
                                        {
                                            if (postVideo != tkrdpDate_.SelectedDate.Value)
                                            {
                                                postVideo = tkrdpDate_.SelectedDate.Value;
                                            }
                                        }
                                        else
                                        {
                                            postVideo = null;
                                        }

                                        fullLengthLiningWorkDetails.LoadByWorkIdAssetId(workId, assetId, Int32.Parse(hdfCompanyId.Value));
                                        fullLengthLiningWorkDetails.Update(workId, fullLengthLiningWorkDetailsGateway.GetP1Date(workId), fullLengthLiningWorkDetailsGateway.GetP1Completed(workId), fullLengthLiningWorkDetailsGateway.GetInstallDate(workId), postVideo);
                                        fullLengthLiningWorkDetails.Save(countryId, provinceId, countyId, cityId, projectId, assetId, companyId, false, false);
                                    }
                                }

                                foreach (GridViewRow row in grdLaterals.Rows)
                                {
                                    string sectionId = grdLaterals.DataKeys[row.RowIndex].Values["SectionID"].ToString();
                                    int assetIdLateral = Convert.ToInt32(((Label)row.FindControl("lblAssetIDLateral")).Text);
                                    bool selected = ((CheckBox)row.FindControl("cbxSelected")).Checked;
                                    DateTime? opened = null; if (((CheckBox)row.FindControl("cbxOpened")).Checked) opened = tkrdpDate_.SelectedDate;
                                    DateTime? brushed = null; if (((CheckBox)row.FindControl("cbxBrushed")).Checked) brushed = tkrdpDate_.SelectedDate;

                                    if (selected)
                                    {
                                        aass.LoadBySectionId(sectionId, companyId);
                                        assetId = aass.GetAssetID(sectionId);
                                        workId = GetWorkId(Int32.Parse(ddlProject.SelectedValue), assetId, "Full Length Lining", companyId);

                                        fullLengthLiningLateralDetails.SaveFll(workId, assetIdLateral, companyId, opened, brushed);
                                    }
                                }
                                break;
                        }

                        DB.CommitTransaction();

                        // Store datasets
                        fullLengthLiningTDS.AcceptChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                DB.RollbackTransaction();

                string url = string.Format("./../../error_page.aspx?error={0}", ex.Message.Replace('\n', ' '));
                Response.Redirect(url);
            }
        }