Memployee_ta.java 3.42 KB
Newer Older
TongZuu committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
package com.csc.library.databean;

import java.text.DecimalFormat;

import com.csc.library.session.DbRecord;
import com.csc.library.session.InitialRecord;
import com.csc.library.utilities.CscCalendar;
import com.csc.library.utilities.MyLog;

public class Memployee_ta extends Memployee {
	
	/*
	 * ŧѹҾѡ͹ٻ 0, 0.5
	 * к DD:HH:SS
 	*/
	public String getString(String fieldName) {   
		try {
			if(fieldName.indexOf(".") > -1){	/* óշٵͷ¡Ҩҡ table 蹷١Ѻ employee  ҧ emp.getString("MJOBCODE.JOBGRADEID") */
	     		String table = fieldName.substring(0,fieldName.indexOf("."));
	     		String field = fieldName.substring(fieldName.indexOf(".")+1);
	     		
	     		DbRecord db = new InitialRecord(this.userPro).getDbRecord(table);
	     		db.setColumn("*");
	     		
	     		this.putChild(db);
	     		this.refreshChild();
	     		
	     		if(this.foundData()){	/*  */
	     			return this.getChild(table).getString(field);
	     		}
	     	} else {	/* ¡Ŵ컡㹵ҧ memployee */
	     		return super.getString(fieldName);
	     	}
		}catch(Exception e){
			MyLog.error(this,e);
		}
     	return "";
     }
	
	/* Ѻʡ ͧѡҹѹ  觵ͧҨҡ MTime2 öʡз Table Memployee  */
	public String getDailyTime0id(CscCalendar date){
		String time0id = "";
		try {
	    	DbRecord timeRec = new InitialRecord(this.userPro).getDbRecord("MTIME0"); 
	    	timeRec.set("time0id",this.getString("time0"));
	    	timeRec.set("companyid",this.getString("companyid"));
	    	timeRec.setColumn("*");
	    	if (timeRec.search() == 1){
	    		if(timeRec.getString("status").equals("1")){ /* 繵ҧ ͧҵ MTime2 ѹèʡ */
		        	DbRecord time2 = new InitialRecord(this.userPro).getDbRecord("MTIME2");
		        	time2.set("time0id", this.getString("time0"));
		        	time2.set("monthid", date.getCurrentMonth());
		        	time2.set("yearid", date.getYear());
		        	time2.set("companyid", this.getString("companyid"));
		        	time2.setColumn("*");
		        	
		        	if(time2.search() == 1){
		        		/* ֧ʡ ѹͧ͹ 㹪ͧʡЪͧá (˹ѹ 3  軡Ԩͧá )*/
		        		DecimalFormat df = new DecimalFormat("00");
		        		time0id = time2.getString("time" + df.format(date.getDate()) + '1');
		        	} else {
		        		MyLog.error("!! Error : can't get time0id from MTIME2 !!");
		        	}
	    		} else { /* 繵ҧ÷ӧҹ ʹ*/
	    			time0id = timeRec.getString("time0id");
	    		}
	    	}
		}catch(Exception e){
			MyLog.error("!! Error : Can't get time0id from employeeid --> " + this.getString("employeeid"));
		}
		return time0id;
	}
	
	/**
	 * ֧ҵ fix  table mempl_fix
	 * @param field  ͿŴͧ
	 * @return double  ѾͧŴ
	 */
	public double getFixDouble(String field) {
		double value = 0.0d;
		try {
			DbRecord mempl = new InitialRecord(this.userPro).getDbRecord("mempl_fix"); 
			mempl.set("employeeid",this.getString("employeeid"));
			mempl.setParam("rsc_skip","true");
			mempl.set("fixtabid",field);
			mempl.setColumn("*");
	    	if (mempl.search() == 1){
	    		value = mempl.getDouble("emp_data");
	    	}
		}catch(Exception e){
			MyLog.error(this,e);
		}
		return value;
	}	
}