Answer to Question #226143 in Java | JSP | JSF for Binura Thiranjaya

Question #226143

To develop Java application and use Java Swing using below

requirements.


Tutora is an educational institute which provides education and

research to country. Currently their entire business process is

operated with books and emails. As a startup company your group has

been hired to automate the manual process of Tutora. The following

main business requirements has been discussed by the client. Implement

a java Swing Application to automate the business requirements.


Build a java program with java swing to Manage Student Registration Issues that can do this tasks (Add,Update,Remove)



1
Expert's answer
2021-08-15T04:05:57-0400
package com.example.tutora.models.sampledata;
	

	import android.content.ContentValues;
	import android.content.Context;
	import android.database.Cursor;
	import android.database.sqlite.SQLiteDatabase;
	

	

	

	public class Student extends database {
	

	    public Student(Context context) {
	        super(context);
	    }
	

	    public boolean insert(String username,String email,String password,int path){
	        SQLiteDatabase database = this.getWritableDatabase();
	        ContentValues contentValues =  new ContentValues();
	        contentValues.put("username",username);
	        contentValues.put("email",email);
	        contentValues.put("password",password);
	        contentValues.put("image",path);
	        if (database.insert("Student",null,contentValues) != -1){
	            return true;
	        }
	

	        return  false;
	    }
	

	    public Cursor getStudent(String username){
	        SQLiteDatabase database = this.getReadableDatabase();
	        Cursor cursor = database.rawQuery("select * from Student where username = ?", new String[]{username});
	        cursor.moveToFirst();
	        return cursor;
	    }
	

	    public boolean isExist(String username,String password){
	        SQLiteDatabase database = this.getReadableDatabase();
	        Cursor cursor = database.rawQuery("select username,password from Student where username=? and password = ?",new String[]{username,password});
	        if(cursor.getCount() == 1){
	            return  true;
	        }
	        return  false;
	    }
	}



public class Course extends database {
    public Course(Context context) {        super(context);    }

    public boolean insert(String name, String category, int rate, String time, double price, int path){        SQLiteDatabase database = this.getWritableDatabase();        ContentValues content = new ContentValues();        content.put("name",name);        content.put("time",time);        content.put("category",category);        content.put("rate",rate);        content.put("price",price);        content.put("image",path);        if(database.insert("Course",null,content) != -1){            database.close();            return true;        }        return  false;    }
    public Cursor getCategory(String category){        SQLiteDatabase database= this.getReadableDatabase();        Cursor cursor = database.rawQuery("select * from Course where category = ?",new String[]{category});        cursor.moveToFirst();        return cursor;    }
}



public class Lesson  extends database {
	

	    public Lesson(Context context) {
	        super(context);
	    }
	

	    public boolean insert(String name, String link,String time,int courseId,String reference, String task, int path){
	        SQLiteDatabase database= this.getWritableDatabase();
	        ContentValues contentValues = new ContentValues();
	        contentValues.put("link",link);
	        contentValues.put("name",name);
	        contentValues.put("courseId",courseId);
	        contentValues.put("reference",reference);
	        contentValues.put("time",time);
	        contentValues.put("task",task);
	        contentValues.put("image",path);
	

	        if(database.insert("Lesson",null,contentValues) != -1){
	            database.close();
	            return true;
	        }
	        return  false;
	    }
	

	    public Cursor getLessons(int id){
	        SQLiteDatabase database = this.getReadableDatabase();
	        Cursor cursor = database.rawQuery("select * from Lesson where id = ?",new String[]{""+id});
	        cursor.moveToFirst();
	        return cursor;
	    }
	

	}



public class database extends SQLiteOpenHelper{
	

	    public static final String DATABASE_NAME = "Tutor.db";
	    public database(Context context) {
	        super(context,DATABASE_NAME,null,1);
	    }
	

	    @Override
	    public void onCreate(SQLiteDatabase db) {
	        db.execSQL("create table Course(id integer primary key autoincrement,name text,time text,category text,price DECIMAL(7,3),image integer,rate integer)");
	        db.execSQL("create table Lesson (id integer primary key autoincrement,name text,link text,courseId integer, time text, reference text,task text,image integer, foreign key (courseId) references Course(id) )");
	        db.execSQL("create table CourseEnrolled (id integer primary key autoincrement, courseId integer,completedLesson inegter, foreign key (courseId) references Course(id))");
	        db.execSQL("create table Student(username text primary key,email text,password text,image integer)");
	        db.execSQL("create table Login(username text primary key)");
	

	    }
	

	    @Override
	    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
	

	    }
	}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Binura Thiranjaya
16.08.21, 06:05

Thank You , How can i contact you.

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS