Ejemplo n.º 1
0
        protected void grdRepairs_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            // Control of footer row
            if (e.Row.RowType == DataControlRowType.Footer)
            {
                // For LT @ MH and VT @ MH
                DropDownList ddlPlLtmh = (DropDownList)e.Row.FindControl("ddlPlLtmhNew");
                DropDownList ddlPlVtmh = (DropDownList)e.Row.FindControl("ddlPlVtmhNew");

                ddlPlLtmh.Items.Add("");
                ddlPlLtmh.Items.Add(hdfUSMH.Value);
                ddlPlLtmh.Items.Add(hdfDSMH.Value);
                ddlPlLtmh.SelectedIndex = 0;

                ddlPlVtmh.Items.Add("");
                ddlPlVtmh.Items.Add(hdfUSMH.Value);
                ddlPlVtmh.Items.Add(hdfDSMH.Value);
                ddlPlVtmh.SelectedIndex = 0;
            }

            // Control of edit rows
            if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Edit) || (e.Row.RowState == (DataControlRowState.Edit | DataControlRowState.Alternate))))
            {
                // For LT @ MH and VT @ MH
                DropDownList ddlPlLtmh = (DropDownList)e.Row.FindControl("ddlPlLtmhEdit");
                DropDownList ddlPlVtmh = (DropDownList)e.Row.FindControl("ddlPlVtmhEdit");

                ddlPlLtmh.Items.Add("");
                ddlPlLtmh.Items.Add(hdfUSMH.Value);
                ddlPlLtmh.Items.Add(hdfDSMH.Value);
                ddlPlLtmh.SelectedValue = ((HiddenField)e.Row.FindControl("hdfPlLtmhEdit")).Value;

                ddlPlVtmh.Items.Add("");
                ddlPlVtmh.Items.Add(hdfUSMH.Value);
                ddlPlVtmh.Items.Add(hdfDSMH.Value);
                ddlPlVtmh.SelectedValue = ((HiddenField)e.Row.FindControl("hdfPlVtmhEdit")).Value;

                // For Defect qualifier and defect details
                string repairType = ((Label)e.Row.FindControl("lblRepairType")).Text;
                int workId = Int32.Parse(((Label)e.Row.FindControl("lblWorkID")).Text);
                string repairPointId = ((Label)e.Row.FindControl("lblRepairPointID")).Text;

                PointRepairsRepairDetailsGateway pointRepairsRepairDetailsGateway = new PointRepairsRepairDetailsGateway(pointRepairsTDS);

                switch (repairType)
                {
                    case "Robotic Reaming":
                        ((DropDownList)e.Row.FindControl("ddlRmDefectQualifierEdit")).SelectedValue = pointRepairsRepairDetailsGateway.GetDefectQualifier(workId, repairPointId);
                        ((DropDownList)e.Row.FindControl("ddlRmDefectDetailsEdit")).SelectedValue = pointRepairsRepairDetailsGateway.GetDefectDetails(workId, repairPointId);
                        ((DropDownList)e.Row.FindControl("ddlPlDefectQualifierEdit")).SelectedValue = "";
                        ((DropDownList)e.Row.FindControl("ddlPlDefectDetailsEdit")).SelectedValue = "";
                        ((DropDownList)e.Row.FindControl("ddlGtDefectQualifierEdit")).SelectedValue = "";
                        ((DropDownList)e.Row.FindControl("ddlGtDefectDetailsEdit")).SelectedValue = "";
                        break;

                    case "Point Lining":
                        ((DropDownList)e.Row.FindControl("ddlPlDefectQualifierEdit")).SelectedValue = pointRepairsRepairDetailsGateway.GetDefectQualifier(workId, repairPointId);
                        ((DropDownList)e.Row.FindControl("ddlPlLengthEdit")).SelectedValue = pointRepairsRepairDetailsGateway.GetLength(workId, repairPointId);
                        ((DropDownList)e.Row.FindControl("ddlPlSize_Edit")).SelectedValue = pointRepairsRepairDetailsGateway.GetSize_(workId, repairPointId);
                        ((DropDownList)e.Row.FindControl("ddlPlDefectDetailsEdit")).SelectedValue = pointRepairsRepairDetailsGateway.GetDefectDetails(workId, repairPointId);
                        ((DropDownList)e.Row.FindControl("ddlRmDefectQualifierEdit")).SelectedValue = "";
                        ((DropDownList)e.Row.FindControl("ddlRmDefectDetailsEdit")).SelectedValue = "";
                        ((DropDownList)e.Row.FindControl("ddlGtDefectQualifierEdit")).SelectedValue = "";
                        ((DropDownList)e.Row.FindControl("ddlGtDefectDetailsEdit")).SelectedValue = "";
                        break;

                    case "Grouting":
                        ((DropDownList)e.Row.FindControl("ddlGtDefectQualifierEdit")).SelectedValue = pointRepairsRepairDetailsGateway.GetDefectQualifier(workId, repairPointId);
                        ((DropDownList)e.Row.FindControl("ddlGtDefectDetailsEdit")).SelectedValue = pointRepairsRepairDetailsGateway.GetDefectDetails(workId, repairPointId);
                        ((DropDownList)e.Row.FindControl("ddlRmDefectQualifierEdit")).SelectedValue = "";
                        ((DropDownList)e.Row.FindControl("ddlRmDefectDetailsEdit")).SelectedValue = "";
                        ((DropDownList)e.Row.FindControl("ddlPlDefectQualifierEdit")).SelectedValue = "";
                        ((DropDownList)e.Row.FindControl("ddlPlDefectDetailsEdit")).SelectedValue = "";
                        break;
                }
            }
        }
        /// <summary>
        /// UpdateForProcess
        /// </summary>
        private void UpdateForProcess()
        {
            // Load comments
            foreach (PointRepairsTDS.RepairDetailsRow row in (PointRepairsTDS.RepairDetailsDataTable)Table)
            {
                PointRepairsRepairDetailsGateway pointRepairsRepairDetailsGateway = new PointRepairsRepairDetailsGateway();
                pointRepairsRepairDetailsGateway.LoadAllByWorkIdRepairPointId(row.WorkID, row.RepairPointID, row.COMPANY_ID);
                row.Comments = pointRepairsRepairDetailsGateway.GetComments(row.WorkID, row.RepairPointID);
            }

            // Format comments
            foreach (PointRepairsTDS.RepairDetailsRow row in (PointRepairsTDS.RepairDetailsDataTable)Table)
            {
                if (!row.IsCommentsNull())
                {
                    row.Comments = row.Comments.Replace("<br>", "\n");
                }
            }
        }
 /// <summary>
 /// LoadAllByWorkIdRepairPointId
 /// </summary>
 /// <param name="workId">workId</param>
 /// <param name="repairPointId">repairPointId</param>
 /// <param name="companyId">companyId</param>
 public void LoadAllByWorkIdRepairPointId(int workId, string repairPointId, int companyId)
 {
     PointRepairsRepairDetailsGateway pointRepairsRepairDetailsGateway = new PointRepairsRepairDetailsGateway(Data);
     pointRepairsRepairDetailsGateway.LoadAllByWorkIdRepairPointId(workId, repairPointId, companyId);
 }
        /// <summary>
        /// Save all repairs to database (direct)
        /// </summary>
        /// <param name="companyId">companyId</param>
        public void Save(int companyId)
        {
            PointRepairsTDS pointRepairsChanges = (PointRepairsTDS)Data.GetChanges();

            if (pointRepairsChanges.RepairDetails.Rows.Count > 0)
            {
                PointRepairsRepairDetailsGateway pointRepairsRepairDetailsGateway = new PointRepairsRepairDetailsGateway(pointRepairsChanges);

                foreach (PointRepairsTDS.RepairDetailsRow row in (PointRepairsTDS.RepairDetailsDataTable)pointRepairsChanges.RepairDetails)
                {
                    // Insert new repair
                    if ((!row.Deleted) && (!row.InDatabase))
                    {
                        int workId = row.WorkID;
                        string repairPointId = row.RepairPointID;
                        string reamDistance = ""; if (!row.IsReamDistanceNull()) reamDistance = row.ReamDistance;
                        DateTime? reamDate = null; if (!row.IsReamDateNull()) reamDate = row.ReamDate;
                        string linerDistance = ""; if (!row.IsLinerDistanceNull()) linerDistance = row.LinerDistance;
                        string direction = ""; if (!row.IsDirectionNull()) direction = row.Direction;
                        int? reinstates = null; if (!row.IsReinstatesNull()) reinstates = row.Reinstates;
                        string ltmh = ""; if (!row.IsLTMHNull()) ltmh = row.LTMH;
                        string vtmh = ""; if (!row.IsVTMHNull()) vtmh = row.VTMH;
                        string distance = ""; if (!row.IsDistanceNull()) distance = row.Distance;
                        string size_ = ""; if (!row.IsSize_Null()) size_ = row.Size_;
                        DateTime? installDate = null; if (!row.IsInstallDateNull()) installDate = row.InstallDate;
                        string mhshot = ""; if (!row.IsMHShotNull()) mhshot = row.MHShot;
                        string groutDistance = ""; if (!row.IsGroutDistanceNull()) groutDistance = row.GroutDistance;
                        DateTime? groutDate = null; if (!row.IsGroutDateNull()) groutDate = row.GroutDate;
                        string approval = ""; if (!row.IsApprovalNull()) approval = row.Approval;
                        bool extraRepair = row.ExtraRepair;
                        bool cancelled = row.Cancelled;
                        string comments = ""; if (!row.IsCommentsNull()) comments = row.Comments;
                        string defectQualifier = ""; if (!row.IsDefectQualifierNull()) defectQualifier = row.DefectQualifier;
                        string defectDetails = ""; if (!row.IsDefectDetailsNull()) defectDetails = row.DefectDetails;
                        string length = ""; if (!row.IsLengthNull()) length = row.Length;
                        DateTime? reinstateDate = null; if (!row.IsReinstateDateNull()) reinstateDate = row.ReinstateDate;

                        WorkPointRepairsRepair workPointRepairsRepair = new WorkPointRepairsRepair(null);
                        workPointRepairsRepair.InsertDirect(workId, repairPointId, row.Type, reamDistance, reamDate, linerDistance, direction, reinstates, ltmh, vtmh, distance, size_, installDate, mhshot, groutDistance, groutDate, approval, extraRepair, cancelled, comments, row.Deleted, row.COMPANY_ID, defectQualifier, defectDetails, length, reinstateDate);
                    }

                    // Update repair
                    if ((!row.Deleted) && (row.InDatabase))
                    {
                        int workId = row.WorkID;
                        string repairPointId = row.RepairPointID;
                        string type = row.Type;

                        // Original values
                        string originalReamDistance = pointRepairsRepairDetailsGateway.GetReamDistanceOriginal(workId, repairPointId);
                        DateTime? originalReamDate = null; if (pointRepairsRepairDetailsGateway.GetReamDateOriginal(workId, repairPointId).HasValue) originalReamDate = pointRepairsRepairDetailsGateway.GetReamDateOriginal(workId, repairPointId);
                        string originalLinerDistance = pointRepairsRepairDetailsGateway.GetLinerDistanceOriginal(workId, repairPointId);
                        string originalDirection = pointRepairsRepairDetailsGateway.GetDirectionOriginal(workId, repairPointId);
                        int? originalReinstates = null; if (pointRepairsRepairDetailsGateway.GetReinstatesOriginal(workId, repairPointId).HasValue) originalReinstates = pointRepairsRepairDetailsGateway.GetReinstatesOriginal(workId, repairPointId);
                        string originalLtmh = pointRepairsRepairDetailsGateway.GetLTMHOriginal(workId, repairPointId);
                        string originalVtmh = pointRepairsRepairDetailsGateway.GetVTMHOriginal(workId, repairPointId);
                        string originalDistance = pointRepairsRepairDetailsGateway.GetDistanceOriginal(workId, repairPointId);
                        string originalSize_ = pointRepairsRepairDetailsGateway.GetSize_Original(workId, repairPointId);
                        DateTime? originalInstallDate = null; if (pointRepairsRepairDetailsGateway.GetInstallDateOriginal(workId, repairPointId).HasValue) originalInstallDate = pointRepairsRepairDetailsGateway.GetInstallDateOriginal(workId, repairPointId);
                        string originalMhShot = pointRepairsRepairDetailsGateway.GetMHShotOriginal(workId, repairPointId);
                        string originalGroutDistance = pointRepairsRepairDetailsGateway.GetGroutDistanceOriginal(workId, repairPointId);
                        DateTime? originalGroutDate = null; if (pointRepairsRepairDetailsGateway.GetGroutDateOriginal(workId, repairPointId).HasValue) originalGroutDate = pointRepairsRepairDetailsGateway.GetGroutDateOriginal(workId, repairPointId);
                        string originalApproval = pointRepairsRepairDetailsGateway.GetApprovalOriginal(workId, repairPointId);
                        bool originalExtraRepair = pointRepairsRepairDetailsGateway.GetExtraRepairOriginal(workId, repairPointId);
                        bool originalCancelled = pointRepairsRepairDetailsGateway.GetCancelledOriginal(workId, repairPointId);
                        string originalComments = pointRepairsRepairDetailsGateway.GetCommentsOriginal(workId, repairPointId);
                        string originalDefectQualifier = pointRepairsRepairDetailsGateway.GetDefectQualifierOriginal(workId, repairPointId);
                        string originalDefectDetails = pointRepairsRepairDetailsGateway.GetDefectDetailsOriginal(workId, repairPointId);
                        string originalLength = pointRepairsRepairDetailsGateway.GetLengthOriginal(workId, repairPointId);
                        DateTime? originalReinstateDate = null; if (pointRepairsRepairDetailsGateway.GetReinstateDateOriginal(workId, repairPointId).HasValue) originalReinstateDate = pointRepairsRepairDetailsGateway.GetReinstateDateOriginal(workId, repairPointId);

                        // New values
                        string newReamDistance = pointRepairsRepairDetailsGateway.GetReamDistance(workId, repairPointId);
                        DateTime? newReamDate = null; if (pointRepairsRepairDetailsGateway.GetReamDate(workId, repairPointId).HasValue) newReamDate = pointRepairsRepairDetailsGateway.GetReamDate(workId, repairPointId);
                        string newLinerDistance = pointRepairsRepairDetailsGateway.GetLinerDistance(workId, repairPointId);
                        string newDirection = pointRepairsRepairDetailsGateway.GetDirection(workId, repairPointId);
                        int? newReinstates = null; if (pointRepairsRepairDetailsGateway.GetReinstates(workId, repairPointId).HasValue) newReinstates = pointRepairsRepairDetailsGateway.GetReinstates(workId, repairPointId);
                        string newLtmh = pointRepairsRepairDetailsGateway.GetLTMH(workId, repairPointId);
                        string newVtmh = pointRepairsRepairDetailsGateway.GetVTMH(workId, repairPointId);
                        string newDistance = pointRepairsRepairDetailsGateway.GetDistance(workId, repairPointId);
                        string newSize_ = pointRepairsRepairDetailsGateway.GetSize_(workId, repairPointId);
                        DateTime? newInstallDate = null; if (pointRepairsRepairDetailsGateway.GetInstallDate(workId, repairPointId).HasValue) newInstallDate = pointRepairsRepairDetailsGateway.GetInstallDate(workId, repairPointId);
                        string newMhShot = pointRepairsRepairDetailsGateway.GetMHShot(workId, repairPointId);
                        string newGroutDistance = pointRepairsRepairDetailsGateway.GetGroutDistance(workId, repairPointId);
                        DateTime? newGroutDate = null; if (pointRepairsRepairDetailsGateway.GetGroutDate(workId, repairPointId).HasValue) newGroutDate = pointRepairsRepairDetailsGateway.GetGroutDate(workId, repairPointId);
                        string newApproval = pointRepairsRepairDetailsGateway.GetApproval(workId, repairPointId);
                        bool newExtraRepair = pointRepairsRepairDetailsGateway.GetExtraRepair(workId, repairPointId);
                        bool newCancelled = pointRepairsRepairDetailsGateway.GetCancelled(workId, repairPointId);
                        string newComments = pointRepairsRepairDetailsGateway.GetComments(workId, repairPointId);
                        string newDefectQualifier = pointRepairsRepairDetailsGateway.GetDefectQualifier(workId, repairPointId);
                        string newDefectDetails = pointRepairsRepairDetailsGateway.GetDefectDetails(workId, repairPointId);
                        string newLength = pointRepairsRepairDetailsGateway.GetLength(workId, repairPointId);
                        DateTime? newReinstateDate = null; if (pointRepairsRepairDetailsGateway.GetReinstateDate(workId, repairPointId).HasValue) newReinstateDate = pointRepairsRepairDetailsGateway.GetReinstateDate(workId, repairPointId);

                        WorkPointRepairsRepair workPointRepairsRepair = new WorkPointRepairsRepair(null);
                        workPointRepairsRepair.Updatedirect(workId, repairPointId, type, originalReamDistance, originalReamDate, originalLinerDistance, originalDirection, originalReinstates, originalLtmh, originalVtmh, originalDistance, originalSize_, originalInstallDate, originalMhShot, originalGroutDistance, originalGroutDate, originalApproval, originalExtraRepair, originalCancelled, originalComments, false, companyId, originalDefectQualifier, originalDefectDetails, originalLength, workId, repairPointId, type, newReamDistance, newReamDate, newLinerDistance, newDirection, newReinstates, newLtmh, newVtmh, newDistance, newSize_, newInstallDate, newMhShot, newGroutDistance, newGroutDate, newApproval, newExtraRepair, newCancelled, newComments, false, companyId, newDefectQualifier, newDefectDetails, newLength, originalReinstateDate, newReinstateDate);

                    }

                    // Delete repair
                    if ((row.Deleted) && (row.InDatabase))
                    {
                        int workId = row.WorkID;
                        string repairPointId = row.RepairPointID;

                        WorkPointRepairsRepair workPointRepairsRepair = new WorkPointRepairsRepair(null);
                        workPointRepairsRepair.DeleteDirect(workId, repairPointId, row.COMPANY_ID);
                    }
                }
            }
        }
        // ////////////////////////////////////////////////////////////////////////
        // PUBLIC METHODS
        //
        /// <summary>
        /// LoadAllByWorkId
        /// </summary>
        /// <param name="workId">workId</param>
        /// <param name="companyId">companyId</param>
        public void LoadAllByWorkId(int workId, int companyId)
        {
            PointRepairsRepairDetailsGateway pointRepairsRepairDetailsGateway = new PointRepairsRepairDetailsGateway(Data);
            pointRepairsRepairDetailsGateway.LoadAllByWorkId(workId, companyId);

            UpdateForProcess();
        }