查询
string sql =string.Format("select * from I_表名");
DataTable dt=this.Engine.Query.QueryTable(sql,null);
int count =dt.Rows.Count;
新增
H3.DataModel.BizObjectSchema schema=this.Engine.BizObjectManager.GetPublishedSchema("表名");
H3.DataModel.BizObject obj =new H3.DataModel.BizObject(this.Request.Engine,schema,H3.Organization.User.SystemUserId);
obj["status"]=1;
obj.Create();
修改
H3.DataModel.BizObjectSchema schema =this.Engine.BizObjectManager.GetPublishedSchema("表名");
H3.DataModel.BizObject obj=new H3.DataModel.BizObject(this.Request.Engine,schema,H3.Organization.User.SystemUserId);
obj["status"]=1;
obj.Update();
string update=string.Format("UPDATE I_表名 SET 要修改的值=修改内容 where 条件");
this.Engine.Query.QueryTable(update,null);
删除
方法一
string delete=string.Format("Delete * from I_表名");
this.Engine.Query.QueryTable(delete,null);
方法二
string schemaCode ="D00002Lead";
this.Request.Engine.BizObjectManager.Clear(schemaCode);
获取文件名
if(actionName=="GetFileNames")
{
string[] ids=(this.Request["ids"]+string.Empty).Split(';');
string sql=string.Format("select GROUP_CONCAT(filename) from H_bizobjectfile where objectid in (‘{0}’)",string.Join("","",ids));
Dictionary<string,object>resDic=new Dictionary<string,object>();
resDic.Add(“fileNames”,this.Engine.Query.QueryTable(sql,null).Rows[0] [0]+ string.Empty);
Response.ReturnData=resDic;
}
OnLoad:function(){
var that=this;
this.F0000001.BindChange('key',function(){
var ids=that.F0000001.GetValue().Attachmentids;
if(dis!="")
{
$.SmartForm.PostForm("GetFileNames",{ids:ids},function(res){
that.F0000002.SetValue(res.ReturnData.FileNames);
},Function(){
},false)
}else{
That.F0000002.SetValue('');
}
})
}
根据角色权限,控制按钮的显示。帮助文档
protected override void OnLoad(H3.SmartForm.LoadSmartFormResponse response)
{
base.OnLoad(response);
H3.Organization.OrgRole[] orgs = this.Request.Engine.Organization.GetUserRoles(this.Request.UserContext.UserId, true);
bool isNQ = false;
foreach(H3.Organization.OrgRole org in orgs)
{
if(org.Name == "财务部")
{
isNQ = true;
break;
}
}
if(this.Request.BizObject.Status == H3.DataModel.BizObjectStatus.Effective)
{
response.Actions.Remove("Remove");
response.Actions.Remove("Edit");
Dictionary < string, H3.SmartForm.ViewAction > dicActions = new Dictionary<string, H3.SmartForm.ViewAction>();
if(this.Request.BizObject.Status == H3.DataModel.BizObjectStatus.Effective && isNQ == true)
{
dicActions.Add("Edit", new H3.SmartForm.ViewAction("Edit", "编辑", ""));
}
if(this.Request.IsCreateMode == false && this.Request.UserContext.UserId == this.Request.BizObject["CreatedBy"] + string.Empty)
{
dicActions.Add("BtnZCTJ", new H3.SmartForm.ViewAction("BtnZCTJ", "再次提交", "1"));
}
foreach(KeyValuePair < string, H3.SmartForm.ViewAction > action in response.Actions)
dicActions.Add(action.Key, action.Value);
response.Actions = new Dictionary<string, H3.SmartForm.ViewAction>();
response.Actions = dicActions;
}
}
如何获取/修改子表数据
H3.DataModel.BizObject[] details = (H3.DataModel.BizObject[]) this.Request.BizObject["D001700Fd87ff61f9c764eeaa13fe8fef7136adf"];
List < H3.DataModel.BizObject > lstObject = new List<H3.DataModel.BizObject>();
foreach(H3.DataModel.BizObject detail in details)
{
detail["F0000039"] = this.Request.BizObject["SeqNo"] + string.Empty;
lstObject.Add(detail);
}
this.Request.FormData["D001700Fd87ff61f9c764eeaa13fe8fef7136adf"].Value = lstObject.ToArray();
读取当前时间(可以结合节点读取审批时间)
this.Request.BizObject["F0000020"] = this.Request.BizObject["F0000020"] != null ? this.Request.BizObject["F0000020"] : System.DateTime.Now;
子表控件前端请求后端(表单输入内容的时候执行特定指令)
var that = this;
this.D001700Fahbra3qlyox7m5lb87xlo2vy4.BindChange( "Set",
function( data ) {
var responseData = data[ 0 ];
if( responseData != null && responseData.DataField == "D001700Fahbra3qlyox7m5lb87xlo2vy4.F0000003" )
{
var currentRowId = responseData.ObjectId;
var course = this.GetCellManager( currentRowId, "D001700Fahbra3qlyox7m5lb87xlo2vy4.F0000003" ).GetValue();
{
$.SmartForm.PostForm( "Getcourse", { currentRowIdback: currentRowId }, function( data )
{
var result = data.ReturnData;
var Id = result[ "Id" ];
that.D001700Fahbra3qlyox7m5lb87xlo2vy4.UpdateRow( currentRowId, { "D001700Fahbra3qlyox7m5lb87xlo2vy4.F0000016": Id });
var a = that.D001700Fahbra3qlyox7m5lb87xlo2vy4.GetCellManager( currentRowId, "D001700Fahbra3qlyox7m5lb87xlo2vy4.F0000016" );
var b = that.D001700Fahbra3qlyox7m5lb87xlo2vy4.GetCellManager( currentRowId, "D001700Fahbra3qlyox7m5lb87xlo2vy4.F0000002" );
a.SetReadonly( true );
b.SetVisible( false );
}
, function( error ) { $.IShowError( "错误", JSON.stringify( error ) ); }, false );
}
}
})
从另一表获取数据,并加载默认项。
protected override void OnLoad(H3.SmartForm.LoadSmartFormResponse response)
{
H3.Data.Filter.Filter filter = new H3.Data.Filter.Filter();
H3.Data.Filter.And andMatcher = new H3.Data.Filter.And();
andMatcher.Add(new H3.Data.Filter.ItemMatcher("F0000002", H3.Data.ComparisonOperatorType.Equal, true));
filter.Matcher = andMatcher;
filter.AddSortBy(new H3.Data.Filter.SortBy("F0000003", H3.Data.Filter.SortDirection.Ascending));
H3.DataModel.BizObjectSchema accountSchema = this.Request.Engine.BizObjectManager.GetPublishedSchema("D001700428bfc13942c4f09aad0c286144ade90");
H3.DataModel.BizObject[] customers = H3.DataModel.BizObject.GetList(this.Request.Engine, this.Request.UserContext.UserId,
accountSchema, H3.DataModel.GetListScopeType.GlobalAll, filter);
if(customers != null)
{
List < H3.DataModel.BizObject > lstObject = new List<H3.DataModel.BizObject>();
foreach(H3.DataModel.BizObject customer in customers)
{
H3.DataModel.BizObject newChild = new H3.DataModel.BizObject(this.Engine, this.Engine.BizObjectManager.GetPublishedSchema("D001700Fcb370695565640bd89ad5fac1c93f43e"), this.Request.UserContext.UserId);
newChild["F0000020"] = customer["F0000001"];
newChild["F0000022"] = customer["F0000004"];
lstObject.Add(newChild);
}
this.Request.BizObject["D001700Fcb370695565640bd89ad5fac1c93f43e"] = lstObject.ToArray();
}
base.OnLoad(response);
}
后端自定义SQL查询系统表
string insuretype = this.Request.BizObject["F0000001"] + string.Empty;
string organization = this.Request.BizObject["OwnerDeptId"] + string.Empty;
string manager = null;
string mysql1 = "SELECT ObjectId,ManagerId FROM H_Company where ObjectId='" + organization + "'";
string mysql2 = "SELECT ObjectId,ManagerId,ParentId FROM H_Organizationunit where ObjectId='" + organization + "'";
string mysql = null;
if(organization == "18f923a7-5a5e-426d-94ae-a55ad1a4b240") { mysql = mysql1; } else { { mysql = mysql2; } }
System.Data.DataTable dtAccount = this.Request.Engine.Query.QueryTable(mysql, null);
manager = dtAccount.Rows[0]["ManagerId"].ToString();
base.OnLoad(response);
氚云常用按钮编码
暂存 Save 提交 Submit
删除 Remove 撤回 RetrieveInstance
同意 Submit 不同意 Reject
作废 CancelInstance 打印 Print
二维码 ViewQrCode 全屏 FullScreen
关闭 Close 编辑 Edit
转交 Forward 已阅 Read
隐藏暂存按钮
if(response.Actions.ContainsKey("Save"))
{
response.Actions.Remove("Save");
}
如果手机端打开页面,则隐藏控件
if(this.Request.IsMobile)
{
response.ReturnData["F0000030"].Visible = false;
response.ReturnData["F0000033"].Visible = false;
}
Status Draft
Status Effective
Status Running
Status Canceled
Status
后端response方法
response.ReturnData
if(this.Request.IsCreateMode)
response.ClosePage = false;
response.Refresh = false;
response.Errors.Add("错误信息");
response.Message = "消息内容";
response.Infos.Add("提醒信息");
response.ReturnData["F0000001"].Visible = false;
response.ReturnData["F0000002"].Editable = false;