1.在客户端显示form
思路: 想要在客户端显示form必须先把form放在 menu item中,然后通过url地址的方式打开form
步骤:
1.建立form
2.建立Menu Item (特别注意:是display类型, 不是action类型 不是action类型 不是action类型 )
3.使用url地址:
https://hmtrain-02e9a583835dcb65aedevaos.axcloud.dynamics.com/?cmp=psgb&mi=menuItem(把menuItem换成自己的菜单项)
2.表、form 数据显示
在客户端显示form数据时,需要把“公司数据源设置为一致”,否则会出现数据不显示现象。
3.button绑定单击事件拿数据
[Control("Button")]
class FormButtonControl1
{
/// <summary>
///
/// </summary>
public void clicked()
{
MultiSelectionHelper helper;
DialogButton button;
helper = MultiSelectionHelper::construct();
helper.parmDatasource(FormDataUtil::getFormDataSource(ayUserTable));
ayUserTable selectedRecord = helper.getFirst();
button = Box::yesNo(strFmt("亲爱的:%1 ,您是否要支付停车费??",ayUserTable.Name),DialogButton::yes);
if(button == DialogButton::Yes)
{
info("ok okok");
}
//info(selectedRecord.Name);
// Box::info("main text",selectedRecord.Name,"help text");
}
}
4.方法总结(lookup)
需求,在从表中显示主表的信息时要求:
1.显示主表中的多个字段
2.符合条件的主表信息
以上需求均可用该方法
//
public void lookup()
{
Query query;
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange range;
SysTableLookup lookup;
yprParkTable yprParkTable;
query = new Query();
lookup = SysTableLookup::newParameters(tableNum(yprParkTable), this);
lookup.addLookupfield(fieldNum(yprParkTable, ParkId));
//引入数据源
queryBuildDataSource = query.addDataSource(tableNum(yprParkTable));
//添加条件
range = queryBuildDataSource.addRange(fieldNum(yprParkTable,Status));
range.value(SysQuery::value(yprStatus::Leisure));
lookup.parmQuery(query);
lookup.performFormLookup();
}
5.dev3练习题
5.1 创建一个基于RunBase类
public class yprBaseRunClassTest extends RunBase
{
//定义变量
DialogField dialogParkId;
DialogField dialogFromDate;
DialogField dialogToDate;
yprVetParkId yprVetParkId;
FromDate fromDate;
ToDate toDate;
#DEFINE.CurrentVersion(1)
#LOCALMACRO.CurrentList
yprVetParkId,
fromDate,
toDate
#ENDMACRO
public boolean getFromDialog()//获取用户填写信息“点击ok”后数据
{
boolean ret;
ret = super();
yprVetParkId = dialogParkId.value();
fromDate = dialogFromDate.value();
toDate = dialogToDate.value();
return ret;
}
//
public static void main(Args _args)
{
yprBaseRunClassTest demoRunBase;
demoRunBase = new yprBaseRunClassTest();
if (demoRunBase.prompt())
{
demoRunBase.run();
}
}
// //对话框描述
static client server ClassDescription description()
{
return "Test RunBase Dialog";
}
//
public Object dialog()//给对话框 获取数据
{
DialogRunBase dialog;
DialogGroup groupPeriod;
dialog = super();
dialogParkId =
dialog.addFieldValue(extendedTypeStr(yprVetParkId),
yprVetParkId);
groupPeriod = dialog.addGroup("Period");
dialogFromDate =
dialog.addFieldValue(extendedTypeStr(FromDate), fromDate,
"Period from");
dialogToDate =
dialog.addFieldValue(extendedTypeStr(ToDate), toDate,
"Period to");
return dialog;
}
//
public container pack()
{
return [#CurrentVersion,#CurrentList];
}
public boolean unpack(container _packedClass)
{
Version version = RunBase::getVersion(_packedClass);
switch (version)
{
case(#CurrentVersion) :
[version,#CurrentList] = _packedClass;
break;
default :
return false;
}
return true;
}
public void run()
{
yprParkTrans yprParkTrans;
select sum(ParkingPrice) from yprParkTrans
where yprParkTrans.ParkId == yprVetParkId
&& yprParkTrans.StartDate >= fromDate
&& yprParkTrans.EndDate <= toDate;
info(strFmt("Sum equals %1", yprParkTrans.ParkingPrice));
}
}
5.2 输入输出文件
5.2.1 输入文件
static void ImportSalesPrice(Args _args)
{
CommaIO commaIO;
container readCon;
str column1, column2, column3;
PriceDiscTable priceDiscTable;
#File
;
commaIO = new CommaIO('c:\\salesprice.csv', #io_read);
if (commaIO)
{
while (commaIO.status() == IO_Status::OK)
{
readCon = commaIO.read();
column1 = conPeek(readCon, 1);
column2 = conPeek(readCon, 2);
column3 = conPeek(readCon, 3);
priceDiscTable.ItemRelation = column1;
priceDiscTable.FromDate =
str2date(column2,123);
priceDiscTable.Amount = str2num(column3);
pricedisctable.insert();
}
}
}
5.2.2 输出文件为csv格式 参考文章
static void yprJobTest(Args _args)
{
TextBuffer textBuffer = new TextBuffer();
yprManagerTable yprManagerTable;
FileIoPermission perm;
counter Lines;
str fileName = "C:\\yprTestFile\\test.csv";
//#define.ExampleFile(@"c:\\AX2009.csv")
//#define.ExampleOpenMode("W")
;
try
{
perm = new FileIoPermission(fileName, "w");
perm.assert();
textBuffer.appendText("Manager Id,");//必须用逗号分开
textBuffer.appendText("Manager Name,");//必须用逗号分开
textBuffer.appendText("Manager phone");
textBuffer.appendText("\n");//下一行必须以回车分开
while select yprManagerTable
{
textBuffer.appendText(strfmt("%1,",yprManagerTable.ManagerId));
textBuffer.appendText(strfmt("%1,",yprManagerTable.Name));
textBuffer.appendText(strFmt("%1,",yprManagerTable.phone));
textBuffer.appendText("\n");
}
Lines = textBuffer.numLines();
try
{
if (textBuffer.toFile(fileName))
info( strfmt("存放在了%1下",fileName));
}
catch ( Exception::Error )
{
error ("Generated file error.");
}
CodeAccessPermission::revertAssert();
}
catch (Exception::Deadlock)
{
retry;
}
}
6.Display方法的正确用法
6.1需求
6.2实现
步骤:
1.在表中的methed中定义好display方法
2.如想在form中的自定义字段中显示,则可以在其属性表中设置
7.临时表赋值+query赋值
7.1需求
7.1实现
1.创建好临时表和对应的form
2.在form中重写init();
public void init()
{
ayEmployeeCopy.Age = 32;
ayEmployeeCopy.EmployeeId = "2001";
ayEmployeeCopy.EmployeeName = "John Mayer";
ayEmployeeCopy.EmployerId = "1001";
ayEmployeeCopy.Gender = ayGender::Male;
ayEmployeeCopy.insert();
ayEmployeeCopy.Age = 24;
ayEmployeeCopy.EmployeeId = "2002";
ayEmployeeCopy.EmployeeName = "Bruno Mars";
ayEmployeeCopy.EmployerId = "1002";
ayEmployeeCopy.Gender = ayGender::Male;
ayEmployeeCopy.insert();
info("111");
Query query;
QueryRun queryRun;
QueryBuildDataSource qbds,qbds1;
//QueryBuildRange qbr,qbr1;
ayEmployee Employee;
//ayEmployer employer;
info("222");
query = new Query();
qbds = query.addDataSource(TableNum (ayEmployer));
qbds1 = qbds.addDataSource(TableNum (ayEmployee));
info("333");
qbds1.addLink(fieldNum(ayEmployer, EmployerId), fieldNum(ayEmployee, EmployerId));
//qbds1.fetchMode(QueryFetchMode::One2Many);
qbds1.joinMode(JoinMode::InnerJoin);
//qbds1.relations(true);
info("444");
qbds1.addRange(FieldNum (ayEmployee,Gender)).value(SysQuery::value(ayGender::Male));
qbds.addRange(FieldNum (ayEmployer,Gender)).value(SysQuery::value(ayGender::Male));
queryRun = new QueryRun(query);
info("555");
while(queryRun.next())
{
info("6666");
employee = queryRun.get(tableNum(ayEmployee));
ayEmployeeCopy.EmployeeId = employee.EmployeeId;
ayEmployeeCopy.EmployerId = employee.EmployerId;
ayEmployeeCopy.EmployeeName = employee.EmployeeName;
ayEmployeeCopy.Age = employee.Age;
ayEmployeeCopy.Gender = employee.Gender;
ayEmployeeCopy.insert();
}
}
8.使用FormRun和MenuAction方式打开form
8.1需求
8.2FormRun实现
1.创建Button
2.绑定单击事件
public void clicked()
{
FormRun fr;
Args args;
args = new Args();
args.name(formStr(ayEmployerInfo));
//form为"将要跳转的form"
args.caller(this);
fr = classfactory.formRunClass(args);
fr.run();
fr.wait(true);
}
8.2MenuAction实现
1.创建Button
2.绑定单击事件
public void clicked()
{
Args args;
args = new Args();
//args.record(zcEmployee::find(zcEmployee.EmployeeId));
new MenuFunction(menuItemDisplayStr(ayEmployerMenuItem),MenuItemType::Display).run(args);
//ayEmployerMenuItem为将要跳转的MenuItem
}
9.表单中点击button更新选中的记录
9.1需求
9.2实现
1.创建一个Button
2.绑定单击事件
public void clicked()
{
Dialog dialog;
DialogGroup dialoggroup;
DialogField dialogField;
ayEmployee ayEmployeeloc;//定义一个ayEmployee变量
dialog = new Dialog("Update Age");
dialoggroup = dialog.addGroup("Age");
//addFieldValue方法的赋值参数格式
dialogField = dialog.addFieldValue(extendedTypeStr(ayVetAge),int2Str(ayEmployee.Age));
if(dialog.run())
{
str id = ayEmployee.EmployeeId;//ayEmployee代表当前选中的值
ttsbegin;
select forupdate ayEmployeeloc
where ayEmployeeloc.EmployeeId == id;
ayEmployeeloc.Age = dialogField.value();
ayEmployeeloc.update();
ttscommit;
}
ayEmployee_ds.research(true);//修改完后,需要ayEmployee_ds.research(true)更新数据(从表——form——客户端),否则会出现"修改完后,只留下一行数据"
//true表示,当更新完光标会停在原来点击的位置
}
10.1需求:
10.Form的关联
10.1需求:
10.2 实现
1.在表上把关联关系搭建好
2.在design中创建一个Menu Item Button
3.在该button中设置为关联的Menu Item
11.报表
有两种方式为报表提供数据源,一种是query,另一种是query+DP形式
11.1 纯query
步骤:
1.建SSRS Report
2.添加DataSets(引入Aot query)和Design
3.建立Out put类型的Menu Item,设置其Object Type,Object、report
4.将该Menu Item添加到Menu中
5.新建Controller类时期继承基类: SrsReportRunController(报表入口)
class ayReportTestController extends SrsReportRunController
{
// menuitem入口
public client static void main(Args _args)
{
ayReportTestController controller = new ayReportTestController();
controller.parmArgs(_args);
controller.parmReportName(ssrsReportStr(ayTestReport2, Report));
//设置report和Design
controller.parmShowDialog(true);
controller.parmDialogCaption('Test Employee RDP report');
controller.startOperation();//调用DP类,纯query此步骤可以省略
}
}
6.build项目,然后部署Report:右键>report>Deploy Report
11.2 query+DP
步骤:
1.建SSRS Report
2.添加DataSets和Design
3.建立Out put类型的Menu Item,设置其Object Type,Object、report
4.将该Menu Item添加到Menu中
5.新建Controller类时期继承基类:
6.新建DP类(该类像report中提供数据源)
[SRSReportQueryAttribute(queryStr(zcRDPEmployeeQuery)),SRSReportParameterAttribute(classStr(zcRDPEmployeeContract))]
public class zcRDPEmployeeRDP extends SRSReportDataProviderBase
{
zcRDPEmployeeTmp employeeTmp;
zcRDPEmployeeContract contract;
BarcodeCode128 barcode;
[SRSReportDataSetAttribute(tablestr(zcRDPEmployeeTmp))]
public zcRDPEmployeeTmp getEmployeeTmp()
{
select employeeTmp;
return employeeTmp;
}
/// <summary>
/// 报表执行入口
/// </summary>
public void processReport()
{
Query query = this.parmQuery();
this.initEmployeeTable(query);
super();
}
private void initEmployeeTable(Query _query)
{
contract = this.parmDataContract() as zcRDPEmployeeContract;
//此处写临时表的insert逻辑
QueryBuildDataSource qbds = _query.addDataSource(TableNum (zcEmployer));
QueryBuildDataSource qbds1 = qbds.addDataSource(TableNum (zcEmployee));
qbds1.addLink(fieldNum(zcEmployer, EmployerId), fieldNum(zcEmployee, EmployerId));
qbds1.fetchMode(QueryFetchMode::One2Many);
qbds1.joinMode(JoinMode::InnerJoin);
qbds1.addRange(fieldNum(zcEmployee, EmployeeId)).value(SysQuery::value(contract.parmAccountNum()));
QueryRun qr = new QueryRun(_query);
while (qr.next())
{
zcEmployee employeeLoc = qr.get(tablenum(zcEmployee));
employeeTmp.EmployeeId = employeeLoc.EmployeeId;
employeeTmp.EmployeeName = employeeLoc.EmployeeName;
employeeTmp.EmployerId = employeeLoc.EmployerId;
/*
Query query = new Query();
QueryBuildDataSource qbds = query.addDataSource(TableNum (zcEmployer));
qbds.addRange(fieldNum(zcEmployer, EmployerId)).value(SysQuery::value(employeeLoc.EmployerId));
QueryRun q = new QueryRun(query);
while (q.next())
{
zcEmployer employerLoc = q.get(tableNum(zcEmployer));
employeeTmp.EmployerName = employerLoc.EmployerName;
}
*/
zcEmployer employerLoc = qr.get(tableNum(zcEmployer));
employeeTmp.EmployerName = employerLoc.EmployerName;
//打印条形码
barcode = Barcode::construct(BarcodeType::Code128);
barcode.string(true, employeeTmp.EmployerId);
employeeTmp.EmployerId = barcode.barcodeStr();
employeeTmp.insert();
}
}
}
7.新建Contract类(该类在DP查询时添加限定条件)
[DataContractAttribute]
public class zcRDPEmployeeContract
{
zcEmployeeId employeeId;
[DataMemberAttribute('zcEmployeeId')]
public zcEmployeeId parmAccountNum(zcEmployeeId _employeeId = employeeId)
{
employeeId = _employeeId;
return employeeId;
}
}
8.新建Build类(如果要给限定的字段做其他功能:eg:lookup等,可以使用该类)
切记如果添加Build方法,需要为Contract类上添加引用
12.设置虚拟机多人使用
run gpedit.msc > Computer configuration > Administrative Templates > Windows Components > Remote Desktop Services > Remote Desktop session host > Connections
Limit number of connections : Disable
Restrict Remote Desktop Services users to a single
Remote Desktop Services session : Disable
run gpupdate -force