📄 contactdao.java
字号:
package gzwj.dao;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Hashtable;
import gzwj.common.CommonFunction;
import gzwj.databean.UserInfoDatabean;
import gzwj.formbean.NewContactFormBean;
import gzwj.iface.DaoCommon;
import gzwj.sql.Dbpool;
public class ContactDao extends Dao implements DaoCommon {
public ContactDao() throws Exception
{
this.db = new Dbpool();
db.getPool(this.Constant.connectName);
}
public Object queryExecute(DateBean context) throws Exception {
ArrayList rList = new ArrayList();
CommonFunction comm=null;
NewContactFormBean formbean =(NewContactFormBean)context;
String User_Full_Name,
User_Company,
User_Phone,
User_Fax,
User_Email,
User_Address,
User_Content,
User_Cell;
String SqlStr;
User_Full_Name=formbean.getUser_Full_Name();
User_Company=formbean.getUser_Company();
User_Phone=formbean.getUser_Phone();
User_Fax=formbean.getUser_Fax();
User_Email=formbean.getUser_Email();
User_Address=formbean.getUser_Address();
User_Content=formbean.getUser_Content();
User_Cell=formbean.getUser_Cell();
SqlStr="insert o_user_master (User_Name,User_Cell,User_State,User_Full_Name,User_Company,User_Phone,User_Fax, User_Email,User_Address,User_Content )values("
+"'FR',"+User_Cell+",0,'"+User_Full_Name+"','"+User_Company+"',+'"+User_Phone+"','"+User_Fax+"','"+User_Email+"','"+User_Address+"','"+User_Content+"')";
System.out.println("Add new Contact User info== "+SqlStr);
db.Update(SqlStr);
return null;
}
public Object queryExecute_ShowTXL(DateBean context) throws Exception {
Hashtable has=new Hashtable();
ArrayList ShowList = new ArrayList();
ArrayList GroupList = new ArrayList();
NewContactFormBean formbean =(NewContactFormBean)context;
String User_ID=formbean.getUser_ID();
String current_page = formbean.getCurrent_page();
String action = formbean.getOption();
String select_page = formbean.getSelectPage();
int page_number = 3;
current_page = current_page == null?"1":current_page;
select_page = select_page == null?"1":select_page;
action= action == null?"HeadPage":action;
int countPage=(int)(Integer.parseInt(current_page)-1)*page_number;
String SqlStrGroup="select distinct (a.group_name) as groupName from o_group_master A, o_user_Group B where a.id=b.group_id and b.user_id= "+User_ID;
//用来得到当前用户所有组名
String SqlStr="select count(*) as total from o_user_master A,o_group_master B, o_user_Group C where a.user_id=c.contact_user_id and b.id=c.group_id and c.user_id="+User_ID;
String SqlStr1="(select c.id as id ,a.user_full_name,a.user_cell,a.user_company,a.user_phone,a.user_fax,a.user_email,a.user_address,a.user_content,b.group_name from";
SqlStr1+=" o_user_master A,o_group_master B, o_user_Group C where a.user_id=c.contact_user_id and b.id=c.group_id and c.user_id="+User_ID+")T";
String SqlStr2="(select c.id from o_user_master A,o_group_master B, o_user_Group C where a.user_id=c.contact_user_id and b.id=c.group_id and c.user_id="+User_ID+")G";
ResultSet set;
int total = 0;
set = db.getRst(SqlStr);
ArrayList list = new ArrayList();
System.out.println("success to execute for this query ");
if(set.next())
{
total = set.getInt("total");
}
if(total > 0)
{
list = cFun.s_multi(total,Integer.parseInt(current_page), action, Integer.parseInt(select_page), page_number);
System.out.println("sleep :" + list);
SqlStr="select top "+page_number+" * from "+SqlStr1+" where id not in(select top "+ countPage +" id from " +SqlStr2+")";
System.out.println("...Return Page SQL== "+SqlStr);
set = null;
set = db.getRst(SqlStr);
System.out.println("success to execute for this query 2");
int i = 1;
ShowList.add(list);
while(set.next())
{
UserInfoDatabean databean=new UserInfoDatabean();
databean.setUser_Address(set.getString("user_Address"));
databean.setUser_Cell(set.getString("user_Cell"));
databean.setUser_Company(set.getString("user_Company"));
databean.setUser_Content(set.getString("user_Content"));
databean.setUser_Email(set.getString("user_Email"));
databean.setUser_Fax(set.getString("user_Fax"));
//databean.setUser_Full_Name(set.getString("user_Full_Name"));
databean.setUser_Phone(set.getString("user_Phone"));
databean.setContact_User_Name(set.getString("user_Full_Name"));
ShowList.add(databean);
}
}
set = null;
set = db.getRst(SqlStrGroup);
while(set.next())
{
GroupList.add(set.getString("groupName"));
}
has.put("ShowList", ShowList);
has.put("GroupList", GroupList);
return has;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -