Ejemplo n.º 1
0
        public static void HapusData(string id)
        {
            DataTugas databaseObject = new DataTugas();

            databaseObject.OpenConnection();
            using (SQLiteCommand cmd = new SQLiteCommand(databaseObject.myConnection))
            {
                cmd.CommandText = "DELETE FROM DataTugas WHERE ID = @I";
                cmd.Prepare();
                cmd.Parameters.AddWithValue("@I", int.Parse(id));
                cmd.ExecuteNonQuery();
            }
            databaseObject.CloseConnection();
        }
Ejemplo n.º 2
0
        public static void InputData(Task task)
        {
            DataTugas databaseObject = new DataTugas();

            databaseObject.nama_tugas = task.nama;
            databaseObject.deadline   = task.deadline;
            databaseObject.kategori   = task.kategori;
            databaseObject.deskripsi  = task.deskripsi;

            /**
             * INSERT INTO DATABASE
             * *
             */
            databaseObject.OpenConnection();
            string        query = "INSERT INTO DataTugas ('NamaTugas','Deadline','Kategori','Deskripsi') VALUES ('" + databaseObject.nama_tugas + "', '" + databaseObject.deadline + "', '" + databaseObject.kategori + "',  '" + databaseObject.deskripsi + "' )";
            SQLiteCommand cmd   = new SQLiteCommand(query, databaseObject.myConnection);

            cmd.ExecuteNonQuery();
            databaseObject.CloseConnection();
        }
Ejemplo n.º 3
0
        public static void EditData(string nama, string deadline, string kategori, string deskripsi, string id)
        {
            DataTugas databaseObject = new DataTugas();

            databaseObject.OpenConnection();
            using (SQLiteCommand cmd = new SQLiteCommand(databaseObject.myConnection))
            {
                cmd.CommandText = "UPDATE DataTugas "
                                  + "SET NamaTugas = @N, Deadline = @D, Kategori = @K, Deskripsi = @Ds "
                                  + "WHERE Id = @I";
                cmd.Prepare();
                cmd.Parameters.AddWithValue("@I", int.Parse(id));
                cmd.Parameters.AddWithValue("@N", nama);
                cmd.Parameters.AddWithValue("@D", deadline);
                cmd.Parameters.AddWithValue("@K", kategori);
                cmd.Parameters.AddWithValue("@Ds", deskripsi);
                cmd.ExecuteNonQuery();
            }
            databaseObject.CloseConnection();
        }
Ejemplo n.º 4
0
        public static Task CariData(string id)
        {
            DataTugas     databaseObject = new DataTugas();
            SQLiteCommand sqCommand      = (SQLiteCommand)databaseObject.myConnection.CreateCommand();

            sqCommand.CommandText = "SELECT NamaTugas, Deadline, Kategori, Deskripsi FROM DataTugas WHERE Id = " + id;
            databaseObject.OpenConnection();
            SQLiteDataReader sqReader = sqCommand.ExecuteReader();
            Task             task     = new Task();

            while (sqReader.Read())
            {
                task.nama      = sqReader.GetString(0);
                task.deadline  = sqReader.GetString(1);
                task.kategori  = sqReader.GetString(2);
                task.deskripsi = sqReader.GetString(3);
            }
            sqReader.Close();
            databaseObject.CloseConnection();
            return(task);
        }