BOS金蝶云星空开发简单账表

一.BOS创建简单账表:

1.左键单击左上角文件->新建。
BOS金蝶云星空开发简单账表_第1张图片
2.选择简单账表,输入名称,编号,点击确定,创建简单账表。
BOS金蝶云星空开发简单账表_第2张图片
3.选择过滤条件框,输入名称,编号,点击确定。
BOS金蝶云星空开发简单账表_第3张图片

二.Visual Studio编辑服务插件,案例如下:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

using Kingdee.BOS;
using Kingdee.BOS.App.Data;
using Kingdee.BOS.Contracts.Report;
using Kingdee.BOS.Core.List;
using Kingdee.BOS.Core.Report;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;

namespace SY.BH.K3Cloud2k
{
[Kingdee.BOS.Util.HotUpdate]
[Description(“报表名称”)]
public class BasePaperWarehousingReport : SysReportBaseService
{

    public override void Initialize()
    {
        base.Initialize();
        //简单账表类型:普通,树形,分页
        this.ReportProperty.ReportType = ReportType.REPORTTYPE_NORMAL;

        //报表名称
        this.ReportProperty.ReportName = new LocaleValue("报表名称", base.Context.UserLocale.LCID);
        this.IsCreateTempTableByPlugin = true;
        this.ReportProperty.IsUIDesignerColumns = false;
        this.ReportProperty.IsGroupSummary = false;
        this.ReportProperty.SimpleAllCols = false;
        this.ReportProperty.IsDefaultOnlyDspSumAndDetailData = true;

        //设置精度控制
        List list = new List();
        this.ReportProperty.DecimalControlFieldList = list;
    }

    public override void BuilderReportSqlAndTempTable(IRptParams filter, string tableName)
    {
        base.BuilderReportSqlAndTempTable(filter, tableName);

        //拼接过滤条件:filter
        DynamicObject dyFilter = filter.FilterParameter.CustomFilter;
        //获取过滤器所有属性
        var keySet = dyFilter.DynamicObjectType.Properties;
        string FDate = dyFilter["FDate"] == null ? "" : ((DateTime)dyFilter["FDate"]).ToString("yyyy-MM-dd");  //该月最近1年

		string FAType = dyFilter["FAType"] == null ? "" : (dyFilter["FAType"]).ToString();  //A类
		string FBType = dyFilter["FBType"] == null ? "" : (dyFilter["FBType"]).ToString();  //B类
		string FNumber = dyFilter["FNumber"] == null ? "" : (dyFilter["FNumber"]).ToString();  //物料编码
		string FName = dyFilter["FName"] == null ? "" : (dyFilter["FName"]).ToString();  //物料名称
		string FSupplierNumber = dyFilter["FSupplierNumber"] == null ? "" : (dyFilter["FSupplierNumber"]).ToString();  //供应商物料编码
		string FSupplier = dyFilter["FSupplier"] == null ? "" : ((DynamicObject)dyFilter["FSupplier"])["Name"].ToString();  //供应商
		string FSpecification = dyFilter["FSpecification"] == null ? "" : (dyFilter["FSpecification"]).ToString();  //型号

		
		StringBuilder fiterSql = new StringBuilder();
		//循环过滤框,拼接sql过滤条件
        foreach (var key in keySet)
        {
            //if (dyFilter[key] != null && dyFilter[key].ToString().IsNullOrEmptyOrWhiteSpace() == false) continue;

            if (dyFilter[key] != null && !string.IsNullOrEmpty(dyFilter[key].ToString()))
            {
                //A类
                if (key.Name.Equals("FAType", StringComparison.OrdinalIgnoreCase) && !FAType.Equals(""))
                {
                    fiterSql.Append($" and c.F_ADD_TEXT11 like '%{FAType}'%");
                }
				//B类
				if (key.Name.Equals("FBType", StringComparison.OrdinalIgnoreCase) && !FBType.Equals(""))
				{
					fiterSql.Append($" and c.F_ADD_TEXT12 like '%{FBType}%'");
				}
				//物料编码
				if (key.Name.Equals("FNumber", StringComparison.OrdinalIgnoreCase) && !FNumber.Equals(""))
				{
					fiterSql.Append($" and c.FNUMBER like '%{FNumber}%'");
				}
				//物料名称
				if (key.Name.Equals("FName", StringComparison.OrdinalIgnoreCase) && !FName.Equals(""))
				{
					fiterSql.Append($" and c1.FNAME like '%{FName}%'");
				}
				//供应商物料编码
				if (key.Name.Equals("FSupplierNumber", StringComparison.OrdinalIgnoreCase) && !FSupplierNumber.Equals(""))
				{
					fiterSql.Append($" and c.F_add_Text3 like '%{FSupplierNumber}%'");
				}
				//供应商
				if (key.Name.Equals("FSupplier", StringComparison.OrdinalIgnoreCase) && !FSupplier.Equals(""))
				{
					fiterSql.Append($" and h.FNAME = '{FSupplier}'");
				}
				//型号
				if (key.Name.Equals("FSpecification", StringComparison.OrdinalIgnoreCase) && !FSpecification.Equals(""))
				{
					fiterSql.Append($" and c1.FSpecification like '%{FSpecification}%'");
				}
			}
		}

        // 默认排序字段:需要从filter中取用户设置的排序字段
        // string seqFld = string.Format(base.KSQL_SEQ, "FSOBillNo ");
        string filterString = filter.FilterParameter.FilterString == "" ? "" : "and" + filter.FilterParameter.FilterString;

		//自行编辑你需要的sql内容,必须包含一个FIDEntityID列作为一值
		string resultSql = $"select FIDENTITYID,* into {tableName} from Table";
        DBUtils.ExecuteDynamicObject(this.Context, resultSql.ToString());
    }

