1. 程式人生 > >根據資料庫獲取新的序列號傳到前臺

根據資料庫獲取新的序列號傳到前臺

var txtOrderID = Ext.create('Ext.form.field.Text', {
    fieldLabel: '條件序號',
name: 'orderid',
allowBlank: true,
readOnly: true,
maxLength: 50
});
//生成新的orderid
Ext.Ajax.request({
    url: 'TUDevCtrl/getNewConditionOrderID',
params: {itemid: ItemID},
async: false,
success: function (response) {
        Ext.Msg
.hide(); var data = Ext.decode(response.responseText); txtOrderID.setValue(data.data); } });

//獲取新的條件序列號
@RequestMapping("/getNewConditionOrderID")
public void getNewConditionOrderID(String itemid, HttpServletResponse response) {
    Json json = new Json();
Print print = new Print();
    int orderId = 0
; try { orderId = tuDevCtrlService.getNewConditionOrderID(itemid); } catch (Exception e) { e.printStackTrace(); } json.setData(orderId); json.setSuccess(true); print.WriteJson(response, json); }
@Override
public int getNewConditionOrderID(String itemid) throws Exception {
    int 
orderID = 0; List<Map<String, Object>> list = sqlMapper.findList("select OrderID from TUDevCtrlCICondition where ItemID='" + itemid + "' order by orderid desc"); if (list != null && list.size() > 0) { orderID = Integer.parseInt(list.get(0).get("OrderID").toString()); orderID++; } else {//第一次return 1 return 1; } return orderID; }