private void GrdCommentsAdd() { if (ValidateCommentsFooter()) { Page.Validate("commentsDataAdd"); if (Page.IsValid) { int workId = Int32.Parse(hdfWorkId.Value); int workIdFll = Int32.Parse(hdfWorkIdFll.Value.Trim()); int companyId = Int32.Parse(hdfCompanyId.Value); int loginId = Convert.ToInt32(Session["loginID"]); DateTime dateTime_ = DateTime.Now; bool inDatabase = false; bool toHistory = false; bool deleted = false; string workType = hdfWorkType.Value; string newSubject = ((TextBox)grdComments.FooterRow.FindControl("tbxSubjectNew")).Text.Trim(); string newType = ((DropDownList)grdComments.FooterRow.FindControl("ddlTypeNew")).SelectedValue.ToString().Trim(); string newComment = ((TextBox)grdComments.FooterRow.FindControl("tbxCommentsNew")).Text.Trim(); int? libraryFilesId = null; if (((Label)grdComments.FooterRow.FindControl("lblLIBRARY_FILES_IDNew")).Text != "") libraryFilesId = Int32.Parse(((Label)grdComments.FooterRow.FindControl("lblLIBRARY_FILES_IDNew")).Text.Trim()); LoginGateway loginGateway = new LoginGateway(); loginGateway.LoadByLoginId(loginId, companyId); string userFullName = loginGateway.GetLastName(loginId, companyId) + " " + loginGateway.GetFirstName(loginId, companyId); if (newType == "Rehab Assessment") { RehabAssessmentCommentDetails model = new RehabAssessmentCommentDetails(rehabAssessmentTDS); model.Insert(workId, newType, newSubject, loginId, dateTime_, newComment, libraryFilesId, deleted, companyId, inDatabase, userFullName, toHistory, workType); } else { if (workIdFll != 0) { RehabAssessmentCommentDetails model = new RehabAssessmentCommentDetails(rehabAssessmentTDS); model.Insert(workIdFll, newType, newSubject, loginId, dateTime_, newComment, libraryFilesId, deleted, companyId, inDatabase, userFullName, toHistory, workType); } } Session.Remove("rehabAssessmentCommentDetailsDummy"); Session["rehabAssessmentTDS"] = rehabAssessmentTDS; Session["rehabAssessmentCommentDetails"] = rehabAssessmentTDS.CommentDetails; grdComments.DataBind(); grdComments.PageIndex = grdComments.PageCount - 1; } } }
public void UpdateDataToCorrectDataSet(int workIdRa, int workIdFll, RehabAssessmentCommentDetails raCommentDetails, FullLengthLiningCommentDetails fllCommentDetails, string workType) { foreach (RehabAssessmentTDS.CommentDetailsRow row in (RehabAssessmentTDS.CommentDetailsDataTable)Table) { int workId = row.WorkID; string type = row.Type; string subject = row.Subject; int loginId = row.UserID; DateTime dateTime_ = row.DateTime_; string comment = row.Comment; int? libraryFilesId = null; if (!row.IsLIBRARY_FILES_IDNull() ) libraryFilesId = row.LIBRARY_FILES_ID; bool deleted = row.Deleted; int companyId = row.COMPANY_ID; bool inDatabase = row.InDatabase; string userFullName = row.UserFullName; bool toHistory = row.ToHistory; if (row.WorkID == workIdRa) { raCommentDetails.Insert(workId, type, subject, loginId, dateTime_, comment, libraryFilesId, deleted, companyId, inDatabase, userFullName, toHistory, workType); } else { if (row.WorkID == workIdFll) { fllCommentDetails.Insert(workId, type, subject, loginId, dateTime_, comment, libraryFilesId, deleted, companyId, inDatabase, userFullName, toHistory, workType); } } } }