	//编辑报表单据头
    public override ReportHeader GetReportHeaders(IRptParams filter)
    {
        //return base.GetReportHeaders(filter);
        ReportHeader header = new ReportHeader();


        var FFIDEntryID = header.AddChild("字段1", new LocaleValue("字段名1"));

        var FNUMBER = header.AddChild("字段2", new LocaleValue("字段名2"));

        var FSupplierNumber = header.AddChild("字段3", new LocaleValue("字段名3"));

        var FSupplier = header.AddChild("字段4", new LocaleValue("字段名4"));


		//复合单据头
		header.AddChild("SH01", new LocaleValue("01月&地区1"));
		header.AddChild("DG01", new LocaleValue("01月&地区2"));
		header.AddChild("HG01", new LocaleValue("01月&地区3"));
		header.AddChild("HJ01", new LocaleValue("01月&1月合计"));

		return header;
    }

	//数据列汇总
	//public override List GetSummaryColumnInfo(IRptParams filter)
	//{
	//    var result = base.GetSummaryColumnInfo(filter);
	//    result.Add(new SummaryField("列名", Kingdee.BOS.Core.Enums.BOSEnums.Enu_SummaryType.SUM));
	//    result.Add(new SummaryField("列名", Kingdee.BOS.Core.Enums.BOSEnums.Enu_SummaryType.SUM));
	//    return result;
	//}

	//报表头赋值
	public override ReportTitles GetReportTitles(IRptParams filter)
    {
        var result = new ReportTitles();
        DynamicObject dyFilter = filter.FilterParameter.CustomFilter;
		result.AddTitle("报表头字段名", dyFilter["过滤框字段名"].ToString());
        return result;
    }

}

}

三.BOS配置服务插件和条件过滤框:

1.在简单账表界面的“过滤窗口业务对象(报表)”中填写上面创建的过滤框的唯一标识。
BOS金蝶云星空开发简单账表_第4张图片

2.点击服务插件,选择注册自己编辑的报表插件。
BOS金蝶云星空开发简单账表_第5张图片
3.操作完成,保存即可。

你可能感兴趣的:(金蝶,c#,开发语言)