NC编辑前事件和编辑后事件

XML配置:

<!-- 编辑事件 -->
    <bean id="appEventHandlerMediator" class="nc.ui.pubapp.uif2app.model.AppEventHandlerMediator">
        <property name="model" ref="bmModel" />
        <property name="handlerMap">
            <map>
                <!-- 表头表尾编辑前事件 -->
                <entry key="nc.ui.pubapp.uif2app.event.card.CardHeadTailBeforeEditEvent">
                    <list>
                        <bean
                            class="nc.ui.ct.fb30.hander.Fb30HeadTailBeforeEditHand">
                        </bean>
                    </list>
                </entry>
                <!-- 表体编辑前事件-->
                <entry key="nc.ui.pubapp.uif2app.event.card.CardBodyBeforeEditEvent">
                    <list>
                    <bean class="nc.ui.ct.fb30.hander.Fb30BodyTailBeforeEditHandler">
                        </bean>
                    </list>
                </entry> 
                <!-- 表体编辑后事件 -->
                <entry key="nc.ui.pubapp.uif2app.event.card.CardBodyAfterEditEvent">
                    <list>
                        <bean class="nc.ui.ct.fb30.hander.Fb30BodyTailAfterEditHandler">
                        </bean>
                    </list>
                </entry>    
                <!-- 表头表尾编辑后事件 -->
            <entry key="nc.ui.pubapp.uif2app.event.card.CardHeadTailAfterEditEvent">
                    <list>
                        <bean
                            class="nc.ui.ct.fb30.hander.Fb30HeadTailAfterEditHandler">
                        </bean>
                    </list>
                </entry>
            </map>
        </property>
    </bean>

事件:

1、表头表尾编辑前事件  Fb30HeadTailBeforeEditHand

public class Fb30HeadTailBeforeEditHand implements IAppEventHandler<CardHeadTailBeforeEditEvent> {

    @Override
    public void handleAppEvent(CardHeadTailBeforeEditEvent e) {
        BillCardPanel billCardPanel = e.getBillCardPanel();
        String key = e.getKey();
        IUAPQueryBS qbs = (IUAPQueryBS) NCLocator.getInstance().lookup(
                IUAPQueryBS.class);
        e.setReturnValue(Boolean.valueOf(true));
        if("pk_bbpro1".equals(key)){
//            UIRefPane refPane =(UIRefPane)billCardPanel.getHeadItem(key).getComponent();
//            nc.ui.bzyct.pub.refmodel.ProjPrepRefModel refModel =(ProjPrepRefModel) refPane.getRefModel();
//             String dept = billCardPanel.getHeadItem("pk_dept").getValue();
//             String wherePart="" ;
//             if(dept!=null){
//              wherePart = " and pro.pk_dept='" + dept + "'   ";
//             }
//             refModel.addWherePart(wherePart);    
             
        }else if ("pk_zht1".equals(key)) {
            UIRefPane refPane =(UIRefPane)billCardPanel.getHeadItem(key).getComponent();
            nc.ui.ct.ap.pub.refmodel.CtArzhRefModel    refModel = (CtArzhRefModel) refPane.getRefModel();
          String pk_pro1 = billCardPanel.getHeadItem("pk_bbpro1").getValue();
//            if (StringUtil.isEmpty(pk_pro1)) {
//                refPane.setEnabled(false);
//            } else {
                refPane.setEnabled(true);
                String wherePart = " and ar30.vprojno_30='" + pk_pro1 + "'   ";
                refModel.addWherePart(wherePart);                

//            }
        }else if ("pk_fbht1".equals(key)) {
//            UIRefPane refPane =(UIRefPane)billCardPanel.getHeadItem(key).getComponent();
//            nc.ui.bgbd.progresschart.refmodel.CttypeRefModel refModel = (CttypeRefModel) refPane.getRefModel();
//          String pk_pro1 = billCardPanel.getHeadItem("pk_zht1").getValue();
            if (StringUtil.isEmpty(pk_pro1)) {
                refPane.setEnabled(false);
            } else {
//                refPane.setEnabled(true);
//                String wherePart = "  and ap30.pk_mainct_30='" + pk_pro1 + "'   ";
//                refModel.addWherePart(wherePart);                
//
            }
        }else if ("def6".equals(key)){

            UIRefPane refPane =(UIRefPane)billCardPanel.getHeadItem(key).getComponent();
            refPane.setMultiSelectedEnabled(true);//自定义参照复选框
            nc.ui.bgbd.sdeptincdis.ref.SdeptIncDisRefModel refModel = (SdeptIncDisRefModel) refPane.getRefModel();
          String pk_dept = billCardPanel.getHeadItem("pk_dept").getValue();
                refPane.setEnabled(true);
                String wherePart = "  and bgbd_funds_claim.cdeptid='"+pk_dept+"'   ";
                refModel.addWherePart(wherePart);                

//            }
        
        }
        
    }

}

