bb6ebafe08a2d4589c0a834b3b679aacdc8d6b10.svn-base 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. package xin.glue.ui.B.common;
  2. import com.posdata.glue.biz.activity.PosActivity;
  3. import com.posdata.glue.biz.constants.PosBizControlConstants;
  4. import com.posdata.glue.context.PosContext;
  5. import com.posdata.glue.dao.vo.PosParameter;
  6. /**
  7. *
  8. * @Description 增、删、改
  9. * @author 梅贵平{meiguiping}
  10. * @date 2011-01-07 下午07:42:42
  11. * @JDK Version jdk1.4.2
  12. */
  13. public class XgSimpleModify extends PosActivity
  14. {
  15. public String runActivity(PosContext context)
  16. {
  17. PosParameter posParam = null;
  18. String sCount = this.getProperty("sqlCount");
  19. if(sCount == null)
  20. return PosBizControlConstants.SUCCESS;
  21. String[] simpleStatus = (String[])context.get("RowStatus");
  22. int iCount = Integer.parseInt(sCount.trim());//获取所对应的sql语句的个数
  23. String[] sql = new String[iCount];//定义存放sqllist的数组
  24. String[] nodeList = new String[iCount];//定义存放各sql语句参数的数组
  25. String[] param = null;
  26. int j =0;
  27. for(int i = 0; i < iCount; i++)
  28. {
  29. posParam = new PosParameter();
  30. j = 0;
  31. sql[i] = this.getProperty("sqlkey"+i);//sql
  32. nodeList[i] = this.getProperty("param"+i);//参数
  33. param = nodeList[i].split("\\|"); //注,不考虑没有参数的情况,作为DML语句,必须存在参数
  34. for(int s = 0; s < simpleStatus.length; s++)
  35. {
  36. if("i".equals(simpleStatus[s]))
  37. {
  38. for(int pi = 0; pi < param.length; pi++)
  39. {
  40. posParam.setValueParamter(j++, ((String[])context.get(param[pi]))[s] );
  41. }
  42. this.getDao("mesdao").insert(sql[i], posParam);
  43. }
  44. else if("u".equals(simpleStatus[s]))
  45. {
  46. for(int pi = 0; pi < param.length; pi++)
  47. {
  48. posParam.setWhereClauseParameter(j++, ((String[])context.get(param[pi]))[s] );
  49. }
  50. this.getDao("mesdao").update(sql[i], posParam);
  51. }
  52. else if("d".equals(simpleStatus[s]))
  53. {
  54. for(int pi = 0; pi < param.length; pi++)
  55. {
  56. posParam.setWhereClauseParameter(j++, ((String[])context.get(param[pi]))[s] );
  57. }
  58. this.getDao("mesdao").delete(sql[i], posParam);
  59. }
  60. }
  61. }
  62. return PosBizControlConstants.SUCCESS;
  63. }
  64. }