You are on page 1of 65

LAPTOP STOCK MAINTENANCE

A PROJECT REPORT

Submitted by

AJITH.S.A
15ITR003
NANDHINI.S
15ITR047
NANDHINI.M
15ITR048

in partial fulfilment of the requirements


for the award of the degree
of

BACHELOR OF TECHNOLOGY
IN
INFORMATION TECHNOLOGY
DEPARTMENT OF INFORMATION TECHNOLOGY
SCHOOL OF COMMUNICATION AND COMPUTER SCIENCES

KONGU ENGINEERING COLLEGE


(Autonomous)
PERUNDURAI ERODE – 638 060
OCTOBER 2017
DEPARTMENT OF INFORMATION TECHNOLOGY
KONGU ENGINEERING COLLEGE
(Autonomous)
PERUNDURAI ERODE – 638060
OCTOBER 2017

BONAFIDE CERTIFICATE

This is to certify that the Project Report entitled LAPTOP STOCK


MAINTENANCE is the bonafide record of project work done by AJITH.S.A (15ITR003),
NANDHINI.S(15ITR047) and NANDHINI.M(15ITR048) in partial fulfilment of the
requirements for the award of the Degree of Bachelor of Technology in Information
Technology of Anna University, Chennai during the year 2017- 2018.

SUPERVISOR HEAD OF THE DEPARTMENT


(Signature with seal)

Date:

Submitted for the end semester viva voce examination held on ___________

INTERNAL EXAMINER EXTERNAL EXAMINER


iii

DEPARTMENT OF INFORMATION TECHNOLOGY


KONGU ENGINEERING COLLEGE
(Autonomous)
PERUNDURAI ERODE - 638060
OCTOBER 2017

DECLARATION

We affirm that the Project Report titled LAPTOP STOCK MAINTENANCE being
submitted in partial fulfilment of the requirements for the award of Bachelor of Technology is
the original work carried out by us. It has not formed the part of any other project report or
dissertation on the basis of which a degree or award was conferred on an earlier occasion on
this or any other candidate.

AJITH.S.A
(15ITR003)

NANDHINI.S
(15ITR047)

NANDHINI.M
(15ITR048)

Date:

I certify that the declaration made by the above candidates is true to the best of my
knowledge.

Date: Name and Signature of the Supervisor with seal


iv

ABSTRACT

The objective of the system is to reducemaintenance of the stock details manually in


record and sharing details. The proposed system is to maintain the stock details in mobile
application. In traditional method, the user manually maintain these details in excel-sheet.It
reduces the user convenience. Disadvantage of the traditional system is that user are not able
share laptop details whenever need. The proposed system overcomes the above problems by
maintaining in an mobile application. This system allows user to share laptop details to
customer via social media (Gmail, Facebook, WhatsApp) whenever they need.
v

ACKNOWLEDGEMENT

First and foremost we acknowledge the abundant grace and presence of Almighty
throughout different phases of the project and its successful completion.
We wish to express our extreme gratefulness to our beloved Correspondent
Thiru.A.VENKATACHALAM B.Sc., and all the trust members of Kongu Vellalar Institute
of Technology Trust for providing all the necessary facilities to complete the project
successfully.
We express our deep sense of gratitude to our beloved Principal
Prof.S.KUPPUSWAMI B.E., M.Sc (Engg)., Dr.Ing (France)., for providing us an
opportunity to complete the project.

We express our heartfelt sincere thanks to our guide and Head of the Department
Dr.S.VARADHAGANAPATHY M.S., M.E., Ph.D., for his valuable suggestions.

We are thankful to our project coordinators Dr.G.K.KAMALAM M.E., MBA.,


Ph.D., and Ms.E.M.ROOPA DEVI M.E., for their valuable guidance and support to
complete our project successfully.
We are thankful to the faculty members of the Department of Information Technology
for their valuable guidance and support.
vi

TABLE OF CONTENTS

CHAPTER TITLE PAGE


NO. NO.
ABSTRACT iv
LIST OF TABLES viii
LIST OF FIGURES ix
LIST OF ABBREVIATIONS x
1 INTRODUCTION 1
1.1 INTRODUCTION 1
1.2 PROBLEM STATEMENT 1
211.3 PROPOSED METHOD 1

2 PROBLEM DEFINITION 2
2.1 EXISTING SYSTEM 2
2.2 PROBLEM STATEMENT 2
2.3 PROPOSED METHOD 2

3 SYSTEM REQUIREMENTS 3
3.1 HARDWARE REQUIREMENTS 3
3.2 SOFTWARE SPECIFICATIONS 3
3.3 SYSTEM DESCRIPTION 3
3.3.1 AndroidStudio IDE 3

4 SYSTEM DESIGN 5
4.1 PROPOSED DESIGN 5
4.1.1 Client Side Module 5
vii

4.1.2 Server Side Module 6


4.1.3 Architectural design 6
4.1.4 Database 6

5 TESTING 8
5.1 VALIDATIONTESTING 8
5.2 VERIFICATION TESTING 8

6 CONCLUSION AND FUTURE SCOPE 9


5.1 CONCLUSION 9
5.2 FUTURE SCOPE 9

FLOW CHART 10
APPENDICES 11
APPENDIX-1 CODING 11
APPENDIX-2 SNAPSHOTS 50

REFERENCES 53
viii

LIST OF TABLES

TABLE NO. TITLE PAGE NO.

4.1 Dealer 10

4.2 Laptop Stocks 10


ix

LIST OF FIGURES

FIGURE NO. TITLE PAGE NO.

4.1 Architecture 6

4.2 Database design 7

7.1 Details Entry 10

7.2 View and Share10

7.3 Home Page 50

7.4 Laptop Information 51

7.5 Dealer List 51

7.6 Laptop List 52

7.7 Sale Receipt 52

7.8 Purchase Receipt 50


x

LIST OF ABBREVIATIONS

UI User Interface

SDK Software Development Kit

SMS Short Message Service

OS Operating System

API Application Programming Interface

IDE Integrated Development Environment

SQL Structured Query Language


1

CHAPTER 1

INTRODUCTION

1.1 INTRODUCTION
Stock Management System is a software which is helpful for the businesses operate
stores, where store owner keeps the records of dealers, purchase, sales, and transaction
details. This project eliminates the paperwork, human faults, manual delay and speed up the
process. Stock Management System will have the ability to track overall worth and available
stock.Here the stock maintenance is the main process by which the stock is to controlled
when purchase or selling products.

1.2 OBJECTIVE
The main objective of the proposed system is to maintain laptop stock details and
share via social media. In traditional method, the user manually maintain these details in
excel sheet.
It reduces the user convenience. Disadvantage of the traditional system is that user are not
ableshare laptop details whenever need. The proposed system overcomes the above problems
by maintaining in an mobile application.

1.3 SCOPE

This Laptop Stock Maintenance System project will be a great help for the stores to
manage stock details and share details via social media.
2

CHAPTER 2

PROBLEM DEFINITION

2.1 EXISTING METHOD/SYSTEM


