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

📄 timesheetsrc.java.svn-base

📁 一个timesheet程序,用来统计开发人员的度量衡web在线程序.用于软件行业
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
package com.nsi.components.timesheet;

import java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.nsi.components.src.NsiAbstractSrc;
import com.nsi.constants.AppConstants;
import com.nsi.control.exceptions.NsiEventException;
import com.nsi.util.ValHelper;

/**
 * @author Chris Ye, created on Oct 2, 2008
 *
 * TimeSheetSrc
 */
public class TimeSheetSrc extends NsiAbstractSrc
{
	private static Log log = LogFactory.getLog(TimeSheetSrc.class);
	private String timesheetid;
	private String resourceid;
	private String weekbegin;
	private TsInfo info;
	private boolean update;
	/**
	 * constructor of TimeSheetSrc
	 * @throws NsiEventException
	 */
	public TimeSheetSrc() throws NsiEventException
	{
		super();
		weekbegin = "";
		info = new TsInfo();
		update = false;
	}
	public String getTimesheetid()
	{
		return timesheetid;
	}
	public void setTimesheetid(String timesheetid)
	{
		this.timesheetid = timesheetid;
	}
	public String getResourceid()
	{
		return resourceid;
	}
	public void setResourceid(String resourceid)
	{
		this.resourceid = resourceid;
	}
	public String getWeekbegin()
	{
		return weekbegin;
	}
	public void setWeekbegin(String weekbegin)
	{
		this.weekbegin = weekbegin;
	}
	public TsInfo getInfo()
	{
		return info;
	}
	public void setInfo(TsInfo info)
	{
		this.info = info;
	}
	public boolean isUpdate()
	{
		return update;
	}
	public void setUpdate(boolean update)
	{
		this.update = update;
	}
	public boolean isExistTimeSheetbyRSIDandWKBGN(String inresourceid, String inweekbegin) throws NsiEventException
	{
		boolean flag = false;
		String sSql = 	"select timesheetid, resourceid, to_char( weekbegining, 'MON-DD-YYYY' ) as weekbegining " +
							"from t_timesheet where resourceid = " + inresourceid.trim() + " " +
							"and weekbegining = to_date('" + inweekbegin + "', 'MON-DD-YYYY' )";
		try
		{
			getConnection();
			List<Map<String,String>> result = sdrc.executeRetrieve(conn, sSql);
			if(!result.isEmpty())
			{
				int size = result.size();
				for (int i = 0; i < size; i++)
				{
					Map<String,String>hashResult = result.get(i);
					timesheetid = hashResult.get("timesheetid");
					weekbegin = hashResult.get("weekbegining");
					resourceid = hashResult.get("resourceid");
				}
				flag = true;
			}
		}
		catch(SQLException se)
		{
			log.error("isExistTimeSheetbyRSIDandWKBGN() -- caught SQLException : ", se);
			throw new NsiEventException("isExistTimeSheetbyRSIDandWKBGN() -- caught SQLException : ", se);
		}
		catch(Exception ex)
		{
			log.error("isExistTimeSheetbyRSIDandWKBGN() -- caught Exception : ", ex);
			throw new NsiEventException("isExistTimeSheetbyRSIDandWKBGN() -- caught Exception : ", ex);
		}
		finally
		{
			closeConnection();
		}
		return flag;
	}
	public boolean isExistTimeSheetbyTSIdandProjActId(String intimesheetid, String inprojactid) throws NsiEventException
	{
		String sSql = 	"select timesheetid, projactid as weekbegining from t_ts_detail " +
							"where timesheetid = " + intimesheetid.trim() + " and projactid = " + inprojactid;
		boolean flag = false;
		try
		{
			getConnection();
			List<Map<String,String>> result = sdrc.executeRetrieve(conn, sSql);
			if(!result.isEmpty())
			{
				flag = true;
			}
		}
		catch(SQLException se)
		{
			log.error("isExistTimeSheetbyTSIdandProjActId() -- caught SQLException : ", se);
			throw new NsiEventException("isExistTimeSheetbyTSIdandProjActId() -- caught SQLException : ", se);
		}
		catch(Exception ex)
		{
			log.error("isExistTimeSheetbyTSIdandProjActId() -- caught Exception : ", ex);
			throw new NsiEventException("isExistTimeSheetbyTSIdandProjActId() -- caught Exception : ", ex);
		}
		finally
		{
			closeConnection();
		}
		return flag;
	}
	public boolean isExistTimeSheetbyTSID(String intimesheetid) throws NsiEventException
	{
		String sSql = "select timesheetid, resourceid, to_char( weekbegining, 'MON-DD-YYYY' ) as weekbegining from t_timesheet where timesheetid = " + intimesheetid.trim();
		boolean flag = false;
		try
		{
			getConnection();
			List<Map<String,String>> result = sdrc.executeRetrieve(conn, sSql);
			if(!result.isEmpty())
			{
				int size = result.size();
				for (int i = 0; i < size; i++)
				{
					Map<String,String>hashResult = result.get(i);
					timesheetid = hashResult.get("timesheetid");
					weekbegin = hashResult.get("weekbegining");
					resourceid = hashResult.get("resourceid");
				}
				flag = true;
			}
		}
		catch(SQLException se)
		{
			log.error("isExistTimeSheetbyTSID() -- caught SQLException : ", se);
			throw new NsiEventException("isExistTimeSheetbyTSID() -- caught SQLException : ", se);
		}
		catch(Exception ex)
		{
			log.error("isExistTimeSheetbyTSIdandProjActId() -- caught Exception : ", ex);
			throw new NsiEventException("isExistTimeSheetbyTSIdandProjActId() -- caught Exception : ", ex);
		}
		finally
		{
			closeConnection();
		}
		return flag;
	}
	public void load() throws NsiEventException
	{
		selectTimeSheet();
	}
	public void store() throws NsiEventException
	{
		if(update)
		{
			String bFinalize = info.getFinalized().trim();
			if("T".equalsIgnoreCase(bFinalize))
			{
				updateTimeSheetDetails(true);
				updateTimeSheetHeader(true);
			}
			else if("U".equalsIgnoreCase(bFinalize)) 
			{
				updateTimeSheetDetails(false);
				updateTimeSheetHeader(true);
			}
			else
			{
				updateTimeSheetDetails(true);
				updateTimeSheetHeader(false);
			}
			update = false;
		}
	}
	private void selectTimeSheet() throws NsiEventException
	{
		String sSql = "select timesheetid, resourceid, to_char( weekbegining, 'MON-DD-YYYY' ) as weekbegining, moduserid, bfinalized, bactive from t_timesheet where timesheetid = " + timesheetid;
		try
		{
			getConnection();
			Map<String,String> result = sdrc.retrieveSingleRow(conn, sSql);
			if(!result.isEmpty())
			{
				info.reset();
				timesheetid = result.get("timesheetid");
				resourceid = result.get("resourceid");
				weekbegin = result.get("weekbegining");
				modifyuser = result.get("moduserid");
				info.setTimesheetid(timesheetid);
				info.setResourceid(resourceid);
				info.setStartweek(weekbegin);
				info.setFinalized(result.get("bfinalized"));
				info.setActive(result.get("bactive"));
				String sSqlDtl = 	"select d.*, pa.projectid, pa.activityid, p.shortname as shortname, a.activity as activity " + 
										"from t_ts_detail d, t_proj_act pa, t_project p, ct_activity a " + 
										"where d.timesheetid = " + timesheetid + " " +
										"and d.projactid = pa.projactid and pa.activityid = a.activityid and pa.projectid=p.projectid " + 
										"order by shortname, activity";
				List<Map<String,String>> detailResult = sdrc.executeRetrieve(conn, sSqlDtl);
				if(!detailResult.isEmpty())
				{
					int size = detailResult.size();
					for (int i = 0; i < size; i++)
					{
						TsDetails detail = new TsDetails();

⌨️ 快捷键说明

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