コード例 #1
0
        /// <summary>
        /// Save all comments to database (direct)
        /// </summary>
        /// <param name="companyId">companyId</param>
        public void Save(int companyId)
        {
            PointRepairsTDS pointRepairsChanges = (PointRepairsTDS)Data.GetChanges();

            if (pointRepairsChanges.CommentDetails.Rows.Count > 0)
            {
                PointRepairsCommentDetailsGateway pointRepairsCommentDetailsGateway = new PointRepairsCommentDetailsGateway(pointRepairsChanges);

                foreach (PointRepairsTDS.CommentDetailsRow row in (PointRepairsTDS.CommentDetailsDataTable)pointRepairsChanges.CommentDetails)
                {
                    // Insert new comment
                    if ((!row.Deleted) && (!row.InDatabase))
                    {
                        int workId = row.WorkID;
                        int refId = row.RefID;
                        int? libraryFilesId = null; if (!row.IsLIBRARY_FILES_IDNull()) libraryFilesId = row.LIBRARY_FILES_ID;

                        WorkComments workComments = new WorkComments(null);
                        workComments.InsertDirect(workId, refId, row.Type, row.Subject, row.UserID, row.DateTime_, row.Comment, libraryFilesId, row.Deleted, row.COMPANY_ID, row.WorkType);
                    }

                    // Update comment
                    if ((!row.Deleted) && (row.InDatabase))
                    {
                        int workId = row.WorkID;
                        int refId = row.RefID;
                        int originalCompanyId = companyId;
                        string type = row.Type;
                        int? libraryFilesId = null; if (!row.IsLIBRARY_FILES_IDNull()) libraryFilesId = row.LIBRARY_FILES_ID;
                        string workType = row.WorkType;

                        // Original values
                        string originalSubject = pointRepairsCommentDetailsGateway.GetSubjectOriginal(workId, refId);
                        int originalUserId = pointRepairsCommentDetailsGateway.GetUserIdOriginal(workId, refId);
                        DateTime originalDateTime_ = pointRepairsCommentDetailsGateway.GetDateTime_Original(workId, refId);
                        string originalComment = pointRepairsCommentDetailsGateway.GetCommentOriginal(workId, refId);
                        bool originalDeleted = pointRepairsCommentDetailsGateway.GetDeletedOriginal(workId, refId);

                        // New values
                        string newSubject = pointRepairsCommentDetailsGateway.GetSubject(workId, refId);
                        string newComment = pointRepairsCommentDetailsGateway.GetComment(workId, refId);

                        WorkComments workComments = new WorkComments(null);
                        workComments.UpdateDirect(workId, refId, type, originalSubject, originalUserId, originalDateTime_, originalComment, libraryFilesId, originalDeleted, originalCompanyId, workType,  workId, refId, type, newSubject, originalUserId, originalDateTime_, newComment, libraryFilesId, originalDeleted, companyId, workType);
                    }

                    // Delete comment
                    if ((row.Deleted) && (row.InDatabase))
                    {
                        int workId = row.WorkID;
                        int refId = row.RefID;

                        WorkComments workComments = new WorkComments(null);
                        workComments.DeleteDirect(workId, refId, row.COMPANY_ID);
                    }
                }
            }
        }
コード例 #2
0
 // ////////////////////////////////////////////////////////////////////////
 // PUBLIC METHODS
 //
 /// <summary>
 /// LoadAllByWorkIdWorkType
 /// </summary>
 /// <param name="workId">workId</param>              
 /// <param name="companyId">companyId</param>
 /// <param name="workType">workType</param>
 public void LoadAllByWorkIdWorkType(int workId, int companyId, string workType)
 {
     PointRepairsCommentDetailsGateway pointRepairsCommentDetailsGateway = new PointRepairsCommentDetailsGateway(Data);
     pointRepairsCommentDetailsGateway.LoadAllByWorkIdWorkType(workId, companyId, workType);
 }