Existing system of maintaining laptop details is carried out manually by the user. It is
because of unavailability of such system to carry out the details through mobile application.
In traditional method, the userneed to manually record laptop details in excel sheet .To check
stock, everytime user need to manually check the details in excel sheet. But this process not
convenient to user. Another disadvantage of the traditional system is that user not able to
share via all possible social media whenever need.For sharing user need to manually type
laptop details. For lot of details this system increases the manpower and time.

2.2 PROBLEM STATEMENT


The main problem in the existing system is that it consumes more time and high man
power to know the number of stock in a particular brand, model, processor. In the existing
system, it is difficult for the user to know the stock and share those details. The existing
method not opt managing large number of stocks. This restricts the user conveience.

2.3 PROPOSED METHOD


The proposed system is to provide easy access for the user to store laptop details. This
system helps to find the no of stocks in particular brand easily. In this project, the user no
need to type for sharing each time. User can share laptop details via any social media by just
clicking share. And this system allows user to know the pending amount in purchasing and
selling.
3

CHAPTER 3

SYSTEM SPECIFICATIONS

3.1 HARDWARE REQUIREMENTS

Processor : Processor with a speed of 2.4GHzand above

RAM : 3.00GB RAM(Minimum) ,8.00GB(Maximum)

Hard Disk :130MB

3.2 SOFTWARE REQUIREMENTS

Platform: Windows 10

Environment : AndroidStudio 3.2

Database : SQLite

3.3 SYSTEM DESCRIPTION

3.3.1 AndroidStudio IDE

Android Studio is the official integrated development environment (IDE) for


Google's Android operating system, built on JetBrains’ IntelliJ IDEA software and designed
specifically for Android development. It is available for download on Windows, macOS and
Linux based operating systems.
4

 Features of AndroidStudio

 Kotlin programming language support

 Android profiler: memory, CPU, network

 Java 8 language features built-in

 Faster build times

 Device file explorer

 Android Instant Apps support

 Adaptive icon wizard

 XML and downloadable fonts

 Android Things support

 Layout editor improvements

 APK profiling and debugging

 Layout inspector improvements

 Improved Gradle sync speed

 AAPT2 is now enabled by default

 Firebase app indexing assistants

 App links assistant


5

CHAPTER 4

SYSTEM DESIGN

4.1 PROPOSED DESIGN


The proposed system has privileges to only the user. The user fill dealer information,
laptop details, payment details in the front end and the stock count, outstanding payment are
calculated at the back end displayed to user at the front end. The system is divided into two
modules
 Client side module
 Server side module

4.1.1 Client Side Module


4.1.1.1 Dealer Information
If the dealer is new to the system, then their details must be stored using the unique
username and other contact details.
4.1.1.2 Laptop Information
Once the dealer information entered, next the page containing the fields for entering
laptop details. Laptop serial number uniquely identify it from storing duplicate information.

4.1.1.3 View Dealer List


Dealer contact details viewed for user.

4.1.1.4 View Laptop Stock List


Stock laptop details viewed for user to share.
6

4.1.1.5 Receipt

Purchase and Sale Payment details can be stored by the system and pending
amountsto pay can be viewed by the user.

4.1.2 Server Side Module

In the server side, the system respond for the request sent by user. The system collects
the details of the laptop, dealer, payment and store in the database to be viewed by the user.

4.1.3 Architectural design

User Interface

Enter
lapto
p,deal Share
Fi
er, Lapto
lte
paym p
r,
ent detail
di
detail s
sp
la s
y

Laptop stock Maintenance


7

Figure 4.1 Architecture

4.1.4 Database design


StockLap

Model
Dealer Brand
Processor
Id(auto increment) RAM
Name Hardisk
Address Display
Phone no Graphics
Balance amount Wifi
Web cam
Microphone
Dealerid

Customer

Name
Address
Sale Receipt
Phone no
Model no
Name
Amount
Amount
Mode of payment
date
8

Figure 4.2Database design

Table 4.2 Dealer

Table 4.3 Laptop Stocks


9

CHAPTER 5

TESTING

5.1 VALIDATION TESTING


TestCase1: Check whether laptop, dealer details stored properly
TestCase2:Check whether payment updated consistently
TestCase3:Check whether all details viewed and shared
TestCase4: Check whether existing dealer detail again stored or not
TestCase5: Check whether system properly respond to the duplicate dealer,laptop
Test Analysis:
The proposed system properly work for the above cases. The system validated and it satisfy
our coding constraints.

5.1 VERIFICATION TESTING


TestCase1: UI design need to satisfy the user’s expectation
TestCase2: Check whether system manages laptop stock details
TestCase3:Check whether details shared via social media or not
Test Analysis:
The test analysis report that our user, application expectation satisfied.
10

CHAPTER 6

CONCLUSION AND FUTURE SCOPE

5.1 CONCLUSION
An efficient application for laptop stock maintenance was presented. This application
can be used to overcome the difficulties of the existing system which includes high man-
power, more time. The system provide the path to manage laptop stock and share those
details.

5.2 FUTURE SCOPE


Future work aims to maintain the stock of the any type of computer hardware and also
mobile phones.
11

FLOW CHART

Enter Details

Enter dealer
information

Yes
If
exist

No

Enter laptop
Payment enter
details

Save

Figure 7.1 Details Entry

View Dealer View lap stock View Transaction

Share
12

Figure 7.2 View and Share

APPENDIX 1-CODING

INDEX PAGE: (xml file)

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:background="@drawable/img7">
<Button
android:id="@+id/entry"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="59dp"
android:background="#98fb98"
android:text="Details Entry" />
<Button
android:id="@+id/vw"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="186dp"
android:background="#98fb98"
android:text="View Details" />
<Button
android:id="@+id/receipt"
android:layout_width="200dp"
13

android:layout_height="wrap_content"

android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="159dp"
android:background="#98fb98"
android:text="Receipt" />
</RelativeLayout>

MainActivity.java

package com.maragatham.maragathamtechnologys;

import android.content.DialogInterface;
import android.content.Intent;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.icu.text.IDNA;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity implements View.OnClickListener


