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 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;
            }
        }