public bool UpdateData(int Idx, int CollectionFileId, int CollectionId, string FileName, string FileUrl, int ListOrder, string Description, string Tags, string Status, DateTime CreatedOnDate, string IPLog, string UserLog, string UserLastUpdate) { using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString)) { context.DeferredLoadingEnabled = false; Gallery_File file = new Gallery_File(); file.FileId = Idx; file.FileName = FileName; file.FileUrl = FileUrl; file.Description = Description; file.ListOrder = ListOrder; file.UserLog = Guid.Parse(UserLog); file.UserLastUpdate = Guid.Parse(UserLastUpdate); file.CreatedOnDate = CreatedOnDate; file.LastModifieddDate = System.DateTime.Now; file.Status = Convert.ToChar(Status); file.Tags = Tags; file.IPLog = IPLog; file.IPLastUpdate = IP; ChangeSet changeSet = null; int changeCount = 0; context.Gallery_Files.Attach(file); context.Refresh(RefreshMode.KeepCurrentValues, file); changeSet = context.GetChangeSet(); changeCount = changeSet.Updates.Count; context.SubmitChanges(); bool result = false; if (changeCount > 0) { Gallery_Collection_File collection_file = new Gallery_Collection_File(); collection_file.CollectionFileId = CollectionFileId; collection_file.CollectionId = CollectionId; collection_file.FileId = Idx; context.Gallery_Collection_Files.Attach(collection_file); context.Refresh(RefreshMode.KeepCurrentValues, collection_file); context.SubmitChanges(); result = true; } return(result); } }
public bool UpdateData(int Idx, int TopicId, string Title, string IconFile, string Description, int ListOrder, string Tags, string Url, string UserLog, string UserLastUpdate, DateTime CreatedOnDate, string IPLog, string Status) { using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString)) { context.Connection.Open(); Gallery_Collection collection_obj = new Gallery_Collection(); collection_obj.CollectionId = Idx; collection_obj.TopicId = TopicId; collection_obj.Title = Title; collection_obj.IconFile = IconFile; collection_obj.Description = Description; collection_obj.ListOrder = ListOrder; collection_obj.UserLog = Guid.Parse(UserLog); collection_obj.UserLastUpdate = Guid.Parse(UserLastUpdate); collection_obj.CreatedOnDate = CreatedOnDate; collection_obj.LastModifieddDate = DateTime.Now; collection_obj.Status = Convert.ToChar(Status); collection_obj.Tags = Tags; collection_obj.Url = Url; collection_obj.IPLog = IPLog; collection_obj.IPLastUpdate = IP; ChangeSet changeSet = null; int changeCount = 0; DbTransaction trans = context.Connection.BeginTransaction(); try { context.Transaction = trans; context.Gallery_Collections.Attach(collection_obj); context.Refresh(RefreshMode.KeepCurrentValues, collection_obj); changeSet = context.GetChangeSet(); changeCount = changeSet.Updates.Count; context.SubmitChanges(); trans.Commit(); } catch (Exception ex) { if (trans != null) { trans.Rollback(); } throw ex; } finally { if (context.Connection != null && context.Connection.State == System.Data.ConnectionState.Open) { context.Connection.Close(); } } if (changeCount > 0) { return(true); } else { return(false); } } }