{
Button b1,b2,b3;
SQLiteDatabase mydb;
public static final String DATABASE_NAME = "maragathamtechdb";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
b1=(Button)findViewById(R.id.entry);
b2=(Button)findViewById(R.id.vw);
b1.setOnClickListener(MainActivity.this);
14

b2.setOnClickListener(MainActivity.this);
b3=(Button)findViewById(R.id.receipt);
b3.setOnClickListener(MainActivity.this);
mydb = openOrCreateDatabase(DATABASE_NAME, MODE_PRIVATE, null);
try {
mydb.execSQL(
"CREATE TABLE IF NOT EXISTS SoldLap (" +
" id INTEGER PRIMARY KEY AUTOINCREMENT," +
" model varchar(20) NOT NULL UNIQUE ," +
" brand varchar(200) NOT NULL ," +
" processorname varchar(200) NOT NULL ," +
" processormodel varchar(200) NOT NULL," +
" ramm varchar(10) NOT NULL," +
" ramserial varchar(30) NOT NULL," +
" hardisk varchar(30) NOT NULL," +
" hdserial varchar(30) NOT NULL," +

" graphics varchar(100) NOT NULL," +


" dispsize varchar(100) NOT NULL," +
" wifiop varchar(10) NOT NULL," +
" webcam varchar(30) NOT NULL," +
" microphone varchar(30) NOT NULL," +
" Amount Integer(30) NOT NULL DEFAULT 0," +
" SaleValue Integer(30) NOT NULL," +
"did NUMERIC NOT NULL ," +
"pdate DATE NOT NULL," +
"sdate DATE NOT NULL);"
);
mydb.execSQL(
"CREATE TABLE IF NOT EXISTS Customer(" +
" id INTEGER PRIMARY KEY AUTOINCREMENT," +
" model varchar(20) NOT NULL UNIQUE ," +
" cName varchar(200) NOT NULL ," +
" processorname varchar(200) NOT NULL ," +
" processormodel varchar(200) NOT NULL," +
" ramm varchar(10) NOT NULL," +
" ramserial varchar(30) NOT NULL," +
" hardisk varchar(30) NOT NULL," +
" hdserial varchar(30) NOT NULL," +
" graphics varchar(100) NOT NULL," +
" dispsize varchar(100) NOT NULL," +
" wifiop varchar(10) NOT NULL," +
" webcam varchar(30) NOT NULL," +
15

" microphone varchar(30) NOT NULL," +


" Amount Integer(30) NOT NULL DEFAULT 0," +
" SaleValue Integer(30) NOT NULL," +
"did NUMERIC NOT NULL ," +
"pdate DATE NOT NULL," +
"sdate DATE NOT NULL);"
);
System.out.println("Created");
}
catch(SQLException e)
{
System.out.println(e.toString());
}
}
@Override
public void onClick(View view) {
switch(view.getId())
{
case R.id.entry:
Intent i1=new Intent(getApplicationContext(), InfoActivity.class);
startActivity(i1);
break;
case R.id.vw:
Intent vi=new Intent(getApplicationContext(),ViewActivity.class);
startActivity(vi);
break;
case R.id.receipt:
Intent v2=new Intent(getApplicationContext(),PurchaseReceipt.class);
startActivity(v2);
break;
}
}
}

1.2 Dealer Information

Activity_dealer.xml

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
16

xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".DealerActivity"
android:background="@drawable/sa3">
<Button
android:id="@+id/next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="27dp"
android:layout_marginEnd="46dp"
android:background="#98fb98"
android:text="Next" />
<ImageButton
android:id="@+id/imageButton2"
android:layout_width="70dp"
android:layout_height="60dp"
android:layout_alignParentStart="true"
android:layout_alignTop="@+id/next"
android:layout_marginStart="49dp"
android:layout_marginBottom="6dp"
app:srcCompat="@drawable/igg3" />

<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="38dp"
android:layout_marginTop="72dp"
android:text="Dealer Name" />
<TextView
android:id="@+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignStart="@+id/textView9"
android:layout_marginTop="145dp"
android:text="Quantity" />
<TextView
android:id="@+id/textView11"
17

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignStart="@+id/textView9"
android:layout_marginTop="191dp"
android:text="Date" />
<Spinner
android:id="@+id/spinner"
android:layout_width="236dp"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="148dp"
android:layout_marginTop="63dp" />
<EditText
android:id="@+id/editText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/textView10"
android:layout_alignStart="@+id/spinner"
android:ems="10"
android:inputType="number" />
CalendarView
android:id="@+id/calendarView"
android:layout_width="255dp"
android:layout_height="293dp"
android:layout_alignParentEnd="true"
android:layout_below="@+id/textView10" />
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="13dp"
android:layout_marginEnd="103dp"
android:text="Next" />

</RelativeLayout>
18

Dealer.java

package com.maragatham.maragathamtechnologys;

import android.content.Intent;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CalendarView;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

public class DealerDateActivity extends AppCompatActivity implements


View.OnClickListener{
Spinner Myspin1;Button b1;
String DATABASE_NAME="maragathamtechdb";
SQLiteDatabase mydb;
String dname="",quty="",ddate="",msg="",NAME="";
CalendarView simpleCalendarView;
EditText ed1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_dealer_date);
Myspin1=(Spinner)findViewById(R.id.spinner);
mydb = openOrCreateDatabase(DATABASE_NAME, MODE_PRIVATE, null);
b1=(Button)findViewById(R.id.button3);
b1.setOnClickListener(DealerDateActivity.this);
ArrayList<String> my_array = new ArrayList<String>();
19

my_array = getDealerValues();
ed1=(EditText)findViewById(R.id.editText);
final ArrayList<String> my_array1 = new ArrayList<String>();
Myspin1 = (Spinner) findViewById(R.id.spinner);
ArrayAdapter my_Adapter = new ArrayAdapter(this,
R.layout.spinner_row,my_array);
Myspin1.setAdapter(my_Adapter);
simpleCalendarView = (CalendarView) findViewById(R.id.calendarView);
simpleCalendarView.setOnDateChangeListener(new
CalendarView.OnDateChangeListener() {
@Override
public void onSelectedDayChange(@NonNull CalendarView calendarView, int i, int
i1, int i2) {
msg = "" + i2 + "/" + (i1 + 1) + "/" + i;
Toast.makeText(getApplicationContext(), msg,
Toast.LENGTH_SHORT).show();
}
});
Myspin1.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id)
{
String selectedItemText = (String) parent.getItemAtPosition(position);
dname=selectedItemText;
Toast.makeText
(getApplicationContext(), "Selected : " + selectedItemText, Toast.LENGTH_SHORT)
.show();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
}
public ArrayList<String> getDealerValues() {

ArrayList<String> my_array = new ArrayList<String>();


try {
Cursor allrows = mydb.rawQuery("SELECT * FROM Dealer", null);
System.out.println("COUNT : " + allrows.getCount());
if (allrows.moveToFirst()) {
do {
String NAME = allrows.getString(1);
my_array.add(NAME);
} while (allrows.moveToNext());
20

}
allrows.close();
} catch (SQLException e) {
Toast.makeText(getApplicationContext(), "Error encountered.",
Toast.LENGTH_LONG);
}
return my_array;
}
private void addQuantity() {
quty = ed1.getText().toString().trim();
long selectedDate = simpleCalendarView.getDate();
if(inputsAreCorrect(quty)) {
try {
String insertSQL1 = "INSERT INTO QuantityS \n" +
"(did,dname,date,quantity)\n" +
"VALUES \n" +
"(?, ?, ?, ?);";
String selectq="SELECT id FROM Dealer WHERE name='"+dname+"'";
Cursor allrows = mydb.rawQuery(selectq,null);
System.out.println("COUNT : " + allrows.getCount());
NAME = "";
if (allrows.moveToFirst()) {
do {
NAME = allrows.getString(0);
} while (allrows.moveToNext());
}
allrows.close();
mydb.execSQL(insertSQL1,new String[]{NAME,dname,msg,quty});
Toast.makeText(getApplicationContext(),""+NAME+" "+dname+" "+"
"+quty+" "+msg, Toast.LENGTH_LONG).show();
Intent ii=new Intent(getApplicationContext(),LapInfoActivity.class);
Bundle extras = new Bundle();
extras.putString("NameId", dname);
extras.putString("Date", msg);
extras.putString("Quantity", quty);
extras.putString("Id", NAME);
ii.putExtras(extras);
startActivity(ii);
} catch (SQLException e) {
Toast.makeText(getApplicationContext(), "Dealer exist",
Toast.LENGTH_LONG).show();
}
}
else
21

{
Toast.makeText(getApplicationContext(), "Not unique",
Toast.LENGTH_LONG).show();
}
}
private boolean inputsAreCorrect(String quty) {
if(quty.isEmpty())
{
ed1.setError("Please enter Quantity");
ed1.requestFocus();
return false;
}
return true;
}
@Override
public void onClick(View v) {
switch(v.getId())
{
case R.id.button3:
addQuantity();
break;
}
}
}

