自定义方法实现单据数据过滤

  

本文发布的目的是想跟大家分享下在k3cloud中怎么通过方法查询自己想要的数据集合,废话少说,直接看方法:


    第一种方法:  通过调用系统方法,也就是你把条件给它,剩下的事不用自己搞定,系统帮你搞了! 

   <summary>

         获取被选择的单据行的数据;

         </summary>

         <param name="formid">单据标识</param>

         <param name="fid">主键</param>

       

        public DynamicObjectCollection GetQuerDate(string formid,string fid)

        {

            QueryBuilderParemeter par1 = new QueryBuilderParemeter();

            par1.FormId=formid;

            par1.FilterClauseWihtKey = " fid=" + fid ;

           par1.SelectItems = SelectorItemInfo.CreateItems("FSERIALID", "FMATERIALID", "FENTRYID");

            QueryBuilderParemeter par2 = par1;

            return QueryServiceHelper.GetDynamicObjectCollection(this.Context, par2);


        }

第二种方法:方法跟第一种类似

        private DynamicObject[] Getquerydata(string formid, string fid)

        {


            FormMetadata metdata = (FormMetadata)MetaDataServiceHelper.Load(Context, formid, true);

            QueryBuilderParemeter par2 = new QueryBuilderParemeter();

            par2.FormId = metdata.BusinessInfo.GetForm().Id;

            par2.FilterClauseWihtKey = " fid=" + fid;

            QueryBuilderParemeter par = par2;

            return BusinessDataServiceHelper.Load(Context, metdata.BusinessInfo.GetDynamicObjectType(), par);

        }

第三种方法:这种需要自己拼接条件得到自己想要的结果集合;

 public DynamicObjectCollection Getdata(string fmaterid,string fserialid)

        {

            StringBuilder str1 = new StringBuilder("/*dialect*/");

            

             str1.AppendFormat(@"select top 1 FACCTGPRICE from ( select  top 1 FBILLID,b.FBILLDATE,b.FBILLNO,b.FBILLFROMID,b.FACCTGPRICE,b.FQTY,b.FORDERNUMBER,STOCKDIM.FMATERIALID,lot.FNUMBER,tce.FNUMBER FCH,

  row_number()over(partition by FMASTERID,tce.FNUMBER order by fbilldate desc) px,b.FBILLENTRYID,FMASTERID

from (select FACCTGID,FBILLDATE,FBILLNO,FBILLFROMID,FACCTGPRICE,FORDERNUMBER,FQTY,FDimeEntryId,FBILLENTRYID,FBILLID from V_HS_OutInStockSeq where FACCTGID>1) b 

inner join (select FENTRYID,FMATERIALID,FLOT from T_HS_InivStockDimension where FENTRYID>1) STOCKDIM on b.FDimeEntryId = STOCKDIM.FENTRYID

left join (select FLOTID,isnull(FNUMBER,'') FNUMBER from T_BD_LOTMASTER where FLOTID>1) LOT on STOCKDIM.FLOT = LOT.FLOTID

left join (select FBILLENTRYID,FLOTID,FBILLFORMID,fbillno from T_BD_LOTMASTERBILLTRACE where FBILLENTRYID>1) tre on tre.FLOTID=STOCKDIM.FLOT and b.FBILLENTRYID=tre.FBILLENTRYID and b.FBILLFROMID=tre.FBILLFORMID and tre.fbillno=b.FBILLNO

left join (  select FBILLFORMID,FBILLENTRYID,fbillno,a.FSERIALID,ter.FNUMBER from T_BD_SERIALBILLTRACE a

 left join T_BD_SERIALBILLTRACE_e b on a.FBILLTRACEID=b.FBILLTRACEID

 left join (select FSERIALID,isnull(FNUMBER,'') FNUMBER from T_BD_SERIALMASTER where FSERIALID>1)  ter on b.FSERIALID=ter.FSERIALID ) tce on tre.FBILLFORMID=tre.FBILLFORMID and tce.FBILLENTRYID=tre.FBILLENTRYID  and tre.fbillno=tce.FBILLNO 

left join T_BD_MATERIAL t on t.FMATERIALID=STOCKDIM.FMATERIALID

where  b.FACCTGPRICE<>0 and t.FMASTERID={0} and  tce.FSERIALID={1}) a where a.px=1", fmaterid, fserialid);

            return DBUtils.ExecuteDynamicObject(this.Context, str1.ToString());



        }

相关文章
相关标签/搜索