Tot_af_manyemp0.java 3.67 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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
package com.csc.library.databean;

import com.csc.library.utilities.MyLog;
import com.csc.library.database.MyHashMap;
import com.csc.library.session.DbInquiry;
import com.csc.library.session.DbRecord;
import com.csc.library.session.DbTable;
import com.csc.library.session.InitialInquiry;
import com.csc.library.session.InitialRecord;
import com.csc.library.session.InitialTable;
import com.csc.library.session.RecordCmp;
import com.csc.library.utilities.CscCalendar;

public class Tot_af_manyemp0 extends RecordCmp{

    public Tot_af_manyemp0() {
        super("Tot_af_manyemp0","Tot_af_manyemp0 Table");
        // TODO Auto-generated constructor stub
    }
    
    protected void postInsertTrigger() throws Exception {         
        super.postInsertTrigger();
        this.genRecord();
    }

    protected void postUpdateTrigger() throws Exception {       
    	super.postUpdateTrigger();
        this.genRecord();        
    }
    
    protected void postDeleteTrigger() throws Exception {               
        super.postDeleteTrigger();
        this.delDataTot_af_process();
    }
    
    /*protected boolean preInsertTrigger() throws Exception {         
        boolean result = super.preInsertTrigger();
        this.genRecord();
        return result;
    }

    protected boolean preUpdateTrigger() throws Exception {       
    	boolean result = super.preUpdateTrigger();
        this.genRecord();      
        return result;
    }
    
    protected boolean preDeleteTrigger() throws Exception {               
    	boolean result = super.preDeleteTrigger();
        this.delDataTot_af_process();
        return result;
    }*/
    
    private void genRecord() {
        try {
            DbTable dt;
            if (this.getChild("Tot_af_manyemp1") != null) {
                dt = (DbTable) this.getChild("Tot_af_manyemp1");
            } else {
                dt = new InitialTable(this.userPro).getDbTable("Tot_af_manyemp1");
                dt.setColumn("*");
                this.putChild(dt);
                this.refreshChild();
            }
            dt.first();
            
            while (!dt.eof()) {
            	try {
	            	DbRecord rec = new InitialRecord(this.userPro).getDbRecord("Tot_af_process");
	                rec.setColumn("*");
	                rec.set("COMPANYID", this.getString("companyid"));
	                rec.set("DOCID", this.getString("otid"));
	                rec.set("DOCTYPE", "OM");
	                rec.set("START_DATE", dt.getString("start_date"));
	                rec.set("END_DATE", dt.getString("end_date"));
	                rec.set("START_TIME", dt.getString("start_time"));
	                rec.set("END_TIME", dt.getString("end_time"));
	                rec.set("EMPLOYEEID", dt.getString("employeeid"));
	                rec.setWFOff();
	                rec.save();
            	} catch (Exception e) {
            		MyLog.error(this, e);           		
            	}
                dt.next();
              }
               
        } catch (Exception e) {
        	MyLog.error(this, e);            
        }
    }
    
    private void delDataTot_af_process() {        
        try {
			DbInquiry inq = new InitialInquiry(this.userPro).getDbInquiry();
			inq.setParam(this.param);
			inq.setSchemaName(this.userPro.getSchemaName());
			inq.initMyTable("Tot_af_process", "docid='" + this.getString("otid") + "' and doctype='OM'", "");
			inq.setColumn("*");
			inq.refresh();
			while (inq.next()) {
				DbRecord rec = inq.getCurrentDbRecord().cloneRecord(true);
				rec.delete();
			}
		} catch (Exception e) {
			MyLog.error(this, e);			
		}
    }
    
    
}