/// <summary> /// Save all comments to database (direct) /// </summary> /// <param name="companyId">companyId</param> public void Save(int companyId) { FullLengthLiningTDS fullLengthLiningCommentDetailsChanges = (FullLengthLiningTDS)Data.GetChanges(); if (fullLengthLiningCommentDetailsChanges.CommentDetails.Rows.Count > 0) { FullLengthLiningCommentDetailsGateway fullLengthLiningCommentDetailsGateway = new FullLengthLiningCommentDetailsGateway(fullLengthLiningCommentDetailsChanges); foreach (FullLengthLiningTDS.CommentDetailsRow row in (FullLengthLiningTDS.CommentDetailsDataTable)fullLengthLiningCommentDetailsChanges.CommentDetails) { // Insert new comments if ((!row.Deleted) && (!row.InDatabase)) { WorkComments workComments = new WorkComments(null); int? libraryFilesId = null; if (!row.IsLIBRARY_FILES_IDNull()) libraryFilesId = row.LIBRARY_FILES_ID; workComments.InsertDirect(row.WorkID, row.RefID, row.Type, row.Subject, row.UserID, row.DateTime_, row.Comment, libraryFilesId, row.Deleted, row.COMPANY_ID, row.WorkType); } // Update comments if ((!row.Deleted) && (row.InDatabase)) { int workId = row.WorkID; int refId = row.RefID; bool originalDeleted = false; int originalCompanyId = companyId; // original values string originalType = fullLengthLiningCommentDetailsGateway.GetTypeOriginal(workId, refId); string originalSubject = fullLengthLiningCommentDetailsGateway.GetSubjectOriginal(workId, refId); int originalUserId = fullLengthLiningCommentDetailsGateway.GetUserIdOriginal(workId, refId); DateTime? originalDateTime = null; if (fullLengthLiningCommentDetailsGateway.GetDateTime_Original(workId, refId) != null) originalDateTime = fullLengthLiningCommentDetailsGateway.GetDateTime_Original(workId, refId); string originalComment = fullLengthLiningCommentDetailsGateway.GetCommentOriginal(workId, refId); int? originalLibraryFilesId = null; if (fullLengthLiningCommentDetailsGateway.GetLIBRARY_FILES_IDOriginal(workId, refId) != null) originalLibraryFilesId = fullLengthLiningCommentDetailsGateway.GetLIBRARY_FILES_IDOriginal(workId, refId); string originalWorkType = fullLengthLiningCommentDetailsGateway.GetWorkTypeOriginal(workId, refId); // new values string newType = fullLengthLiningCommentDetailsGateway.GetType(workId, refId); string newSubject = fullLengthLiningCommentDetailsGateway.GetSubject(workId, refId); string newComment = fullLengthLiningCommentDetailsGateway.GetComment(workId, refId); int? newLibraryFilesId = null; if (fullLengthLiningCommentDetailsGateway.GetLIBRARY_FILES_IDOriginal(workId, refId) != null) originalLibraryFilesId = fullLengthLiningCommentDetailsGateway.GetLIBRARY_FILES_ID(workId, refId); WorkComments workComments = new WorkComments(null); workComments.UpdateDirect(workId, refId, originalType, originalSubject, originalUserId, originalDateTime, originalComment, originalLibraryFilesId, originalDeleted, originalCompanyId, originalWorkType, workId, refId, newType, newSubject, originalUserId, originalDateTime, newComment, newLibraryFilesId, originalDeleted, originalCompanyId, originalWorkType); } // Deleted comments if ((row.Deleted) && (row.InDatabase)) { WorkComments workComments = new WorkComments(null); workComments.DeleteDirect(row.WorkID, row.RefID, row.COMPANY_ID); } } } }
protected void grdComments_RowDataBound(object sender, GridViewRowEventArgs e) { if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Normal) || ((e.Row.RowState == DataControlRowState.Alternate)))) { if (((Label)e.Row.FindControl("lblUserId")).Text != "") { int loginId = Int32.Parse(hdfLoginId.Value); bool adminPermission = bool.Parse(hdfAdminPermission.Value); int rowUserId = Int32.Parse(((Label)e.Row.FindControl("lblUserId")).Text); if ((loginId == rowUserId) || (adminPermission)) { e.Row.FindControl("ibtnDelete").Visible = true; e.Row.FindControl("ibtnEdit").Visible = true; } else { e.Row.FindControl("ibtnDelete").Visible = false; e.Row.FindControl("ibtnEdit").Visible = false; } } } if ((e.Row.RowType == DataControlRowType.DataRow) && ((e.Row.RowState == DataControlRowState.Edit) || (e.Row.RowState == (DataControlRowState.Edit | DataControlRowState.Alternate)))) { int workId = Int32.Parse(((Label)e.Row.FindControl("lblWorkID")).Text.Trim()); int refId = Int32.Parse(((Label)e.Row.FindControl("lblRefID")).Text.Trim()); FullLengthLiningCommentDetailsGateway fullLengthLiningCommentDetailsGateway = new FullLengthLiningCommentDetailsGateway(fullLengthLiningTDS); string type = fullLengthLiningCommentDetailsGateway.GetType(workId, refId); if (type != "Rehab Assessment") { ((TextBox)e.Row.FindControl("tbxTypeEdit")).Visible = false; ((DropDownList)e.Row.FindControl("ddlTypeEdit")).SelectedValue = type; ((DropDownList)e.Row.FindControl("ddlTypeEdit")).Visible = true; } else { ((TextBox)e.Row.FindControl("tbxTypeEdit")).Text = type; ((TextBox)e.Row.FindControl("tbxTypeEdit")).Visible = true; ((DropDownList)e.Row.FindControl("ddlTypeEdit")).Visible = false; ((DropDownList)e.Row.FindControl("ddlTypeEdit")).SelectedValue = "M1"; } } }