1.1 Laptop Information

activity_lapinfo.xml

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".LapInfoActivity"
android:background="@drawable/sa3">
<TextView
android:id="@+id/textView13"
22

android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/spinner2"
android:layout_alignStart="@+id/textView15"
android:text="Brand" />
<TextView
android:id="@+id/textView14"
android:layout_width="74dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignStart="@+id/textView13"
android:layout_marginStart="-10dp"
android:layout_marginTop="60dp"
android:text="Processor" />
<TextView
android:id="@+id/textView15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="14dp"
android:layout_marginTop="106dp"
android:text="RAM" />
<TextView
android:id="@+id/textView16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignTop="@+id/spinner5"
android:layout_marginStart="13dp"
android:layout_marginTop="0dp"
android:text="Hardisk" />
<TextView
android:id="@+id/textView17"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="@+id/textView13"
android:layout_alignParentTop="true"
android:layout_marginEnd="-17dp"
android:layout_marginTop="190dp"
android:text="Graphics" />
<TextView
android:id="@+id/textView18"
android:layout_width="wrap_content"
23

android:layout_height="wrap_content"
android:layout_alignStart="@+id/textView13"
android:layout_below="@+id/spinner6"
android:text="Display" />
<Button
android:id="@+id/button6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginEnd="88dp"
android:text="Save" />
<Spinner
android:id="@+id/spinner2"
android:layout_width="116dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginTop="14dp"
android:layout_toEndOf="@+id/textView19" />
<Spinner
android:id="@+id/spinner3"
android:layout_width="117dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView14"
android:layout_alignStart="@+id/spinner2" />
<Spinner
android:id="@+id/spinner4"
android:layout_width="117dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView15"
android:layout_alignStart="@+id/spinner2" />
<Spinner
android:id="@+id/spinner5"
android:layout_width="117dp"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignStart="@+id/spinner2"
android:layout_marginTop="143dp" />

<Spinner
android:id="@+id/spinner6"
android:layout_width="116dp"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/spinner2"
24

android:layout_alignTop="@+id/textView17" />
<Spinner
android:id="@+id/spinner7"
android:layout_width="117dp"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/spinner2"
android:layout_alignTop="@+id/textView18" />
<TextView
android:id="@+id/textView19"
android:layout_width="88dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignStart="@+id/textView13"
android:layout_marginBottom="228dp"
android:text="Processor model" />
<EditText
android:id="@+id/editText6"
android:layout_width="114dp"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/spinner2"
android:layout_alignTop="@+id/textView19"
android:ems="10"
android:inputType="textPersonName" />
<EditText
android:id="@+id/editText7"
android:layout_width="112dp"
android:layout_height="wrap_content"
android:layout_below="@+id/editText6"
android:layout_toEndOf="@+id/textView19"
android:ems="10"
android:inputType="textPersonName" />
<TextView
android:id="@+id/textView21"
android:layout_width="wrap_content"
android:layout_height="39dp"
android:layout_alignStart="@+id/textView13"
android:layout_below="@+id/editText6"
android:text="Ram serial" />

<TextView
android:id="@+id/textView24"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
25

android:layout_alignStart="@+id/textView13"
android:layout_marginBottom="145dp"
android:text="HD serial" />
<EditText
android:id="@+id/editText9"
android:layout_width="112dp"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/spinner2"
android:layout_below="@+id/editText7"
android:ems="10"
android:inputType="textPersonName" />
<TextView
android:id="@+id/textView25"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/editText12"
android:layout_alignParentStart="true"
android:text="Amount" />
<EditText
android:id="@+id/editText12"
android:layout_width="112dp"
android:layout_height="wrap_content"
android:layout_below="@+id/textView24"
android:layout_marginTop="-145dp"
android:layout_toEndOf="@+id/textView19"
android:ems="10"
android:inputType="number" />
<TextView
android:id="@+id/textView27"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginBottom="66dp"
android:text="Sale Value" />
<EditText
android:id="@+id/editText13"
android:layout_width="107dp"
android:layout_height="wrap_content"
android:layout_alignEnd="@+id/editText7"
android:layout_below="@+id/editText12"
android:layout_marginEnd="4dp"
android:ems="10"
android:inputType="number" />
26

<Button
android:id="@+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:layout_marginStart="92dp"
android:text="+ New" />
<TextView
android:id="@+id/textView12"
android:layout_width="42dp"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/editText9"
android:layout_alignParentEnd="true"
android:layout_marginEnd="101dp"
android:text="Wifi" />
<RadioGroup
android:id="@+id/wifi"
android:layout_width="129dp"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/textView12"
android:layout_below="@+id/textView24"
android:layout_marginTop="-145dp"
android:orientation="horizontal">
<RadioButton
android:id="@+id/yes1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Yes" />
<RadioButton
android:id="@+id/no1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No" />
</RadioGroup>

<TextView
android:id="@+id/textView20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/spinner5"
android:layout_alignStart="@+id/textView12"
android:text="Webcam" />
<RadioGroup
27

android:id="@+id/webcam"
android:layout_width="129dp"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/textView12"
android:layout_alignTop="@+id/textView17"
android:orientation="horizontal">
<RadioButton
android:id="@+id/yes2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Yes" />

<RadioButton
android:id="@+id/no2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No" />
</RadioGroup>
<TextView
android:id="@+id/textView22"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/textView12"
android:layout_centerVertical="true"
android:text="Microphone" />
<RadioGroup
android:id="@+id/mphone"
android:layout_width="126dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="205dp"
android:layout_marginEnd="17dp"
android:orientation="horizontal">

<RadioButton
android:id="@+id/yes3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Yes" />

<RadioButton
android:id="@+id/no3"
android:layout_width="wrap_content"
28

android:layout_height="wrap_content"
android:text="No" />
</RadioGroup>
<TextView
android:id="@+id/textView23"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="@+id/textView22"
android:layout_alignParentTop="true"
android:layout_marginTop="22dp"
android:text="Model No" />
<EditText
android:id="@+id/editText8"
android:layout_width="138dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_below="@+id/textView13"
android:ems="10"
android:inputType="textPersonName" />