2、表体编辑前事件  Fb30BodyTailBeforeEditHandler

public class Fb30BodyTailBeforeEditHandler implements IAppEventHandler<CardBodyBeforeEditEvent> {
    @Override
    public void handleAppEvent(CardBodyBeforeEditEvent e) {
        e.setReturnValue(Boolean.valueOf(true));

        String key=e.getKey();
        IUAPQueryBS qbs = (IUAPQueryBS) NCLocator.getInstance().lookup(
                IUAPQueryBS.class);
        BillCardPanel billCardPanel = e.getBillCardPanel();
        int row=e.getRow();
        if(key.equals("pk_pro1")){
            UIRefPane refPane =(UIRefPane)billCardPanel.getBodyItem(key).getComponent();
            nc.ui.pmpub.ref.ProjectDefaultRefModel refModel =  (ProjectDefaultRefModel) refPane.getRefModel();
             String pk_dept = billCardPanel.getHeadItem("pk_dept").getValue();
            String wherePart = "  and pk_duty_dept='"+pk_dept+"'   ";
            refModel.addWherePart(wherePart);
        
        } 
    }

}

3、表体编辑后事件  Fb30BodyTailAfterEditHandler

public class Fb30BodyTailAfterEditHandler implements IAppEventHandler<CardBodyAfterEditEvent>{

    @Override
    public void handleAppEvent(CardBodyAfterEditEvent e) {
        String key=e.getKey();//获取关键字
        IUAPQueryBS qbs = (IUAPQueryBS) NCLocator.getInstance().lookup(
                IUAPQueryBS.class);
        BillCardPanel card = e.getBillCardPanel();
        int row=e.getRow();
        if(key.equals("bxnum")){
        int rowcount=e.getBillCardPanel().getRowCount();
        UFDouble znum=UFDouble.ZERO_DBL;
        for(int i=0;i<rowcount;i++){
            UFDouble num= new UFDouble(card.getBodyValueAt(i, "bxnum")==null?"0":card.getBodyValueAt(i, "bxnum").toString()) ;
            znum=znum.add(num);
        }
        card.setHeadItem("znum", znum);
        
        //收款比例就是已收款金额除以主合同金额加变更金额
        //流程中支付金额
        UFDouble lczmny = SafeUFDoubleUtil.valueOf((card.getHeadItem("def7").getValueObject()));
            UFDouble fbhtnum = new UFDouble(card.getHeadItem("fbhtnum").getValue());
            UFDouble yzfnum = new UFDouble(card.getHeadItem("yzfnum").getValue());
            if (fbhtnum.compareTo(UFDouble.ZERO_DBL) > 0) {
                //分院内部结算不知道为什么注释掉了?
                //TODO
//                card.setHeadItem("ljfkbl", (yzfnum.add(znum).add(lczmny)).div(fbhtnum).multiply(new UFDouble(100)));
            }
    }
}
}

4、表头表尾编辑后事件  Fb30HeadTailAfterEditHandler 

public class Fb30HeadTailAfterEditHandler implements IAppEventHandler<CardHeadTailAfterEditEvent> {

