1. 程式人生 > 其它 >氚雲後臺程式碼小栗子,點選按鈕進行計算並同步資料到另外一張表單

氚雲後臺程式碼小栗子,點選按鈕進行計算並同步資料到另外一張表單

    protected override void OnSubmit(string actionName, H3.SmartForm.SmartFormPostValue postValue, H3.SmartForm.SubmitSmartFormResponse response)
    {
        if(actionName == "BtnJiShuan")
        {
            //評估資料物件
            BizObject pgsjObj = this.Request.BizObject;
            if((string) pgsjObj["
F0000045"] == "已計算") { return; } BizObjectSchema schema = this.Request.Engine.BizObjectManager.GetPublishedSchema("D101303ZXDF"); BizObject zxdfobj = new BizObject(this.Request.Engine, schema, this.Request.UserContext.UserId); pgsjObj[
"F0000045"] = "已計算"; //賦值 zxdfobj["F0000011"] = this.Request.BizObjectId;//關聯 zxdfobj["F0000001"] = pgsjObj["F0000001"];//標題 //明細賦值 BizObject[] details = (BizObject[]) pgsjObj["D101303PGSJMX"]; //獲取子表屬性並強制轉換為物件陣列 if(details != null && details.Length > 0
) { List < H3.DataModel.BizObject > lstObject = new List<H3.DataModel.BizObject>(); foreach(BizObject detail in details) { string type = (string) detail["F0000046"]; BizObjectSchema mxschema = this.Request.Engine.BizObjectManager.GetPublishedSchema("D101303ZXDFMX"); BizObject zxdfmxobj = new BizObject(this.Request.Engine, mxschema, this.Request.UserContext.UserId); zxdfmxobj["F0000002"] = detail["F0000044"]; double r = 0.00; zxdfmxobj["F0000008"] = r; lstObject.Add(zxdfmxobj); } double avgmss = summss / countmss; double avgxs = sumxs / countxs; double avgxz = sumxz / countxz; zxdfobj["D101303ZXDFMX"] = lstObject.ToArray(); zxdfobj.Status = BizObjectStatus.Effective; zxdfobj.Create(); pgsjObj.Update(); } } base.OnSubmit(actionName, postValue, response); }
View Code