</RelativeLayout>

LaptopInfoActivity.java

package com.maragatham.maragathamtechnologys;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Color;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
29

import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;

import java.util.ArrayList;

public class LapInfoActivity extends AppCompatActivity implements


View.OnClickListener{

Spinner SpinBrand,SpinDisp,SpinGraphics,SpinRam,SpinProcessor,SpinHD;
ArrayList<String>my_array;
Button save,newb;
String dtename="",did="",qy="",name="",model="";
int count,quant,amt;
EditText ed1,ed2,ed3,ed4,ed5,ed6;
RadioGroup rg1,rg2,rg3;
RadioButton y1,n1,y2,n2,y3,n3;
String
brandname="",pro_name="",pro_model="",rammm="",rammmserial="",hd="",hdser="",grap
hic="",dsize="",wifi="",webcam="",mphone="",amount="",salevalue="";
SQLiteDatabase mydb; public static final String DATABASE_NAME =
"maragathamtechdb";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lap_info);
mydb = openOrCreateDatabase(DATABASE_NAME, MODE_PRIVATE, null);
SpinBrand=(Spinner)findViewById(R.id.spinner2);
SpinProcessor=(Spinner)findViewById(R.id.spinner3);
SpinRam=(Spinner)findViewById(R.id.spinner4);
SpinHD=(Spinner)findViewById(R.id.spinner5);
SpinGraphics=(Spinner)findViewById(R.id.spinner6);
SpinDisp=(Spinner)findViewById(R.id.spinner7);
save=(Button)findViewById(R.id.button6);
newb=(Button)findViewById(R.id.button4);
save.setOnClickListener(LapInfoActivity.this);
newb.setOnClickListener(LapInfoActivity.this);
ed1=(EditText)findViewById(R.id.editText6);
ed2=(EditText)findViewById(R.id.editText7);
ed3=(EditText)findViewById(R.id.editText9);
ed4=(EditText)findViewById(R.id.editText12);
30

ed5=(EditText)findViewById(R.id.editText13);
ed6=(EditText)findViewById(R.id.editText8);
rg1=(RadioGroup)findViewById(R.id.wifi);
rg2=(RadioGroup)findViewById(R.id.webcam);
rg3=(RadioGroup)findViewById(R.id.mphone);

y1 = (RadioButton) findViewById(R.id.yes1);
y2 = (RadioButton) findViewById(R.id.yes2);
y3 = (RadioButton) findViewById(R.id.yes3);
n1 = (RadioButton) findViewById(R.id.no1);
n2 = (RadioButton) findViewById(R.id.no2);
n3 = (RadioButton) findViewById(R.id.no3);
my_array = new ArrayList<String>();
my_array = getTableValues("BrandName");
Bundle extras = getIntent().getExtras();
name = extras.getString("NameId");
dtename = extras.getString("Date");
qy=extras.getString("Quantity");
did=extras.getString("Id");
Toast.makeText(getApplicationContext(),"Name: \n"+name+" Date
:\n"+dtename+"Quantity "+qy+" id "+did,Toast.LENGTH_LONG).show();
checkStatus();
createLap();
ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(
this,R.layout.spinner_row,my_array){
@Override
public View getDropDownView(int position, View convertView,
ViewGroup parent) {
View view = super.getDropDownView(position, convertView, parent);
TextView tv = (TextView) view;
if(position == 1) {
tv.setTextColor(Color.parseColor("blue"));
}
else {
tv.setTextColor(Color.parseColor("#FF657A86"));
}
return view;
}
};
spinnerArrayAdapter.setDropDownViewResource(R.layout.spinner_row);
SpinBrand.setAdapter(spinnerArrayAdapter);
my_array = getTableValues("Processor");
spinnerArrayAdapter = new ArrayAdapter<String>(
this,R.layout.spinner_row,my_array){
31

@Override
public View getDropDownView(int position, View convertView,
ViewGroup parent) {
View view = super.getDropDownView(position, convertView, parent);
TextView tv = (TextView) view;
if(position == 1) {
tv.setTextColor(Color.parseColor("blue"));
}
else {
tv.setTextColor(Color.parseColor("#FF657A86"));
}
return view;
}
};
spinnerArrayAdapter.setDropDownViewResource(R.layout.spinner_row);
SpinProcessor.setAdapter(spinnerArrayAdapter);

my_array = getTableValues("RAM");
spinnerArrayAdapter = new ArrayAdapter<String>(
this,R.layout.spinner_row,my_array){
@Override
public View getDropDownView(int position, View convertView,
ViewGroup parent) {
View view = super.getDropDownView(position, convertView, parent);
TextView tv = (TextView) view;
if(position == 1) {
tv.setTextColor(Color.parseColor("blue"));
}
else {
tv.setTextColor(Color.parseColor("#FF657A86"));
}
return view;
}
};
spinnerArrayAdapter.setDropDownViewResource(R.layout.spinner_row);
SpinRam.setAdapter(spinnerArrayAdapter);

my_array = getTableValues("Hardisk");
spinnerArrayAdapter = new ArrayAdapter<String>(
this,R.layout.spinner_row,my_array){
@Override
public View getDropDownView(int position, View convertView,
ViewGroup parent) {
View view = super.getDropDownView(position, convertView, parent);
32

TextView tv = (TextView) view;


if(position == 1) {
tv.setTextColor(Color.parseColor("blue"));
}
else {
tv.setTextColor(Color.parseColor("#FF657A86"));
}
return view;
}
};
spinnerArrayAdapter.setDropDownViewResource(R.layout.spinner_row);
SpinHD.setAdapter(spinnerArrayAdapter);

my_array = getTableValues("Graphics");
spinnerArrayAdapter = new ArrayAdapter<String>(
this,R.layout.spinner_row,my_array){
@Override
public View getDropDownView(int position, View convertView,
ViewGroup parent) {
View view = super.getDropDownView(position, convertView, parent);
TextView tv = (TextView) view;
if(position == 1) {
tv.setTextColor(Color.parseColor("blue"));
}
else {
tv.setTextColor(Color.parseColor("#FF657A86"));
}
return view;
}
};
spinnerArrayAdapter.setDropDownViewResource(R.layout.spinner_row);
SpinGraphics.setAdapter(spinnerArrayAdapter);

my_array = getTableValues("Display");
spinnerArrayAdapter = new ArrayAdapter<String>(
this,R.layout.spinner_row,my_array){
@Override
public View getDropDownView(int position, View convertView,
ViewGroup parent) {
View view = super.getDropDownView(position, convertView, parent);
TextView tv = (TextView) view;
if(position == 1) {
33

tv.setTextColor(Color.parseColor("blue"));
}
else {
tv.setTextColor(Color.parseColor("#FF657A86"));
}
return view;
}
};
spinnerArrayAdapter.setDropDownViewResource(R.layout.spinner_row);
SpinDisp.setAdapter(spinnerArrayAdapter);

SpinDisp.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String selectedItemText = (String) parent.getItemAtPosition(position);
if(selectedItemText.equalsIgnoreCase("Add new Item"))
{
showAddItemDialog(LapInfoActivity.this,"Display");
}
else
{
dsize=""+selectedItemText;
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {

}
});

