Extjs 查询出用户,实现增删改查功能 (重点在于查询后替换和分页问题)

jsp:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<%@page import="java.net.URLDecoder"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

%>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
   <script>
   var roleID = '<%=roleID%>'
var basePath = '<%=basePath%>';
var rtn = '<%=rtn%>';
</script>
    <title>topFrameManage</title>
    
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">    
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<link rel="stylesheet" type="text/css" href="<%=basePath %>ext/resources/css/ext-all.css"/>
    <script type="text/javascript" src="<%=basePath %>ext/adapter/ext/ext-base.js"></script>
    <script type="text/javascript" src="<%=basePath %>ext/ext-all.js"></script>
    <script type="text/javascript" src="<%=basePath %>ext/source/locale/ext-lang-zh_CN.js"></script>
    
    <link rel="stylesheet" type="text/css" href="<%=basePath %>css/column-tree.css"/>
    <link rel="stylesheet" type="text/css" href="<%=basePath %>css/columnLock.css"/>
    <script type="text/javascript" src="<%=basePath %>js/XMLHttpRequest.js"></script>
    <script type="text/javascript" src="<%=basePath %>js/TreeCheckNodeUI.js"></script>
    <script type="text/javascript" src="<%=basePath %>js/comm2.js"></script>
    <script type="text/javascript" src="<%=basePath %>bizApp/userInfo/displayUser.js"></script>
 
  </head>
  
  <body>


  </body>

</html>



js:

