• No se han encontrado resultados

Plan de prueba del producto multimedia “Constitución II”

CAPÍTULO 2 MODELO DE PRUEBAS

2.2 DESCRIPCIÓN GENERAL DE LA ESTRAT E GIA DE PRUEBA A UTILIZAR

2.2.1 Plan de prueba del producto multimedia “Constitución II”

package Model;

import java.util.*;

import java.sql.*;

import com.*;

import java.io.*;

public class Fees extends Connect {

/////Function for connect to the MySQL Server Database////////////

public Fees() {

Connect.connect_mysql();

}

//////////Save the Fees Details /////

public String saveFees(HashMap feesData) {

String SQL = "INSERT INTO fees (fees_student_id, fees_month, fees_amount, fees_date) VALUES (?, ?, ?, ?);";

int record=0;

String error = "";

try {

pstmt = connection.prepareStatement(SQL, Statement.RETURN_GENERATED_KEYS);

pstmt.setString(1,(String) feesData.get("fees_student_id"));

pstmt.setString(2,(String) feesData.get("fees_month"));

pstmt.setString(3,(String) feesData.get("fees_amount"));

pstmt.setString(4,(String) feesData.get("fees_date"));

record = pstmt.executeUpdate();

ResultSet rs = pstmt.getGeneratedKeys();

if(rs.next()) {

int last_inserted_id = rs.getInt(1);

error = Integer.toString(last_inserted_id);

}

pstmt.close();

connection.close();

}

catch(Exception e) {

StringWriter writer = new StringWriter();

PrintWriter printWriter = new PrintWriter( writer );

e.printStackTrace( printWriter );

printWriter.flush();

String stackTrace = writer.toString();

error+="Error : "+stackTrace;

System.out.println(" Error : "+ e.toString());

}

return error;

}

//////////////////Function for getting Fees Details//////////

public HashMap getFeesDetails(int fees_id) {

HashMap results = new HashMap();

int count=0;

try {

String SQL = "SELECT * FROM fees WHERE fees_id = "+fees_id ; statement = connection.createStatement();

rs = statement.executeQuery(SQL);

while(rs.next()) {

results.put("fees_id",rs.getString("fees_id"));

results.put("fees_student_id",Integer.parseInt(rs.getString("fees_student_id")));

results.put("fees_month",Integer.parseInt(rs.getString("fees_month")));

results.put("fees_amount",rs.getString("fees_amount"));

results.put("fees_date",Integer.parseInt(rs.getString("fees_date")));

count++;

}

if(count==0) {

results.put("fees_id","");

results.put("fees_student_id",0);

results.put("fees_month",0);

results.put("fees_amount","");

results.put("fees_date","");

} }

catch(Exception e) {

System.out.println("Error is: "+ e);

}

return results;

}

////// Function for updating fees details ////

public String updateFees(HashMap feesData) {

String SQL = "UPDATE 'fees' SET 'fees_student_id' = ?, 'fees_month' =

?, 'fees_amount' = ?, 'fees_date' = ? WHERE 'fees_id' = ?;";

String error = "";

int record=0;

try {

pstmt = connection.prepareStatement(SQL);

pstmt.setString(1,(String) feesData.get("fees_student_id"));

pstmt.setString(2,(String) feesData.get("fees_month"));

pstmt.setString(3,(String) feesData.get("fees_amount"));

pstmt.setString(4,(String) feesData.get("fees_date"));

pstmt.setString(5,(String) feesData.get("fees_id"));

record = pstmt.executeUpdate();

pstmt.close();

connection.close();

}

catch(Exception e) {

StringWriter writer = new StringWriter();

PrintWriter printWriter = new PrintWriter( writer );

e.printStackTrace( printWriter );

printWriter.flush();

String stackTrace = writer.toString();

error+="Error : "+stackTrace;

System.out.println(" Error : "+ e.toString());

}

return error;

}

////////////////Function for getting all the feess details listing////////////////////

public ArrayList getAllFees(String student_id) {

String SQL = "SELECT * FROM fees, student where fees_student_id = student_id";

int count=0;

ArrayList resultArray = new ArrayList();

try {

if(!student_id.equals("0")) {

SQL = "SELECT * FROM fees, student WHERE fees_student_id = student_id AND fees_student_id = "+student_id;

}

statement = connection.createStatement();

rs = statement.executeQuery(SQL);

while(rs.next()) {

HashMap results = new HashMap();

results.put("fees_id",rs.getString("fees_id"));

results.put("fees_student_id",Integer.parseInt(rs.getString("fees_student_id")));

results.put("fees_month",Integer.parseInt(rs.getString("fees_month")));

results.put("fees_amount",rs.getString("fees_amount"));

results.put("fees_date",rs.getString("fees_date"));

results.put("student_name",rs.getString("student_first_name")+"

"+rs.getString("student_middle_name")+" "+rs.getString("student_last_name"));

count++;

resultArray.add(results);

} }

catch(Exception e) {

System.out.println("Error is: "+ e);

}

return resultArray;

}

/////Function for Getting the List////////////

public String getMonthOption(Integer SelID) {

int selectedID = SelID.intValue();

return

Connect.getOptionList("month","month_id","month_name","month_id,month_name

",selectedID,"1");

} }

Coding of Login.java

package Model;

import java.util.*;

import java.sql.*;

import com.*;

import java.io.*;

public class Login extends Connect {

/////Function for connect to the MySQL Server Database////////////

public Login() {

Connect.connect_mysql();

}

//////////////////Function for Update the airport////////////////////////

public boolean changePassword(String old_password,String new_password, int login_id)

{

String SQL;

int count = 0;

try {

SQL = "SELECT * FROM login WHERE login_password = '"+old_password+"' AND login_id = "+login_id ;

statement = connection.createStatement();

rs = statement.executeQuery(SQL);

while(rs.next()) count++;

if(count==1) {

SQL = "UPDATE login SET login_password=? WHERE login_id=?";

int record=0;

pstmt = connection.prepareStatement(SQL);

pstmt.setString(1,new_password);

pstmt.setInt(2,1);

record = pstmt.executeUpdate();

pstmt.close();

connection.close();

} }

catch(Exception e) {

System.out.println(" Error : "+ e.toString());

}

if(count==0) return false;

return true;

}

//////////////////Function for geting the Single Airport Details//////////

public boolean checkLogin(String login_user,String login_password) {

int count=0;

try {

String SQL = "SELECT * FROM login WHERE login_user = '"+login_user+"' AND login_password = '"+login_password+"'" ;

statement = connection.createStatement();

//////////////////Function for getting Login Details//////////

public HashMap getLoginDetails(String login_user,String login_password) { AND login_password = '"+login_password+"'" ;

statement = connection.createStatement();

rs = statement.executeQuery(SQL);

while(rs.next()) {

resultsArray.put("login_id",rs.getString("login_id"));

resultsArray.put("login_emp_id",rs.getString("login_emp_id"));

resultsArray.put("login_user",rs.getString("login_user"));

resultsArray.put("login_level",rs.getString("login_level"));

count++;

}

if(count==0) {

resultsArray.put("login_id","");

resultsArray.put("login_emp_id","");

resultsArray.put("login_user","");

resultsArray.put("login_level","");

} }

catch(Exception e) {

System.out.println("Error is: "+ e);

}

return resultsArray;

} }

Coding of Salary.java

package Model;

import java.util.*;

import java.sql.*;

import com.*;

import java.io.*;

public class Salary extends Connect {

/////Function for connect to the MySQL Server Database////////////

public Salary() {

Connect.connect_mysql();

}

//////////Save User Details /////

public String saveSalary(HashMap salaryData) {

String SQL = "INSERT INTO salary (sal_employe_id, sal_month, sal_year, sal_amount) VALUES (?, ?, ?, ?);";

int record=0;

String error = "";

try {

pstmt = connection.prepareStatement(SQL);

pstmt.setString(1,(String) salaryData.get("sal_employe_id"));

pstmt.setString(2,(String) salaryData.get("sal_month"));

pstmt.setString(3,(String) salaryData.get("sal_year"));

pstmt.setString(4,(String) salaryData.get("sal_amount"));

record = pstmt.executeUpdate();

pstmt.close();

connection.close();

}

catch(Exception e) {

StringWriter writer = new StringWriter();

PrintWriter printWriter = new PrintWriter( writer );

e.printStackTrace( printWriter );

printWriter.flush();

String stackTrace = writer.toString();

error+="Error : "+stackTrace;

System.out.println(" Error : "+ e.toString());

}

return error;

}

//////////////////Function for getting Users Details//////////

public HashMap getSalaryDetails(int sal_id) {

HashMap results = new HashMap();

int count=0;

try {

String SQL = "SELECT * FROM salary WHERE sal_id = "+sal_id ; statement = connection.createStatement();

rs = statement.executeQuery(SQL);

while(rs.next()) {

results.put("sal_id",rs.getString("sal_id"));

results.put("sal_employe_id",Integer.parseInt(rs.getString("sal_employe_id")));

results.put("sal_year",rs.getString("sal_year"));

results.put("sal_month",Integer.parseInt(rs.getString("sal_month")));

results.put("sal_amount",rs.getString("sal_amount"));

count++;

}

if(count==0) {

results.put("sal_id","");

results.put("sal_employe_id",0);

results.put("sal_year","");

results.put("sal_month",0);

results.put("sal_amount","");

} }

catch(Exception e) {

System.out.println("Error is: "+ e);

}

return results;

}

//////////////////Function for getting Users Details//////////

public String getMonth(int mon_id) {

public String updateSalary(HashMap salaryData) {

String SQL = "UPDATE salary SET sal_employe_id = ?,sal_year

= ?,sal_month = ?,sal_amount = ? WHERE sal_id = ?";

String error = "";

int record=0;

try {

pstmt = connection.prepareStatement(SQL);

pstmt.setString(1,(String) salaryData.get("sal_employe_id"));

pstmt.setString(2,(String) salaryData.get("sal_year"));

pstmt.setString(3,(String) salaryData.get("sal_month"));

pstmt.setString(4,(String) salaryData.get("sal_amount"));

pstmt.setString(5,(String) salaryData.get("sal_id"));

record = pstmt.executeUpdate();

pstmt.close();

connection.close();

}

catch(Exception e) {

StringWriter writer = new StringWriter();

PrintWriter printWriter = new PrintWriter( writer );

e.printStackTrace( printWriter );

printWriter.flush();

String stackTrace = writer.toString();

error+="Error : "+stackTrace;

System.out.println(" Error : "+ e.toString());

}

return error;

}

public boolean delete_login(int airline_id) {

return true;

}

////////////////Function for getting all the Airport Details////////////////////

public ArrayList getAllSalary(String emp_id) {

String SQL = "SELECT * FROM salary";

int count=0;

ArrayList resultArray = new ArrayList();

try {

if(!emp_id.equals("0")) {

SQL = "SELECT * FROM salary WHERE sal_employe_id =

"+emp_id;

}

statement = connection.createStatement();

rs = statement.executeQuery(SQL);

while(rs.next()) {

HashMap results = new HashMap();

results.put("sal_id",rs.getString("sal_id"));

results.put("sal_employe_id",Integer.parseInt(rs.getString("sal_employe_id")));

results.put("sal_year",rs.getString("sal_year"));

results.put("sal_month",Integer.parseInt(rs.getString("sal_month")));

/////Function for Getting the List////////////

public String getMonthOption(Integer SelID) {

int selectedID = SelID.intValue();

return

Connect.getOptionList("month","month_id","month_name","month_id,month_name

",selectedID,"1");

}

/////Function for Getting the List////////////

public String getEmployeeOption(Integer SelID) {

int selectedID = SelID.intValue();

return

Connect.getOptionList("employee","employee_id","employee_id","employee_id,emp loyee_id",selectedID,"1");

}

}

Coding of Student.java

package Model;

import java.util.*;

import java.sql.*;

import com.*;

import java.io.*;

public class Student extends Connect {

/////Function for connect to the MySQL Server Database////////////

public Student() {

Connect.connect_mysql();

}

//////////Save User Details /////

public String saveStudent(HashMap studentData) {

String SQL = "INSERT INTO student (student_user, student_password, student_level, student_sal, student_first_name, student_middle_name, student_last_name, student_gender, student_address, student_village,

student_state, student_country, student_landline, student_mobile, student_email, student_status, student_deparment, student_dob, student_nationalty) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?);";

int record=0,last_inserted_id=0;

String error = "";

try {

pstmt = connection.prepareStatement(SQL);

pstmt.setString(1,(String) studentData.get("student_user"));

pstmt.setString(2,(String) studentData.get("student_password"));

pstmt.setString(3,(String) studentData.get("student_level"));

pstmt.setString(4,(String) studentData.get("student_sal"));

pstmt.setString(5,(String) studentData.get("student_first_name"));

pstmt.setString(6,(String) studentData.get("student_middle_name"));

pstmt.setString(7,(String) studentData.get("student_last_name"));

pstmt.setString(8,(String) studentData.get("student_gender"));

pstmt.setString(9,(String) studentData.get("student_address"));

pstmt.setString(10,(String) studentData.get("student_village"));

pstmt.setString(11,(String) studentData.get("student_state"));

pstmt.setString(12,(String) studentData.get("student_country"));

pstmt.setString(13,(String) studentData.get("student_landline"));

pstmt.setString(14,(String) studentData.get("student_mobile"));

pstmt.setString(15,(String) studentData.get("student_email"));

pstmt.setString(16,(String) studentData.get("student_status"));

pstmt.setString(17,(String) studentData.get("student_deparment"));

pstmt.setString(18,(String) studentData.get("student_dob"));

pstmt.setString(19,(String) studentData.get("student_nationalty"));

record = pstmt.executeUpdate();

/// Get the Last Insert ID ///

rs = pstmt.getGeneratedKeys();

if(rs.next()) {

last_inserted_id = rs.getInt(1);

}

pstmt.close();

}

catch(Exception e) {

StringWriter writer = new StringWriter();

PrintWriter printWriter = new PrintWriter( writer );

e.printStackTrace( printWriter );

printWriter.flush();

String stackTrace = writer.toString();

error+="Error : "+stackTrace;

System.out.println(" Error : "+ e.toString());

}

/// Save Credentials to Login ////

SQL = "INSERT INTO login (login_emp_id, login_user, login_password, login_email) VALUES (?, ?, ?, ? );";

try {

pstmt = connection.prepareStatement(SQL);

pstmt.setInt(1,last_inserted_id);

pstmt.setString(2,(String) studentData.get("student_user"));

pstmt.setString(3,(String) studentData.get("student_password"));

pstmt.setString(4,(String) studentData.get("student_email"));

record = pstmt.executeUpdate();

pstmt.close();

connection.close();

}

catch(Exception e) {

StringWriter writer = new StringWriter();

PrintWriter printWriter = new PrintWriter( writer );

e.printStackTrace( printWriter );

printWriter.flush();

String stackTrace = writer.toString();

error+="Error : "+stackTrace;

System.out.println(" Error : "+ e.toString());

}

return error;

}

//////////////////Function for getting Users Details//////////

public HashMap getStudentDetails(int student_id) {

HashMap resultsArray = new HashMap();

int count=0;

try {

String SQL = "SELECT * FROM student WHERE student_id =

"+student_id ;

statement = connection.createStatement();

rs = statement.executeQuery(SQL);

while(rs.next()) {

resultsArray.put("student_id",rs.getString("student_id"));

resultsArray.put("student_user",rs.getString("student_user"));

resultsArray.put("student_level",rs.getString("student_level"));

resultsArray.put("student_sal",Integer.parseInt(rs.getString("student_sal")));

resultsArray.put("student_first_name",rs.getString("student_first_name"));

resultsArray.put("student_middle_name",rs.getString("student_middle_name"));

resultsArray.put("student_last_name",rs.getString("student_last_name"));

resultsArray.put("student_gender",rs.getString("student_gender"));

resultsArray.put("student_address",rs.getString("student_address"));

resultsArray.put("student_village",rs.getString("student_village"));

resultsArray.put("student_state",Integer.parseInt(rs.getString("student_state")));

resultsArray.put("student_country",Integer.parseInt(rs.getString("student_country"

)));

resultsArray.put("student_landline",rs.getString("student_landline"));

resultsArray.put("student_mobile",rs.getString("student_mobile"));

resultsArray.put("student_email",rs.getString("student_email"));

resultsArray.put("student_status",Integer.parseInt(rs.getString("student_status")));

resultsArray.put("student_deparment",Integer.parseInt(rs.getString("student_depar ment")));

resultsArray.put("student_dob",rs.getString("student_dob"));

resultsArray.put("student_nationalty",rs.getString("student_nationalty"));

count++;

}

if(count==0) {

resultsArray.put("student_id","");

resultsArray.put("student_user","");

resultsArray.put("student_level","");

resultsArray.put("student_sal",0);

resultsArray.put("student_first_name","");

resultsArray.put("student_middle_name","");

resultsArray.put("student_last_name","");

resultsArray.put("student_gender","");

resultsArray.put("student_address","");

resultsArray.put("student_village","");

resultsArray.put("student_state",0);

resultsArray.put("student_country",0);

resultsArray.put("student_landline","");

resultsArray.put("student_mobile","");

resultsArray.put("student_email","");

resultsArray.put("student_status",0);

resultsArray.put("student_deparment",0);

resultsArray.put("student_dob","");

resultsArray.put("student_nationalty","");

} }

catch(Exception e) {

System.out.println("Error is: "+ e);

}

return resultsArray;

}

public String updateStudent(HashMap studentData) {

String SQL = "UPDATE student SET student_sal = ?,

student_first_name = ?, student_middle_name = ?, student_last_name = ?, student_gender = ?, student_address = ?, student_village = ?, student_state = ?, student_country = ?, student_landline = ?, student_mobile = ?, student_email = ?, student_status = ?, student_deparment = ?, student_dob = ?, student_nationalty

= ? WHERE student_id = ?";

String error = "";

int record=0;

try {

pstmt = connection.prepareStatement(SQL);

pstmt.setString(1,(String) studentData.get("student_sal"));

pstmt.setString(2,(String) studentData.get("student_first_name"));

pstmt.setString(3,(String) studentData.get("student_middle_name"));

pstmt.setString(4,(String)

StringWriter writer = new StringWriter();

PrintWriter printWriter = new PrintWriter( writer );

e.printStackTrace( printWriter );

printWriter.flush();

String stackTrace = writer.toString();

error+="Error : "+stackTrace;

System.out.println(" Error : "+ e.toString());

}

return error;

}

public boolean deleteStudent(int student_id) {

return true;

}

/////Function for Getting the List////////////

public String getStateOption(Integer SelID) {

int selectedID = SelID.intValue();

return

Connect.getOptionList("state","state_id","state_name","state_id,state_name",select edID,"1");

}

/////Function for Getting the List////////////

public String getStudentsOption(Integer SelID) {

int selectedID = SelID.intValue();

return

Connect.getOptionList("student","student_id","student_id","student_id,student_id", selectedID,"1");

}

/////Function for Getting the List////////////

public String getCountryOption(Integer SelID) {

int selectedID = SelID.intValue();

return

Connect.getOptionList("country","country_id","country_name","country_id,country_

name",selectedID,"1");

}

/////Function for Getting the List////////////

public String getSalutionOption(Integer SelID) {

int selectedID = SelID.intValue();

return

Connect.getOptionList("salutions","sl_id","sl_name","sl_id,sl_name",selectedID,"1")

; }

/////Function for Getting the List////////////

public String getConnectionTypeOption(Integer SelID) {

int selectedID = SelID.intValue();

return

Connect.getOptionList("connection_type","cont_id","cont_name","cont_id,cont_nam e",selectedID,"1");

}

/////Function for Getting the List////////////

public String getJobTypeOption(Integer SelID) {

int selectedID = SelID.intValue();

public String getCategoryOption(Integer SelID) {

int selectedID = SelID.intValue();

return

Connect.getOptionList("category","category_id","category_name","category_id,cate gory_name",selectedID,"1");

}

////////////////Function for getting all the Airport Details////////////////////

public ArrayList getAllStudent() {

int count=0;

String error = "";

ArrayList resultArray = new ArrayList();

HashMap results = new HashMap();

results.put("student_id",rs.getString("student_id"));

results.put("student_user",rs.getString("student_user"));

results.put("student_level",rs.getString("student_level"));

results.put("student_sal",rs.getString("student_sal"));

results.put("student_first_name",rs.getString("student_first_name"));

results.put("student_middle_name",rs.getString("student_middle_name"));

results.put("student_last_name",rs.getString("student_last_name"));

results.put("student_gender",rs.getString("student_gender"));

results.put("student_address",rs.getString("student_address"));

results.put("student_village",rs.getString("student_village"));

results.put("student_state",rs.getString("student_state"));

results.put("student_country",rs.getString("student_country"));

results.put("student_landline",rs.getString("student_landline"));

results.put("student_mobile",rs.getString("student_mobile"));

results.put("student_email",rs.getString("student_email"));

results.put("student_status",Integer.parseInt(rs.getString("student_status")));

results.put("student_deparment",Integer.parseInt(rs.getString("student_deparment

")));

results.put("student_dob",rs.getString("student_dob"));

results.put("student_nationalty",rs.getString("student_nationalty"));

count++;

resultArray.add(results);

} }

catch(Exception e) {

StringWriter writer = new StringWriter();

PrintWriter printWriter = new PrintWriter( writer );

e.printStackTrace( printWriter );

printWriter.flush();

String stackTrace = writer.toString();

error+="Error : "+stackTrace;

System.out.println(" Error : "+ e.toString());

}

return resultArray;

}

public String getDepartment(int jt_id) {

HashMap results = new HashMap();

String SQL = "";

String value = "";

int count=0;

try {

SQL = "SELECT jt_name FROM job_type WHERE jt_id = "+jt_id ;

statement = connection.createStatement();

public String getStatus(int category_id) {

value = rs.getString("category_name");

} }

catch(Exception e) {

System.out.println("Error is: "+ e);

}

return value;

} }

Future scope of the Project:

Today, the market place is flooded with several student information options for school and colleges to choose from. A variety of innovative products and services are being offered spoiling customers for choice. Student Information System is no more a privilege enjoyed by managers and employees. In the last couple of years, the growth of IT Industry has been phenomenal as more have started discovering the benefits of using this platform. Therefore we will made this system live and provide Software as Service (SAS) in future.

Conclusion of the Project:

Our project is only a humble venture to satisfy the needs in a school to manage their project work. Several user friendly coding have also adopted. This package shall prove to be a powerful package in satisfying all the requirements of the school. The objective of software planning is to provide a frame work that enables the manger to make reasonable estimates made within a limited time frame at the beginning of the software project and should be updated regularly as the project progresses.

Bibliography

 Google for problem solving

 http://www.javaworld.com/javaworld/jw-01-1998/jw-01-Credentialreview.html

 Database Programming with JDBC and Java by O'Reilly

 Head First Java 2nd Edition

 http://www.jdbc-tutorial.com/

 Java and Software Design Concepts by Apress

Documento similar