package com.example.sawan.onlineattendance;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.os.AsyncTask;
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.EditText;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import org.apache.http.NameValuePair;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.List;
public class Faculty extends AppCompatActivity {
JSONParser jParser = new JSONParser();
JSONObject json;
static String button;
Button update, continu, dricNotice,hodNotice,notice;
static boolean ma = false;
Context ctx;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ctx = this;
setContentView(R.layout.activity_faculty);
update = (Button) findViewById(R.id.faculty_code_button);
continu = (Button) findViewById(R.id.continu);
dricNotice = (Button) findViewById(R.id.PrincipalNotice);
hodNotice = (Button) findViewById(R.id.HODNotice);
notice = (Button) findViewById(R.id.HODLogin);
update.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
button = "update";
new Login().execute();
}
});
dricNotice.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
button = "dricNotice";
new Login().execute();
}
});
hodNotice.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
button = "hodNotice";
new Login().execute();
}
});
notice.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent login = new Intent(getApplicationContext(), TeacherHODLogin.class);
System.out.println("........................................ login.....................................................");
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
System.out.println("........................................ 1......................................................");
startActivity(login);
finish();
}
});
continu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent login = new Intent(getApplicationContext(), FacultyPage.class);
System.out.println("........................................ login.....................................................");
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
System.out.println("........................................ 1......................................................");
startActivity(login);
finish();
}
});
}
private class Login extends AsyncTask<String, String, String> {
@SuppressWarnings("WrongThread")
@Override
protected String doInBackground(String... strings) {
String table = Identification.TableName;
// if(button.equals("HOD"))
// {
// String url_login = "http 192.168.43.156:8081/OnlineAttendance/Student";
// List<NameValuePair> params = new ArrayList<NameValuePair>();
// for (int i = 0; i < Identification.FacultySubjectRecord.length; i++)
// {
// params.add(new BasicNameValuePair("Branch" + i, Identification.FacultySubjectRecord[i][0]));
// System.out.println("....." + Identification.FacultySubjectRecord[i][0]);
// params.add(new BasicNameValuePair("Section" + i, Identification.FacultySubjectRecord[i][1]));
// System.out.println("....." + Identification.FacultySubjectRecord[i][1]);
// params.add(new BasicNameValuePair("Subject" + i, Identification.FacultySubjectRecord[i][2]));
// System.out.println("....." + Identification.FacultySubjectRecord[i][2]);
// }
// params.add(new BasicNameValuePair("t", table));
// params.add(new BasicNameValuePair("row", Identification.FacultySubjectRecord.length + ""));
// params.add(new BasicNameValuePair("faculty", Identification.StudentRoll));
// params.add(new BasicNameValuePair("download", button));
// json = jParser.makeHttpRequest(url_login, "GET", params);
// String Sname = null;
// DataBase db=new DataBase(ctx);
// db.deleteData(db);
// try
// {
// System.out.println(Sname=json.getString("info"));
// int m = json.getInt("row");
// System.out.println("m value....."+m) ;
// if (Sname.equals("success"))
// {
// int j = 0;
// int k=0;
// Identification.StudentRecord = new String[m][6];
// System.out.println("inseide " + Identification.StudentRecord.length);
// System.out.println("condition is : " + (j <= m));
// while (j < m)
// {
// String name = json.getString("name" + k);
// k++;
// Identification.StudentRecord[j][0] = name;
// String rool = json.getString("roll" + k);
// k++;
// Identification.StudentRecord[j][1] = rool;
// String branch = json.getString("branch" + k);
// k++;
// Identification.StudentRecord[j][2] = branch;
// String section = json.getString("Section" + k);
// k++;
// Identification.StudentRecord[j][3] = section;
// System.out.println("section value " + Identification.StudentRecord[j][2]);
// String Attendance = json.getString("Attendance" + k);
// k++;
// Identification.StudentRecord[j][4] = Attendance;
// String SubCode= json.getString("SubjectCode" + k);
// k++;
// Identification.StudentRecord[j][5] = SubCode;
// System.out.println("j value is : " + j);
// j++;
// }
// for (int i = 0; i < m; i++)
// {
// System.out.println("...........DataBase class Insert Method is called..........");
//
// db.insertRecord(Identification.StudentRecord[i][0], Identification.StudentRecord[i][1], Identification.StudentRecord[i][2], Identification.StudentRecord[i][3], Identification.StudentRecord[i][4],Identification.StudentRecord[i][5]);
// System.out.println("...........DataBase class Insert Method is called succeful..........");
// }
//
//
// Intent login = new Intent(getApplicationContext(), FacultySubjectSettingPage.class);
// System.out.println("........................................ login.....................................................");
// login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// System.out.println("........................................ 1......................................................");
// startActivity(login);
// finish();
// }
// else
// {
// Intent login = new Intent(getApplicationContext(), Error.class);
// System.out.println("........................................ login.....................................................");
// login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// System.out.println("........................................ 1......................................................");
// startActivity(login);
// finish();
// }
//
// } catch (Exception e) {
// System.out.println("........................................ 1......................................................");
// e.printStackTrace();
// }
// }
// else
if(button.equals("facultydata"))
{
Intent login = new Intent(getApplicationContext(), TeacherNotice.class);
System.out.println("........................................ login.....................................................");
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
System.out.println("........................................ 1......................................................");
startActivity(login);
finish();
}
else if(button.equals("update"))
{
String url_login = http:// 192.168.43.156:8081/OnlineAttendance/StudentUpdate";
List<NameValuePair> params = new ArrayList<NameValuePair>();
DataBase db=new DataBase(ctx);
Cursor cs=db.getInformation(db);
int ror=cs.getCount();
cs.moveToNext();
System.out.println( " row value is : "+ror);
int k=0;
for(int i=0;i<cs.getCount();i++)
{
params.add(new BasicNameValuePair("name"+k,cs.getString(0)));
System.out.println( " name vzlue is : "+cs.getString(0));
k++;
params.add(new BasicNameValuePair("roll"+k,cs.getString(1)));
System.out.println( " roll no is : "+cs.getString(1));
k++;
params.add(new BasicNameValuePair("branch"+k,cs.getInt(2)+""));
System.out.println( " branch no is : "+cs.getString(2));
k++;
params.add(new BasicNameValuePair("section"+k,cs.getString(3)));
System.out.println( " roll no is : "+cs.getString(3));
k++;
params.add(new BasicNameValuePair("attendance"+k,cs.getInt(4)+""));
System.out.println( " attendance no is : "+cs.getString(4));
k++;
params.add(new BasicNameValuePair("subjectcode"+k,cs.getInt(5)+""));
System.out.println("..........subcode value is........."+cs.getInt(5));
k++;
cs.moveToNext();
}
params.add(new BasicNameValuePair("row",ror+""));
params.add(new BasicNameValuePair("table",Identification.TableName));
params.add(new BasicNameValuePair("facultyCode",Identification.FacultyCode));
json = jParser.makeHttpRequest(url_login, "GET", params);
String Sname=null;
try {
if (json.getString("info").equals("success")) {
Cursor cs2=db.getInformation3(db);
int ror2=cs2.getCount();
cs2.moveToFirst();
List<NameValuePair> params2 = new ArrayList<NameValuePair>();
for(int i=0;i<cs2.getCount();i++)
{
params2.add(new BasicNameValuePair("faccode"+i,cs2.getInt(0)+""));
params2.add(new BasicNameValuePair("subcode"+i,cs2.getInt(1)+""));
params2.add(new BasicNameValuePair("lecno"+i,cs2.getInt(2)+""));
params2.add(new BasicNameValuePair("str"+i,cs2.getInt(3)+""));
params2.add(new BasicNameValuePair("br"+i,cs2.getInt(4)+""));
params2.add(new BasicNameValuePair("sec"+i,cs2.getString(5)+""));
cs2.moveToNext();
}
params2.add(new BasicNameValuePair("row",ror2+""));
params2.add(new BasicNameValuePair("table",Identification.TableName));
String url_login2 = "http:/ /192.168.43.156:8081/OnlineAttendance/FacultyDataUpdation";
json = jParser.makeHttpRequest(url_login2, "GET", params2);
String Sname2=null;
if(json.getString("info2").equals("success"))
{
String url_login3 = http:// 192.168.43.156:8081/OnlineAttendance/Student";
List<NameValuePair> params3 = new ArrayList<NameValuePair>();
for (int i = 0; i < Identification.FacultySubjectRecord.length; i++)
{
params3.add(new BasicNameValuePair("Branch" + i, Identification.FacultySubjectRecord[i][0]));
System.out.println("....." + Identification.FacultySubjectRecord[i][0]);
params3.add(new BasicNameValuePair("Section" + i, Identification.FacultySubjectRecord[i][1]));
System.out.println("....." + Identification.FacultySubjectRecord[i][1]);
params3.add(new BasicNameValuePair("Subject" + i, Identification.FacultySubjectRecord[i][2]));
System.out.println("....." + Identification.FacultySubjectRecord[i][2]);
}
params3.add(new BasicNameValuePair("t", table));
params3.add(new BasicNameValuePair("row", Identification.FacultySubjectRecord.length + ""));
params3.add(new BasicNameValuePair("faculty", Identification.StudentRoll));
params3.add(new BasicNameValuePair("download", button));
json = jParser.makeHttpRequest(url_login3, "GET", params3);
System.out.println("...........................1 ..............................");
System.out.println("...........................1 ..............................");
System.out.println("...........................1 ..............................");
System.out.println("...........................1 ..............................");
System.out.println("...........................1 ..............................");
String Sname3 = null;
System.out.println("...........................1 ..............................");
System.out.println("...........................1 ..............................");
System.out.println("...........................1 ..............................");
System.out.println("...........................1 ..............................");
db.deleteData(db);
System.out.println("...........................1 ..............................");
System.out.println("...........................1 ..............................");
System.out.println("...........................1 ..............................");
System.out.println("...........................1 ..............................");
System.out.println("...........................1 ..............................");
System.out.println("...........................1 ..............................");
try
{
System.out.println(Sname3=json.getString("info"));
int m = json.getInt("row");
System.out.println("m value....."+m) ;
if (Sname3.equals("success")) {
int j = 0;
int q = 0;
Identification.StudentRecord = new String[m][6];
System.out.println("inseide " + Identification.StudentRecord.length);
System.out.println("condition is : " + (j <= m));
while (j < m) {
String name = json.getString("name" + q);
q++;
Identification.StudentRecord[j][0] = name;
String rool = json.getString("roll" + q);
q++;
Identification.StudentRecord[j][1] = rool;
String branch = json.getString("branch" + q);
q++;
Identification.StudentRecord[j][2] = branch;
String section = json.getString("Section" + q);
q++;
Identification.StudentRecord[j][3] = section;
System.out.println("section value " + Identification.StudentRecord[j][2]);
String Attendance = json.getString("Attendance" + q);
q++;
Identification.StudentRecord[j][4] = Attendance;
String SubCode = json.getString("SubjectCode" + q);
q++;
Identification.StudentRecord[j][5] = SubCode;
System.out.println("j value is : " + j);
j++;
}
for (int i = 0; i < m; i++) {
System.out.println("...........DataBase class Insert Method is called..........");
db.insertRecord(Identification.StudentRecord[i][0], Identification.StudentRecord[i][1], Identification.StudentRecord[i][2], Identification.StudentRecord[i][3], Identification.StudentRecord[i][4], Identification.StudentRecord[i][5]);
System.out.println("...........DataBase class Insert Method is called succeful..........");
}
}
String url_login4 = "http: 192.168.43.156:8081/OnlineAttendance/StudentRecordUpdateAttendance";
List<NameValuePair> params4 = new ArrayList<NameValuePair>();
Cursor cs3=db.getInformation5(db);
int ror3=cs3.getCount();
cs3.moveToNext();
System.out.println( " row value is : "+ror3);
k=0;
for(int i=0;i<cs3.getCount();i++)
{
params4.add(new BasicNameValuePair("name"+k,cs3.getString(0)));
System.out.println("................"+cs3.getString(0));
k++;
params4.add(new BasicNameValuePair("roll"+k,cs3.getString(1)));
System.out.println("................"+cs3.getString(1));
k++;
params4.add(new BasicNameValuePair("subject"+k,cs3.getInt(2)+""));
System.out.println("................"+cs3.getString(2));
k++;
params4.add(new BasicNameValuePair("faculty"+k,cs3.getString(3)));
System.out.println("................"+cs3.getString(3));
k++;
params4.add(new BasicNameValuePair("day"+k,cs3.getString(4)+""));
System.out.println("................"+cs3.getString(4));
k++;
params4.add(new BasicNameValuePair("month"+k,cs3.getString(5)+""));
System.out.println("................"+cs3.getString(5));
k++;
params4.add(new BasicNameValuePair("year"+k,cs3.getString(6)+""));
System.out.println("................"+cs3.getString(6));
k++;
params4.add(new BasicNameValuePair("hour"+k,cs3.getString(7)+""));
System.out.println("................"+cs3.getString(7));
k++;
params4.add(new BasicNameValuePair("minu"+k,cs3.getString(8)+""));
System.out.println("................"+cs3.getString(8));
k++;
params4.add(new BasicNameValuePair("number"+k,cs3.getInt(9)+""));
System.out.println("................"+cs3.getString(9));
k++;
cs3.moveToNext();
}
params4.add(new BasicNameValuePair("row",ror3+""));
params4.add(new BasicNameValuePair("table",Identification.TableName));
json = jParser.makeHttpRequest(url_login4, "GET", params4);
String Sname5=null;
if(json.getString("info6").equals("success"))
{
db.deleteData4(db);
Intent login = new Intent(getApplicationContext(),Successful.class);
System.out.println("........................................ login.....................................................");
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
System.out.println("........................................ 1......................................................");
startActivity(login);
finish();
}
}
catch (Exception e)
{
System.out.println("...........Dtadata download error in upadation..........");
e.printStackTrace();
}
}
}
else
{
Intent login = new Intent(getApplicationContext(), Error.class);
System.out.println("........................................ login.....................................................");
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
System.out.println("........................................ 1......................................................");
startActivity(login);
finish();
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
else if(button.equals("dricNotice"))
{
String url_login2 = "http 192.168.43.156:8081/OnlineAttendance/DirectorNoticeServlet";
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("t", Identification.TableName));
params.add(new BasicNameValuePair("cutoff", button));
params.add(new BasicNameValuePair("text", "faltu"));
json = jParser.makeHttpRequest(url_login2, "GET", params);
System.out.println("................ 7......................." + json);
String s = null;
try {
if (json.getString("info").equals("success")) {
Identification.FacultyDrictorNotices=json.getString("name");
Intent login = new Intent(getApplicationContext(), FacultyDrictorNotice.class);
System.out.println("........................................ login.....................................................");
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
System.out.println("........................................ 1......................................................");
startActivity(login);
finish();
}
else
{
Intent login = new Intent(getApplicationContext(), Error.class);
System.out.println("........................................ login.....................................................");
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
System.out.println("........................................ 1......................................................");
startActivity(login);
finish();
}
} catch (Exception e) {
e.printStackTrace();
}
}
else if(button.equals("hodNotice"))
{
String url_login2 = "http 192.168.43.156:8081/OnlineAttendance/DirectorNoticeServlet";
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("t", Identification.TableName));
params.add(new BasicNameValuePair("cutoff", button));
params.add(new BasicNameValuePair("text", "faltu"));
json = jParser.makeHttpRequest(url_login2, "GET", params);
System.out.println("................ 7......................." + json);
String s = null;
try {
if (json.getString("info").equals("success")) {
Identification.FacultyDrictorNotices=json.getString("name");
Intent login = new Intent(getApplicationContext(), FacultyHODNotice.class);
System.out.println("........................................ login.....................................................");
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
System.out.println("........................................ 1......................................................");
startActivity(login);
finish();
}
else
{
Intent login = new Intent(getApplicationContext(), Error.class);
System.out.println("........................................ login.....................................................");
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
System.out.println("........................................ 1......................................................");
startActivity(login);
finish();
}
} catch (Exception e) {
e.printStackTrace();
}
}
else if(button.equals("HOD"))
{
Intent login = new Intent(getApplicationContext(), TeacherHODLogin.class);
System.out.println("........................................ login.....................................................");
login.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
System.out.println("........................................ 1......................................................");
startActivity(login);
finish();
}
return null;
}
}
}
No comments:
Post a Comment