/**
* 库存查询
*
* @author Pos_User
*
*/
public class RepertoryQueryActivity extends BaseActivity implements
OnClickListener {
private ClearEditText mCompanyCode;// 机构代码
private ClearEditText mDeptno;// 商品编码
private ClearEditText mDommodity;// 分类编号
private RadioButton mRepertory;// 库存
private RadioButton mRepertory1;// 负库存
private Button mSeachButton;
// private RadioButton mKucun,mFuKucun;
private LinearLayout ll_repertory;
private String len = "0";
private Boolean isLogin = true; // 判断用户是否登录 false为未登录
private String m_reason = "";
private int m_id;
// private LinearLayout mBack;
private RadioGroup mRadioGroup;
private MyListView m_listMLv = null;
private String m_ID = "9";
private final static int SCANNIN_GREQUEST_CODE = 1;
String m_CompanyCode = null, m_Dommodity = null;
private String m_company = "";
private String company;
private RepertoryQueryAdapter m_adapter = null;
List<KeyValueDTO> m_list = new ArrayList<KeyValueDTO>();
List<RepertoryQueryDTO> m_listXLv = new ArrayList<RepertoryQueryDTO>();
private ProgressDialog m_dialog;
UserCenterMessageManager messageManager = UserCenterMessageManager
.getInstance();
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.layout_repertory_query);
initView();
initData();
getIntentData();
}
@Override
protected void onResume() {
if (messageManager != null) {
// 进行消息注册
messageManager.registerObserver(this);
}
super.onResume();
}
@Override
protected void onPause() {
if (messageManager != null) {
// 进行消息注销
messageManager.unregisterObserver(this);
}
super.onPause();
}
/**
* 得到传值数据方法
*/
private void getIntentData() {
Intent intent = getIntent();
m_company = intent.getStringExtra("company");
}
private void loadLenData(String len, String query) {
messageManager.type(len, query);
}
private void initData() {
}
private void initView() {
// mBack = (LinearLayout) findViewById(R.id.common_ll_back);
ll_repertory=(LinearLayout) findViewById(R.id.ll_repertory);
mCompanyCode = (ClearEditText) findViewById(R.id.et_company_code);
mDeptno = (ClearEditText) findViewById(R.id.et_deptno);
mDommodity = (ClearEditText) findViewById(R.id.et_deptno);
mRepertory = (RadioButton) findViewById(R.id.rb_radiobutton1);
mRepertory1 = (RadioButton) findViewById(R.id.rb_radiobutton2);
mSeachButton = (Button) findViewById(R.id.common_btn_search);
// mBack = (LinearLayout) findViewById(R.style.common_btn_back_style);
// mKucun=(RadioButton) findViewById(R.id.rb_radiobutton1);
// mFuKucun=(RadioButton) findViewById(R.id.rb_radiobutton2);
mRadioGroup = (RadioGroup) findViewById(R.id.kucun_group);
// mBack.setOnClickListener(this);
mCompanyCode.setOnClickListener(this);
mSeachButton.setOnClickListener(this);
mRadioGroup
.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
if (mRepertory.getId() == checkedId) {
Toast.makeText(RepertoryQueryActivity.this, "库存",
Toast.LENGTH_SHORT).show();
m_id=0;
// repertoryQuery(m_CompanyCode, m_Dommodity, "0" );
}
if (mRepertory1.getId() == checkedId) {
Toast.makeText(RepertoryQueryActivity.this, "负库存",
Toast.LENGTH_SHORT).show();
// repertoryQuery(m_CompanyCode, m_Dommodity, "1" );
m_id=1;
}
}
});
//
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.common_ll_back:
finish();
case R.id.common_btn_search:
SharedPreferences userInfo_prf = getSharedPreferences("userInfo",
MODE_PRIVATE);
isLogin = userInfo_prf.getBoolean(PreferenceKey.USER_LOGOUT_FLAG,
true);
m_reason = UserManager.getInstance().m_user.reason;
if (!isLogin && !m_reason.equals("") && m_reason != null) {
checkInfo();
} else {
WindowDialogUtil.getInstance().initSureCancelDialog(
RepertoryQueryActivity.this, "登录提示", "您未登录,请登录后再查询");
}
break;
}
}
/**
* 检查输入信息是否规范
*/
private void checkInfo() {
// 商品编号
String encoding = mDeptno.getText().toString().trim();
// 机构代码
String barCode = mCompanyCode.getText().toString().trim();
m_CompanyCode = barCode;
// 分类编号
String name = mDommodity.getText().toString().trim();
m_Dommodity = name;
// // 库存
// String plu = mRepertory.getText().toString().trim();
// // 负库存
// String plu1 = mRepertory1.getText().toString().trim();
// 隐藏软键盘
((InputMethodManager) getSystemService(INPUT_METHOD_SERVICE))
.hideSoftInputFromWindow(RepertoryQueryActivity.this
.getCurrentFocus().getWindowToken(),
InputMethodManager.HIDE_NOT_ALWAYS);
if (encoding.equals("") && barCode.equals("")) {
Toast.makeText(RepertoryQueryActivity.this, "请最少输入一个条件!",
Toast.LENGTH_SHORT).show();
} else {
ll_repertory.setVisibility(View.GONE);
if (m_id==0) {
repertoryQuery(m_CompanyCode, m_Dommodity, "0" );
}else if (m_id==1) {
repertoryQuery(m_CompanyCode, m_Dommodity, "1" );
}
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch (requestCode) {
case SCANNIN_GREQUEST_CODE:
if (resultCode == RESULT_OK) {
}
break;
}
}
public void typeReplyCB(String result, String reason, List<KeyValueDTO> list) {
super.typeReplyCB(result, reason, list);
WindowDialogUtil.getInstance().DismissAllDialog();
if (result.equalsIgnoreCase("0")) {
m_list = list;
if (len.equals("2")) {
lenDialogShow(mCompanyCode, m_list);
} else {
lenDialogShow(mCompanyCode, m_list);
}
} else {
Toast.makeText(RepertoryQueryActivity.this, reason,
Toast.LENGTH_LONG).show();
}
}
/**
* 调用库存查询数据接口
*
* @param number
* 部门编号
* @param length
* 部门长度
*/
private void repertoryQuery(String number, String ccode, String type) {
m_dialog = WindowDialogUtil.customProgressDialog(this, R.anim.frame);
messageManager.repertoryQuery(number, ccode, type, company);
}
@Override
public void repertoryQueryCB(String result, String reason,
List<RepertoryQueryDTO> list) {
super.repertoryQueryCB(result, reason, list);
WindowDialogUtil.dismissLoadingDialog(this, m_dialog);
if (result.equalsIgnoreCase("0")) {
m_listXLv = list;
setAdapter(m_listXLv, m_ID);
} else {
// m_progressBar.setVisibility(View.GONE);
m_listMLv.setVisibility(View.GONE);
Toast.makeText(RepertoryQueryActivity.this, reason,
Toast.LENGTH_LONG).show();
}
}
private void setAdapter(List<RepertoryQueryDTO> list, String id) {
id = m_ID;
m_listMLv.setVisibility(View.VISIBLE);
m_adapter = new RepertoryQueryAdapter(RepertoryQueryActivity.this, list);
m_listMLv.setAdapter(m_adapter);
}
private void lenDialogShow(final ClearEditText m_lenEt,
final List<KeyValueDTO> list) {
final Dialog dialog_more = new Dialog(this,
R.style.birthday_time_dialog);
dialog_more.setCancelable(true);
dialog_more.setCanceledOnTouchOutside(true);
LayoutInflater localLayoutInflater = LayoutInflater.from(this);
View localView = localLayoutInflater.inflate(
R.layout.layout_worker_dialog, null);
localView
.findViewById(R.id.common_dialog_tv_confirm);
localView
.findViewById(R.id.common_dialog_tv_show);
TextView cancelTv = (TextView) localView
.findViewById(R.id.common_dialog_tv_cancel);
// dialog_more.getWindow().setWindowAnimations(R.style.in_down_out_up);
dialog_more.setContentView(localView);
// showTv.setText(list.get(0).name);
cancelTv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog_more.dismiss();
}
});
}
}
以下是xml文件 里面有单选框的布局可供参考、
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/img_common_bg"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/login_rl_title"
style="@style/common_top_title_style" >
<LinearLayout
android:id="@+id/common_ll_back"
android:layout_width="50dp"
android:layout_height="fill_parent"
android:layout_alignParentLeft="true"
android:gravity="center"
android:orientation="vertical" >
<ImageView style="@style/common_btn_back_style" />
</LinearLayout>
<Button
android:id="@+id/main_btn_more"
android:layout_width="65dp"
android:layout_height="45dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="5dp"
android:background="@drawable/img_common_right_selector"
android:gravity="center"
android:text="更多"
android:textColor="@color/common_white"
android:visibility="gone" />
<TextView
style="@style/common_tv_title_style"
android:text="库存查询" />
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="30dp"
android:background="@drawable/img_commodity_box"
android:gravity="center_vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="请输入查询条件"
android:textColor="@color/common_white" />
</LinearLayout>
<LinearLayout android:id="@+id/ll_repertory"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="45dp"
android:gravity="center_vertical"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="机构代码"
android:textColor="@color/common_black"
android:textSize="14dp" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="30dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@drawable/img_search_keyword"
android:gravity="center_vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal" >
<com.shangyi.widget.ClearEditText
android:id="@+id/et_company_code"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="15dp"
android:background="@null"
android:imeOptions="actionSearch"
android:singleLine="true"
android:textSize="14dp" >
<requestFocus />
</com.shangyi.widget.ClearEditText>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<!-- -->
<ImageView
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="@drawable/img_common_x" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="45dp"
android:gravity="center_vertical"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="商品编码:"
android:textColor="@color/common_black"
android:textSize="14dp" />
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="30dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@drawable/img_search_keyword"
android:gravity="center_vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal" >
<com.shangyi.widget.ClearEditText
android:id="@+id/et_deptno"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="15dp"
android:background="@null"
android:imeOptions="actionSearch"
android:singleLine="true"
android:textSize="14dp" >
</com.shangyi.widget.ClearEditText>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<ImageView
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="@drawable/img_common_x" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="45dp"
android:gravity="center_vertical"
android:orientation="horizontal" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="库存类型:"
android:textColor="@color/common_black"
android:textSize="14dp" />
<RadioGroup android:id="@+id/kucun_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton android:id="@+id/rb_radiobutton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="库存"/>
<RadioButton
android:id="@+id/rb_radiobutton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="负库存"/>
</RadioGroup>
</LinearLayout>
<ImageView
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="@drawable/img_common_x" />
<Button
android:id="@+id/common_btn_search"
android:layout_width="80dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:layout_marginTop="15dp"
android:background="@drawable/img_search_bg"
android:text="查询" />
</LinearLayout>
</LinearLayout>