SpinBrand.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String selectedItemText = (String) parent.getItemAtPosition(position);
if(selectedItemText.equalsIgnoreCase("Add new Item"))
{
Toast.makeText(getApplicationContext(),"Enter new
item",Toast.LENGTH_LONG).show();
showAddItemDialog(LapInfoActivity.this,"BrandName");
}
else
{
brandname=""+selectedItemText;
34

}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {

}
});

SpinHD.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String selectedItemText = (String) parent.getItemAtPosition(position);
if(selectedItemText.equalsIgnoreCase("Add new Item"))
{
Toast.makeText(getApplicationContext(),"Enter new
item",Toast.LENGTH_LONG).show();
showAddItemDialog(LapInfoActivity.this,"Hardisk");
}
else
{
hd=""+selectedItemText;
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {

}
});

SpinGraphics.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String selectedItemText = (String) parent.getItemAtPosition(position);
if(selectedItemText.equalsIgnoreCase("Add new Item"))
{
Toast.makeText(getApplicationContext(),"Enter new
item",Toast.LENGTH_LONG).show();
showAddItemDialog(LapInfoActivity.this,"Graphics");
}
else
{
graphic=""+selectedItemText;
}
}
35

@Override
public void onNothingSelected(AdapterView<?> parent) {

}
});

SpinProcessor.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String selectedItemText = (String) parent.getItemAtPosition(position);
if(selectedItemText.equalsIgnoreCase("Add new Item"))
{
Toast.makeText(getApplicationContext(),"Enter new
item",Toast.LENGTH_LONG).show();
showAddItemDialog(LapInfoActivity.this,"Processor");
}
else
{
pro_name=""+selectedItemText;
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {

}
});

SpinRam.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
String selectedItemText = (String) parent.getItemAtPosition(position);
if(selectedItemText.equalsIgnoreCase("Add new Item"))
{
Toast.makeText(getApplicationContext(),"Enter new
item",Toast.LENGTH_LONG).show();
showAddItemDialog(LapInfoActivity.this,"RAM");
}
else
{
rammm=""+selectedItemText;
}
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
36

}
});

private void checkStatus() {


try {
Cursor allrows = mydb.rawQuery("SELECT * FROM QuantityS WHERE did='"+did+"' and
date='"+dtename+"'", null);
System.out.println("COUNT : " + allrows.getCount());

if (allrows.moveToFirst()) {
do {

String t = allrows.getString(4);
String t1 = allrows.getString(5);
quant=Integer.parseInt(t);
count=Integer.parseInt(t1);
Toast.makeText(getApplicationContext(),"Dealer name "+name+" Date
"+dtename+"Quantity "+
quant+" No of entries "+count+" Balance Entries ",Toast.LENGTH_LONG).show();

} while (allrows.moveToNext());
}
allrows.close();

} catch (SQLException e) {
Toast.makeText(getApplicationContext(), "Error encountered.",
Toast.LENGTH_LONG);
}
try {

Cursor allrows = mydb.rawQuery("SELECT * FROM Dealer WHERE id='"+did+"'", null);


System.out.println("COUNT : " + allrows.getCount());

if (allrows.moveToFirst()) {
do {
int t = allrows.getInt(4);
amt=t;
} while (allrows.moveToNext());
37

}
allrows.close();

} catch (SQLException e) {
Toast.makeText(getApplicationContext(), "Error encountered.",
Toast.LENGTH_LONG);
}
}

private void createLap() {


try {
mydb.execSQL(
"CREATE TABLE IF NOT EXISTS StockLap (" +
" id INTEGER PRIMARY KEY AUTOINCREMENT," +
" model varchar(20) NOT NULL UNIQUE ,"+
" brand varchar(200) NOT NULL ," +
" processorname varchar(200) NOT NULL ," +
" processormodel varchar(200) NOT NULL," +
" ramm varchar(10) NOT NULL," +
" ramserial varchar(30) NOT NULL," +
" hardisk varchar(30) NOT NULL," +
" hdserial varchar(30) NOT NULL,"+
" graphics varchar(100) NOT NULL,"+
" dispsize varchar(100) NOT NULL,"+
" wifiop varchar(10) NOT NULL,"+
" webcam varchar(30) NOT NULL,"+
" microphone varchar(30) NOT NULL,"+
" Amount Integer(30) NOT NULL DEFAULT 0,"+
" SaleValue Integer(30) NOT NULL,"+
"did NUMERIC NOT NULL ,"+
"ddate DATE NOT NULL);"
);
Toast.makeText(this, "Quant created", Toast.LENGTH_SHORT).show();
}
catch(SQLException e) {
Toast.makeText(this, "Quant not created", Toast.LENGTH_SHORT).show();
}
}
private void showAddItemDialog(Context c, final String table) {
String name="";
if(table=="BrandName")
name="bname";
else if(table=="Hardisk")
name="hname";
38

else if(table=="Graphics")
name="gname";
else if(table=="RAM")
name="rname";
else if(table=="Display")
name="dname";
else if(table=="Processor")
name="pname";

final EditText taskEditText = new EditText(c);


final String finalName = name;
AlertDialog dialog = new AlertDialog.Builder(c)
.setTitle("Add a new task")
.setMessage("What do you want to do next?")
.setView(taskEditText)
.setPositiveButton("Add", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
String task = String.valueOf(taskEditText.getText());
try
{
String insertSQL1 = "INSERT INTO "+ table +"( "+ finalName +")\n" +
"VALUES \n" +
"(?);";
mydb.execSQL(insertSQL1, new String[]{task});
Toast.makeText(getApplicationContext(),"Added",Toast.LENGTH_LONG).show();
loadSpinner(table);
}
catch(SQLException e)
{
Toast.makeText(getApplicationContext(),"Already in
list",Toast.LENGTH_LONG).show();
}

}
})
.setNegativeButton("Cancel", null)
.create();
dialog.show();

}
private void loadSpinner(String table)
{
ArrayList<String> my_array1 = new ArrayList<String>();
39

my_array1 = getTableValues(table);
if(table=="BrandName")
SpinBrand = (Spinner) findViewById(R.id.spinner2);
else if(table=="Hardisk")
SpinHD = (Spinner) findViewById(R.id.spinner5);
else if(table=="Graphics")
SpinGraphics = (Spinner) findViewById(R.id.spinner6);
else if(table=="RAM")
SpinRam = (Spinner) findViewById(R.id.spinner4);
else if(table=="Display")
SpinDisp = (Spinner) findViewById(R.id.spinner7);
else if(table=="Processor")
SpinProcessor = (Spinner) findViewById(R.id.spinner3);
final ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(
this,R.layout.spinner_row,my_array1){
@Override
public View getDropDownView(int position, View convertView,
ViewGroup parent) {
View view = super.getDropDownView(position, convertView, parent);
TextView tv = (TextView) view;
if(position == 1) {
tv.setTextColor(Color.parseColor("blue"));
}
else {
tv.setTextColor(Color.parseColor("#FF657A86"));
}
return view;
}
};

spinnerArrayAdapter.setDropDownViewResource(R.layout.spinner_row);
if(table=="BrandName") {
SpinBrand.setAdapter(spinnerArrayAdapter);
} else if(table=="Hardisk")
SpinHD.setAdapter(spinnerArrayAdapter);
else if(table=="Graphics")
SpinGraphics.setAdapter(spinnerArrayAdapter);
else if(table=="RAM")
SpinRam.setAdapter(spinnerArrayAdapter);
else if(table=="Display")
SpinDisp.setAdapter(spinnerArrayAdapter);
else if(table=="Processor")
SpinProcessor.setAdapter(spinnerArrayAdapter);
}
40

