⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 messagein.java

📁 《短信平台系统》向注册用户提供向指定手机或通讯录中手机发送短信的功能
💻 JAVA
字号:
package com.ascenttech.hib.po;

import java.util.List;

import javax.servlet.http.HttpSession;

import com.ascenttech.hib.help.FenBean;
import com.ascenttech.hib.vo.HibernateSessionFactory;
import com.ascenttech.hib.vo.t_messgae_in.TMessageIn;
import com.ascenttech.struts.form.ShouForm;

import net.sf.hibernate.HibernateException;
import net.sf.hibernate.Query;
import net.sf.hibernate.Session;
import net.sf.hibernate.Transaction;

public class MessageIn {
	//精确查询用
    private String se=null;
    //接受分页显示起市值
    private int first;
//  接受分页显示每页最大值
    private int max;
    //接收用户下发标志
    private String subport;
    //查询记录总数
    private int maxRowCount;
    //查询总记录数用
    private String count;
    //查询总数据用
    private String sl;
    //接受form
    private ShouForm sf;
	public MessageIn(ShouForm sf) {
		super();
		// TODO Auto-generated constructor stub
		this.sf = sf;
	}

	public MessageIn(int first, int max, String subport) {
		super();
		// TODO Auto-generated constructor stub
		this.first = first;
		this.max = max;
		this.subport = subport;
	}
//查询用
	public MessageIn(int first, int max,String se,ShouForm sf,String subport) {
		super();
		// TODO Auto-generated constructor stub
		this.first = first;
		this.max = max;
		this.se = se;
		this.sf = sf;
		this.subport = subport;
	}

	public MessageIn() {
		super();
		// TODO Auto-generated constructor stub
	}

	public FenBean select() {
		
		Integer f1=new Integer(0);
		Integer f2=new Integer(1);		
           
		if(se==null){
		count="select count(*)from TMessageIn where subport=" + subport;
		sl="from TMessageIn as t where t.subport='"
			+ subport+"'and (t.flag='"+f1+"' or t.flag='"+f2+"')";
		}
		if(se!=null){
			if(se.equals("0")){
				count="select count(*)from TMessageIn where subport=" + subport;
				sl="from TMessageIn as t where t.subport='"
					+ subport+"'and (t.flag='"+f1+"' or t.flag='"+f2+"')";
			}
			if(se.equals("1")){
				
		
				String c=sf.getSelect2();
				System.out.println(c+"33333333333333333333");
				System.out.println(subport+"8888888888888888888888888888");
				count="select count(*)from TMessageIn where subport=" + subport+" and cell="+c;
				
				sl="from TMessageIn as t where t.subport='"
					+ subport+"' and t.cell='"+c
					+"' and (t.flag='"+f1+"' or t.flag='"+f2+"')";
		
			}
		/*	if(se.equals("0")){
				count="select count(*)from TMessageIn where subport=" + subport;
				sl="from TMessageIn as t where t.subport='"
					+ subport+"'and (t.flag='"+f1+"' or t.flag='"+f2+"')";
			}
			if(se.equals("0")){
				count="select count(*)from TMessageIn where subport=" + subport;
				sl="from TMessageIn as t where t.subport='"
					+ subport+"'and (t.flag='"+f1+"' or t.flag='"+f2+"')";
			}
			if(se.equals("0")){
				count="select count(*)from TMessageIn where subport=" + subport;
				sl="from TMessageIn as t where t.subport='"
					+ subport+"'and (t.flag='"+f1+"' or t.flag='"+f2+"')";
			}*/
		}
		List list = null;
		Transaction ts = null;
		
		FenBean fb = null;
		Query query=null;
		try {
			Session session = HibernateSessionFactory.currentSession();
			ts = session.beginTransaction();
           
			maxRowCount = ((Integer) session.iterate(count).next()).intValue();
			System.out.println(maxRowCount+"2222222222222222");

			 query = session.createQuery(sl);
         
			query.setFirstResult(first);
			System.out.println(first+"00000000000000000000000000");
			query.setMaxResults(max);
			System.out.println(max+"111111111111111111111111111111111");
			list = query.list();
			System.out.println(list.size()+"6666666666666666666666666666666");

			if (query != null) {
				fb = new FenBean(list, maxRowCount);
				return fb;

			}
			ts.commit();
		} catch (HibernateException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		try {
			ts.rollback();
		} catch (HibernateException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		return fb;
	}

	public String delete(String[] id) {
		String deleteok = null;
		System.out.println("eeeeeeeeeeeeeeeeeeeee");
		String seqnum[] = id;
		if (seqnum != null)
			for (int i = 0; i < seqnum.length; i++) {
				
				// 得到id转化成数据库的类型
				String d = seqnum[i];
				Long l = Long.valueOf(d);
				// 连接数据库
				Transaction ts = null;
				try {
					Session session = HibernateSessionFactory.currentSession();

					Query query = session
							.createQuery("from TMessageIn where seqnum=" + d);
					System.out.println("update1111!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
					List list = query.list();
					TMessageIn ti = (TMessageIn) list.get(0);
					Integer f = new Integer(-1);
					ti.setFlag(f);

					ts = session.beginTransaction();
					session.save(ti);
					System.out.println("update222222!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
					ts.commit();// 不写数据库不执行语句

				} catch (HibernateException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				try {
					ts.rollback();
				} catch (HibernateException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}
			}
				// 验证修改成功
				for (int i1 = 0; i1 < seqnum.length; i1++) {
					// 得到id转化成数据库的类型
					String d1 = seqnum[i1];
					Long l1 = Long.valueOf(d1);
					// 连接数据库

					try {
						Session session1 = HibernateSessionFactory
								.currentSession();

						Query query1 = session1
								.createQuery("from TMessageIn where seqnum="
										+ d1);
						List list1 = query1.list();
						TMessageIn ti1 = (TMessageIn) list1.get(0);
						Integer k = new Integer(-1);
						System.out.println("yanzheng 1111!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
						if (ti1.getFlag().equals(k)) {
							deleteok = "ok";
							return deleteok;
						} else {
							deleteok = "no";
							return deleteok;
						}

					} catch (HibernateException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}

				}

			
		return deleteok;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -