public int DeleteJoinProject(Member member) { try { con.Open(); string query = "DELETE FROM JoinProjects " + "WHERE JoineProjectID = @JoinProjectID OR UserID = @UserID OR ProjectID = @ProjectID"; SqlCommand cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@JoinProjectID", member.JoinProjectID); cmd.Parameters.AddWithValue("@UserID", member.UserID); cmd.Parameters.AddWithValue("@ProjectID", member.ProjectID); return cmd.ExecuteNonQuery(); } catch (SqlException i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } catch (Exception i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } finally { con.Close(); } }
public int InsertContact(Contact contact) { try { con.Open(); string query = "INSERT INTO Contacts " + "(User01 " + ",User02) "+ "VALUES " + "(@User01 " + ",@User02)"; SqlCommand cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@User01", contact.User01); cmd.Parameters.AddWithValue("@User02", contact.User02); return cmd.ExecuteNonQuery(); } catch (SqlException i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } catch (Exception i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } finally { con.Close(); } }
public int DeleteProject(Project project) { try { con.Open(); string query = "DELETE FROM Projects " + "WHERE ProjectID = @ProjectID OR ProjectName = @ProjectName OR OwnerUser = @OwnerUser"; SqlCommand cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@ProjectID", project.ProjectID); cmd.Parameters.AddWithValue("@ProjectName", project.ProjectName); cmd.Parameters.AddWithValue("@OwnerUser", project.OwnerUser); return cmd.ExecuteNonQuery(); } catch (SqlException i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } catch (Exception i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } finally { con.Close(); } }
public int DeleteMessage(Message message) { try { con.Open(); string query = "DELETE FROM Messages " + "WHERE MessageID = @MessageID OR Sender = @Sender OR Receiver = @Receiver "; SqlCommand cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@MessageID", message.MessageID); cmd.Parameters.AddWithValue("@Sender", message.Sender); cmd.Parameters.AddWithValue("@Receiver", message.Receiver); return cmd.ExecuteNonQuery(); } catch (SqlException i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } catch (Exception i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } finally { con.Close(); } }
public int DeleteState(State state) { try { con.Open(); string query = "DELETE FROM States " + "WHERE StateID = @StateID OR StateName = @StateName OR ProjectID = @ProjectID"; SqlCommand cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@StateID", state.StateID); cmd.Parameters.AddWithValue("@StateName", state.StateName); cmd.Parameters.AddWithValue("@ProjectID", state.ProjectID); return cmd.ExecuteNonQuery(); } catch (SqlException i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } catch (Exception i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } finally { con.Close(); } }
public int DeleteUser(User user) { try { con.Open(); string query = "DELETE FROM Users " + "WHERE UserID = @UserID OR Email = @Email"; SqlCommand cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@UserID", user.UserID); cmd.Parameters.AddWithValue("@Email", user.Email); return cmd.ExecuteNonQuery(); } catch (SqlException i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } catch (Exception i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } finally { con.Close(); } }
public int DeleteNotification(Notification notification) { try { con.Open(); string query = "DELETE FROM Notifications " + "WHERE NotificationID = @NotificationID OR UserID = @UserID "; SqlCommand cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@NotificationID", notification.NotificationID); cmd.Parameters.AddWithValue("@UserID", notification.UserID); return cmd.ExecuteNonQuery(); } catch (SqlException i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } catch (Exception i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } finally { con.Close(); } }
public int InsertNotification(Notification notification) { try { con.Open(); string query = "INSERT INTO Notifications " + "(UserID " + ",Content) " + "VALUES " + "(@UserID " + ",@Content)"; SqlCommand cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@UserID", notification.UserID); cmd.Parameters.AddWithValue("@Content", notification.Content); return cmd.ExecuteNonQuery(); } catch (SqlException i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } catch (Exception i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } finally { con.Close(); } }
public int DeleteComment(Comment comment) { try { con.Open(); string query = "DELETE FROM Comments " + "WHERE CommentID = @CommentID OR UserID = @UserID OR TaskID = @TaskID"; SqlCommand cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@CommentID", comment.CommentID); cmd.Parameters.AddWithValue("@UserID", comment.UserID); cmd.Parameters.AddWithValue("@TaskID", comment.TaskID); return cmd.ExecuteNonQuery(); } catch (SqlException i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } catch (Exception i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } finally { con.Close(); } }
public DataTable SelectGroup(int groupId, string lowercase, string uppercase) { try { con = new SqlConnection(connectionString); con.Open(); string query = "SELECT * " + "FROM Groups " + "WHERE GroupID = @GroupID OR Lowercase = @Lowercase OR Uppercase = Uppercase"; cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@GroupID", groupId); cmd.Parameters.AddWithValue("@Lowercase", lowercase); cmd.Parameters.AddWithValue("@Uppercase", uppercase); da = new SqlDataAdapter(cmd); ds = new DataSet(); da.Fill(ds, "Groups"); DataTable dt = ds.Tables["Groups"]; return dt; } catch (SqlException i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return null; } catch (Exception i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return null; } finally { con.Close(); } }
public int InsertComment(Comment comment) { try { con.Open(); string query = "INSERT INTO Comments " + "(Content " + ",UserID " + ",TaskID) " + "VALUES " + "(@Content " + ",@UserID " + ",@TaskID )"; SqlCommand cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@Content", comment.Content); cmd.Parameters.AddWithValue("@UserID", comment.UserID); cmd.Parameters.AddWithValue("@TaskID", comment.TaskID); return cmd.ExecuteNonQuery(); } catch (SqlException i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } catch (Exception i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } finally { con.Close(); } }
public int InsertMessage(Message message) { try { con.Open(); string query = "INSERT INTO Messages " + "(Sender " + ",Receiver " + ",Content) " + "VALUES " + "(@Sender " + ",@Receiver " + ",@Content)"; SqlCommand cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@Sender", message.Sender); cmd.Parameters.AddWithValue("@Receiver", message.Receiver); cmd.Parameters.AddWithValue("@Content", message.Content); return cmd.ExecuteNonQuery(); } catch (SqlException i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } catch (Exception i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } finally { con.Close(); } }
public int InsertJoinProject(Member member) { try { con.Open(); string query = "INSERT INTO JoinProjects " + "(ProjectID " + ",UserID " + ",RoleID) " + "VALUES " + "(@ProjectID " + ",@UserID " + ",@RoleID)"; SqlCommand cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@ProjectID", member.ProjectID); cmd.Parameters.AddWithValue("@UserID", member.UserID); cmd.Parameters.AddWithValue("@RoleID", member.RoleID); return cmd.ExecuteNonQuery(); } catch (SqlException i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } catch (Exception i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } finally { con.Close(); } }
public DataTable SelectGender(string genderId) { try { con = new SqlConnection(connectionString); con.Open(); string query = "SELECT * " + "FROM Genders " + "WHERE GenderID = @GenderID"; cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@GenderID", genderId); da = new SqlDataAdapter(cmd); ds = new DataSet(); da.Fill(ds, "Genders"); DataTable dt = ds.Tables["Genders"]; return dt; } catch (SqlException i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return null; } catch (Exception i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return null; } finally { con.Close(); } }
public DataTable SelectNotifiction(Notification notification) { try { con = new SqlConnection(connectionString); con.Open(); string query = "SELECT * " + "FROM Notifications " + "WHERE NotificationID = @NotificationID OR UserID = @UserID"; cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@NotificationID", notification.NotificationID); cmd.Parameters.AddWithValue("@UserID", notification.UserID); da = new SqlDataAdapter(cmd); ds = new DataSet(); da.Fill(ds, "Notifications"); DataTable dt = ds.Tables["Notifications"]; return dt; } catch (SqlException i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return null; } catch (Exception i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return null; } finally { con.Close(); } }
public int InsertProject(Project project) { try { con.Open(); string query = "INSERT INTO Projects " + "(ProjectName " + ",Description " + ",OwnerUser " + ",StartDate " + ",DueDate) " + "VALUES " + "(@ProjectName " + ",@Description " + ",@OwnerUser " + ",@StartDate " + ",@DueDate)"; SqlCommand cmd = new SqlCommand(query, con); cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@ProjectName", project.ProjectName); cmd.Parameters.AddWithValue("@Description", project.Description); cmd.Parameters.AddWithValue("@OwnerUser", project.OwnerUser); cmd.Parameters.AddWithValue("@StartDate", project.StartDate); cmd.Parameters.AddWithValue("@DueDate", project.DueDate); return cmd.ExecuteNonQuery(); } catch (SqlException i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } catch (Exception i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } finally { con.Close(); } }
public DataTable SelectUser(User user) { try { con = new SqlConnection(connectionString); con.Open(); string query = "SELECT * " + "FROM USers " + "WHERE UserID = @UserID OR Name = @Name OR GroupID = @GroupID OR " + "Email = @Email OR Password = @Password"; cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@UserID", user.UserID); cmd.Parameters.AddWithValue("@Name", user.Name); cmd.Parameters.AddWithValue("@GroupID", user.GroupID); cmd.Parameters.AddWithValue("@Email", user.Email); cmd.Parameters.AddWithValue("@Password", user.Password); da = new SqlDataAdapter(cmd); ds = new DataSet(); da.Fill(ds, "Users"); DataTable dt = ds.Tables["Users"]; return dt; } catch (SqlException i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return null; } catch (Exception i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return null; } finally { con.Close(); } }
public int InsertState(State state) { try { con.Open(); string query = "INSERT INTO States " + "(StateName " + ",Description " + ",ProjectID " + ",NextState " + ",StartDate " + ",DueDate) " + "VALUES " + "(@StateName " + ",@Description " + ",@ProjectID " + ",@NextState " + ",@StartDate " + ",@DueDate)"; SqlCommand cmd = new SqlCommand(query, con); cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@StateName", state.StateName); cmd.Parameters.AddWithValue("@Description", state.Description); cmd.Parameters.AddWithValue("@ProjectID", state.ProjectID); cmd.Parameters.AddWithValue("@NextState", state.NextState); cmd.Parameters.AddWithValue("@StartDate", state.StartDate); cmd.Parameters.AddWithValue("@DueDate", state.DueDate); return cmd.ExecuteNonQuery(); } catch (SqlException i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } catch (Exception i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } finally { con.Close(); } }
public int InsertUser(User user) { try { con.Open(); string query = "INSERT Users " + "(Name, " + "GroupID, " + "Email, " + "Password, " + "Avatar, " + "UserTypeId, " + "GenderID, " + "AuthenticationTypeID)" + "VALUES " + "(@Name, " + "@GroupID, " + "@Email, " + "@Password, " + "@Avatar, " + "@UserTypeId, " + "@GenderID, " + "@AuthenticationTypeID)"; SqlCommand cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@UserID", user.UserID); cmd.Parameters.AddWithValue("@Name", user.Name); cmd.Parameters.AddWithValue("@GroupID", user.GroupID); cmd.Parameters.AddWithValue("@Email", user.Email); cmd.Parameters.AddWithValue("@Password", user.Password); cmd.Parameters.AddWithValue("@Avatar", user.Avatar); cmd.Parameters.AddWithValue("@UserTypeID", user.UserTypeID); cmd.Parameters.AddWithValue("@AuthenticationTypeID", user.AuthenticationTypeID); return cmd.ExecuteNonQuery(); } catch (SqlException i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } catch (Exception i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } finally { con.Close(); } }
public int UpdateState(State state) { try { con.Open(); string query = "UPDATE States " + "SET StateName = @StateName " + ",Description = @Description " + ",ProjectID = @ProjectID " + ",NextState = @NextState " + ",StartDate = @StartDate " + ",DueDate = @DueDate " + "WHERE StateID = @StateID" ; SqlCommand cmd = new SqlCommand(query, con); cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@StateID", state.StateID); cmd.Parameters.AddWithValue("@StateName", state.StateName); cmd.Parameters.AddWithValue("@Description", state.Description); cmd.Parameters.AddWithValue("@ProjectID", state.ProjectID); cmd.Parameters.AddWithValue("@NextState", state.NextState); cmd.Parameters.AddWithValue("@StartDate", state.StartDate); cmd.Parameters.AddWithValue("@DueDate", state.DueDate); return cmd.ExecuteNonQuery(); } catch (SqlException i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } catch (Exception i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } finally { con.Close(); } }
public int InsertTask(Task task) { try { con.Open(); string query = "INSERT Tasks " + "(TaskName, " + "Description, " + "StateID, " + "ProjectID, " + "Comments, " + "Status, " + "StartDate, " + "DueDate)" + "VALUES " + "(@TaskName, " + "@Description, " + "@StateID, " + "@ProjectID, " + "@Comments, " + "@Status, " + "@StartDate, " + "@DueDate)"; SqlCommand cmd = new SqlCommand(query, con); cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@TaskName", task.TaskName); cmd.Parameters.AddWithValue("@Description", task.Description); cmd.Parameters.AddWithValue("@StateID", task.StateID); cmd.Parameters.AddWithValue("@ProjectID", task.ProjectID); cmd.Parameters.AddWithValue("@Comments", task.Comments); cmd.Parameters.AddWithValue("@Status", task.Status); cmd.Parameters.AddWithValue("@StartDate", task.StartDate); cmd.Parameters.AddWithValue("@DueDate", task.DueDate); return cmd.ExecuteNonQuery(); } catch (SqlException i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } catch (Exception i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } finally { con.Close(); } }
public DataTable SelectComment(Comment comment) { try { con = new SqlConnection(connectionString); con.Open(); string query = "SELECT * " + "FROM Comments " + "WHERE CommentID = @CommentID OR UserID = @UserID OR TaskID = @TaskID"; cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@CommentID", comment.CommentID); cmd.Parameters.AddWithValue("@UserID", comment.UserID); cmd.Parameters.AddWithValue("@TaskID", comment.TaskID); da = new SqlDataAdapter(cmd); ds = new DataSet(); da.Fill(ds, "Comments"); DataTable dt = ds.Tables["Comments"]; return dt; } catch (SqlException i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return null; } catch (Exception i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return null; } finally { con.Close(); } }
public DataTable SelectProject(Project project) { try { con = new SqlConnection(connectionString); con.Open(); string query = "SELECT * " + "FROM Projects " + "WHERE ProjectID = @ProjectID OR ProjectName = @ProjectName OR OwnerUser = @OwnerUser"; cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@ProjectID", project.ProjectID); cmd.Parameters.AddWithValue("@ProjectName", project.ProjectName); cmd.Parameters.AddWithValue("@OwnerUser", project.OwnerUser); da = new SqlDataAdapter(cmd); ds = new DataSet(); da.Fill(ds, "Projects"); DataTable dt = ds.Tables["Projects"]; return dt; } catch (SqlException i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return null; } catch (Exception i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return null; } finally { con.Close(); } }
public DataTable SelectMessage(Message message) { try { con = new SqlConnection(connectionString); con.Open(); string query = "SELECT * " + "FROM Messages " + "WHERE MessageID = @MessageID OR Sender = @Sender OR Receiver = @Receiver "; cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@MessageID", message.MessageID); cmd.Parameters.AddWithValue("@Sender", message.Sender); cmd.Parameters.AddWithValue("@Receiver", message.Receiver); da = new SqlDataAdapter(cmd); ds = new DataSet(); da.Fill(ds, "Messages"); DataTable dt = ds.Tables["Messages"]; return dt; } catch (SqlException i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return null; } catch (Exception i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return null; } finally { con.Close(); } }
public int UpdateProject(Project project) { try { con.Open(); string query = "UPDATE Projects " + "SET ProjectName = @ProjectName " + ",Description = @Description " + ",OwnerUser = @OwnerUser " + ",StartDate = @StartDate " + ",DueDate = @DueDate " + "WHERE ProjectID = @ProjectID"; SqlCommand cmd = new SqlCommand(query, con); cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@ProjectID", project.ProjectID); cmd.Parameters.AddWithValue("@ProjectName", project.ProjectName); cmd.Parameters.AddWithValue("@Description", project.Description); cmd.Parameters.AddWithValue("@OwnerUser", project.OwnerUser); cmd.Parameters.AddWithValue("@StartDate", project.StartDate); cmd.Parameters.AddWithValue("@DueDate", project.DueDate); return cmd.ExecuteNonQuery(); } catch (SqlException i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } catch (Exception i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return 0; } finally { con.Close(); } }
public DataTable SelectJoinProject(Member member) { try { con = new SqlConnection(connectionString); con.Open(); string query = "SELECT * " + "FROM JoinProjects " + "WHERE JoinProjectID = @JoinProjectID OR ProjectID = @ProjectID OR UserID = @UserID OR RoleID = @RoleID"; cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@JoinProjectID", member.JoinProjectID); cmd.Parameters.AddWithValue("@ProjectID", member.ProjectID); cmd.Parameters.AddWithValue("@UserID", member.UserID); cmd.Parameters.AddWithValue("@RoleID", member.RoleID); da = new SqlDataAdapter(cmd); ds = new DataSet(); da.Fill(ds, "JoinProjects"); DataTable dt = ds.Tables["JoinProjects"]; return dt; } catch (SqlException i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return null; } catch (Exception i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return null; } finally { con.Close(); } }
public DataTable SelectState(State state) { try { con = new SqlConnection(connectionString); con.Open(); string query = "SELECT * " + "FROM States " + "WHERE StateID = @StateID OR StateName = @StateName OR ProjectID = @ProjectID"; cmd = new SqlCommand(query, con); cmd.Parameters.AddWithValue("@StateID", state.StateID); cmd.Parameters.AddWithValue("@StateName", state.StateName); cmd.Parameters.AddWithValue("@ProjectID", state.ProjectID); da = new SqlDataAdapter(cmd); ds = new DataSet(); da.Fill(ds, "States"); DataTable dt = ds.Tables["States"]; return dt; } catch (SqlException i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return null; } catch (Exception i) { Logs logging = new Logs(); logging.InsertLog(new Log()); return null; } finally { con.Close(); } }