private ArrayList<String> getTableValues(String table) {


ArrayList<String> my_array1 = new ArrayList<String>();
try {
Cursor allrows = mydb.rawQuery("SELECT * FROM "+table, null);
System.out.println("COUNT : " + allrows.getCount());
if (allrows.moveToFirst()) {
do {
String NAME = allrows.getString(1);
my_array1.add(NAME);
} while (allrows.moveToNext());
}
allrows.close();

} catch (Exception e) {
Toast.makeText(getApplicationContext(), "Error encountered.",
Toast.LENGTH_LONG);
}
return my_array1;
}
private void addLap() {
int insert=0;
int deal=0,qcount=0,amountnew=0;
String mm="",m1="",m2="";
pro_model=ed1.getText().toString();
rammmserial=ed2.getText().toString();
hdser=ed3.getText().toString();
amount=ed4.getText().toString();
salevalue=ed5.getText().toString();
model=ed6.getText().toString();
int selectedId = rg1.getCheckedRadioButtonId();
if(selectedId == y1.getId()) {
mm="yes ";
} else if(selectedId == n1.getId()) {
mm = "no";
}
int selectedId1 = rg2.getCheckedRadioButtonId();
if(selectedId1 == y2.getId()) {
m1="yes ";
} else if(selectedId1 == n2.getId()) {
m1= "no";
}
int selectedId2= rg3.getCheckedRadioButtonId();
if(selectedId2 == y3.getId()) {
m2="yes ";
41

} else if(selectedId2 == n3.getId()) {


m2= "no";
}
String msg=""+model+" "+brandname+" "+pro_name+" "+rammm+" "+hd+"
"+graphic+" "+dsize+" "+pro_model+" "+rammmserial+" "+hdser+" "+amount+"
"+salevalue+" "+" "+mm+" "+m1+" "+m2;
amountnew=Integer.valueOf(amount);
amt+=amountnew;
if(quant>count)
{
try
{
String insertSQL1 = "INSERT INTO StockLap \n" +
"(model,brand,processorname,processormodel,ramm,ramserial,hardisk,hdserial,graphics,disp
size,wifiop,\n"+
"webcam,microphone,Amount,SaleValue,did,ddate)\n" +
"VALUES \n" +
"(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
if(inputsAreCorrect(model,pro_model,rammmserial,hdser,amount,salevalue)) {
mydb.execSQL(insertSQL1, new String[]{model, brandname, pro_name,
pro_model, rammm, rammmserial, hd, hdser, graphic, dsize, mm, m1, m2, amount, salevalue,
did, dtename});
insert = 1;
}

}
catch(SQLException e)
{
Toast.makeText(getApplicationContext(),"Inserted
successfully",Toast.LENGTH_LONG).show();
}
}
else
{
Toast.makeText(getApplicationContext(),"Your choosen entry limit
exceed",Toast.LENGTH_LONG).show();
}
if(insert == 1)
{
try
{
String sql = "UPDATE Dealer\n" +
"SET Amount = ? \n" +
"WHERE id = ?;\n";
42

mydb.execSQL(sql, new String[]{String.valueOf(amt),String.valueOf(did)});


deal=1;
}
catch(SQLException e)
{
Toast.makeText(getApplicationContext(),"Not updated dealer
amount",Toast.LENGTH_LONG).show();
}

}
if(deal==1 && insert ==1)
{
try
{
String sql = "UPDATE QuantityS\n" +
"SET count = ? \n" +
"WHERE did = ?and date=?;\n";
count=count+1;
mydb.execSQL(sql, new
String[]{String.valueOf(count),String.valueOf(did),dtename});

Toast.makeText(this, "Updated successfully", Toast.LENGTH_SHORT).show();


}
catch(SQLException e)
{
Toast.makeText(getApplicationContext(),"Not updated dealer
amount",Toast.LENGTH_LONG).show();
}
}
Toast.makeText(getApplicationContext(),msg,Toast.LENGTH_LONG).show();
}
private boolean inputsAreCorrect(String ml, String pr,String rm,String hdd,String
amount,String sale) {
if (ml.isEmpty()) {
ed6.setError("Please enter a Model no");
ed6.requestFocus();
return false;
}

if (pr.isEmpty()) {
ed1.setError("Please enter processor no");
ed1.requestFocus();
return false;
}
43

if (rm.isEmpty()) {
ed2.setError("Please enter ram serial no");
ed2.requestFocus();
return false;
}

if (hdd.isEmpty()) {
ed3.setError("Please enter hardisk no");
ed3.requestFocus();
return false;
}

if (amount.isEmpty()) {
ed4.setError("Please enter Amount");
ed4.requestFocus();
return false;
}

if (sale.isEmpty()) {
ed5.setError("Please enter sale amount");
ed5.requestFocus();
return false;
}
return true;
}
@Override
public void onClick(View v) {
switch(v.getId())
{
case R.id.button6:
addLap();

break;
case R.id.button4:
Intent iii=new Intent(getApplicationContext(),LapInfoActivity.class);
Bundle extras = new Bundle();
extras.putString("NameId", name);
extras.putString("Date", dtename);
extras.putString("Quantity", qy);
extras.putString("Id", did);
iii.putExtras(extras);
startActivity(iii);
break;
44

}
}
}

2.3 Purchase Receipt

activity_purchase_receipt.xml

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".PurchaseReceipt"
android:background="@drawable/sa3">

<TextView
android:id="@+id/textView311"
android:layout_width="195dp"
android:layout_height="48dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="0dp"
android:background="@color/colorAccent"
android:text="Purchase Receipt"
android:textColor="#ffffff"
android:textAlignment="center"
/>

<TextView
android:id="@+id/textView312"
android:layout_width="190dp"
android:layout_height="48dp"
android:layout_alignBottom="@+id/textView311"
android:layout_alignParentEnd="true"
android:background="@color/colorPrimaryDark"
android:text="SaleReceipt"
android:textColor="#ffffff"
45

android:textAlignment="center"/>

<TextView
android:id="@+id/Delr"
android:layout_width="97dp"
android:layout_height="wrap_content"
android:layout_above="@+id/spinner11"
android:layout_alignParentStart="true"
android:layout_marginBottom="-78dp"
android:layout_marginStart="17dp"
android:text="Dealer :" />

<Spinner
android:id="@+id/spinner11"
android:layout_width="190dp"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/editText10"
android:layout_alignParentTop="true"
android:layout_marginTop="56dp" />

<TextView
android:id="@+id/textView31"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignStart="@+id/Delr"
android:layout_marginTop="106dp"
android:text="Mode of Payment" />

<TextView
android:id="@+id/textView32"
android:layout_width="112dp"
android:layout_height="42dp"
android:layout_alignParentTop="true"
android:layout_alignStart="@+id/Delr"
android:layout_marginTop="142dp"
android:text="If Others Specify here" />

<TextView
android:id="@+id/textView33"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignStart="@+id/Delr"
46

android:layout_marginTop="230dp"
android:text="cheque No:" />

<TextView
android:id="@+id/textView34"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignStart="@+id/Delr"
android:layout_marginBottom="224dp"
android:text="Amount" />

<TextView
android:id="@+id/textView35"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/editText15"
android:layout_alignStart="@+id/Delr"
android:text="Remarks" />

<RadioGroup
android:layout_width="179dp"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/spinner11"
android:layout_alignTop="@+id/textView31"
android:orientation="horizontal">

<RadioButton
android:id="@+id/radioButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="12dp"
android:text="Cheque" />

<RadioButton
android:id="@+id/radioButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/textView32"
android:layout_alignParentEnd="true"
android:layout_marginBottom="-176dp"
android:text="Cash" />
</RadioGroup>
47

<EditText
android:id="@+id/editText10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/textView32"
android:layout_alignParentEnd="true"
android:ems="10"
android:inputType="textPersonName" />

<EditText
android:id="@+id/editText11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/textView33"
android:layout_alignParentEnd="true"
android:ems="10"
android:inputType="number" />

<EditText
android:id="@+id/editText14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/textView34"
android:layout_alignParentEnd="true"
android:ems="10"
android:inputType="number" />

<EditText
android:id="@+id/editText15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_marginBottom="157dp"
android:ems="10"
android:inputType="textMultiLine" />

<Button
android:id="@+id/button5"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="Save" />
48

<Button
android:id="@+id/button7"
android:layout_width="wrap_content"
android:layout_height="47dp"
android:layout_alignEnd="@+id/Delr"
android:layout_alignParentBottom="true"
android:text="Cancel" />

<TextView
android:id="@+id/textView47"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignStart="@+id/Delr"
android:layout_marginBottom="92dp"
android:text="choose date"
android:textColor="#000fff"/>

<TextView
android:id="@+id/textView48"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignStart="@+id/spinner11"
android:layout_alignTop="@+id/textView47" />

<Button
android:id="@+id/button10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="@+id/spinner11"
android:layout_alignParentBottom="true"
android:text="home" />

</RelativeLayout>

Purchasereceipt.java

package com.maragatham.maragathamtechnologys;
import android.app.AlertDialog;
49

import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.CalendarView;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import java.util.ArrayList;
public class PurchaseReceipt extends AppCompatActivity implements
View.OnClickListener{

TextView tv1,tv2,setdate;
SQLiteDatabase mydb;
Spinner My_spinner;
ArrayAdapter my_Adapter;
ArrayList<String>my_array1;
Button home;
String DATABASE_NAME="maragathamtechdb";String basespinner="",msg="";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_purchase_receipt);
home=(Button)findViewById(R.id.button10);
tv1=(TextView)findViewById(R.id.textView47);
tv2=(TextView)findViewById(R.id.textView312);
setdate=(TextView)findViewById(R.id.textView48);
tv1.setOnClickListener(PurchaseReceipt.this);
tv2.setOnClickListener(PurchaseReceipt.this);
home.setOnClickListener(PurchaseReceipt.this);
mydb = openOrCreateDatabase(DATABASE_NAME, MODE_PRIVATE, null);
ArrayList<String> my_array = new ArrayList<String>();
my_array = getTableValues();
My_spinner = (Spinner) findViewById(R.id.spinner11);
my_Adapter = new ArrayAdapter(this, R.layout.spinner_row,my_array);
My_spinner.setAdapter(my_Adapter);
50

}
public ArrayList<String> getTableValues() {
ArrayList<String> my_array = new ArrayList<String>();
try {
mydb = openOrCreateDatabase(DATABASE_NAME, Context.MODE_PRIVATE, null);
Cursor allrows = mydb.rawQuery("SELECT * FROM Dealer", null);
System.out.println("COUNT : " + allrows.getCount());
if (allrows.moveToFirst()) {
do {
String NAME = allrows.getString(1);
my_array.add(NAME);
} while (allrows.moveToNext());
}
allrows.close();
} catch (SQLException e) {
Toast.makeText(getApplicationContext(), "Error encountered.",
Toast.LENGTH_LONG);}
return my_array;
}
private void chooseDate(Context c) {
final CalendarView cv=new CalendarView(c);
cv.setOnDateChangeListener(new CalendarView.OnDateChangeListener() {
@Override
public void onSelectedDayChange(@NonNull CalendarView calendarView, int i, int i1, int
i2) {
msg = "" + i2 + "/" + (i1 + 1) + "/" + i;
}
});
AlertDialog dialog = new AlertDialog.Builder(c)
.setTitle("Date Picker")
.setMessage("Choose Date")
.setView(cv)
.setPositiveButton("Add", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT).show();
setdate.setText(msg);
}
})
.setNegativeButton("Cancel", null)
.create();
dialog.show();
}
@Override
51

