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);
            }
        }
Exemple #2
0
 public void Delete(int Idx)
 {
     using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
     {
         context.CommandTimeout         = Settings.CommandTimeout;
         context.DeferredLoadingEnabled = false;
         Gallery_Collection collection_obj = context.Gallery_Collections.Single(p => p.CollectionId == Idx);
         context.Gallery_Collections.DeleteOnSubmit(collection_obj);
         context.SubmitChanges();
     }
 }
 public static int?InsertData(Gallery_Topic entity)
 {
     using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
     {
         int?   o_return = 0;
         string UserLog  = Convert.ToString(entity.UserLog);
         var    q        = context.Gallery_Topics_Insert(UserLog, IP, entity.Gallery_TopicName,
                                                         entity.Alias, entity.ParentId, entity.Description, entity.Status, ref o_return);
         context.SubmitChanges();
         return(o_return);
     }
 }
        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);
            }
        }
        public void UpdateStatus(string userid, int fileid, char status)
        {
            using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
            {
                var query = from x in context.Gallery_Files
                            where x.FileId == fileid
                            select x;

                foreach (Gallery_File file in query)
                {
                    file.Status            = status;
                    file.UserLastUpdate    = Guid.Parse(userid);
                    file.IPLastUpdate      = IP;
                    file.LastModifieddDate = System.DateTime.Now;
                }
                context.SubmitChanges();
            }
        }
Exemple #6
0
        public void UpdateStatus(string userid, int topicid, char status)
        {
            using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
            {
                var query = from x in context.Gallery_Collections
                            where x.CollectionId == topicid
                            select x;

                foreach (Gallery_Collection cllection in query)
                {
                    cllection.Status            = status;
                    cllection.IPLastUpdate      = IP;
                    cllection.UserLastUpdate    = Guid.Parse(userid);
                    cllection.LastModifieddDate = System.DateTime.Now;
                }
                context.SubmitChanges();
            }
        }
        public void UpdateStatus(string userid, int topicid, char status)
        {
            using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
            {
                var query = from x in context.Gallery_Topics
                            where x.Gallery_TopicId == topicid
                            select x;

                foreach (Gallery_Topic topic in query)
                {
                    topic.Status          = status;
                    topic.IPLastUpdate    = IP;
                    topic.UserLastUpdate  = Guid.Parse(userid);
                    topic.LastUpdatedDate = System.DateTime.Now;
                }
                context.SubmitChanges();
            }
        }
Exemple #8
0
        public bool InsertData(int TopicId, string Title, string IconFile, string Description, string Tags, string Url,
                               string UserLog, string Status)
        {
            using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
            {
                System.Nullable <Int32> ListOrder  = (int?)context.Gallery_Collections.Max(x => (int?)x.CollectionId) ?? 0;
                Gallery_Collection      collection = new Gallery_Collection();
                collection.TopicId           = TopicId;
                collection.Title             = Title;
                collection.IconFile          = IconFile;
                collection.Description       = Description;
                collection.ListOrder         = ListOrder + 1;
                collection.UserLog           = Guid.Parse(UserLog);
                collection.UserLastUpdate    = Guid.Parse(UserLog);
                collection.CreatedOnDate     = System.DateTime.Now;
                collection.LastModifieddDate = System.DateTime.Now;
                collection.Status            = Convert.ToChar(Status);
                collection.Tags         = Tags;
                collection.Url          = Url;
                collection.IPLog        = IP;
                collection.IPLastUpdate = IP;


                context.Gallery_Collections.InsertOnSubmit(collection);
                context.SubmitChanges();
                int newCollectionId = collection.CollectionId;
                if (newCollectionId > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Exemple #9
0
        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);
                }
            }
        }