    @Override
    public void handleAppEvent(CardHeadTailAfterEditEvent e) {
        BillCardPanel billCardPanel = e.getBillCardPanel();
        String key = e.getKey();
        IUAPQueryBS qbs = (IUAPQueryBS) NCLocator.getInstance().lookup(
                IUAPQueryBS.class);
        UFDouble lcznum=UFDouble.ZERO_DBL;
     if (key.equals("pk_zht1") || key.equals("ysknum")||key.equals("vdef4")){
            UFDouble zhtnum = new UFDouble(billCardPanel.getHeadItem("zhtnum").getValue());
            UFDouble ysknum = new UFDouble(billCardPanel.getHeadItem("ysknum")
                    .getValue());
            UFDouble zbgnum = new UFDouble(billCardPanel.getHeadItem("dmainchngmny")
                    .getValue());
            billCardPanel.setHeadItem("zskbl", ysknum.div(zhtnum.add(zbgnum)).multiply(new UFDouble(100)));
            String oldzhtpk =billCardPanel.getHeadItem("oldzhtpk")==null?null:billCardPanel.getHeadItem("oldzhtpk").getValue();
            if(oldzhtpk!=null && !oldzhtpk.equals(e.getValue())){
                billCardPanel.setHeadItem("vdef20", null);
                billCardPanel.setHeadItem("pk_fbht1", null);
                billCardPanel.setHeadItem("vdef19", null);
                billCardPanel.setHeadItem("pk_supplier", null);
                billCardPanel.setHeadItem("fbhtcode", null);
                billCardPanel.setHeadItem("fbhtnum", null);
                billCardPanel.setHeadItem("dpuchngmny", null);
                billCardPanel.setHeadItem("yzfnum", null);
                billCardPanel.setHeadItem("znum", null);
                billCardPanel.setHeadItem("def6", null);
                billCardPanel.setHeadItem("ljfkbl", null);
                billCardPanel.setHeadItem("print1", null);
                billCardPanel.setHeadItem("print2", null);
                billCardPanel.setHeadItem("bisfile", null);
                billCardPanel.setHeadItem("vdef1", null);
                
            
            }
            billCardPanel.setHeadItem("oldzhtpk", e.getValue());
        //    billCardPanel.setHeadItem("zskbl", ysknum.div(zhtnum).multiply(new UFDouble(100)));

        }else if(key.equals("pk_fbht1")){
            String fbhtcode = billCardPanel.getHeadItem("fbhtcode").getValue();
            UFDouble fbhtnum = new UFDouble(billCardPanel.getHeadItem("fbhtnum")
                    .getValue());
            UFDouble znum = new UFDouble(billCardPanel.getHeadItem("znum")
                    .getValue());
            UFDouble def3 = new UFDouble(billCardPanel.getHeadItem("def3")
                    .getValue());
            UFDouble zfbbxnum = new UFDouble(billCardPanel.getHeadItem("yzfnum")
                    .getValue());
            UFDouble fbbgnum = new UFDouble(billCardPanel.getHeadItem("dpuchngmny")
                    .getValue());
            
            if(zfbbxnum.toDouble() == 0){
                billCardPanel.setHeadItem("yzfnum", 0);
            }
            
            String pk_fbht1=billCardPanel.getHeadItem("pk_fbht1").getValue();
            if(pk_fbht1!=null && !pk_fbht1.equals("")){
            String sql="select sum(znum) from ct_fbpayapply where pk_fbht1='"
                    +pk_fbht1 + "' and nvl(dr,0)=0 and  approvestatus in (2)    ";
            
            String yzfSql = " select nvl(cap.vdef2,0) from ct_ap cap where cap.pk_ct_ap = '"
                    +pk_fbht1 + "' and nvl(cap.dr,0)=0 ";
            try {
                 lcznum = SafeUFDoubleUtil.valueOf(qbs.executeQuery(sql,
                        new ColumnProcessor()));

                Object numAlready =  qbs.executeQuery(yzfSql, new ColumnProcessor());
                UFDouble alreadynum = null;
                if(numAlready == null){
                    alreadynum = new UFDouble(0);
                }else{
                    alreadynum = new UFDouble(numAlready.toString());
                }
                 
                
                billCardPanel.setHeadItem("def7", lcznum);    
                billCardPanel.setHeadItem("yzfnum", alreadynum);    
                
                //billCardPanel.setHeadItem("ljfkbl", (zfbbxnum.add(def3).add(lcznum)).div(fbhtnum).multiply(new UFDouble(100)));
                billCardPanel.setHeadItem("ljfkbl", (zfbbxnum.add(def3).add(lcznum)).div(fbhtnum.add(fbbgnum)).multiply(new UFDouble(100)));
                    billCardPanel.setHeadItem("ljfkbl", (zfbbxnum.add(znum).add(lcznum)).div(fbhtnum.add(fbbgnum)).multiply(new UFDouble(100)));

                //pk_supplier->getcolvalue( ct_ap,cvendorid ,pk_ct_ap , pk_fbht1) ;
                
                String sql2="select name from bd_supplier where pk_supplier =(select cvendorid from ct_ap where pk_ct_ap='"+ billCardPanel.getHeadItem("pk_fbht1").getValue()+"' and nvl(dr,0)=0 )  and nvl(dr,0)=0";
                String name=qbs.executeQuery(sql2,
                        new ColumnProcessor())==null?null:qbs.executeQuery(sql2,
                                new ColumnProcessor()).toString();
                if(name!=null){
                    int rowcount=e.getBillCardPanel().getRowCount();
                    for(int i=0;i<rowcount;i++){
                        billCardPanel.setBodyValueAt(name, i, "skdw");
                        //billCardPanel.execBodyFormula(i, "skdw");
                    }
                    }
                
                
            } catch (BusinessException e1) {
                // TODO 自动生成的 catch 块
                e1.printStackTrace();
            }
            }else{
                int rowcount=e.getBillCardPanel().getRowCount();
                for(int i=0;i<rowcount;i++){
                    billCardPanel.setBodyValueAt(null, i, "skdw");
                    //billCardPanel.execBodyFormula(i, "skdw");
                }
            }
            
        }else if ("yzfnum".equals(key) ||"def3".equals(key) ){
            UFDouble fbhtnum = new UFDouble(billCardPanel.getHeadItem("fbhtnum")
                    .getValue());
            UFDouble yzfnum = new UFDouble(billCardPanel.getHeadItem("yzfnum")
                    .getValue());
            UFDouble def3 = new UFDouble(billCardPanel.getHeadItem("def3")
                    .getValue());
            UFDouble def7 = new UFDouble(billCardPanel.getHeadItem("def7")
                    .getValue());
            UFDouble fbbgnum = new UFDouble(billCardPanel.getHeadItem("dpuchngmny")
                    .getValue());
            billCardPanel.setHeadItem("ljfkbl", (yzfnum.add(def3).add(def7)).div(fbhtnum.add(fbbgnum)).multiply(new UFDouble(100)));
            billCardPanel.setHeadItem("ljfkbl", (yzfnum.add(def3).add(lcznum)).div(fbhtnum).multiply(new UFDouble(100)));

        }else if("vpaystatus".equals(key)){
            String sta= billCardPanel.getHeadItem("vpaystatus").getValue()==null?"":billCardPanel.getHeadItem("vpaystatus").getValue().toString();
            if(sta.equals("3")){
                billCardPanel.getHeadItem("vevaluationno").setNull(true);
            }else{
                billCardPanel.getHeadItem("vevaluationno").setNull(false);

            }
        }else if("pk_bbpro1".equals(key)){
            String pk_bbpro1= billCardPanel.getHeadItem("pk_bbpro1").getValue()==null?null:billCardPanel.getHeadItem("pk_bbpro1").getValue().toString();

            if(pk_bbpro1!=null){
            String sql="select pk_project from  bd_project where def27='"+pk_bbpro1+"' and nvl(dr,0)=0 ";
            try {
                String pk_project=qbs.executeQuery(sql,
                        new ColumnProcessor()) ==null?null:qbs.executeQuery(sql,
                                new ColumnProcessor()).toString();
                if(pk_project!=null){
                int rowcount=e.getBillCardPanel().getRowCount();
                for(int i=0;i<rowcount;i++){
                    billCardPanel.setBodyValueAt(pk_project, i, "pk_pro1");
                    //billCardPanel.execBodyFormula(i, "pk_pro1");
                }
                }
            } catch (BusinessException e1) {
                // TODO 自动生成的 catch 块
                e1.printStackTrace();
            }
            }
            billCardPanel.setHeadItem("pk_zht1", null);
            billCardPanel.setHeadItem("zhtcode", null);
            billCardPanel.setHeadItem("zhtnum", null);
            billCardPanel.setHeadItem("ysknum", null);
            billCardPanel.setHeadItem("zskbl", null);
            billCardPanel.setHeadItem("pk_fbht1", null);
            billCardPanel.setHeadItem("fbhtcode", null);
            billCardPanel.setHeadItem("fbhtnum", null);
            billCardPanel.setHeadItem("pk_supplier", null);
            billCardPanel.setHeadItem("yzfnum", 0);
            billCardPanel.setHeadItem("ljfkbl", null);
            
            int rowcount=e.getBillCardPanel().getRowCount();
            for(int i=0;i<rowcount;i++){
                billCardPanel.setBodyValueAt(null, i, "skdw");
                billCardPanel.setBodyValueAt(null, i, "pk_pro1");

            }
                

        }
        else if ("def6".equals(key)){//bgbd_funds_claim ,nclaimmoney , pk_fundsclaim,def6
            UIRefPane refPane =(UIRefPane)billCardPanel.getHeadItem(key).getComponent();
        String[] def6=refPane.getRefPKs();
            if(def6.length>0){
                StringBuffer wherepar=new StringBuffer();
                for(int i=0;i<def6.length;i++){
                    if(i==def6.length-1){
                        wherepar.append("'"+def6[i]+"'");
                    }else{
                        wherepar.append("'"+def6[i]+"',");
                    }
                }
                
                String sql="select sum(nclaimmoney) from  bgbd_funds_claim where pk_fundsclaim in ("+wherepar.toString()+") and nvl(dr,0)=0";
                try {
                    UFDouble bcsqnum = qbs.executeQuery(sql,
                            new ColumnProcessor()) == null ? UFDouble.ZERO_DBL
                            : new UFDouble(qbs.executeQuery(sql,
                                    new ColumnProcessor()).toString());
//                    billCardPanel.setHeadItem("def3", bcsqnum);

                    
                    
                    if(bcsqnum.compareTo(UFDouble.ZERO_DBL)>0){
                        
                        UFDouble fbhtnum = new UFDouble(billCardPanel.getHeadItem("fbhtnum")
                                .getValue());
                        UFDouble yzfnum = new UFDouble(billCardPanel.getHeadItem("yzfnum")
                                .getValue());
                        UFDouble def7 = new UFDouble(billCardPanel.getHeadItem("def7")
                                .getValue());
                        UFDouble fbbgnum = new UFDouble(billCardPanel.getHeadItem("dpuchngmny")
                                .getValue());
                        if(fbhtnum.compareTo(UFDouble.ZERO_DBL)>0){
                        billCardPanel.setHeadItem("ljfkbl", (yzfnum.add(bcsqnum).add(def7)).div(fbhtnum.add(fbbgnum)).multiply(new UFDouble(100)));
                        billCardPanel.setHeadItem("ljfkbl", (yzfnum.add(bcsqnum).add(lcznum)).div(fbhtnum).multiply(new UFDouble(100)));
                        }
                    }
                
                } catch (NumberFormatException e1) {
                    // TODO 自动生成的 catch 块
                    e1.printStackTrace();
                } catch (BusinessException e1) {
                    // TODO 自动生成的 catch 块
                    e1.printStackTrace();
                }
            }
            

            
        }
        
        
    }

}

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
机明nc编辑合并软件是一款用于数控编程的软件工具。它主要用于编辑、合并和优化数控程序代码,使得数控机床可以准确地执行相应的加工工序。 机明nc编辑合并软件具有以下功能和特点: 1. 代码编辑:该软件提供了强大的代码编辑功能,可以轻松地编辑数控程序代码。用户可以通过该软件对程序代码进行添加、删除、修改和重排等操作,以满足不同加工需求。 2. 代码合并:该软件还能够将多个数控程序代码合并成一个文件。通过将多个程序代码合并,可以减少程序加载和切换的时间,提高数控机床的加工效率。 3. 代码优化:机明nc编辑合并软件还提供了代码优化功能。通过对代码进行优化,可以减少加工时间、提高精度和加工表面质量。例如,通过合理的刀具路径规划和减少不必要的切削次数等手段,可以实现更高效的加工过程。 4. 兼容性:该软件支持各种常见的数控编程语言,如G代码和M代码等。用户可以根据自己的需求选择相应的编程语言,并进行相应的编辑和合并操作。 5. 易用性:机明nc编辑合并软件具有直观的用户界面和友好的操作流程,使用户能够快速上手使用。同时,它还提供了详细的帮助文档和技术支持,帮助用户解决使用过程中遇到的问题。 总之,机明nc编辑合并软件是一款功能强大且易于使用的数控编程工具。它可以帮助用户编辑、合并和优化数控程序代码,提高数控机床的加工效率和精度。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值