You are on page 1of 17

SCHOOL OF INFORMATION TECHNOLOGY &

ENGINEERING

COURSE CODE: SWE1007


COURSE NAME: PROGRAMMING IN JAVA
SLOT: D2+TD2 AND L35+L36

PROJECT TITLE: OFFLINE MESSAGING


SYSTEM

TEAM DETAILS:

18MIS0152 KISHORE.B
18MIS0392 SIVAKUMAR.M
18MIS0137 SAM EUJIN.J

SUBMITTED TO: PROF.THANAPAL.P


ABSTRACT:
There are many possibilities of chatting and sending
messages from one source to other through internet. But chatting
inside a organization is some what difficult. In this project we are
going to do an offline messaging system. So by this method it could
be much easier to chat within its organisation and also online traffic
will be reduced. The messages in the offline system are displayed in
an sequential manner. So that we could reduce the cost.
MODULES :
1. Welcome page

The start page of the application where the user will be given access to
register and login into the chat application and use it when they are in the organisation.

2. Register page

The user will be given rights to register into the application using their
employee id once the owner have added them into the company employee database.

3. Login page

The user and the owner can be logged in using the credentials that they have
given during the time of registration.

4. Employee page

This page is only accessed by the owner or the manger of the company where
he can add new employee details into the database so that the employee can register and
chat using this application.

5. Chat page

The logged in user can select the employee to whom he want to have a chat
and proceed to the chat section.

6. Chat section

The page for the chat where the user can have interactive session with the
other employee with the use of localhost used in the company/organisation.
Welcome page:

private void B1ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

this.dispose();

new RegisterPage().setVisible(true);

private void B2ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

this.dispose();

new LoginPage().setVisible(true);

private void B3ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

this.dispose();
System.exit(0);

Register page:

private void B1ActionPerformed(java.awt.event.ActionEvent evt) {

try

Connection con =
DriverManager.getConnection("jdbc:derby://localhost:1527/OfflineMessangingSystem","ro
ot","root");

String s1 = T1.getText();

String s2 = T2.getText();

String s3 = T3.getText();

String sql1 = "select * from employee";

Statement sta = con.createStatement();

ResultSet rs = sta.executeQuery(sql1);

boolean flag = false;


while(rs.next())

if(s1.equals(rs.getString(1).trim()))

flag = true;

if(flag)

if(s3.equals(s2))

String sql = "insert into registerpage values('"+s1+"','"+s2+"')";

int n = sta.executeUpdate(sql);

L5.setText("Successfully registered..");

else

L5.setText("Password do not match!!");

else

L5.setText("Employee is not available");

catch(SQLException e)
{

L5.setText("Creation error");

private void B2ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

this.dispose();

new WelcomePage().setVisible(true);

Login page:

private void B1ActionPerformed(java.awt.event.ActionEvent evt) {

boolean flag = false;

String s1 = T1.getText();
String s2 = T2.getText();

try

if(s1.equals("admin") && s2.equals("admin"))

this.dispose();

new EmployeePage().setVisible(true);

else

Connection con =
DriverManager.getConnection("jdbc:derby://localhost:1527/OfflineMessangingSystem","ro
ot","root");

String sql1 = "select * from registerpage";

Statement sta = con.createStatement();

ResultSet rs = sta.executeQuery(sql1);

while(rs.next())

if(s1.equals(rs.getString(1).trim()) && s2.equals(rs.getString(2).trim()))

flag = true;

catch(SQLException e)

{
L4.setText("Database error");

if(flag)

this.dispose();

new ChatPage(s1).setVisible(true);

else

L4.setText("invalid");

private void B2ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

this.dispose();

new WelcomePage().setVisible(true);

}
Employee page:

private void B1ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

try

Connection con =
DriverManager.getConnection("jdbc:derby://localhost:1527/OfflineMessangingSystem","ro
ot","root");

String s1 = T1.getText();

String s2 = T2.getText();

if(s1.length()!= 0 && s2.length() != 0)

String sql = "insert into employee values('"+s1+"','"+s2+"')";

Statement sta = con.createStatement();

int n = sta.executeUpdate(sql);

L5.setText("added");

else

L5.setText("Wrong details!!");

catch(SQLException e)

L5.setText("Creation error");

}
}

private void B2ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

this.dispose();

new WelcomePage().setVisible(true);

Chat page:

private void B1ActionPerformed(java.awt.event.ActionEvent evt) {

// TODO add your handling code here:

boolean flag = false;

String s1 = T1.getText();

try
{

Connection con =
DriverManager.getConnection("jdbc:derby://localhost:1527/OfflineMessangingSystem","ro
ot","root");

String sql1 = "select * from employee";

Statement sta = con.createStatement();

ResultSet rs = sta.executeQuery(sql1);

while(rs.next())

if(s1.equals(UserName))

L3.setText("Dont type your ID");

else

if(s1.equals(rs.getString(1).trim()))

flag = true;

catch(SQLException e)

}
if(flag)

this.dispose();

new ChatSection().setVisible(true);

else

L3.setText("Invalid");

Cbat Section:

static ServerSocket ss;


static Socket s;

static DataInputStream din;

static DataOutputStream dout;

String msgin = "";

try

ss = new ServerSocket(1201);

s = ss.accept();

din = new DataInputStream(s.getInputStream());

dout = new DataOutputStream(s.getOutputStream());

while(!msgin.equals("exit"))

msgin = din.readUTF();

msg_area.setText(msg_area.getText().trim()+"\n"+msgin);

catch(Exception e)

private void msg_sendActionPerformed(java.awt.event.ActionEvent evt) {

try {

String msgout = "";


msgout = msg_text.getText().trim();

dout.writeUTF(msgout);

} catch (IOException ex) {

Logger.getLogger(ChatSection.class.getName()).log(Level.SEVERE, null, ex);

}
ye s i will inf0rm in 5 min

NetBea«s IDE B2
File Edrt Vieur Nau*gate Solve Refactor RW Debug Prgfl Ie Team Tools W ndow Hop

.-.ava & la x 10.Ouisuver.Java x @ O•*¥feotjava x D' .›a a x lgj SO i fr&s4ertir/ 16 . I x lgj sQt i t‹t•r!6eny:hr fs...1 K ”°

l SELECT ° FROM AOOT.AEGI%TER%A€E FETCH FIB9T lOO ROWS ONLT;

DtPt02

You might also like