Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
Helping_hand-419-423-604
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tharun kumar
Helping_hand-419-423-604
Commits
a67cd413
Commit
a67cd413
authored
5 years ago
by
Tharun kumar
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
6fbdcdbb
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
MainActivity.java
+103
-0
103 additions, 0 deletions
MainActivity.java
with
103 additions
and
0 deletions
MainActivity.java
0 → 100644
+
103
−
0
View file @
a67cd413
package
com.example.fund_restart
;
import
androidx.appcompat.app.AlertDialog
;
import
androidx.appcompat.app.AppCompatActivity
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.content.Intent
;
import
android.database.Cursor
;
import
android.database.sqlite.SQLiteDatabase
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.widget.Button
;
import
android.widget.EditText
;
import
android.widget.TextView
;
import
android.widget.Toast
;
public
class
MainActivity
extends
AppCompatActivity
implements
View
.
OnClickListener
{
EditText
email
,
password
;
Button
loginbutton
;
TextView
register
,
logintext
,
admin_login
;
SQLiteDatabase
d
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
activity_main
);
logintext
=
findViewById
(
R
.
id
.
logintext
);
email
=
(
EditText
)
findViewById
(
R
.
id
.
username
);
password
=
(
EditText
)
findViewById
(
R
.
id
.
password
);
admin_login
=
findViewById
(
R
.
id
.
adminlog
);
register
=
findViewById
(
R
.
id
.
register
);
register
.
setOnClickListener
(
this
);
logintext
.
setOnClickListener
(
this
);
admin_login
.
setOnClickListener
(
this
);
d
=
openOrCreateDatabase
(
"StudentDB"
,
Context
.
MODE_PRIVATE
,
null
);
}
@Override
public
void
onClick
(
View
v
)
{
if
(
v
.
getId
()
==
R
.
id
.
adminlog
){
Intent
admin
=
new
Intent
(
this
,
Adminpre
.
class
);
startActivity
(
admin
);
}
if
(
v
.
getId
()
==
R
.
id
.
register
){
Intent
register_intent
=
new
Intent
(
this
,
Register
.
class
);
startActivity
(
register_intent
);
}
if
(
v
.
getId
()
==
R
.
id
.
logintext
){
if
(
email
.
getText
().
toString
().
isEmpty
()
||
password
.
getText
().
toString
().
isEmpty
())
{
{
AlertDialog
.
Builder
alertDialog
=
new
AlertDialog
.
Builder
(
MainActivity
.
this
);
alertDialog
.
setTitle
(
"Alert"
);
alertDialog
.
setMessage
(
"Fill all the details"
);
alertDialog
.
setPositiveButton
(
"ok"
,
new
DialogInterface
.
OnClickListener
()
{
@Override
public
void
onClick
(
DialogInterface
dialog
,
int
which
)
{
}
});
alertDialog
.
show
();
}}
else
{
Cursor
cus
=
d
.
rawQuery
(
"SELECT count(email) FROM student WHERE email ='"
+
email
.
getText
()
+
"'"
,
null
);
if
(
cus
.
moveToFirst
())
{
if
(
cus
.
getInt
(
0
)>=
1
)
{
Cursor
cu
=
d
.
rawQuery
(
"SELECT password FROM student WHERE email='"
+
email
.
getText
()
+
"'"
,
null
);
if
(
cu
.
moveToFirst
())
{
// Displaying record if found
if
(
cu
.
getString
(
0
).
equals
(
password
.
getText
().
toString
())
)
{
Toast
.
makeText
(
getApplicationContext
(),
"Logging in...."
,
Toast
.
LENGTH_SHORT
).
show
();
Intent
x
=
new
Intent
(
MainActivity
.
this
,
Login
.
class
);
startActivity
(
x
);
}
else
{
showMessage
(
"Error"
,
"Invalid password"
);
password
.
setText
(
""
);
}
}
cu
.
close
();
}
else
if
(
cus
.
getInt
(
0
)==
0
)
{
showMessage
(
"Create an account first"
,
"No account found in this name"
);
}
}
cus
.
close
();}
}
}
private
void
showMessage
(
String
error
,
String
invalid_password
)
{
AlertDialog
.
Builder
builder
=
new
AlertDialog
.
Builder
(
this
);
builder
.
setCancelable
(
true
);
builder
.
setTitle
(
error
);
builder
.
setMessage
(
invalid_password
);
builder
.
show
();
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment