You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

285 lines
9.7 KiB
Plaintext

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>JS开发框架展示</title>
<script src="../WF/Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script src="../WF/Scripts/config.js" type="text/javascript"></script>
<script src="../WF/Comm/Gener.js" type="text/javascript"></script>
<script type="text/javascript">
window.onload =
function Test() {
// var emp = new Entity("BP.Port.Emp", "liyan");
//emp.Delete();
//return;
//创建一个实体,获取实体的属性.
var emp = new Entity("BP.Port.Emp", "liyan");
var name = emp.Name;
var deptNo = emp.FK_Dept; //部门编号
var deptName = emp.FK_DeptText; //部门名称.
//emp.Delete();
//emp.Update();
//emp.Insert();
alert("用户编号:" + emp.No + ",名称:" + emp.Name + "部门编号:" + emp.FK_Dept + ",部门名称:" + emp.FK_DeptText);
return;
//获得当前用户信息.
var currUser = new WebUser();
var no = currUser.No;
var name = currUser.Name;
var fk_dept = currUser.FK_Dept;
var deptName = currUser.FK_DeptName;
// entity
// 创建一个空实体.
var emp = new Entity("BP.Port.Emp");
emp.No = "ranzun";
emp.Name = "冉尊";
emp.FK_Dept = "1";
//emp.Email = "sdfsdfsd";
//emp.Tel
var insert = emp.Insert(); //增加.
alert("插入结果:" + insert);
//更新.
emp.Name = "张三风";
var update = emp.Update();
alert("更新结果:" + update);
//执行保存.
var save = emp.Save();
alert("保存结果:" + save);
//删除.
var del = emp.Delete();
alert("删除结果:" + del);
//创建一个实体,获取实体的属性.
var emp = new Entity("BP.Port.Emp", "liyan");
var name = emp.Name;
var deptNo = emp.FK_Dept; //部门编号
var deptName = emp.FK_DeptText; //部门名称.
alert("用户编号:" + emp.No + ",名称:" + emp.Name + "部门编号:" + emp.FK_Dept + ",部门名称:" + emp.FK_DeptText);
//执行实体的方法.
var msg = emp.DoMethodReturnString("ResetPass"); //重置密码:不带参数的方法.
alert(msg);
//执行实体的方法.
//var msg2 = emp.DoMethodReturnString("ChangePass", "@oldpass=123@pass1=456@pass2=456"); //重置密码:不带参数的方法.
var msg2 = emp.DoMethodReturnString("ChangePass", "123", "321", "321"); //重置密码:不带参数的方法.
alert(msg2);
//var en = new Entity("BP.Sys.GroupField");
//en.Lab = "xxx";
//en.FrmID = "xxxx";
//en.Insert();
//执行分组移动。
var ens = new Entities("BP.Sys.GroupFields");
ens.DoMethodReturnString("Move", "xxx,x,,xxxxx");
return;
}
function Test_FrmEntity() {
var frm = new Entity("ND101Dtl1");
frm.RefPK = 100;
frm.FYLX = 1;
frm.XiaoJi = 100.01;
frm.BeiZhu = 'sss';
var i = frm.Insert();
alert(JSON.stringify(frm));
}
function Test_EntityPara() {
//实体参数.
var ur = new Entity("BP.Sys.UserRegedit");
ur.MyPK = "admin_BP.WF.Template.SQLTemplates_SearchAttrs";
var i = ur.RetrieveFromDBSources();
if (i == 0)
ur.Insert();
ur.SetPara("SQLType", "all"); //给参数字段赋值.
ur.Update(); //执行更新.
//alert("aaa");
// 重新查询出来.
ur.MyPK = "admin_BP.WF.Template.SQLTemplates_SearchAttrs";
i = ur.RetrieveFromDBSources();
if (ur.GetPara("SQLType") != "all") {
alert('参数字段没有保存成功.');
return;
}
}
function Test_Adv() {
var emp = new Entity("BP.Port.Emp");
emp.No = "zhoupeng";
//判断是否
if (emp.IsExits() == false)
{
}
var i = emp.RetrieveFromDBSources(); //从数据库查询,查询不到不返回异常.
if (i == 0)
alert('实体不存在');
emp.No = 'zhoupeng';
emp.Retrieve(); //从数据库或者缓存查询,如果不存在就抛出异常.
emp.No = "zhoupeng";
var bool = emp.IsExit(); //根据主键判断该实体是否存在.
if (bool == false)
alert('实体不存在');
//删除部门编号为 0012的员工.
var delNum = emp.Delete("FK_Dept", "0012");
alert('共有:' + delNum + "数据被删除.");
}
function TestEns() {
var emps = new Entities("BP.Port.Emps", "FK_Dept", "1");
alert("BP.Port.Emps查询到:" + emps.length);
//获得性别为女的学生.
var students1 = new Entities("BP.Demo.Students", "XB", "0");
alert("Students XB=0 查询到:" + students1.length);
for (var i = 0; i < students1.length; i++) {
//通过json访问属性.
var jsonEn = students1[i];
var info = jsonEn.No + " - " + jsonEn.Name;
alert(info);
//把json转化为entity.
var student = new Entity("BP.Demo.Student", jsonEn);
var info = student.No + " - " + student.Name;
alert(info);
//可以对entities 进行操作.
//student.Update();
//student.Delete();
}
//获得性别为女的学生并且按年龄排序.
var students2 = new Entities("BP.Demo.Students", "XB", "0", "Age");
alert("Students XB=0 查询到:" + students2.length);
//获得性别为女的,并且班级为01 的学生.
var students3 = Entities("BP.Demo.Students", "XB", "0", "FK_BanJi", "01");
alert("Students XB=0 ,FK_BanJi=01 查询到:" + students3.length);
//获得性别为女的,并且班级为01 的学生, 按照年龄排序.
var students3 = Entities("BP.Demo.Students", "XB", "0", "FK_BanJi", "01", "Age");
alert("Students XB=0 ,FK_BanJi=01 查询到:" + students3.length);
}
function TestEns_Adv() {
var emps = new Entities("BP.Port.Emps");
var num = emps.RetrieveAll(); //调用查询全部返回num个数量.
alert("BP.Port.Emps查询到:" + emps.length);
//获得性别为女的学生.
var students = new Entities("BP.Demo.Students");
students.Retrieve("XB", 0);
alert("Students XB=0 查询到:" + students.length);
//查询性别为女的并按照年龄排序.
students.Retrieve("XB", 0, "Age");
alert("Students XB=0 查询到:" + students.length);
//查询性别为女的并班级=01的学生, 按照年龄排序.
students.Retrieve("XB", 0, "FK_BanJi", "01");
alert("Students XB=0 查询到:" + students.length);
//查询性别为女的并班级=01的学生, 按照年龄排序.
students.Retrieve("XB", 0, "FK_BanJi", "01", "Age");
alert("Students XB=0 查询到:" + students.length);
//查询全部.
students.RetrieveAll();
alert("Students 全部数据,查询到:" + students.length);
}
//执行方法.
function TestEns_Method() {
var ens = new Entities("BP.Demo.Students");
var data = ens.DoMethodReturnString("EnsMothed");
alert('ens执行方法的结果为:' + data);
var data = ens.DoMethodReturnString("EnsMothedParas", "abc", "123");
alert('ens执行方法的结果为:' + data);
}
function ExecHttpHandlerMonthod() {
//执行分组移动。
var ens = new Entities("BP.Sys.GroupFields");
ens.DoMethodReturnString("Move", "xxxxxx,xxxx,dddxxx,xxxxx");
//执行非静态的方法,有参数,仅仅传递指定的参数其他参数不处理.
var handler =new HttpHandler("BP.WF.HttpHandler.WF_AppClassic");
handler.AddUrlData(); //把url参数加入里面去.
handler.AddFormData(); //把form数据加入里面去.
handler.AddPara("TB_No", "zhoupeng");
handler.AddPara("TB_PW", "123");
//执行提交.
// var result = handler.Login_Submit();
//var resultJSON = handler.DoMethodReturnJSON("Login_Submit");
var result = handler.DoMethodReturnString("Login_Submit");
//处理结果.
if (result.indexOf('err@') == 0) {
alert(result); //登录失败.
return;
}
}
//直接访问数据库.
function DBAccessRun() {
var sql = "UPDATE Port_Emp SET Name='张三' WHERE No='zhangsan' AND 1=2 ";
var result = DBAccess.RunSQL(sql);
alert("一共[" + result + "] 条记录被更新");
sql = "SELECT No,Name FROM Demo_Student WHERE XB='0' AND 1=2 ";
var dt = DBAccess.RunSQLReturnTable(sql);
alert("一共[" + dt.lenght + "] 条记录被查询到");
var url = "http:xxxxx/sss";
var dt = DBAccess.RunUrlReturnJSON(url);
var dt = DBAccess.RunUrlReturnString(url);
// var dt = DBAccess.RunUrlCrossReturnJSON(sql);
// var dt = DBAccess.RunUrlCrossReturnString(sql);
}
</script>
</head>
<body>
</body>
</html>