public void onClick(View v) {


switch(v.getId())
{
case R.id.textView312:
Intent p1=new Intent(getApplicationContext(),SaleReceipt.class);
startActivity(p1);
break;
case R.id.textView47:
chooseDate(PurchaseReceipt.this);
break;
case R.id.button10:
Intent p2=new Intent(getApplicationContext(),MainActivity.class);
startActivity(p2);
break;
}
}

APPENDIX 2-SCREENSHOT
52

Fig 7.3 Home Page

Fig 7.4 Laptop Information


53

Fig 7.5 Dealer List

Fig 7.6Laptop List


54

Fig 7.7 Sale Receipt

Fig 7.8 Purchase Receipt


55

REFERENCES

[1] http://developer.android.com/guide/basics/what-is- android.html


[2] 3G Mobile Terminal Development Trend of the operating system
[M/OL] http://pda.c114.net/32/c4948.html, 2007
[3] Android Architecture 2010[R/OL].
http://www.cnmsdn.com/html/201003/1268713218ID2058_2 .html
[4] Static detection of malicious code in executable programs by J.
Bergeron, M. Debbabi, J. Desharnais, M. M. Erhioui, Y. Lavoie, and
N. Tawbi.
[5] Android Official Website (2008)—“Android | Official Website”,
<http://www.android.com/>
[6] An Android Application Sandbox System for Suspicious Software
Detection, by Thomas Bl¨asing, Leonid Batyuk, Aubrey-Derrick
Schmidt, Seyit Ahmet Camtepe, and Sahin Albayrak
[7] www.blackhat.com

You might also like