动态设置单身栏位名

首先看图:三个月的日期分别显示到三个页签上,当前月份10月

代码:

##定义全局数组变量,长度31,因一个月最多31天
DEFINE g_month_day   ARRAY[31] OF VARCHAR(1000)
DEFINE g_month_day2  ARRAY[31] OF VARCHAR(1000)
DEFINE g_month_day3  ARRAY[31] OF VARCHAR(1000)

###动态设置单身列名2011/12/08-------------------------------------------------------
FUNCTION q131_set(p_year,p_month)
DEFINE p_year      varchar(4),
       p_month     varchar(2),
       l_azn01     varchar(10),
       l_days      DEC(5,0)
       
##计算当月天数   
SELECT max(azn01)-min(azn01)+1 INTO l_days FROM azn_file WHERE azn02=p_year and azn04=p_month

##FOREACH 当月的每一天赋值给数组     
DECLARE q131_cusr01  CURSOR FOR  
    select month(azn01)||'月'||day(azn01)||'日' from azn_file where azn02=p_year and azn04=p_month
LET g_i=1
FOREACH q131_cusr01 INTO l_azn01
      IF SQLCA.sqlcode THEN
         CALL cl_err('Foreach:',SQLCA.sqlcode,1)
         EXIT FOREACH
      END IF
      LET g_month_day[g_i]=l_azn01
    LET g_i = g_i + 1
END FOREACH

##判断大小月份隐藏不需要的栏位
IF l_days=28 THEN 
	 CALL cl_set_comp_visible("d31,d30,d29",FALSE)
ELSE IF l_days=29 THEN
	 CALL cl_set_comp_visible("d31,d30",FALSE)
ELSE IF l_days=30 THEN
	 CALL cl_set_comp_visible("d31",FALSE)
  END IF 
 END IF 
END IF 
##设定字段的显示名称	
  CALL cl_set_comp_att_text("d01",g_month_day[1])
  CALL cl_set_comp_att_text("d02",g_month_day[2])
  CALL cl_set_comp_att_text("d03",g_month_day[3])
  CALL cl_set_comp_att_text("d04",g_month_day[4])
  CALL cl_set_comp_att_text("d05",g_month_day[5])
  CALL cl_set_comp_att_text("d06",g_month_day[6])
  CALL cl_set_comp_att_text("d07",g_month_day[7])
  CALL cl_set_comp_att_text("d08",g_month_day[8])
  CALL cl_set_comp_att_text("d09",g_month_day[9])
  CALL cl_set_comp_att_text("d10",g_month_day[10])
  CALL cl_set_comp_att_text("d11",g_month_day[11])
  CALL cl_set_comp_att_text("d12",g_month_day[12])
  CALL cl_set_comp_att_text("d13",g_month_day[13])
  CALL cl_set_comp_att_text("d14",g_month_day[14])
  CALL cl_set_comp_att_text("d15",g_month_day[15])
  CALL cl_set_comp_att_text("d16",g_month_day[16])
  CALL cl_set_comp_att_text("d17",g_month_day[17])
  CALL cl_set_comp_att_text("d18",g_month_day[18])
  CALL cl_set_comp_att_text("d19",g_month_day[19])
  CALL cl_set_comp_att_text("d20",g_month_day[20])
  CALL cl_set_comp_att_text("d21",g_month_day[21])
  CALL cl_set_comp_att_text("d22",g_month_day[22])
  CALL cl_set_comp_att_text("d23",g_month_day[23])
  CALL cl_set_comp_att_text("d24",g_month_day[24])
  CALL cl_set_comp_att_text("d25",g_month_day[25])
  CALL cl_set_comp_att_text("d26",g_month_day[26])
  CALL cl_set_comp_att_text("d27",g_month_day[27])
  CALL cl_set_comp_att_text("d28",g_month_day[28])
  CALL cl_set_comp_att_text("d29",g_month_day[29])
  CALL cl_set_comp_att_text("d30",g_month_day[30])  
  CALL cl_set_comp_att_text("d31",g_month_day[31])
  
##设定字段颜色   
CALL cl_set_comp_font_color("d01,d02,d03,d04,d05,d06,d07,d08,d09,d10,d11,d12,d13,d14,d15,d16,d17,d18,d19,d20,d21,d22,d23,d24,d25,d26,d27,d28,d29,d30,d31", "RED") 
CALL cl_set_comp_font_color("sum", "GREEN")   
   
