public int Save(YunShanOA.Model.DocumentModel.DocumentApply myDocumentApply) { Document u; bool found = false; if (myDocumentApply.DocumentID == -1) { // new record u = new Document(); db.Document.InsertOnSubmit(u); found = true; } else { // existing record u = (from myDocumentApplys in db.Document where myDocumentApplys.DocumentID == myDocumentApply.DocumentID select myDocumentApplys).FirstOrDefault(); if (u != null) { found = true; u.DocumentID = myDocumentApply.DocumentID; } } if (found) { u.Status = myDocumentApply.Status; u.WFID = myDocumentApply.WFID; u.DocumentName = myDocumentApply.DocumentName; u.DocumentPath = myDocumentApply.DocumentPath; u.DocumentAuthor = myDocumentApply.Author; try { db.SubmitChanges(); } catch (ChangeConflictException) { db.ChangeConflicts.ResolveAll(RefreshMode.OverwriteCurrentValues); db.SubmitChanges(); } return u.DocumentID; } else return -1; }
partial void DeleteDocument(Document instance);
partial void UpdateDocument(Document instance);
partial void InsertDocument(Document instance);
private Model.DocumentModel.DocumentApply Fillrecord(Document item) { DocumentApply d = null; if (item != null) { d = new DocumentApply(); d.DocumentID = item.DocumentID; d.Author = item.DocumentAuthor; d.DocumentPath = item.DocumentPath; d.Status = item.Status; d.WFID = item.WFID; d.DocumentName = item.DocumentName; } return d; }