コード例 #1
0
        /// <summary>
        /// Delete ProjectAssigned using ProjectAssigned Object
        /// </summary>
        /// <param name="projectassigned"></param>
        public void Delete(ProjectAssigned projectassigned)
        {
            if (Exists(projectassigned.Username))
            {
                string query = $"DELETE FROM {Table} WHERE Username = @username;";

                List <MySqlParameter> parameters = new List <MySqlParameter>
                {
                    new MySqlParameter("username", MySqlDbType.VarChar)
                    {
                        Value = projectassigned.Username
                    }
                };

                if (functions.ExecuteNonQuery(query, parameters))
                {
                    Debug.WriteLine("DeleteProjectAssigned: The projectassigned was deleted successfully.");
                }
                else
                {
                    Debug.WriteLine("DeleteProjectAssigned: An error has occured.");
                }
            }
            else
            {
                Debug.WriteLine("DeleteProjectAssigned: Cannot delete projectassigned");
            }
        }
コード例 #2
0
        /// <summary>
        /// Get ProjectAssigned Object From Sql Database
        /// </summary>
        /// <param name="username">Primary Key</param>
        /// <returns>ProjectAssigned Object</returns>
        public ProjectAssigned Get(string username)
        {
            if (Exists(username))
            {
                string query =
                    $"SELECT Username, Email, Name, ProjectId " +
                    $"FROM {Table} WHERE(Username = @username)";

                List <MySqlParameter> parameters = new List <MySqlParameter>
                {
                    new MySqlParameter("username", MySqlDbType.VarChar)
                    {
                        Value = username
                    }
                };

                if (functions.ExecuteReader(query, parameters, out DataTable dataTable))
                {
                    DataRow         row             = dataTable.Rows[0];
                    ProjectAssigned projectassigned = new ProjectAssigned
                    {
                        Username  = row["username"].ToString(),
                        Email     = row["email"].ToString(),
                        Name      = row["name"].ToString(),
                        ProjectId = row["projectid"].ToString()
                    };
                    return(projectassigned);
                }
                else
                {
                    Debug.WriteLine("GetProjectAssigned: An error has occured while trying to get projectassigned.");
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
コード例 #3
0
        /// <summary>
        /// Inserts ProjectAssigned into Sql Database
        /// </summary>
        /// <param name="projectassigned">ProjectAssigned Object</param>
        public void Insert(ProjectAssigned projectassigned)
        {
            if (!Exists(projectassigned.Username))
            {
                string query =
                    $"INSERT INTO {Table} (Username, Email, Name, ProjectId)" +
                    $" VALUES(@username, @email, @name, @projectid);";

                List <MySqlParameter> parameters = new List <MySqlParameter>
                {
                    new MySqlParameter("username", MySqlDbType.VarChar)
                    {
                        Value = projectassigned.Username
                    },
                    new MySqlParameter("email", MySqlDbType.VarChar)
                    {
                        Value = projectassigned.Email
                    },
                    new MySqlParameter("name", MySqlDbType.VarChar)
                    {
                        Value = projectassigned.Name
                    },
                    new MySqlParameter("projectid", MySqlDbType.VarChar)
                    {
                        Value = projectassigned.ProjectId
                    },
                };

                if (functions.ExecuteNonQuery(query, parameters))
                {
                    Debug.WriteLine("InsertProjectAssigned: The projectassigned was added successfully.");
                }
                else
                {
                    Debug.WriteLine("InsertProjectAssigned: An error has occured.");
                }
            }
        }