Esempio n. 1
0
        public int InsertFile(File_Post file_Post, Group group, Member member)
        {
            using (SqlConnection dbcon = new SqlConnection(ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("uspInsertFile", dbcon);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add(new SqlParameter("@GroupID", group.GroupId));
                cmd.Parameters.Add(new SqlParameter("@MemberID", member.MemberId));
                cmd.Parameters.Add(new SqlParameter("@File", file_Post.File));
                cmd.Parameters.Add(new SqlParameter("@FileName", file_Post.FileName));
                cmd.Parameters.Add(new SqlParameter("@FileCaption", file_Post.FileCaption));
                cmd.Parameters.Add(new SqlParameter("@FileSize", file_Post.FileSize));

                SqlParameter returnValue = new SqlParameter("@Return_Value", DbType.Int32);
                returnValue.Direction = ParameterDirection.ReturnValue;

                cmd.Parameters.Add(returnValue);
                int postId = 0;
                try
                {
                    dbcon.Open();
                    cmd.ExecuteNonQuery();
                    postId = Int32.Parse(cmd.Parameters["@Return_Value"].Value.ToString());
                }
                catch (SqlException e)
                {
                    MessageBox.Show(e.ToString());
                }
                return(postId);
            }
        }
Esempio n. 2
0
        protected void SaveFile(AjaxFileUploadEventArgs file)
        {
            byte[] fileBytes = file.GetContents();
            string fileName  = file.FileName.Split('\\').Last();

            File_Post filePost = new File_Post();
            Group     g        = new Group();
            PostDAL   postDAl  = new PostDAL();

            aMember.MemberId = (string)Session["memberID"];
            g.GroupId        = int.Parse(ThisGroupsID.Value);


            filePost.File     = fileBytes;
            filePost.FileName = fileName;
            filePost.FileSize = file.FileSize;

            filePost.FileCaption = captionP;

            postDAl.InsertFile(filePost, g, aMember);
        }
Esempio n. 3
0
        public ArrayList GetPost(Post post)
        {
            ArrayList custArray;
            using (SqlConnection dbConnection = new SqlConnection(ConnectionString))
            {
                SqlCommand dbCommand = new SqlCommand("uspGetPost", dbConnection);
                dbCommand.CommandType = CommandType.StoredProcedure;
                dbCommand.Parameters.Add(new SqlParameter("@PostID", post.PostId));
                dbCommand.Parameters.Add(new SqlParameter("@PostType", post.PostType));

                dbConnection.Open();
                SqlDataReader dbReader = dbCommand.ExecuteReader();
                custArray = new ArrayList();

                if (post.PostType == "Event")
                {
                    while (dbReader.Read())
                    {
                        Event_Post aCountry = new Event_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["EventName"].ToString(), dbReader["EventDetails"].ToString(), dbReader["EventVenue"].ToString(), DateTime.Parse(dbReader["StartDate"].ToString()), DateTime.Parse(dbReader["EndDate"].ToString()), dbReader["Host"].ToString(), dbReader["EventType"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "Text")
                {
                    while (dbReader.Read())
                    {
                        Text_Post aCountry = new Text_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["PostText"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "Photo")
                {
                    while (dbReader.Read())
                    {

                        Photo_Post aCountry = new Photo_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["PhotoCaption"].ToString(), dbReader["PhotoName"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                //else if (post.PostType == "Article")
                //{
                //    while (dbReader.Read())
                //    {
                //        Article_Post aCountry = new Article_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["Title"].ToString(), dbReader["ArticleText"].ToString());
                //        custArray.Add(aCountry);
                //    }
                //}
                else if (post.PostType == "Video")
                {
                    while (dbReader.Read())
                    {
                        Video_Post aCountry = new Video_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["VideoCaption"].ToString(), long.Parse(dbReader["VideoSize"].ToString()), dbReader["VideoName"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "File")
                {
                    while (dbReader.Read())
                    {
                        File_Post aCountry = new File_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["FileCaption"].ToString(), long.Parse(dbReader["FileSize"].ToString()), dbReader["FileName"].ToString());
                        custArray.Add(aCountry);
                    }
                }

                dbConnection.Close();
            }
            return custArray;
        }
Esempio n. 4
0
        public ArrayList GetPost(Post post)
        {
            ArrayList custArray;

            using (SqlConnection dbConnection = new SqlConnection(ConnectionString))
            {
                SqlCommand dbCommand = new SqlCommand("uspGetPost", dbConnection);
                dbCommand.CommandType = CommandType.StoredProcedure;
                dbCommand.Parameters.Add(new SqlParameter("@PostID", post.PostId));
                dbCommand.Parameters.Add(new SqlParameter("@PostType", post.PostType));

                dbConnection.Open();
                SqlDataReader dbReader = dbCommand.ExecuteReader();
                custArray = new ArrayList();

                if (post.PostType == "Event")
                {
                    while (dbReader.Read())
                    {
                        Event_Post aCountry = new Event_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["EventName"].ToString(), dbReader["EventDetails"].ToString(), dbReader["EventVenue"].ToString(), DateTime.Parse(dbReader["StartDate"].ToString()), DateTime.Parse(dbReader["EndDate"].ToString()), dbReader["Host"].ToString(), dbReader["EventType"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "Text")
                {
                    while (dbReader.Read())
                    {
                        Text_Post aCountry = new Text_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["PostText"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "Photo")
                {
                    while (dbReader.Read())
                    {
                        Photo_Post aCountry = new Photo_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["PhotoCaption"].ToString(), dbReader["PhotoName"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                //else if (post.PostType == "Article")
                //{
                //    while (dbReader.Read())
                //    {
                //        Article_Post aCountry = new Article_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["Title"].ToString(), dbReader["ArticleText"].ToString());
                //        custArray.Add(aCountry);
                //    }
                //}
                else if (post.PostType == "Video")
                {
                    while (dbReader.Read())
                    {
                        Video_Post aCountry = new Video_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["VideoCaption"].ToString(), long.Parse(dbReader["VideoSize"].ToString()), dbReader["VideoName"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "File")
                {
                    while (dbReader.Read())
                    {
                        File_Post aCountry = new File_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["FileCaption"].ToString(), long.Parse(dbReader["FileSize"].ToString()), dbReader["FileName"].ToString());
                        custArray.Add(aCountry);
                    }
                }

                dbConnection.Close();
            }
            return(custArray);
        }
Esempio n. 5
0
        public int InsertFile(File_Post file_Post, Group group, Member member)
        {
            using (SqlConnection dbcon = new SqlConnection(ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("uspInsertFile", dbcon);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add(new SqlParameter("@GroupID", group.GroupId));
                cmd.Parameters.Add(new SqlParameter("@MemberID", member.MemberId));
                cmd.Parameters.Add(new SqlParameter("@File", file_Post.File));
                cmd.Parameters.Add(new SqlParameter("@FileName", file_Post.FileName));
                cmd.Parameters.Add(new SqlParameter("@FileCaption", file_Post.FileCaption));
                cmd.Parameters.Add(new SqlParameter("@FileSize", file_Post.FileSize));

                SqlParameter returnValue = new SqlParameter("@Return_Value", DbType.Int32);
                returnValue.Direction = ParameterDirection.ReturnValue;

                cmd.Parameters.Add(returnValue);
                int postId = 0;
                try
                {
                    dbcon.Open();
                    cmd.ExecuteNonQuery();
                    postId = Int32.Parse(cmd.Parameters["@Return_Value"].Value.ToString());
                }
                catch (SqlException e)
                {
                    MessageBox.Show(e.ToString());
                }
                return postId;
            }
        }
Esempio n. 6
0
        public ArrayList GetPostCaption(Post post)
        {
            ArrayList custArray;
            using (SqlConnection dbConnection = new SqlConnection(ConnectionString))
            {
                SqlCommand dbCommand = new SqlCommand("uspGetPostCaption", dbConnection);
                dbCommand.CommandType = CommandType.StoredProcedure;
                dbCommand.Parameters.Add(new SqlParameter("@PostID", post.PostId));
                dbCommand.Parameters.Add(new SqlParameter("@PostType", post.PostType));

                dbConnection.Open();
                SqlDataReader dbReader = dbCommand.ExecuteReader();
                custArray = new ArrayList();

                if (post.PostType == "Event")
                {
                    while (dbReader.Read())
                    {
                        Event_Post aCountry = new Event_Post(dbReader["EventName"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "Text")
                {
                    while (dbReader.Read())
                    {
                        Text_Post aCountry = new Text_Post(dbReader["PostText"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "Photo")
                {
                    while (dbReader.Read())
                    {
                        Photo_Post aCountry = new Photo_Post(dbReader["PhotoCaption"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "Article")
                {
                    while (dbReader.Read())
                    {
                        Article_Post aCountry = new Article_Post(dbReader["Title"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "Video")
                {
                    while (dbReader.Read())
                    {
                        Video_Post aCountry = new Video_Post(dbReader["VideoCaption"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "File")
                {
                    while (dbReader.Read())
                    {
                        File_Post aCountry = new File_Post(dbReader["FileCaption"].ToString());
                        custArray.Add(aCountry);
                    }
                }

                dbConnection.Close();
            }
            return custArray;
        }
Esempio n. 7
0
        public ArrayList GetPostCaption(Post post)
        {
            ArrayList custArray;

            using (SqlConnection dbConnection = new SqlConnection(ConnectionString))
            {
                SqlCommand dbCommand = new SqlCommand("uspGetPostCaption", dbConnection);
                dbCommand.CommandType = CommandType.StoredProcedure;
                dbCommand.Parameters.Add(new SqlParameter("@PostID", post.PostId));
                dbCommand.Parameters.Add(new SqlParameter("@PostType", post.PostType));

                dbConnection.Open();
                SqlDataReader dbReader = dbCommand.ExecuteReader();
                custArray = new ArrayList();

                if (post.PostType == "Event")
                {
                    while (dbReader.Read())
                    {
                        Event_Post aCountry = new Event_Post(dbReader["EventName"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "Text")
                {
                    while (dbReader.Read())
                    {
                        Text_Post aCountry = new Text_Post(dbReader["PostText"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "Photo")
                {
                    while (dbReader.Read())
                    {
                        Photo_Post aCountry = new Photo_Post(dbReader["PhotoCaption"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "Article")
                {
                    while (dbReader.Read())
                    {
                        Article_Post aCountry = new Article_Post(dbReader["Title"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "Video")
                {
                    while (dbReader.Read())
                    {
                        Video_Post aCountry = new Video_Post(dbReader["VideoCaption"].ToString());
                        custArray.Add(aCountry);
                    }
                }
                else if (post.PostType == "File")
                {
                    while (dbReader.Read())
                    {
                        File_Post aCountry = new File_Post(dbReader["FileCaption"].ToString());
                        custArray.Add(aCountry);
                    }
                }

                dbConnection.Close();
            }
            return(custArray);
        }