class
ViewButtonListener
implements
OnClickListener {
private
int
position;
Object cname;
Object data;
Object displayContent;
EditText txtEname;
EditText txtCname;
EditText txtData;
EditText txtDisplayContent;
EditText txtRemark;
View layout;
ViewButtonListener(
int
position) {
this
.position = position;
cname = dataList.get(position).get(
"cname"
);
data = dataList.get(position).get(
"data"
);
displayContent = dataList.get(position).get(
"displaycontent"
);
LayoutInflater inflater = getLayoutInflater();
layout = inflater.inflate(R.layout.systemcodemodify,
(ViewGroup) findViewById(R.id.modifyDialog));
txtEname = (EditText) layout.findViewById(R.id.txtEname);
txtCname = (EditText) layout.findViewById(R.id.txtCname);
txtData = (EditText) layout.findViewById(R.id.txtData);
txtDisplayContent = (EditText) layout
.findViewById(R.id.txtDisplay);
txtRemark = (EditText) layout.findViewById(R.id.txtRemark);
}
@Override
public
void
onClick(View view) {
int
vid = view.getId();
if
(vid == holder.btnUpdate.getId()) {
txtEname.setText(owner.ename);
txtCname.setText(cname.toString());
txtData.setText(data.toString());
txtDisplayContent.setText(displayContent.toString());
txtEname.setEnabled(
false
);
txtCname.setEnabled(
false
);
txtData.setEnabled(
false
);
final
AlertDialog.Builder builder =
new
AlertDialog.Builder(
owner);
builder.setIcon(R.drawable.info);
builder.setTitle(R.string.titleSystemCodeModifyName);
builder.setView(layout);
builder.setPositiveButton(R.string.btnSave,
null
);
builder.setNegativeButton(R.string.btnClose,
null
);
final
AlertDialog dialog = builder.create();
dialog.show();
dialog.getButton(AlertDialog.BUTTON_POSITIVE)
.setOnClickListener(
new
View.OnClickListener() {
@Override
public
void
onClick(View v) {
if
(txtDisplayContent.getText().toString()
.trim().length() ==
0
) {
ShowMessage(
"显示值不能为空!"
);
return
;
}
SoapObject soapObject =
new
systemcodedetail()
.ModifySystemCode(ename, data
.toString(), txtDisplayContent.getText().toString().trim()
.toString(), txtRemark
.getText().toString());
Boolean isSuccess = Boolean
.valueOf(soapObject.getProperty(
"IsSuccess"
).toString());
if
(isSuccess) {
ShowMessage(R.string.SaveSuccess);
dialog.dismiss();
}
else
{
String errorMsg = soapObject
.getProperty(
"ErrorMessage"
)
.toString();
ShowMessage(errorMsg);
}
}
});
}
else
if
(vid == holder.btnDelete.getId()) {
SoapObject soapObject =
new
systemcodedetail()
.DeleteSystemCode(ename, data.toString());
Boolean isSuccess = Boolean.valueOf(soapObject.getProperty(
"IsSuccess"
).toString());
if
(isSuccess) {
ShowMessage(R.string.DeleteSuccess);
}
else
{
String errorMsg = soapObject
.getProperty(
"ErrorMessage"
).toString();
ShowMessage(errorMsg);
}
}
}
}
class
Holder {
public
TextView labCname;
public
TextView labDisplay;
public
TextView labData;
public
Button btnUpdate;
public
Button btnDelete;
}
}