public int InsertTextAndReturnPostID(Group group, Text_Post text_Post, Member member) { using (SqlConnection dbcon = new SqlConnection(ConnectionString)) { SqlCommand cmd = new SqlCommand("uspInsertTextAndReturnPostID", 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("@PostText", text_Post.PostText)); 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); } }
public void MoveShape(string postText, string sessionMemberID, int groupID) { memberID = sessionMemberID; StringBuilder htmlText = new StringBuilder(); Member aMember = new Member(memberID); htmlText.Append(postText); //htmlText.Replace("cat", "dog",); //htmlText.S //string[] parts = postText.Split(''); Text_Post aText_Post = new Text_Post(postText); Group aGroup = new Group(); aGroup.GroupId = groupID; int postId = postDAL.InsertText(aGroup, aText_Post, aMember); #region GET POST ArrayPosts = bl.GetASinglePost(postId); int count = ArrayPosts.Count; for (int i = 0; i < count; ++i) { OpenWrapper(i); #region TEXT POST GetTextPosts(); #endregion CloseWrapper(); } string postToClients = concatinater.ToString(); #endregion //Updating all Clients Clients.shapeMoved(Context.ConnectionId, postToClients, groupID); }
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; }
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); }
public int InsertTextAndReturnPostID(Group group, Text_Post text_Post, Member member) { using (SqlConnection dbcon = new SqlConnection(ConnectionString)) { SqlCommand cmd = new SqlCommand("uspInsertTextAndReturnPostID", 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("@PostText", text_Post.PostText)); 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; } }
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; }
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); }