氚云常用代码

官方帮助文档

查询

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;	//状态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();

//Sql语句修改
string update=string.Format("UPDATE I_表名 SET 要修改的值=修改内容 where 条件");
this.Engine.Query.QueryTable(update,null);

删除

方法一
//SQL语句删除全部
string delete=string.Format("Delete * from I_表名");
this.Engine.Query.QueryTable(delete,null);
方法二
//清除表单D00002Lead的所有数据。数据清除后不可恢复,请谨慎操作。
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>();//创建新数组,类似于string创建新的变量
        //数组格式,用遍历的方式读取里面一条条的内容,这个跟传统直线思维有所区别,details是整个数组,detail是单条数据。
        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 + "'";//构造mysql文本语言
        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);//获取mysql读取到的数据
        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   		     //0 = 草稿    1= 生效   3 = 作废

后端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;	//设置字段不可写
  • 5
    点赞
  • 23
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值