关于H3BPM数据库如何实现排序取数据的问题-创新互联

问题:

我们提供的服务有:成都网站建设、网站建设、微信公众号开发、网站优化、网站认证、新区ssl等。为成百上千家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的新区网站制作公司

在打印模板中获取子表内容,可从数据库中取数据,而当前项目数据库里面数据按年度录入,但是只需要显示近3年的数据,插件如何实现排序取数据?

解决方法:

1、先直接写一个SQL语句,把近3年排序后的数据读取出来

2、在调用子表接口加载数据

3、示例:

var monthly = DateTime.Now.Month;

            var selectsql = string.Format(@"SELECT

                                              t1.Yearly,

                                              t1.Monthly,

                                              t1.BudgetUnitName,

                                              t1.BudgetUnitCode,

                                              t1.BudgetItemName,

                                              t1.BudgetItemCode,

                                              t1.Budget

                                              FROM XL_YS_BudgetPay t1

                                              WHERE t1.Yearly = {0}

                                              --AND Monthly > {1}

                                              AND t1.BudgetUnitCode = '{2}'

                                              AND BudgetItemCode = '{3}'

                                              ORDER BY Monthly", yearly, monthly, budgetunitcode, budgetitemcode);

var dt = OThinker.H3.WorkSheet.AppUtility.Engine.Query.QueryTable(selectsql);

var list = new List();

var monthlist = new List { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "December" };

if (dt.Rows.Count > 0)

{

//DeptCostBudgetInfo 为子表名称

              BizObjectSchema childSchema = this.ActionContext.Schema.GetProperty("DeptCostBudgetInfo").ChildSchema;

               var bizObject = new BizObject(this.ActionContext.Engine, childSchema, this.ActionContext.User.UserID);

               bizObject["DataType"] = "原始";

               bizObject["BudgetItemName"] = dt.Rows[0]["BudgetItemName"].ToString();

               bizObject["BudgetItemCode"] = dt.Rows[0]["BudgetItemCode"].ToString();

               var bizObject2 = new BizObject(this.ActionContext.Engine, childSchema, this.ActionContext.User.UserID);

               bizObject2["DataType"] = "修改";

               bizObject2["BudgetItemName"] = dt.Rows[0]["BudgetItemName"].ToString();

               bizObject2["BudgetItemCode"] = dt.Rows[0]["BudgetItemCode"].ToString();

               for (int i = 0; i < monthlist.Count; i++)

               {

                 bizObject[monthlist] = dt.Rows["Budget"].ToString();

                 bizObject2[monthlist] = dt.Rows["Budget"].ToString();

                }

                list.Add(bizObject);

                list.Add(bizObject2);

               }

               if (bos != null)

               {

                   if (bos.Length > 1)

                   {

                       list.AddRange(bos);

                   }

               }

               this.ActionContext.InstanceData["DeptCostBudgetInfo"].Value = list.ToArray();

               ActionContext.InstanceData.Submit();

另外有需要云服务器可以了解下创新互联cdcxhl.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


分享题目:关于H3BPM数据库如何实现排序取数据的问题-创新互联
网址分享:http://ybzwz.com/article/dicjdd.html