public int InsertEvent(Event_Post events, Group group, Member member) { using (SqlConnection dbcon = new SqlConnection(ConnectionString)) { SqlCommand cmd = new SqlCommand("uspInsertEvent", 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("@EventName", events.EventName)); cmd.Parameters.Add(new SqlParameter("@EventDetails", events.EventDetails)); cmd.Parameters.Add(new SqlParameter("@EventVenue", events.EventVenue)); cmd.Parameters.Add(new SqlParameter("@StartDate", events.StartDate)); cmd.Parameters.Add(new SqlParameter("@EndDate", events.EndDate)); cmd.Parameters.Add(new SqlParameter("@Host", events.Host)); cmd.Parameters.Add(new SqlParameter("@EventType", events.EventType)); 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 List <Event_Post> GetEventName(Post post) { using (SqlConnection con = new SqlConnection(ConnectionString)) { SqlCommand cmd = new SqlCommand("uspGetEventName", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@PostID", post.PostId); List <Event_Post> EventList = new List <Event_Post>(); try { con.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Event_Post aEvent = new Event_Post(reader["EventName"].ToString()); EventList.Add(aEvent); }//End while reader.Close(); } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.Message.ToString()); } return(EventList); } }
public void AddEventPost(string sessionMemberID, string startDate, string endDate, string name, string host, string venue, int groupID, string details, string type) { memberID = sessionMemberID; StringBuilder htmlText = new StringBuilder(); Member aMember = new Member(memberID); Group aGroup = new Group(groupID); PostDAL postDAL = new PostDAL(); Reusable_Methods reusable_Methods = new Reusable_Methods(); /* * NEEDS ATTENTION !!!!!!!!! * * */ DateTime startDateD = reusable_Methods.CreateDateTime(startDate); DateTime endDateD = reusable_Methods.CreateDateTime(endDate); /* * END NEEDS ATTENTION !!!!!!!!! */ //DateTime startDateD = reusable_Methods.FormatDateFromDateTimePicker(startDate); // DateTime endDateD = reusable_Methods.FormatDateFromDateTimePicker(endDate); Event_Post aEvent_Post = new Event_Post(name, details, venue, startDateD, endDateD, host, type); int postId = postDAL.InsertEvent(aEvent_Post, aGroup, aMember); #region GET POST ArrayPosts = bl.GetASinglePost(postId); int count = ArrayPosts.Count; for (int i = 0; i < count; ++i) { OpenWrapper(i); #region EVENT POST GetEventPosts(); #endregion CloseWrapper(); } #endregion string postToClients = concatinater.ToString(); //Updating all Clients Clients.insertEvent(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 InsertEvent(Event_Post events, Group group, Member member) { using (SqlConnection dbcon = new SqlConnection(ConnectionString)) { SqlCommand cmd = new SqlCommand("uspInsertEvent", 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("@EventName", events.EventName)); cmd.Parameters.Add(new SqlParameter("@EventDetails", events.EventDetails)); cmd.Parameters.Add(new SqlParameter("@EventVenue", events.EventVenue)); cmd.Parameters.Add(new SqlParameter("@StartDate", events.StartDate)); cmd.Parameters.Add(new SqlParameter("@EndDate", events.EndDate)); cmd.Parameters.Add(new SqlParameter("@Host", events.Host)); cmd.Parameters.Add(new SqlParameter("@EventType", events.EventType)); 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 List<Event_Post> GetEventName(Post post) { using (SqlConnection con = new SqlConnection(ConnectionString)) { SqlCommand cmd = new SqlCommand("uspGetEventName", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@PostID", post.PostId); List<Event_Post> EventList = new List<Event_Post>(); try { con.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Event_Post aEvent = new Event_Post(reader["EventName"].ToString()); EventList.Add(aEvent); }//End while reader.Close(); } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.Message.ToString()); } return EventList; } }
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); }