Ext.BLANK_IMAGE_URL = basePath + 'ext/resources/images/default/s.gif';
Ext.SSL_SECURE_URL = basePath + 'ext/resources/images/default/s.gif';
var baseUrl = basePath + 'AjaxListener?className=com.dvision.digitalplatform.bizApp.userInfo.displayUser';
var tree_unit = '';
var tree_unit_id = '0'; 
var queryPar = "";
Ext.onReady(function() {


//角色信息


var reader = new Ext.data.JsonReader({
                    id : 'ID',
                     root : 'root',
                    totalProperty : 'totalProperty',
                    fields : ['POSTALCODE','MASK','USERDESC','ADDRESS','USERNAME','EMAIL','PASSWORD','FIXEDIP','LINKPHONE','OVERIP','LINKMOBILE','USERID']
                });
  




var openUrl = baseUrl;
openUrl += '&methodName=getUser';
openUrl += '&paramCount=3';
// openUrl += '&param_0=0';
// openUrl += '&param_1=10';
                
roleStore = new Ext.data.Store({
              proxy : new Ext.data.HttpProxy({
                       url : openUrl
            }),
             reader : reader
    }); 
     
   roleStore.load({
        params : {
                param_0 : 0,
                param_1 : 17,
                param_2 : ""
         }
    });
//--------------------------------------------------------------------------------------------------------------
var button4 = new Ext.Action({
text:'查询',
id:'button4',
handler : function() {

Ext.MessageBox.prompt("用户名称模糊查询","请输入用户关键字名称:" ,function(button,str){
queryPar = encodeURI(str);
if(button=="ok"){
     
     queryPar = encodeURI(str);
     
     roleStore.baseParams['param_2']=encodeURI(str); 
   roleStore.removeAll();
   //Ext.getCmp('cx').setDisabled(true);
   roleStore.reload({
  params:{
  className : 'com.dvision.digitalplatform.bizApp.userInfo.displayUser',
                           methodName : 'getUser',
                           paramCount : '3',
                           param_0 : 0,
                           param_1 : 17,
                           param_2 : encodeURI(str)
  }
   });
grid.getView().refresh();
 }
});

    },
    iconCls : ''
    
});              
//-----------------------------------------------------------------------------------------------------------
var bbar = new Ext.PagingToolbar({
            id:'bb',
            pageSize : 17,
            store:roleStore,
           storeParams : {
                           className : 'com.dvision.digitalplatform.bizApp.userInfo.displayUser',
                           methodName : 'getUser',
                           paramCount : '3',
                           param_0 : '0',
                           param_1 : '15',
                           param_2 : queryPar                            
                           },   
              paramNames : {
                           start : 'param_0',
                           limit : 'param_1',
                            param_2 : 'param_2'
                            },
            displayInfo : true,
            displayMsg : "显示 {0} - {1},共 {2}条",
            emptyMsg : '没有数据需要分页',
            stripeRows : true,
            items : ['-']
     });


var sm = new Ext.grid.CheckboxSelectionModel({
singleSelect : false
});


function renderPwd(value,p,record){  
                   return '******' ;
        }  
var grid = new Ext.grid.GridPanel({
id :'grid',
ds : roleStore,
cm : new Ext.grid.ColumnModel([
sm,
{
width : 60,
header : '用户编号',
align : 'left',
dataIndex : 'USERID',
sortable:true
},
{
width : 120,
header : '用户名称',
align : 'left',
dataIndex : 'USERNAME'
},
{
width : 120,
header : '用户密码',
align : 'left',
dataIndex : 'PASSWORD',
renderer: renderPwd
}
,
{
width : 120,
header : '用户描述',
align : 'left',
dataIndex : 'USERDESC'
}
,
{
width : 120,
header : '联系手机',
align : 'left',
dataIndex : 'LINKMOBILE'
}
,
{
width : 120,
header : '联系电话',
align : 'left',
dataIndex : 'LINKPHONE'
}
,
{
width : 160,
header : '电子邮件',
align : 'left',
dataIndex : 'EMAIL'
}
,
{
width :180,
header : '联系地址',
align : 'left',
dataIndex : 'ADDRESS'
}
,
{
width : 120,
header : '邮政编码',
align : 'left',
dataIndex : 'POSTALCODE'
}
,

{
width : 120,
header : '开始IP',
align : 'left',
dataIndex : 'FIXEDIP'
},
{
width : 120,
header : '结束IP',
align : 'left',
dataIndex : 'OVERIP'
},
{
width : 120,
header : '子网掩码',
align : 'left',
dataIndex : 'MASK'
}

]),
sm:sm,
width : 689,
height :430,
frame: false,
fill : true,
bbar :bbar
});






//------------------------------------------------------------------------------------------------------------------------
var button1 = new Ext.Action({
text:'添加',
id:'button',
handler : function() {
resetPopWin1(true);
    },
    iconCls : ''
});
var button2 = new Ext.Button ({allowDepress : false,
text:'删除',
            handler : function delguide()
        {
      var re = grid.getSelectionModel().getSelections();           
      if(re==null||re=='')
              {
              Ext.Msg.show({
  title:'注意',
  msg: '请选择需要删除的数据',
  buttons: Ext.Msg.OK,
  icon: Ext.MessageBox.QUESTION 
              });
              }else
              {
                  Ext.Msg.show({
                      title:'注意',
                      msg: '确定删除所选所有数据?',
                      buttons: Ext.Msg.YESNO,
                      icon: Ext.MessageBox.QUESTION,
                      fn:function(btn){
                         if(btn=='yes')
                  {
                  
                    var arrId = '';
                      for(var i=0;i<re.length;i++) {
                     
                      if(i>0){
       arrId = arrId + ',' + re[i].get('USERID'); 
      }else{
       arrId = arrId + re[i].get('USERID'); 
      } 
      
}
                      
                 var deleteInfo  =  baseUrl;
                               deleteInfo += '&methodName=delUser';
                   deleteInfo += '&paramCount=1';
                   deleteInfo += '&param_0='+arrId;
                   
                   http.send(deleteInfo,function(rtn){
        if(rtn=='1')
        {
        Ext.Msg.alert("提示","信息删除成功!    ");
                       roleStore.reload();
        }
        else if(rtn=='-1')
        {
        Ext.Msg.alert("提示","信息删除失败!    ");
        }
        });
                  }
                      }
                   });
              }
        }
 
});




var popWin = new Ext.Window({
       id : 'popWin',
       layout : 'fit',
       anchor : '50%',
       width : 500,
       height : 400,
       closeAction : 'hide',
       plain : true,
       modal : true,
       items : [
       new Ext.FormPanel({
      labelWidth:90, // label settings here cascade unless overridden
      frame : true,
      layout : 'form',
      title:'应用设置',
      align:'right',
      bodyStyle:'padding:5px 5px 0',
      width: 500,
      id:'myform',
      height:400,
      items:[
         {
          layout : 'form',
          items : [
               {         
                   xtype:'textfield',
                   id:'w_id',  
                   layout : 'form',
                   fieldLabel: '用户编号',
                   labelSeparator:':',
                   width:200,
                   //allowBlank: false,
                   disabled:true  
             },
             {           
                   xtype:'hidden',
                   id:'w_depth',  
                   layout : 'form',
                   fieldLabel: 'depth',
                   labelSeparator:':',
                   width:200
             },
             {         
                    xtype:'textfield',
                    id:'w_name',  
                    layout : 'form',
                    fieldLabel: '用户名称',
                    labelSeparator:':',
                    width:200,
                    //allowBlank: false,
                    disabled:false  
             },
             {         
                    xtype:'textfield',
                    inputType: 'password',
                    id:'w_pass',  
                    layout : 'form',
                    fieldLabel: '用户密码',
                    labelSeparator:':',
                    width:200,
                    //allowBlank: false,
                    disabled:false
                   
             },
             {         
                    xtype:'textfield',
                    id:'w_desc',  
                    layout : 'form',
                    fieldLabel: '用户描述',
                    labelSeparator:':',
                    width:200,
                    //allowBlank: false,
                    disabled:false  
             },
             {         
                    xtype:'textfield',
                    id:'w_mobile',  
                    layout : 'form',
                    fieldLabel: '联系手机',
                    labelSeparator:':',
                    width:200,
                    //allowBlank: false,
                    disabled:false  
             },
             {         
                    xtype:'textfield',
                    id:'w_phone',  
                    layout : 'form',
                    fieldLabel: '联系电话',
                    labelSeparator:':',
                    width:200,
                    //allowBlank: false,
                    disabled:false  
             },
             {         
                    xtype:'textfield',
                    id:'w_email',  
                    layout : 'form',
                    fieldLabel: '电子邮件',
                    labelSeparator:':',
                    width:200,
                    //allowBlank: false,
                    disabled:false  
             },
             {         
                    xtype:'textfield',
                    id:'w_address',  
                    layout : 'form',
                    fieldLabel: '联系地址',
                    labelSeparator:':',
                    width:200,
                    //allowBlank: false,
                    disabled:false  
             },
             {         
                    xtype:'textfield',
                    id:'w_code',  
                    layout : 'form',
                    fieldLabel: '邮政编码',
                    labelSeparator:':',
                    width:200,
                    //allowBlank: false,
                    disabled:false  
             },
             {         
                    xtype:'textfield',
                    id:'w_ips',  
                    layout : 'form',
                    fieldLabel: '开始IP',
                    labelSeparator:':',
                    width:200,
                    //allowBlank: false,
                    disabled:false  
             },
             {         
                    xtype:'textfield',
                    id:'w_ipe',  
                    layout : 'form',
                    fieldLabel: '结束IP',
                    labelSeparator:':',
                    width:200,
                    //allowBlank: false,
                    disabled:false  
             },
             {         
                    xtype:'textfield',
                    id:'w_mask',  
                    layout : 'form',
                    fieldLabel: '子网掩码',
                    labelSeparator:':',
                    width:200,
                    //allowBlank: false,
                    disabled:false  
             }
  ]
        }
     ],
      tbar : [{
                    text : '保存',
                    handler : btnSave,
                    iconCls:'save'
                 },'-', {
                    text : '关闭',
                    handler : function() {
                        popWin.hide();
                       //store.proxy = new Ext.data.HttpProxy({
                         // url : openUrl
                       //})
                       // store.removeAll();
                       // store.reload();
                    }
                }]
  })
                   ]
   });


function resetPopWin(bAdd){
roleStore.reload();
var sel;
if(!bAdd){
sel = grid.getSelectionModel().getSelections();
if(sel.length == 0){
Ext.MessageBox.alert('提示信息', '请选择修改项');
return;
}
if(sel.length > 1){
Ext.MessageBox.alert('提示信息', '只能选择一个修改项!');
return;
}
saveUrl = '';
saveUrl = baseUrl;
   saveUrl +="&methodName=updateUser";


}else{
saveUrl = '';
   saveUrl = baseUrl;
   saveUrl+="&methodName=updateUser";
}
Ext.getCmp('w_id').setValue(bAdd?'':sel[0].data.USERID);
Ext.getCmp('w_name').setValue(bAdd?'':sel[0].data.USERNAME);
Ext.getCmp('w_pass').setValue(bAdd?'':sel[0].data.PASSWORD);
Ext.getCmp('w_desc').setValue(bAdd?'':sel[0].data.USERDESC);
Ext.getCmp('w_mobile').setValue(bAdd?'':sel[0].data.LINKMOBILE);
Ext.getCmp('w_phone').setValue(bAdd?'':sel[0].data.LINKPHONE);
Ext.getCmp('w_email').setValue(bAdd?'':sel[0].data.EMAIL);
Ext.getCmp('w_address').setValue(bAdd?'':sel[0].data.ADDRESS);
Ext.getCmp('w_code').setValue(bAdd?'':sel[0].data.POSTALCODE);
Ext.getCmp('w_ips').setValue(bAdd?'':sel[0].data.FIXEDIP);
Ext.getCmp('w_ipe').setValue(bAdd?'':sel[0].data.OVERIP);
Ext.getCmp('w_mask').setValue(bAdd?'':sel[0].data.MASK);
//Ext.getCmp('w_depth').setValue(bAdd?'0':sel[0].data.DEPTH);
popWin.show();
}
function resetPopWin1(bAdd){
roleStore.reload();

saveUrl = '';
   saveUrl = baseUrl;
   saveUrl+="&methodName=addUser";

Ext.getCmp('w_id').setValue(bAdd?'':sel[0].data.USERID);
Ext.getCmp('w_name').setValue(bAdd?'':sel[0].data.USERNAME);
Ext.getCmp('w_pass').setValue(bAdd?'':sel[0].data.PASSWORD);
Ext.getCmp('w_desc').setValue(bAdd?'':sel[0].data.USERDESC);
Ext.getCmp('w_mobile').setValue(bAdd?'':sel[0].data.LINKMOBILE);
Ext.getCmp('w_phone').setValue(bAdd?'':sel[0].data.LINKPHONE);
Ext.getCmp('w_email').setValue(bAdd?'':sel[0].data.EMAIL);
Ext.getCmp('w_address').setValue(bAdd?'':sel[0].data.ADDRESS);
Ext.getCmp('w_code').setValue(bAdd?'':sel[0].data.POSTALCODE);
Ext.getCmp('w_ips').setValue(bAdd?'':sel[0].data.FIXEDIP);
Ext.getCmp('w_ipe').setValue(bAdd?'':sel[0].data.OVERIP);
Ext.getCmp('w_mask').setValue(bAdd?'':sel[0].data.MASK);
//Ext.getCmp('w_depth').setValue(bAdd?'0':sel[0].data.DEPTH);
popWin.show();
}


var button3 = new Ext.Action({
text:'修改',
id:'button',
handler : function() {
resetPopWin(false);
    },
    iconCls : ''
});


var button5 = new Ext.Action({
text:'',
id:'button',
handler : function() {

    },
    iconCls : ''
});


var pnl = new Ext.Panel({
title:'用户信息管理',
layout : 'form',
width : 750,
height :400,
labelAlign : 'left',
labelWidth : 80,
frame : true,
width:200,
region:'center',
collapsible : false,
autoScroll: false,
tbar : ['-',button1,'-',button2,'-',button3,'-',button4,'-',button5],
items:[{

bodyStyle:'padding:0',
layout:'fit',
items:[grid]

}]
});


var viewport = new Ext.Viewport({
        layout:"fit",
height:300,
items:[pnl]
});




function  btnSave()
   { 
      var formStore=new Object();
      formStore.id=Ext.getCmp('w_id').getValue();
       formStore.name=Ext.getCmp('w_name').getValue();
       formStore.pass =Ext.getCmp('w_pass').getValue();
       formStore.desc = Ext.getCmp('w_desc').getValue();
formStore.mobile = Ext.getCmp('w_mobile').getValue();
formStore.phone = Ext.getCmp('w_phone').getValue();
formStore.email = Ext.getCmp('w_email').getValue();
formStore.address = Ext.getCmp('w_address').getValue();
formStore.code = Ext.getCmp('w_code').getValue();
formStore.ips = Ext.getCmp('w_ips').getValue();
formStore.ipe = Ext.getCmp('w_ipe').getValue();
formStore.mask = Ext.getCmp('w_mask').getValue();
       //formStore.depth = Ext.getCmp('w_depth').getValue();
var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
      if(Ext.ComponentMgr.get("w_name").getValue()=="")
      {
      Ext.Msg.alert('提示信息','用户名称不能为空!      ');
          return ;
      }
      if(Ext.ComponentMgr.get("w_mobile").getValue()!=""){
       if(Ext.ComponentMgr.get("w_mobile").getValue().length!=11)
      {
      Ext.Msg.alert('提示信息','手机号码不正确!      ');
          return ;
      }
      }
       if(Ext.ComponentMgr.get("w_code").getValue()!=""){
       if(Ext.ComponentMgr.get("w_code").getValue().length!=6)
      {
      Ext.Msg.alert('提示信息','邮政编码不正确!      ');
          return ;
      }
      }
      if(Ext.ComponentMgr.get("w_email").getValue()!=""){
       if(!myreg.test(Ext.ComponentMgr.get("w_email").getValue()))
      {
      Ext.Msg.alert('提示信息','邮件格式不正确!      ');
          return ;
      }
      }
       if(Ext.ComponentMgr.get("w_pass").getValue()=="")
      {
      Ext.Msg.alert('提示信息','用户密码不能为空!      ');
          return ;
      } 
      if(Ext.getCmp('w_ips').getValue()!=""){
      if(Ext.getCmp('w_ips').getValue().match(/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])){3}$/))
      {
      }else{
   
      Ext.Msg.alert('提示信息','开始IP格式不对!')
          return ;
      }
      } 
       if(Ext.getCmp('w_ipe').getValue()!=""){
       if(Ext.getCmp('w_ipe').getValue().match(/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])){3}$/))
      {
      }else{
   
      Ext.Msg.alert('提示信息','结束IP格式不对!')
          return ;
      }
      }
       if(Ext.getCmp('w_mask').getValue()!=""){ 
       if(Ext.getCmp('w_mask').getValue().match(/^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])(\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])){3}$/))
      {
      }else{
   
      Ext.Msg.alert('提示信息','子网掩码格式不对!')
          return ;
      } 
      }
           saveUrl += '&paramCount=12';
           saveUrl += '&param_0='+ formStore.id;
           saveUrl += '&param_1='+ formStore.name;
           saveUrl += '&param_2='+ formStore.pass
           saveUrl += '&param_3='+ formStore.desc;
           saveUrl += '&param_4='+ formStore.mobile;
           saveUrl += '&param_5='+ formStore.phone;
           saveUrl += '&param_6='+ formStore.email;
           saveUrl += '&param_7='+ formStore.address;
           saveUrl += '&param_8='+ formStore.code;
           saveUrl += '&param_9='+ formStore.ips;
           saveUrl += '&param_10='+ formStore.ipe;
           saveUrl += '&param_11='+ formStore.mask; 
           //saveUrl += '&param_12='+ formStore.depth;
           
        http.send(saveUrl,function(rtn){
        if(rtn=='1')
        {
        Ext.Msg.alert("提示","更新信息成功!    ");
        popWin.hide();
                       roleStore.reload();
        }
        else if(rtn=='-1')
        {
        Ext.Msg.alert("提示","更新信息失败!    ");
        }
        }
//         ,Ext.util.JSON.encode(formStore)
        );
         
}




