<?xml version="1.0" encoding="UTF-8"?>
<!--
    $Author: DJ  
    $Date: 2013-5-6 下午3:04:46  
    $Revision: 1.0  
    $Purpose: 
-->
<bm:model xmlns:e="leaf.service.exception" xmlns:o="leaf.database.local.oracle" xmlns:bm="http://www.leaf-framework.org/schema/bm" xmlns:f="leaf.database.features" alias="t1" baseTable="CSH_BANK_BRANCH">
    <bm:fields>
        <bm:field name="company_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="COMPANY_ID"/>
        <bm:field name="bank_id" databaseType="NUMBER" datatype="java.lang.Long" physicalName="BANK_ID"/>
        <bm:field name="bank_code" forInsert="false" forUpdate="false" prompt="HLS.BANK_CODE"/>
        <bm:field name="bank_full_name" forInsert="false" forUpdate="false" prompt="HLS.BANK_FULL_NAME"/>
        <bm:field name="bank_branch_code" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BANK_BRANCH_CODE" prompt="HLS.BANK_BRANCH_CODE"/>
        <bm:field name="bank_branch_id" databaseType="NUMBER" datatype="java.lang.Long" insertExpression="csh_bank_branch_s.nextval" physicalName="BANK_BRANCH_ID"/>
        <bm:field name="bank_branch_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="BANK_BRANCH_NAME" prompt="HLS.BANK_BRANCH_NAME"/>
        <bm:field name="ebank_cmb_bbknbr" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="EBANK_CMB_BBKNBR"/>
        <bm:field name="ebank_cmb_bbknbr_name" forInsert="false" forUpdate="false" prompt="所属分行"/>
        <bm:field name="phone" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="PHONE" prompt="CSH101.CSH_BANK_BRANCH.PHONE"/>
        <bm:field name="contact_name" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="CONTACT_NAME" prompt="CSH101.CSH_BANK_BRANCH.CONTACT_NAME"/>
        <bm:field name="e_mail_address" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="E_MAIL_ADDRESS" prompt="CSH101.CSH_BANK_BRANCH.E_MAIL_ADDRESS"/>
        <bm:field name="address" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ADDRESS" prompt="CSH101.CSH_BANK_BRANCH.ADDRESS"/>
        <bm:field name="enabled_flag" databaseType="VARCHAR2" datatype="java.lang.String" physicalName="ENABLED_FLAG" prompt="HLS.ENABLED_FLAG"/>
    </bm:fields>
    <bm:operations>
        <bm:operation name="query">
            <bm:query-sql><![CDATA[
                SELECT
                    t1.bank_branch_id,
                    t1.bank_id,
                    (SELECT d.bank_code FROM csh_bank d WHERE d.bank_id=t1.bank_id
                    ) bank_code,
                    (SELECT d.bank_full_name FROM csh_bank d WHERE d.bank_id=t1.bank_id
                    ) bank_full_name,
                    t1.company_id,
                    t1.bank_branch_code,
                    t1.bank_branch_name,
                    t1.ebank_cmb_bbknbr,
                    (select b.code_value_name from sys_codes a,sys_code_values_vl b where a.code_id=b.code_id and a.code='EBANK_CMB_BBKNBR' and b.code_value=t1.ebank_cmb_bbknbr
                    ) ebank_cmb_bbknbr_name,
                    t1.phone,
                    t1.contact_name,
                    t1.e_mail_address,
                    t1.enabled_flag,
                    t1.address,
                    t1.creation_date,
                    t1.created_by,
                    t1.last_update_date,
                    t1.last_updated_by
                FROM
                    csh_bank_branch t1 #WHERE_CLAUSE#
            ]]></bm:query-sql>
        </bm:operation>
        <bm:operation name="insert">
            <bm:parameters>
                <bm:parameter name="bank_branch_id" input="false" output="true" outputPath="@bank_branch_id"/>
            </bm:parameters>
            <bm:update-sql><![CDATA[
        		begin
        		
				  HLS_EBANK_SAVE_PKG.branch_manage(p_sql_type		 => 'INSERT',
				  							  p_bank_branch_id   => ${@bank_branch_id},
								              p_bank_id          => ${@bank_id},
								              p_company_id       => ${/session/@company_id},
								              p_bank_branch_code => ${@bank_branch_code},
								              p_bank_branch_name => ${@bank_branch_name},
								              p_ebank_cmb_bbknbr => ${@ebank_cmb_bbknbr},
								              p_phone            => ${@phone},
								              p_contact_name     => ${@contact_name},
								              p_e_mail_address   => ${@e_mail_address},
								              p_enabled_flag     => ${@enabled_flag},
								              p_address          => ${@address},
								              p_user_id          => ${/session/@user_id});

				end;
        	]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="update">
            <bm:update-sql><![CDATA[
        		begin
        		
				  HLS_EBANK_SAVE_PKG.branch_manage(p_sql_type		 => 'UPDATE',
				  							  p_bank_branch_id   => ${@bank_branch_id},
								              p_bank_id          => ${@bank_id},
								              p_company_id       => ${/session/@company_id},
								              p_bank_branch_code => ${@bank_branch_code},
								              p_bank_branch_name => ${@bank_branch_name},
								              p_ebank_cmb_bbknbr => ${@ebank_cmb_bbknbr},
								              p_phone            => ${@phone},
								              p_contact_name     => ${@contact_name},
								              p_e_mail_address   => ${@e_mail_address},
								              p_enabled_flag     => ${@enabled_flag},
								              p_address          => ${@address},
								              p_user_id          => ${/session/@user_id});

				end;
        	]]></bm:update-sql>
        </bm:operation>
        <bm:operation name="delete">
            <bm:update-sql><![CDATA[
        		begin
        		
				  HLS_EBANK_SAVE_PKG.branch_manage(p_sql_type		 => 'DELETE',
				  							  p_bank_branch_id   => ${@bank_branch_id},
								              p_bank_id          => ${@bank_id},
								              p_company_id       => ${/session/@company_id},
								              p_bank_branch_code => ${@bank_branch_code},
								              p_bank_branch_name => ${@bank_branch_name},
								              p_ebank_cmb_bbknbr => ${@ebank_cmb_bbknbr},
								              p_phone            => ${@phone},
								              p_contact_name     => ${@contact_name},
								              p_e_mail_address   => ${@e_mail_address},
								              p_enabled_flag     => ${@enabled_flag},
								              p_address          => ${@address},
								              p_user_id          => ${/session/@user_id});

				end;
        	]]></bm:update-sql>
        </bm:operation>
    </bm:operations>
    <bm:data-filters>
        <bm:data-filter enforceOperations="query" expression="t1.bank_id=${@bank_id}"/>
    </bm:data-filters>
    <bm:features>
        <f:standard-who/>
        <o:sequence-pk/>
    </bm:features>
    <bm:primary-key>
        <bm:pk-field name="bank_branch_id"/>
    </bm:primary-key>
    <e:exception-descriptor-config>
        <e:exception-descriptor exception="java.sql.SQLException" handleClass="leaf.database.SQLExceptionDescriptor">
            <e:error-message code="1" message="CSH101.ERROR.BANK_BRANCH_CODE_REPEATED"/>
        </e:exception-descriptor>
    </e:exception-descriptor-config>
</bm:model>
