Пример #1
0
        public void Delete(int Idx)
        {
            using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
            {
                context.CommandTimeout         = Settings.CommandTimeout;
                context.DeferredLoadingEnabled = false;
                Gallery_File gallery_obj = context.Gallery_Files.Single(p => p.FileId == Idx);
                context.Gallery_Files.DeleteOnSubmit(gallery_obj);

                Gallery_Collection_File collection_file_obj = context.Gallery_Collection_Files.Single(p => p.FileId == Idx);
                context.Gallery_Collection_Files.DeleteOnSubmit(collection_file_obj);
                context.SubmitChanges();
            }
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        public bool InsertData(int CollectionId, string FileName, string FileUrl,
                               string Description, string UserLog, string Status, string Tags)
        {
            using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
            {
                int?ListOrder = (int?)context.Gallery_Collections.Max(x => (int?)x.CollectionId) ?? 0;

                Gallery_File file = new Gallery_File();
                file.FileName      = FileName;
                file.FileUrl       = FileUrl;
                file.ListOrder     = ListOrder + 1;
                file.Description   = Description;
                file.UserLog       = Guid.Parse(UserLog);
                file.CreatedOnDate = System.DateTime.Now;
                file.Status        = Convert.ToChar(Status);
                file.Tags          = Tags;
                file.IPLog         = IP;

                bool result = false;
                context.DeferredLoadingEnabled = false;
                context.Gallery_Files.InsertOnSubmit(file);
                context.SubmitChanges();
                int FileId = file.FileId;
                if (FileId > 0)
                {
                    Gallery_Collection_File collection_file = new Gallery_Collection_File();
                    collection_file.CollectionId = CollectionId;
                    collection_file.FileId       = FileId;

                    context.Gallery_Collection_Files.InsertOnSubmit(collection_file);
                    context.SubmitChanges();
                    result = true;
                }
                return(result);
            }
        }
Пример #4
0
 partial void DeleteGallery_File(Gallery_File instance);
Пример #5
0
 partial void UpdateGallery_File(Gallery_File instance);
Пример #6
0
 partial void InsertGallery_File(Gallery_File instance);