private DocRecordFollow CreateNewDocFollow() { DocRecordFollow follow = new DocRecordFollow(); follow.Id = GenerateFollowId(DocId); follow.DocRecodId = DocId; follow.FollowContent = FollowContent; follow.FollowDate = FollowDate; return(follow); }
private void DataGridRow_MouseDoubleClick(object sender, MouseButtonEventArgs e) { DataGridRow selectedRow = sender as DataGridRow; if (selectedRow != null) { DocRecordFollow recordFollow = selectedRow.Item as DocRecordFollow; if (recordFollow != null) { _controller.OnSelectedFollowChanged(recordFollow); } } }
protected override void Save() { if (!IsValid()) { string msg = string.Empty; foreach (var error in Errors) { msg += error.Value?.FirstOrDefault() ?? ""; msg += "\n"; } Helper.ShowMessage(msg); return; } try { using (IUnitOfWork unit = new UnitOfWork()) { DocRecordFollow follow = null; if (string.IsNullOrEmpty(FollowId)) { follow = CreateNewDocFollow(); unit.DocRecordFollows.Add(follow); DocRecordFile file = CreateDocFile(DocId, follow.Id, FollowPath); unit.DocRecordFiles.Add(file); } else { follow = unit.DocRecordFollows.GetById(FollowId); DocRecordFile file = unit.DocRecordFiles.Query(x => x.DocFollowId == FollowId).SingleOrDefault(); if (file != null) { UpdateDocFile(file, FollowPath); } else { var docFile = CreateDocFile(follow.DocRecodId, follow.Id, FollowPath); unit.DocRecordFiles.Add(docFile); } UpdateDocFollow(follow); } unit.Save(); FollowId = follow.Id; ControlState(ControllerStates.Saved); } } catch (Exception ex) { Helper.LogShowError(ex); } }
public void OnSelectedFollowChanged(DocRecordFollow recordFollow) { try { FollowId = recordFollow.Id; FollowDate = recordFollow.FollowDate; FollowContent = recordFollow.FollowContent; string followFilePath = GetFollowFile(FollowId); if (!string.IsNullOrEmpty(followFilePath)) { FollowPath = Path.Combine(_docRecordFolder, GetFollowFile(FollowId)); } else { FollowPath = string.Empty; } ControlState(ControllerStates.Saved); } catch (Exception ex) { Helper.LogShowError(ex); } }
private void UpdateDocFollow(DocRecordFollow follow) { follow.FollowContent = FollowContent; follow.FollowDate = FollowDate; }