package BWP.MobileSale.MobileAdjustGoodsBill;
import java.math.BigDecimal;
import java.util.HashMap;
import BWP.MobileSale.LoginedActivity;
import BWP.MobileSale.R;
import BWP.MobileSale.Util.ActivityUtil;
import BWP.MobileSale.Util.StringUtil;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MobileAdjustGoodsBillDetailEditActivity extends LoginedActivity{

	private TextView textViewGoodsName;
	private EditText editTextNumber;
	private int position;
	private HashMap<String,Object> detail;
	
	@SuppressWarnings("unchecked")
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.mobileadjustgoodsbill_detail_edit);
		Intent intent = getIntent();
		position = intent.getIntExtra("Position", -1);
		detail = (HashMap<String, Object>) intent.getSerializableExtra("Detail");		
		textViewGoodsName = ActivityUtil.Find(this, R.id.TextView_Goods_Name);
		editTextNumber = ActivityUtil.Find(this, R.id.EditText_Number);
		
		textViewGoodsName.setText(StringUtil.ToString(detail.get("Goods_Name")));
		editTextNumber.setText(StringUtil.ToString(detail.get("UnitNum")));
		
		Button buttonOK = ActivityUtil.Find(this, R.id.Button_OK);
		Button buttonCancel = ActivityUtil.Find(this, R.id.Button_Cancel);
		buttonOK.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				detail.put("UnitNum", StringUtil.ParseMoney(editTextNumber.getText().toString()));
				Intent intent =new Intent();
				intent.putExtra("Detail", detail);
				intent.putExtra("Position", position);
				ActivityUtil.Finish(MobileAdjustGoodsBillDetailEditActivity.this, intent);				
			}
		});
		
		buttonCancel.setOnClickListener(new OnClickListener() {
			
			public void onClick(View v) {
				finish();				
			}
		});
	}
	
	
}
