package BWP.MobileSale;

import java.util.Date;
import java.util.HashMap;
import java.util.List;

import org.forks.jsonrpc.RpcFacade;
import org.forks.jsonrpc.RpcObject;

import BWP.MobileSale.Util.ActivityUtil;
import BWP.MobileSale.Util.DateTimeUtil;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class UserMessageDetailActivity extends Activity {
	
	private TextView text_sender,text_senderTime,text_category,text_content;
	private Button btn;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		setContentView(R.layout.usermassage_detail);
		
		Intent intent = getIntent();
		long billId = intent.getLongExtra("ID", 0);
		String method = "/MainSystem/MainSystem/Rpcs/MessageRpc/GetByID";
		RpcObject bill = RpcFacade.rpcCall(method,billId);
		text_sender = (TextView)this.findViewById(R.id.TextView_Sender);
		text_senderTime = (TextView)this.findViewById(R.id.TextView_SenderTime);
		text_category = (TextView)this.findViewById(R.id.TextView_Category);
		text_content = (TextView)this.findViewById(R.id.TextView_Content);
		String sender = bill.getString("Message_Sender");
		Date senderTime = bill.getDate("Message_SentTime");
		String category = bill.getString("Message_Category");
		String content = bill.getString("MessageTextContent");
		if(sender!=null&&sender!=""){
			text_sender.setText(sender);
		}
		if(senderTime!=null){
			text_senderTime.setText(DateTimeUtil.FormatDate(senderTime));
		}
		if(category!=null&&category!=""){
			text_category.setText(category);
		}

		if(content!=null&&content!=""){
			text_content.setText(content);
		}

		
		btn = (Button) findViewById(R.id.Button_Return);
		btn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				finish();
			}
		});
		
		
		String method2 = "/MainSystem/MainSystem/Rpcs/MessageRpc/MarkRead";
		RpcFacade.rpcCall(method2,bill.getLong("Message_ID"));
	}

}
