Esempio n. 1
0
  public void setjobDetail() {
    Cursor cursor =
        DatabaseView.query(
            "SELECT * FROM ServiceJob, Purchase, Product, Company WHERE jobNo ='"
                + selectedjobNo
                + "'"
                + " AND Purchase.prodNo = Product.prodNo AND Purchase.comNo = Company.comNo AND Purchase.serialNo = ServiceJob.serialNo");
    cursor.moveToFirst();
    String _jobProblem = cursor.getString(cursor.getColumnIndex("jobProblem"));
    String _jobSerialNo = cursor.getString(cursor.getColumnIndex("serialNo"));
    String _jobRequestDate = cursor.getString(cursor.getColumnIndex("requestDate"));
    String _jobVisitDate = cursor.getString(cursor.getColumnIndex("visitDate"));
    String _jobStartTime = cursor.getString(cursor.getColumnIndex("jobStartTime"));
    String _jobEndTime = cursor.getString(cursor.getColumnIndex("jobEndTime"));
    String _jobRemark = cursor.getString(cursor.getColumnIndex("remark"));
    companyID = cursor.getString(cursor.getColumnIndex("comNo"));
    prodctID = cursor.getString(cursor.getColumnIndex("prodNo"));

    jobNo.setText(selectedjobNo);
    jobProblem.setText(_jobProblem);
    jobSerialNo.setText(_jobSerialNo);
    jobRequestDate.setText(_jobRequestDate);
    jobVisitDate.setText(_jobVisitDate);
    jobStartTime.setText(_jobStartTime);
    jobEndTime.setText(_jobEndTime);
    jobRemark.setText(_jobRemark);
    jobCompany.setText(cursor.getString(cursor.getColumnIndex("comName")));
    jobCompany.setOnClickListener(this);
    productName.setText(cursor.getString(cursor.getColumnIndex("prodName")));
    productName.setOnClickListener(this);
    for (int i = 0; i < jobStatusItem.length; i++)
      if (jobStatusItem[i].equalsIgnoreCase(cursor.getString(cursor.getColumnIndex("jobStatus"))))
        jobStatus.setSelection(i);
  }
Esempio n. 2
0
  @Override
  public void onClick(View view) {

    if (view.getId() == productName.getId()) {
      Bundle bundle = new Bundle();
      bundle.putString("selectedJobNo", productName.getText().toString());
      Fragment productIssue = new F_ProductIssue();
      productIssue.setArguments(bundle);
      ((A_Entry) getActivity()).transferTo(productIssue, true);
    } else if (view.getId() == jobCompany.getId()) {
      Bundle bundle = new Bundle();
      bundle.putString("comName", jobCompany.getText().toString());
      Fragment companyDetails = new F_CompanyDetails();
      companyDetails.setArguments(bundle);
      ((A_Entry) getActivity()).transferTo(companyDetails, true);
    } else if (view.getId() == btn_photo.getId()) {
      try {
        ((BitmapDrawable) image_preview.getDrawable()).getBitmap().recycle();
      } catch (NullPointerException e) {

      }
      Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
      // fileURI = getOutputMediaFileUri(MEDIA_TYPE_IMAGE);
      fileURI = getImageUri();
      intent.putExtra(MediaStore.EXTRA_OUTPUT, fileURI); // set the image file name
      startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
    } else if (view.getId() == btn_postpone.getId()) {
      for (int i = 0; i < jobStatusItem.length; i++)
        if (jobStatusItem[i].equals("postponed")) {
          jobStatus.setSelection(i);
          DatabaseView.exec(
              "UPDATE ServiceJob SET jobStatus = 'postponed' WHERE jobNo ='"
                  + jobNo.getText().toString()
                  + "'");
          Toast.makeText(
                  getActivity(), "Successful change the status to postpone!", Toast.LENGTH_SHORT)
              .show();
        }
    } else if (view.getId() == btn_cancelJob.getId()) {
      for (int i = 0; i < jobStatusItem.length; i++)
        if (jobStatusItem[i].equals("cancelled")) {
          jobStatus.setSelection(i);
          DatabaseView.exec(
              "UPDATE ServiceJob SET jobStatus = 'cancelled' WHERE jobNo ='"
                  + jobNo.getText().toString()
                  + "'");
          Toast.makeText(
                  getActivity(), "Successful change the status to cancel!", Toast.LENGTH_SHORT)
              .show();
        }
    } else if (view.getId() == btn_viewImage.getId()) {

      final AlertDialog.Builder ab = new AlertDialog.Builder(getActivity());
      final ImageView iv = new ImageView(getActivity());

      try {
        final Bitmap bm = convertJPG(getImageUri());
        if (bm == null) return;
        iv.setImageBitmap(bm);
        ab.setView(iv);
        ab.setPositiveButton(
            "OK",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialogInterface, int i) {}
            });
        ab.show();
      } catch (OutOfMemoryError e) {
        try {
          ((BitmapDrawable) iv.getDrawable()).getBitmap().recycle();
          Toast.makeText(getActivity(), "Sorry, try again", Toast.LENGTH_SHORT).show();
          e.printStackTrace();
        } catch (Exception ee) {

        }
      }

    } else if (view.getId() == btn_viewSign.getId()) {
      final AlertDialog.Builder ab = new AlertDialog.Builder(getActivity());
      final ImageView iv = new ImageView(getActivity());
      try {
        final Bitmap bm = _signView.loadFromStorage(getActivity(), getSignViewFileName());
        if (bm == null) return;
        iv.setImageBitmap(bm);
        ab.setView(iv);
        ab.setPositiveButton(
            "OK",
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialogInterface, int i) {}
            });
        ab.show();
      } catch (OutOfMemoryError e) {
        try {
          ((BitmapDrawable) iv.getDrawable()).getBitmap().recycle();
          Toast.makeText(getActivity(), "Sorry, try again", Toast.LENGTH_SHORT).show();
          e.printStackTrace();
        } catch (Exception ee) {

        }
      }
    }
  }