Ejemplo n.º 1
0
        private void GrdFLAddLateralsNewAdd()
        {
            if (ValidateLateralFooter())
            {
                Page.Validate("AddLateralsAdd");
                if (Page.IsValid)
                {
                    string size = ((TextBox)grdLaterals.FooterRow.FindControl("tbxNewSize")).Text.Trim();
                    string material = ((DropDownList)grdLaterals.FooterRow.FindControl("ddlNewMaterial")).SelectedValue.ToString().Trim();
                    string live = ((DropDownList)grdLaterals.FooterRow.FindControl("ddlNewLive")).SelectedValue.Trim();
                    string videoDistance = ((TextBox)grdLaterals.FooterRow.FindControl("tbxNewVideoDistance")).Text.Trim();
                    string clockPosition = ((TextBox)grdLaterals.FooterRow.FindControl("tbxNewClockPosition")).Text.Trim();
                    string distanceToCentre = ((TextBox)grdLaterals.FooterRow.FindControl("tbxNewDistanceToCentre")).Text.Trim();
                    string timeOpened = "";
                    DateTime? reinstate = null;
                    string comments = ((TextBox)grdLaterals.FooterRow.FindControl("tbxNewComments")).Text.Trim();

                    // Reverse Setup calculation
                    string reverseSetup = "";
                    if (videoDistance != "")
                    {
                        Distance videoDistanceD = new Distance(videoDistance);
                        Distance videoLength = new Distance(tbxVideoLength.Text.Trim());

                        Distance reverseSetupD = videoLength - videoDistanceD;
                        switch (videoDistanceD.DistanceType)
                        {
                            case 1:
                                reverseSetup = reverseSetupD.ToStringInEng1();
                                break;
                            case 2:
                                reverseSetup = reverseSetupD.ToStringInEng2();
                                break;
                            case 3:
                                reverseSetup = reverseSetupD.ToStringInEng3();
                                break;
                            case 4:
                                reverseSetup = reverseSetupD.ToStringInMet1();
                                break;
                            case 5:
                                reverseSetup = reverseSetupD.ToStringInMil1();
                                break;
                        }
                    }

                    bool inProject = ((CheckBox)grdLaterals.FooterRow.FindControl("cbxInProject")).Checked;
                    int workId = Int32.Parse(hdfWorkId.Value);
                    int companyId = Int32.Parse(hdfCompanyId.Value);
                    string lateralId = GetLateralIdIncrement();
                    string clientLateralId = ((TextBox)grdLaterals.FooterRow.FindControl("tbxNewClientLateralId")).Text.Trim();
                    string connectionType = ""; connectionType = ((DropDownList)grdLaterals.FooterRow.FindControl("ddlNewConnectionType")).SelectedValue;
                    string mn = ((TextBox)grdLaterals.FooterRow.FindControl("tbxNewMn")).Text.Trim();
                    string clientInspectionNo = ((TextBox)grdLaterals.FooterRow.FindControl("tbxNewClientInspectionNo")).Text.Trim();
                    DateTime? v1Inspection = null;
                    bool requiresRoboticPrep = ((CheckBox)grdLaterals.FooterRow.FindControl("ckbxRequiresRoboticPrepNew")).Checked;
                    DateTime? requiresRoboticPrepDate = null;
                    if (((RadDatePicker)grdLaterals.FooterRow.FindControl("tkrdpRequiresRoboticPrepDateNew")).SelectedDate.HasValue)
                    {
                        requiresRoboticPrepDate = ((RadDatePicker)grdLaterals.FooterRow.FindControl("tkrdpRequiresRoboticPrepDateNew")).SelectedDate.Value;
                    }

                    bool holdClientIssue = ((CheckBox)grdLaterals.FooterRow.FindControl("ckbxHoldClientIssueNew")).Checked;
                    bool holdLFSIssue = ((CheckBox)grdLaterals.FooterRow.FindControl("ckbxHoldLFSIssueNew")).Checked;
                    bool lineLateral = ((CheckBox)grdLaterals.FooterRow.FindControl("cbxNewJl")).Checked;
                    string flange = ((DropDownList)grdLaterals.FooterRow.FindControl("ddlFlangeNew")).SelectedValue;
                    bool dyeTestReq = ((CheckBox)grdLaterals.FooterRow.FindControl("ckbxDyeTestReqNew")).Checked;
                    DateTime? dyeTestComplete = null; if (((RadDatePicker)grdLaterals.FooterRow.FindControl("tkrdpDyeTestCompleteNew")).SelectedDate.HasValue) dyeTestComplete = ((RadDatePicker)grdLaterals.FooterRow.FindControl("tkrdpDyeTestCompleteNew")).SelectedDate.Value;

                    // Insert
                    FullLengthLiningLateralDetails model = new FullLengthLiningLateralDetails(fullLengthLiningTDS);
                    model.Insert(videoDistance, clockPosition, distanceToCentre, timeOpened, reverseSetup, reinstate, comments, lateralId, size, material, false, companyId, inProject, live, clientLateralId, connectionType, mn, clientInspectionNo, v1Inspection, requiresRoboticPrep, requiresRoboticPrepDate, holdClientIssue, holdLFSIssue, lineLateral, flange, lineLateral, dyeTestReq, dyeTestComplete);

                    // Store datasets
                    Session.Remove("flAddLateralsNewDummy");
                    Session["fullLengthLiningTDS"] = fullLengthLiningTDS;
                    grdLaterals.DataBind();
                    grdLaterals.PageIndex = grdLaterals.PageCount - 1;

                    tbxLaterals.Text = model.GetTotalLaterals().ToString();
                    tbxLiveLaterals.Text = model.GetLiveLaterals().ToString();
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Save
        /// </summary>
        /// <param name="projectId">projectId</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>
        /// <param name="loginId">loginId</param>
        public void Save(int projectId, Int64 countryId, Int64? provinceId, Int64? countyId, Int64? cityId, int companyId, int loginId)
        {
            FullLengthLiningTDS fullLengthLiningTDS = new FullLengthLiningTDS();

            foreach (WincapBulkUploadTDS.WincapBulkUploadRow row in (WincapBulkUploadTDS.WincapBulkUploadDataTable)Table)
            {
                string state = ""; if (!row.IsStateNull()) state = row.State;
                string direction = ""; if (!row.IsDirectionNull()) direction = row.Direction;
                string distance = ""; if (!row.IsDistanceNull()) distance = row.Distance;
                string videoDistance = ""; if (!row.IsVideoDistanceNull()) videoDistance = row.VideoDistance;
                string clockPosition = ""; if (!row.IsClockPositionNull()) clockPosition = row.ClockPosition;
                string distanceToCentre = ""; if (!row.IsDistanceToCentreNull()) distanceToCentre = row.DistanceToCentre;
                string reverseSetup = ""; if (!row.IsReverseSetupNull()) reverseSetup = row.ReverseSetup;
                string comments = ""; if (!row.IsCommentsNull()) comments = row.Comments;
                string measuredFromMh = "USMH";
                if (row.Direction.Contains("D"))
                {
                    measuredFromMh = "DSMH";
                }

                int section_assetId = SaveSection(row.SectionID, projectId, countryId, provinceId, countyId, cityId, companyId);

                WorkFullLengthLining workFullLengthLining = new WorkFullLengthLining(null);
                int workId = workFullLengthLining.InsertDirectEmptyWorks(projectId, section_assetId, null, "", null, null, null, null, null, null, null, false, false, false, false, false, false, false, companyId, false, "", "");

                FullLengthLiningLateralDetails flLateralDetails = new FullLengthLiningLateralDetails();
                flLateralDetails.LoadForEdit(workId, section_assetId, companyId, projectId);

                // Generate increment
                string lateralIdIncrement = "";

                if (measuredFromMh == "USMH" || measuredFromMh == "")
                {
                    lateralIdIncrement = flLateralDetails.GetMaxLateralId2();
                }
                else
                {
                    if (measuredFromMh == "DSMH")
                    {
                        lateralIdIncrement = flLateralDetails.GetMinLateralId2();
                    }
                }

                string videoLength = "";

                string lateralId = "FL-" + lateralIdIncrement;

                FullLengthLiningLateralDetails model = new FullLengthLiningLateralDetails(fullLengthLiningTDS);
                model.Insert(videoDistance, clockPosition, distanceToCentre, "", reverseSetup, null, comments, lateralId, "", "", false, companyId, true, state, "", "", "", "", null, false, null, false, false, false, "", false, false, null);

                model.Save(workId, projectId, section_assetId, countryId, provinceId, countyId, cityId, videoLength, companyId, false, false, null);
            }
        }