package com.example.sawan.onlineattendance;
import android.content.Intent;
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.Spinner;
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 FacultySubjectSetting extends AppCompatActivity {
Button btn;
String fca;
JSONParser jParser = new JSONParser();
JSONObject json;
private static String url_login = "http:// 192. 168. 43. 156: 8081 /OnlineAttendance/UpdateTeaherSubjectSettingSearch";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_faculty_subject_setting);
btn=(Button)findViewById(R.id.search);
Spinner spinner4 = (Spinner) findViewById(R.id.spinner_faculty);
ArrayAdapter<CharSequence> adapter4 = ArrayAdapter.createFromResource(
this, R.array.Faculty, android.R.layout.simple_spinner_item);
adapter4.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner4.setAdapter(adapter4);
spinner4.setOnItemSelectedListener(new MyOnItemSelectedListener());
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Spinner sp4 = (Spinner)findViewById(R.id.spinner_faculty);
String facu = sp4.getSelectedItem().toString();
fca=Integer.parseInt(facu)+"";
new Login().execute();
}
});
}
private class Login extends AsyncTask<String, String, String> {
@SuppressWarnings("WrongThread")
@Override
protected String doInBackground(String... strings) {
String username = fca;
String table = Identification.TableName;
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("u",username));
params.add(new BasicNameValuePair("t",table));
json = jParser.makeHttpRequest(url_login, "GET", params);
String Sname=null;
try {
System.out.println(json.getString("info"));
int m=json.getInt("row");
if( json.getString("info").equals("success"))
{
int j=1;
Identification.FacultySubjectRecord=new String[m][3];
Identification.FacultyCode=json.getString("facultyCode");
System.out.println("condition is : "+(j<=m));
while(j<=m)
{
String sub=json.getString("sub"+j);
System.out.println("inseide "+sub);
System.out.println("inseide "+Identification.FacultySubjectRecord.length);
System.out.println("inseide "+(j-1));
System.out.println("inseide "+Identification.FacultySubjectRecord[j-1][0]);
Identification.FacultySubjectRecord[j-1][0]=sub;
System.out.println("nrfjnkmlk kgkm :");
System.out.println("inseide "+Identification.FacultySubjectRecord[j-1][0]);
String branch=json.getString("branch"+j);
Identification.FacultySubjectRecord[j-1][1]=branch;
String section=json.getString("section"+j);
Identification.FacultySubjectRecord[j-1][2]=section;
System.out.println("inseide "+Identification.FacultySubjectRecord[j-1][2]);
System.out.println("j value is : "+j);
j++;
}
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)
{
}
return null;
}
}
}
import android.content.Intent;
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.Spinner;
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 FacultySubjectSetting extends AppCompatActivity {
Button btn;
String fca;
JSONParser jParser = new JSONParser();
JSONObject json;
private static String url_login = "http:// 192. 168. 43. 156: 8081 /OnlineAttendance/UpdateTeaherSubjectSettingSearch";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_faculty_subject_setting);
btn=(Button)findViewById(R.id.search);
Spinner spinner4 = (Spinner) findViewById(R.id.spinner_faculty);
ArrayAdapter<CharSequence> adapter4 = ArrayAdapter.createFromResource(
this, R.array.Faculty, android.R.layout.simple_spinner_item);
adapter4.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner4.setAdapter(adapter4);
spinner4.setOnItemSelectedListener(new MyOnItemSelectedListener());
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Spinner sp4 = (Spinner)findViewById(R.id.spinner_faculty);
String facu = sp4.getSelectedItem().toString();
fca=Integer.parseInt(facu)+"";
new Login().execute();
}
});
}
private class Login extends AsyncTask<String, String, String> {
@SuppressWarnings("WrongThread")
@Override
protected String doInBackground(String... strings) {
String username = fca;
String table = Identification.TableName;
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("u",username));
params.add(new BasicNameValuePair("t",table));
json = jParser.makeHttpRequest(url_login, "GET", params);
String Sname=null;
try {
System.out.println(json.getString("info"));
int m=json.getInt("row");
if( json.getString("info").equals("success"))
{
int j=1;
Identification.FacultySubjectRecord=new String[m][3];
Identification.FacultyCode=json.getString("facultyCode");
System.out.println("condition is : "+(j<=m));
while(j<=m)
{
String sub=json.getString("sub"+j);
System.out.println("inseide "+sub);
System.out.println("inseide "+Identification.FacultySubjectRecord.length);
System.out.println("inseide "+(j-1));
System.out.println("inseide "+Identification.FacultySubjectRecord[j-1][0]);
Identification.FacultySubjectRecord[j-1][0]=sub;
System.out.println("nrfjnkmlk kgkm :");
System.out.println("inseide "+Identification.FacultySubjectRecord[j-1][0]);
String branch=json.getString("branch"+j);
Identification.FacultySubjectRecord[j-1][1]=branch;
String section=json.getString("section"+j);
Identification.FacultySubjectRecord[j-1][2]=section;
System.out.println("inseide "+Identification.FacultySubjectRecord[j-1][2]);
System.out.println("j value is : "+j);
j++;
}
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)
{
}
return null;
}
}
}
No comments:
Post a Comment