END FUNCTION                      
---------------------------------------------------

#######前一月2011/12/09 by fmx-
FUNCTION q131_set2(p_year,p_month)    
DEFINE p_year      varchar(4),
       p_month     varchar(2),
       l_azn01     varchar(10),
       l_days      DEC(5,0)

SELECT year(add_months(last_day(g_today),-1)),month(add_months(last_day(g_today),-1)) 
INTO p_year,p_month
FROM DUAL
    
SELECT max(azn01)-min(azn01)+1 INTO l_days FROM azn_file WHERE azn02=p_year and azn04=p_month
       
DECLARE q131_cusr0b  CURSOR FOR  
    select month(azn01)||'月'||day(azn01)||'日' from azn_file where azn02=p_year and azn04=p_month
LET g_i=1
FOREACH q131_cusr0b INTO l_azn01
      IF SQLCA.sqlcode THEN
         CALL cl_err('Foreach:',SQLCA.sqlcode,1)
         EXIT FOREACH
      END IF
      LET g_month_day2[g_i]=l_azn01
    LET g_i = g_i + 1
END FOREACH

IF l_days=28 THEN 
	 CALL cl_set_comp_visible("d31b,d30b,d29b",FALSE)
ELSE IF l_days=29 THEN
	 CALL cl_set_comp_visible("d31b,d30b",FALSE)
ELSE IF l_days=30 THEN
	 CALL cl_set_comp_visible("d31b",FALSE)
  END IF 
 END IF 
END IF 	
  CALL cl_set_comp_att_text("d01b",g_month_day2[1])
  CALL cl_set_comp_att_text("d02b",g_month_day2[2])
  CALL cl_set_comp_att_text("d03b",g_month_day2[3])
  CALL cl_set_comp_att_text("d04b",g_month_day2[4])
  CALL cl_set_comp_att_text("d05b",g_month_day2[5])
  CALL cl_set_comp_att_text("d06b",g_month_day2[6])
  CALL cl_set_comp_att_text("d07b",g_month_day2[7])
  CALL cl_set_comp_att_text("d08b",g_month_day2[8])
  CALL cl_set_comp_att_text("d09b",g_month_day2[9])
  CALL cl_set_comp_att_text("d10b",g_month_day2[10])
  CALL cl_set_comp_att_text("d11b",g_month_day2[11])
  CALL cl_set_comp_att_text("d12b",g_month_day2[12])
  CALL cl_set_comp_att_text("d13b",g_month_day2[13])
  CALL cl_set_comp_att_text("d14b",g_month_day2[14])
  CALL cl_set_comp_att_text("d15b",g_month_day2[15])
  CALL cl_set_comp_att_text("d16b",g_month_day2[16])
  CALL cl_set_comp_att_text("d17b",g_month_day2[17])
  CALL cl_set_comp_att_text("d18b",g_month_day2[18])
  CALL cl_set_comp_att_text("d19b",g_month_day2[19])
  CALL cl_set_comp_att_text("d20b",g_month_day2[20])
  CALL cl_set_comp_att_text("d21b",g_month_day2[21])
  CALL cl_set_comp_att_text("d22b",g_month_day2[22])
  CALL cl_set_comp_att_text("d23b",g_month_day2[23])
  CALL cl_set_comp_att_text("d24b",g_month_day2[24])
  CALL cl_set_comp_att_text("d25b",g_month_day2[25])
  CALL cl_set_comp_att_text("d26b",g_month_day2[26])
  CALL cl_set_comp_att_text("d27b",g_month_day2[27])
  CALL cl_set_comp_att_text("d28b",g_month_day2[28])
  CALL cl_set_comp_att_text("d29b",g_month_day2[29])
  CALL cl_set_comp_att_text("d30b",g_month_day2[30])  
  CALL cl_set_comp_att_text("d31b",g_month_day2[31])
   
CALL cl_set_comp_font_color("d01b,d02b,d03b,d04b,d05b,d06b,d07b,d08b,d09b,d10b,d11b,d12b,d13b,d14b,d15b,d16b,d17b,d18b,d19b,d20b,d21b,d22b,d23b,d24b,d25b,d26b,d27b,d28b,d29b,d30b,d31b", "RED") 
CALL cl_set_comp_font_color("sumb", "GREEN")   
   
END FUNCTION 


#######后一月2011/12/09 by fmx-
FUNCTION q131_set3(p_year,p_month)    
DEFINE p_year      varchar(4),
       p_month     varchar(2),
       l_azn01     varchar(10),
       l_days      DEC(5,0)

