2.保存到dthealth/web/csp下
3.进入demo 1 网页系统配置->菜单管理,将它放到注册建卡菜单下,菜单项名为培训测试
1..MAC文件是m语言,下面是test111.MAC
test111
aa()
w "abc"
q 0
2..cls是类文件,方法的写法与上面不一样
ClassMethod aa()
{
w "abc"
q 0
}
3.建立临时Global
DHC-APP>set ^TEMP=3//Global物理存储到数据库,terminal关了的话还会有,其他变量会消失
DHC-APP>S ^TEMP("A")=1//设置节点
DHC-APP>s ^TEMP("B")=2
4.$h日期函数
$ZDate 把$Horolog 格式的日期值按照指定格式显示
+号表示第一个非数字符号前的数字
$ZDateH 是$ZDate 的反函数
$ZTime 把$Horolog 格式的时间值按照指定格式显示。
$ZTimeH $ZTime 的反函数。
DHC-APP>w $h
63802,58589
DHC-APP>w $zd(63802)
09/07/2015
DHC-APP>w $zd(63802,3)
2015-09-07
DHC-APP>w +$h
63802
DHC-APP>w $zd(+$h,3)
2015-09-07
DHC-APP>w $zdh("2015-9-7",3)
63802
DHC-APP>w $zdh("2024-9-7",3)-$zdh("2015-9-7",3)
3288
DHC-APP>w $zt(58543)
16:15:43
DHC-APP>w $zt(58543,2)
16:15
DHC-APP>w $zt(58543,3)
04:15:43PM
DHC-APP>w $zt($p($h,",",2))
17:07:50
5.$i
对每次运行的global产生唯一一个值
DHC-APP>w $i(^TEMP)
4
DHC-APP>w $i(^TEMP)
5
DHC-APP>w $i(^TEMP)
6
6.$e截取字符串
DHC-APP>s a="abcdef"
DHC-APP>w $e(a,2)
b
DHC-APP>w $e(a,2,4)
bcd
7.for循环1加到100
ClassMethod testfor()
{
s m=0
f i=1:1:100 d
.s m=m+i
s sum=m
q sum
}
DHC-APP>w ##class(web.test111).testfor()
5050
ClassMethod testfor()
{
s m=0
s ctlocrowid=""
//q和d,f和s空两个空格
f s ctlocrowid=$o(^CTLOC(ctlocrowid)) q:ctlocrowid="" d
.s m=m+1
s sum=m
q sum
}
zw ^STUDENT
9.buildIndices()重建索引指定的类
上一篇 IIS配置问题1.建立Student表
表名:t_Student RowID:St_RowID
属性:StCode,StName,StSexDR,StDob
StSexDR为性别指向,指向一个CTSex性别表
Class User.Student Extends %Persistent [ SqlRowIdName = St_RowID, SqlTableName = t_Student, StorageStrategy = StudentStorage ]
{
Property StCode As %String [ Required, SqlColumnNumber = 2, SqlFieldName = st_code ];
Property StName As %String [ SqlColumnNumber = 3, SqlFieldName = st_name ];
Property StSexDR As CTSex [ SqlColumnNumber = 4, SqlFieldName = st_sex_dr ];
Property StDob As %Date [ SqlColumnNumber = 5, SqlFieldName = st_dob ];
Relationship ChildCourse As User.StuCourse [ Cardinality = children, Inverse = StudParRef ];
Index indexcode On StCode;
}
Class User.Course Extends %Persistent [ SqlRowIdName = C_RowID, SqlTableName = t_Course, StorageStrategy = CourseStorage ]
{
Property Code As %String [ SqlColumnNumber = 2, SqlFieldName = C_Code ];
/// 课程描述
Property Desc As %String [ SqlColumnNumber = 3, SqlFieldName = C_Desc ];
Property DateFrom As %Date [ SqlColumnNumber = 4, SqlFieldName = C_DateFrom ];
Property Active As %String(DISPLAYLIST = ",Yes,No", MAXLEN = 3, TRUNCATE = 1, VALUELIST = ",Y,N") [ SqlColumnNumber = 5, SqlFieldName = C_Active ];
Property UserDr As User.SSUser [ SqlColumnNumber = 6, SqlFieldName = C_User_Dr ];
}
3.学生选课表
Class User.StuCourse Extends %Persistent [ SqlRowIdName = SC_RowID, SqlTableName = t_StuCourse, StorageStrategy = stucourse ]
{
Index RowIDBasedIDKeyIndex On SCChildSub [ IdKey, PrimaryKey, Unique ];
Relationship StudParRef As User.Student [ Cardinality = parent, Inverse = ChildCourse, Required, SqlFieldName = SC_S_ParRef ];
Property SCChildSub As %Library.Numeric(SCALE = 0) [ InitialExpression = {$i(^STUDENT($p($s($d(initvalue):initvalue,1:%d(0)),$c(1)),"C",0))}, Required, SqlColumnNumber = 2, SqlFieldName = SC_ChildSub ];
Property SCCourseDr As User.Course [ SqlColumnNumber = 3, SqlFieldName = SC_Course_Dr ];
Property SCScore As %Float [ SqlColumnNumber = 4, SqlFieldName = SC_Score ];
}
4.查询某个学生的选课情况
Class web.StuCourse Extends %Persistent
{
ClassMethod FindCourseByStud(stuno)
{
Quit:stuno="" ""
;第二个空是返回值
set stuId=$o(^STUDENTi(0,"No",stuno,""))
set sub=0
For set sub=$o(^STUDENT(stuId,"C",sub)) quit:sub="" d
.set g=^STUDENT(stuId,"C",sub)
.set CourseId=$p(g,"^",1)
.set CourseDesc=$p(^COURSE(CourseId),"^",2)
.set Score=$p(g,"^",2)
.Write CourseDesc_" "_Score
}
}
上一篇
IIS配置问题