Exemplo n.º 1
0
  @Override
  public void saveEmployee(Employee db) {

    String name = db.getName();
    String gender = db.getGender();
    String dateOfBirth = db.getDateOfBirth();
    String dateOfJoining = db.getDateOfJoining();
    String passportNo = db.getPassportNum();
    String passportExpiryDate = db.getPassportExpiryDate();
    String visaNum = db.getVisaNum();
    String visaExpiryDate = db.getVisaExpiryDate();
    String localContactNum = db.getLocalContactNum();
    String internationalContactNum = db.getInternationalContactNum();
    String createdBy = db.getCreatedBy();
    String createdOn = db.getCreatedOn();
    String updatedBy = db.getLastUpdatedBy();
    String updatedOn = db.getLastUpdatedOn();
    String healthCardExpiryDate = db.getHealthCardExpiryDate();
    String healthCardExpirydate2 = db.getHealthCardExpiryDate2();
    String bankName = db.getBankName();
    String branchName = db.getBranchName();
    String accountNum = db.getAccountNum();
    double basicSalary = db.getBasicSalary();
    String addressLine1 = db.getAddressLine1();
    String addressLine2 = db.getAddressLine2();
    String addressLine3 = db.getAddressLine3();
    String username = db.getUsername();

    String iquery =
        "insert into employee_master(emp_name,gender,date_of_birth,date_of_joining,passport_no,"
            + "passport_expiry_date,visa_no,visa_expiry_date,local_contact_no,international_contact_no,"
            + "creation_by,creation_date,last_updated_by,last_updated_on,health_card_expiry,health_card_expiry2,bank_name,"
            + "bank_branch_name,bank_account_no,basic_salary,address_line1,address_line2,address_line3,loginid) "
            + "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";

    jdbcTemplate.update(
        iquery,
        new Object[] {
          name,
          gender,
          dateOfBirth,
          dateOfJoining,
          passportNo,
          passportExpiryDate,
          visaNum,
          visaExpiryDate,
          localContactNum,
          internationalContactNum,
          createdBy,
          createdOn,
          updatedBy,
          updatedOn,
          healthCardExpiryDate,
          healthCardExpirydate2,
          bankName,
          branchName,
          accountNum,
          basicSalary,
          addressLine1,
          addressLine2,
          addressLine3,
          username
        });

    String password = db.getPassword();
    String role = db.getRole();
    System.out.println(role);

    iquery = "insert into employees(username, password, authority) values(?,?,?)";
    jdbcTemplate.update(iquery, new Object[] {username, password, role});
  }
Exemplo n.º 2
0
  @Override
  public void updateEmployee(Employee db) {

    String name = db.getName();
    String gender = db.getGender();
    String dateOfBirth = db.getDateOfBirth();
    String dateOfJoining = db.getDateOfJoining();
    String passportNo = db.getPassportNum();
    String passportExpiryDate = db.getPassportExpiryDate();
    String visaNum = db.getVisaNum();
    String visaExpiryDate = db.getVisaExpiryDate();
    String localContactNum = db.getLocalContactNum();
    String internationalContactNum = db.getInternationalContactNum();
    String createdBy = db.getCreatedBy();
    String createdOn = db.getCreatedOn();
    String updatedBy = db.getLastUpdatedBy();
    String updatedOn = db.getLastUpdatedOn();
    String healthCardExpiryDate = db.getHealthCardExpiryDate();
    String healthCardExpiryDate2 = db.getHealthCardExpiryDate2();
    String bankName = db.getBankName();
    String branchName = db.getBranchName();
    String accountNum = db.getAccountNum();
    double basicSalary = db.getBasicSalary();
    String addressLine1 = db.getAddressLine1();
    String addressLine2 = db.getAddressLine2();
    String addressLine3 = db.getAddressLine3();
    String username = db.getUsername();

    String editQuery =
        "update employee_master set emp_name=?,gender=?,date_of_birth=?,date_of_joining=?,passport_no=?,"
            + "passport_expiry_date=?,visa_no=?,visa_expiry_date=?,local_contact_no=?,international_contact_no=?,"
            + "creation_by=?,creation_date=?,last_updated_by=?,last_updated_on=?,health_card_expiry=?,"
            + "health_card_expiry2=?,bank_name=?,bank_branch_name=?,bank_account_no=?,basic_salary=?,address_line1=?,"
            + "address_line2=?,address_line3=? where loginid=? ";

    jdbcTemplate.update(
        editQuery,
        new Object[] {
          name,
          gender,
          dateOfBirth,
          dateOfJoining,
          passportNo,
          passportExpiryDate,
          visaNum,
          visaExpiryDate,
          localContactNum,
          internationalContactNum,
          createdBy,
          createdOn,
          updatedBy,
          updatedOn,
          healthCardExpiryDate,
          healthCardExpiryDate2,
          bankName,
          branchName,
          accountNum,
          basicSalary,
          addressLine1,
          addressLine2,
          addressLine3,
          username
        });
  }