##后一月的天数
SELECT year(add_months(last_day(g_today),+1)),month(add_months(last_day(g_today),+1)) 
INTO p_year,p_month
FROM DUAL 
    
SELECT max(azn01)-min(azn01)+1 INTO l_days FROM azn_file WHERE azn02=p_year and azn04=p_month
       
DECLARE q131_cusr0c  CURSOR FOR  
    select month(azn01)||'月'||day(azn01)||'日' from azn_file where azn02=p_year and azn04=p_month
LET g_i=1
FOREACH q131_cusr0c INTO l_azn01
      IF SQLCA.sqlcode THEN
         CALL cl_err('Foreach:',SQLCA.sqlcode,1)
         EXIT FOREACH
      END IF
      LET g_month_day3[g_i]=l_azn01
    LET g_i = g_i + 1
END FOREACH

IF l_days=28 THEN 
	 CALL cl_set_comp_visible("d31c,d30c,d29c",FALSE)
ELSE IF l_days=29 THEN
	 CALL cl_set_comp_visible("d31c,d30c",FALSE)
ELSE IF l_days=30 THEN
	 CALL cl_set_comp_visible("d31c",FALSE)
  END IF 
 END IF 
END IF 	
  CALL cl_set_comp_att_text("d01c",g_month_day3[1])
  CALL cl_set_comp_att_text("d02c",g_month_day3[2])
  CALL cl_set_comp_att_text("d03c",g_month_day3[3])
  CALL cl_set_comp_att_text("d04c",g_month_day3[4])
  CALL cl_set_comp_att_text("d05c",g_month_day3[5])
  CALL cl_set_comp_att_text("d06c",g_month_day3[6])
  CALL cl_set_comp_att_text("d07c",g_month_day3[7])
  CALL cl_set_comp_att_text("d08c",g_month_day3[8])
  CALL cl_set_comp_att_text("d09c",g_month_day3[9])
  CALL cl_set_comp_att_text("d10c",g_month_day3[10])
  CALL cl_set_comp_att_text("d11c",g_month_day3[11])
  CALL cl_set_comp_att_text("d12c",g_month_day3[12])
  CALL cl_set_comp_att_text("d13c",g_month_day3[13])
  CALL cl_set_comp_att_text("d14c",g_month_day3[14])
  CALL cl_set_comp_att_text("d15c",g_month_day3[15])
  CALL cl_set_comp_att_text("d16c",g_month_day3[16])
  CALL cl_set_comp_att_text("d17c",g_month_day3[17])
  CALL cl_set_comp_att_text("d18c",g_month_day3[18])
  CALL cl_set_comp_att_text("d19c",g_month_day3[19])
  CALL cl_set_comp_att_text("d20c",g_month_day3[20])
  CALL cl_set_comp_att_text("d21c",g_month_day3[21])
  CALL cl_set_comp_att_text("d22c",g_month_day3[22])
  CALL cl_set_comp_att_text("d23c",g_month_day3[23])
  CALL cl_set_comp_att_text("d24c",g_month_day3[24])
  CALL cl_set_comp_att_text("d25c",g_month_day3[25])
  CALL cl_set_comp_att_text("d26c",g_month_day3[26])
  CALL cl_set_comp_att_text("d27c",g_month_day3[27])
  CALL cl_set_comp_att_text("d28c",g_month_day3[28])
  CALL cl_set_comp_att_text("d29c",g_month_day3[29])
  CALL cl_set_comp_att_text("d30c",g_month_day3[30])  
  CALL cl_set_comp_att_text("d31c",g_month_day3[31])
   
CALL cl_set_comp_font_color("d01c,d02c,d03c,d04c,d05c,d06c,d07c,d08c,d09c,d10c,d11c,d12c,d13c,d14c,d15c,d16c,d17c,d18c,d19c,d20c,d21c,d22c,d23c,d24c,d25c,d26c,d27c,d28c,d29c,d30c,d31c", "RED") 
CALL cl_set_comp_font_color("sumc", "GREEN")   
   
END FUNCTION 


 MAIN函数中调用即可:

####2011/12/08 by fmx
    LET g_year=YEAR(g_today)
    LET g_month=month(g_today)
    CALL q131_set(g_year,g_month)    ##当月
    CALL q131_set2(g_year,g_month)   ##前一月
    CALL q131_set3(g_year,g_month)   ##后一月


 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值