private long addProductShown() { // lấy giá trị Product product = (Product) mSpinner_Product.getSelectedItem(); long productId = product.get_id(); int number = Integer.valueOf(mInputLayout_Number.getEditText().getText() + ""); long retailPrice = Long.valueOf(mInputLayout_RetailPrice.getEditText().getText() + ""); // gán giá trị mProductShown = new ProductShown(); mProductShown.setAssignId(mAssignId); mProductShown.setProductId(productId); mProductShown.setNumber(number); mProductShown.setRetailPrice(retailPrice); mProductShown.setSessionCode(DatabaseUtil.getCodeGenerationByTime()); mProductShown.setCreateBy(UserPref.getUserPrefId(this)); mProductShown.setCreateAt(Calendar.getInstance()); mProductShown.setUploadStatus(UploadStatus.WAITING_UPLOAD); long id = ProductShownData.add(this, mProductShown); mProductShown.set_id(id); return id; }
private void initVars() { mDialog = new ProgressDialog(this); mProductAddNew = new Product() { { set_id(ProductAdapter.ACTION_ID_ADD); setName(getString(R.string.action_add_product)); } }; // --- Product --- spinner_Product_init(); // khởi tạo giá trị qua Intent mAssignId = getIntent().getLongExtra(EXTRA_ASSIGN_ID, -1); long mPSId = getIntent().getLongExtra(EXTRA_PRODUCT_SHOWN_ID, -1); if (mPSId == -1) { isAddNew = true; } else { // Hiển thị Cập nhật updateUIAddOrEdit(false); isAddNew = false; mProductShown = ProductShownData.getById(this, mPSId); spinner_Product_setSelection(mProductShown.getProductId()); mInputLayout_Number.getEditText().setText(mProductShown.getNumber() + ""); mInputLayout_RetailPrice.getEditText().setText(mProductShown.getRetailPrice() + ""); } }