//getRoleData();
Ext.getCmp('button').setDisabled(true);




});



java:

package com.dvision.digitalplatform.bizApp.userInfo;


import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;


import javax.servlet.ServletException;
import javax.sql.DataSource;


import net.sf.json.JSONArray;


import com.dvision.digitalplatform.ajaxUtil.DAO;
import com.dvision.digitalplatform.utils.CollectionUtil;
import com.dvision.digitalplatform.utils.StringUtil;


public class displayUser {


public String getUser(String start, String limit,String str) throws UnsupportedEncodingException{
if(str!=null){
str=URLDecoder.decode(str,"utf-8");
}
//System.out.println(str);
DAO dao = new DAO();
Vector v = new Vector();
Vector v2 = new Vector();
HashMap fatherhm = new HashMap();
String rtn = "";
int p1=Integer.parseInt(start);
int p2=p1+Integer.parseInt(limit);
if(str==null){
try {

v = dao.execCommand("select count(1) as userid from T_User");
   if (Integer.parseInt(((Hashtable) v.get(0)).get("USERID").toString()) <= p2)
p2 = Integer.parseInt(((Hashtable) v.get(0)).get("USERID").toString());

v=dao.execCommand("select a.postalcode,a.username,a.password,a.linkmobile,a.linkphone,a.address,a.userid userID,a.email,a.userdesc,a.fixedIP,a.overIP,a.mask from T_User a left outer join T_AreaInfo b on a.areaid = b.areaid left outer join T_PolicyInfo c on a.defaultPolicyid = c.PolicyID");
for(int i=p1;i<p2;i++){
Hashtable ht=(Hashtable)v.get(i);
v2.add(ht);
}

rtn = "{\"totalProperty\":\"" + v.size() + "\",\"root\":"
+ JSONArray.fromObject(v2).toString() + "}";
} catch (ServletException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}else{
String sq12="select count(1) as username from T_User where T_User.username like '%' '"+str+"' '%'";
 String sql="select a.postalcode,a.username,a.password,a.linkmobile,a.linkphone,a.address,a.userid userID,a.email,a.userdesc,a.fixedIP,a.overIP,a.mask from T_User a left outer join T_AreaInfo b on a.areaid = b.areaid left outer join T_PolicyInfo c on a.defaultPolicyid = c.PolicyID where a.username like '%' '"+str+"' '%'";
 try {
v =dao.execCommand(sq12);
if (Integer.parseInt(((Hashtable) v.get(0)).get("USERNAME").toString()) <= p2)
p2 = Integer.parseInt(((Hashtable) v.get(0)).get("USERNAME").toString());
System.out.println(p2);
v=dao.execCommand(sql);
for(int i=p1;i<p2;i++){
Hashtable ht=(Hashtable)v.get(i);
v2.add(ht);
}
rtn = "{\"totalProperty\":\"" + v.size() + "\",\"root\":"
+ JSONArray.fromObject(v2).toString() + "}";
} catch (Exception e) {
e.printStackTrace();
}
}
//System.out.println(rtn);
if(rtn==""){
return null;
}
return rtn;
}

public String updateUser(String id,String name,String pass,String desc,String mobile,String phone,String email,String address,String code,String ips,String ipe,String mask) throws UnsupportedEncodingException{
DAO dao=new DAO();
String rtn="";
name=StringUtil.isoToGBK(name);
pass=StringUtil.isoToGBK(pass);
desc=StringUtil.isoToGBK(desc);
mobile=StringUtil.isoToGBK(mobile);
phone=StringUtil.isoToGBK(phone);
email=StringUtil.isoToGBK(email);
address=StringUtil.isoToGBK(address);
code=StringUtil.isoToGBK(code);
ips=StringUtil.isoToGBK(ips);
ipe=StringUtil.isoToGBK(ipe);
mask=StringUtil.isoToGBK(mask);

String sql="update T_User set username='"+ name +"',password='"+pass+"',userdesc='"+desc+"',linkmobile='"+mobile+"',linkphone='"+phone+"',postalcode='"+code+"', email='"+email+"',address='"+address+"',fixedIP='"+ips+"',overIP='"+ipe+"',mask='"+mask+"' where userid="+id;
try {
if(dao.execUpdate(sql)){
rtn="1";
}else{
rtn="-1";
}
} catch (Exception e) {
e.printStackTrace();
}
return rtn;
}

 public String addUser(String id,String name,String pass,String desc,String mobile,String phone,String email,String address,String code,String ips,String ipe,String mask) throws UnsupportedEncodingException{
 String rtn="";
 DAO dao =new DAO();
name=StringUtil.isoToGBK(name);
pass=StringUtil.isoToGBK(pass);
desc=StringUtil.isoToGBK(desc);
mobile=StringUtil.isoToGBK(mobile);
phone=StringUtil.isoToGBK(phone);
email=StringUtil.isoToGBK(email);
address=StringUtil.isoToGBK(address);
code=StringUtil.isoToGBK(code);
ips=StringUtil.isoToGBK(ips);
ipe=StringUtil.isoToGBK(ipe);
mask=StringUtil.isoToGBK(mask);
 String sql="insert into T_User(username,password,userdesc,linkmobile,linkphone,email,address,postalcode,fixedIP,overIP,mask,areaid)values('"+name+"','"+pass+"','"+desc+"','"+mobile+"','"+phone+"','"+email+"','"+address+"','"+code+"','"+ips+"','"+ipe+"','"+mask+"',0)";
try {
if(dao.execUpdate(sql)){
rtn="1";
}else {
rtn="-1";
}
} catch (Exception e) {
e.printStackTrace();
}

 return rtn;
 }

 public String delUser(String id){
 
 System.out.println(id);
 String rtn="";
 DAO dao=new DAO();
 String sql="delete from T_User where userid in ("+id+")";
 try {
if (dao.execUpdate(sql)) {
rtn="1";
} else {
rtn="-1";
}
} catch (Exception e) {
e.printStackTrace();
}
 return rtn;
 }


}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值