コード例 #1
0
ファイル: BuiltOnSql.cs プロジェクト: N-ickJones/Archive
        public void Insert(BuiltOn builtOn)
        {
            if (!Exists(builtOn.ProjectId))
            {
                string query =
                    "INSERT INTO builtOn (ProjectId, TaskId)" +
                    " VALUES(@projectid, @taskid);";

                List <MySqlParameter> parameters = new List <MySqlParameter>
                {
                    new MySqlParameter("projectid", MySqlDbType.VarChar)
                    {
                        Value = builtOn.ProjectId
                    },
                    new MySqlParameter("taskid", MySqlDbType.VarChar)
                    {
                        Value = builtOn.TaskId
                    },
                };

                if (functions.ExecuteNonQuery(query, parameters))
                {
                    Debug.WriteLine("InsertBuiltOn: The builtOn was added successfully.");
                }
                else
                {
                    Debug.WriteLine("InsertBuiltOn: An error has occured.");
                }
            }
        }
コード例 #2
0
ファイル: BuiltOnSql.cs プロジェクト: N-ickJones/Archive
        public void Delete(BuiltOn builtOn)
        {
            if (Exists(builtOn.ProjectId))
            {
                string query = "DELETE FROM builtOn WHERE ProjectId = @projectid;";

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

                if (functions.ExecuteNonQuery(query, parameters))
                {
                    Debug.WriteLine("DeleteBuiltOn: The builtOn was deleted successfully.");
                }
                else
                {
                    Debug.WriteLine("DeleteBuiltOn: An error has occured.");
                }
            }
            else
            {
                Debug.WriteLine("DeleteBuiltOn: Cannot delete builtOn");
            }
        }
コード例 #3
0
ファイル: BuiltOnSql.cs プロジェクト: N-ickJones/Archive
        public BuiltOn Get(string projectid)
        {
            if (Exists(projectid))
            {
                string query =
                    "SELECT ProjectId, TaskId " +
                    "FROM builtOn WHERE(ProjectId = @projectid)";

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

                if (functions.ExecuteReader(query, parameters, out DataTable dataTable))
                {
                    DataRow row     = dataTable.Rows[0];
                    BuiltOn builtOn = new BuiltOn
                    {
                        ProjectId = row["projectid"].ToString(),
                        TaskId    = row["taskid"].ToString(),
                    };
                    return(builtOn);
                }
                else
                {
                    Debug.WriteLine("GetBuiltOn: An error has occured while trying to get builtOn.");
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }