function jsProductData() {
}
/*服务登记列表*/
jsProductData.ServiceRecordGrid = null;
window.onload = function() {
    jsProductData.LoadToolBarBtn();
    jsProductData.LoadServiceRecordList();
    $("#treeServiceType").height(document.body.clientHeight - 220);
    jsProductData.LoadServiceRecordTypeTree();
}

/*生成工具条*/
/*通讯簿操作按钮*/
jsProductData.LoadToolBarBtn = function() {
    customOption = { items: [
        { type: 'button', text: '增加行', useable: 'T', className: 'tableAdd', handler: function() {
            jsProductData.AddGridRow();
        }
        },
        { type: 'button', text: '保存', useable: 'T', className: 'tableEdit', handler: function() {
            jsProductData.SaveGridData();
        }
        }
     ]
    };
    $("#custom-toolbar").toolbar(customOption);
}

/*生成列表*/
jsProductData.LoadServiceRecordList = function() {
    var w = document.body.clientWidth - 182;
    var gh = document.body.clientHeight - 290;
    if (w < 0) {
        w = 1030 - 182;
        gh = 670 - 290;
    }
    var serviceOption =
    {
        height: gh,
        width: w,
        colModel: [
            { display: '中文名', name: 'CNName', width: (w * 0.2), sortable: false },
            { display: '属性名', name: 'FieldName', width: (w * 0.2), sortable: false },
            { display: '输入方式', name: 'ImportMode', width: (w * 0.4), sortable: false, process: jsProductData.importMode },
            { display: '操作', name: 'ID', width: (w * 0.15), sortable: false, process: jsProductData.setContorl },
            { display: '数据类型', name: 'FieldDataType', width: (w * 0.2), sortable: false, hide: true },
            { display: '操作方式', name: 'OperateConditon', width: (w * 0.2), sortable: false, hide: true },
            { display: '产品类型ID', name: 'ProductTypeID', width: (w * 0.2), sortable: false, hide: true },
            { display: '录入数据', name: 'ValueMethod', width: (w * 0.2), sortable: false, hide: true },
            { display: '产品类型数据', name: 'ProductTypeControl', width: (w * 0.2), sortable: false, hide: true }
        ],
        customFunction: jsProductData.ShowPage
    };
    jsProductData.ServiceRecordGrid = $("#tbServiceGrid").ikegrid(serviceOption);
    serviceOption = null;
};

jsProductData.ShowPage = function(pageSize, pageIndex, searchStr, extpara, order) {
    try {
        if (searchStr != "" && searchStr != undefined) {
            var obj = $.parseJSON("[{" + searchStr + "}]");
//            jsProductData.getDataMadeContorl(obj);
            return obj[0];
        } else {
        var objStr = DBReader.selectSqlForJson("select ID, AttributeName as FieldName, AttributeValue as ImportMode, CNName,ProductTypeID, FieldDataType , ValueMethod , OperateConditon,ProductTypeControl  from T_ProductTypeAttribute");
            var obj = $.parseJSON("[{" + objStr + "}]");
            return obj[0].result > 0 ? obj[0] : null;
        }
    } catch (e) {
        alert("ERROR FOR jsProductData.ShowPage " + e.message);
    }
    return null;
};

/*输入方式*/
jsProductData.importMode = function(value, pid, rows) {
    var contorl = unescape(rows.ProductTypeControl);
    return contorl == "undefined" ? "" : contorl;
}
/*设计、删除按钮*/
jsProductData.setContorl = function(value, pid, rows) {
var contorl = "<input type='button' class='btn' dataSource = '" + (rows.ValueMethod == undefined ? "" : rows.ValueMethod) + "' value='设计' onclick='jsProductData.designCondition(this,\"" + pid + "\");'/>&nbsp;<input type='button' class='btn' value='删除' onclick='jsProductData.deleteCondition(\"" + pid + "\");'/>";
    return contorl;
}
/*设计按钮*/
jsProductData.designCondition = function(obj, pid) {
    var _data = obj.dataSource;
    var showText = obj.parentElement.parentElement.parentElement.cells[0].children[0].innerText;
    var FormIndex = ShowWindow.getFormIdx();
    var controlName = "Row_" + pid;
    //    if (typeof (pid) == "object") {
    //        pid = "\"" + pid.id + "\"";
    //    }
    if (_data != undefined && _data.length > 0) {
        document.getElementById("RowSourceInput").dataSource = _data;
        ShowWindow.ShowMoledDialog("Application/TeleSecretary/eOA_EditControl/eOA_EditInputOrModifyControl.htm?formIdx=" + FormIndex + "&sqlType=access&tableName=T_ProductAttribute|ProductAttributeName&showText=" + showText + "&type=EditControl&insertSource=" + escape('ShowWindow.opener.document(App.query("formIdx")).frames["tab_item_frame_tab-systemMan"].frames["tdRegistration"].document.getElementById("RowSourceInput")') + "&controlName=" + controlName + "&sheetList=CallInputSheet&action=jsIndexPage.freshItemPage('tab-systemMan','jsSystemSettings.getProductData(\"" + pid + "\",\"@str\")')", "取值方式", 600, 650);
    } else {
    ShowWindow.ShowMoledDialog("Application/TeleSecretary/eOA_EditControl/eOA_EditInputOrModifyControl.htm?formIdx=" + FormIndex + "&sqlType=access&tableName=T_ProductAttribute|ProductAttributeName&showText=" + showText + "&controlName=" + controlName + "&type=AddControl&sheetList=CallInputSheet&action=jsIndexPage.freshItemPage('tab-systemMan','jsSystemSettings.getProductData(\"" + pid + "\",\"@str\")')", "取值方式", 600, 650);
    }
}

/*删除按钮*/
jsProductData.deleteCondition = function(pid) {
    rowObj = jsProductData.ServiceRecordGrid.getRowByID(pid);
    jsProductData.ServiceRecordGrid.deleteRow(rowObj.rowIndex);
}

/*获取设计数据*/
jsProductData.getSource = function(pid, str) {
    App.SetNullHref(0);
    var contorl = $.parseJSON(unescape(str));
    var _row = jsProductData.ServiceRecordGrid.getRowByID(pid);
    _row.cells[0].childNodes[0].innerText = contorl.title;
    _row.cells[1].children[0].innerText = contorl.identity;
    var platObj = document.createElement("DIV");
    platObj.innerHTML = unescape(contorl.content);
    if (platObj.childNodes[0] != null && platObj.children[0].tagName.toLowerCase() == "table") {
        _row.cells[2].children[0].innerHTML = "从 " + platObj.children[0].cells[0].innerHTML + " 到 " + platObj.children[0].cells[1].innerHTML
    } else {
        _row.cells[2].children[0].innerHTML = unescape(contorl.content);
    }
    _row.cells[3].children[0].children[0].dataSource = str;
    _row.cells[6].children[0].innerHTML = $("#hideProductTypeId").val(); ;
    _row.cells[7].children[0].innerHTML = str;
    if (contorl.format == "dateTime") {
        _row.cells[4].children[0].innerHTML = contorl.format;
        _row.cells[5].children[0].innerHTML = contorl.isEndTime;
    } else if (contorl.format == "text") {
        _row.cells[4].children[0].innerHTML = contorl.format;
        _row.cells[5].children[0].innerHTML = contorl.dataType;
    } else if (contorl.format == "decimal" || contorl.format == "telphone") {        
        _row.cells[4].children[0].innerHTML = (contorl.type =="decimal" ? "NUMERIC(8,4)" : "long");
        _row.cells[5].children[0].innerHTML = "";
    }
    platObj.innerHTML = "";
    platObj = null;
    CollectGarbage();
}

/*服务登记类型树*/
jsProductData.LoadServiceRecordTypeTree = function() {
    var treeString = GetTree("SELECT * FROM T_ProductType", "T_ProductType", 0);
    var menudata = [];
    if (treeString != "") {
        menudata = $.parseJSON(treeString);
    }
    var op = { data: menudata, onnodeclick: jsProductData.ReLoadServiceList, foldtheme: "yellow", theme: "bbit-tree-no-lines", spacepic: "../../AppFrame/APICss/Shared/images/s.gif" };
    $("#treeServiceType").treeview(op);
    treeString = null;
    menudata = null;
    CollectGarbage();
};
/*点击树方法*/
jsProductData.ReLoadServiceList = function(item) {
    //    var objStr = $.parseJSON("[{" + DBReader.selectSqlForJson("SELECT T_ProductAttribute.ProductID as ID, T_ProductAttribute.ProductAttributeName as FieldName, T_ProductAttribute.ProductAttributeValue as ImportMode, T_ProductAttribute.CNName, T_ProductAttribute.FieldDataType , T_ProductAttribute.ValueMethod , T_ProductAttribute.OperateConditon FROM  T_ProductAttribute where T_ProductAttribute.ProductID in (select id from T_Product WHERE T_Product.ProductTypeID=" + item.id + ")") + "}]");
    //    var strObj = DBReader.selectSqlForJson("select id from T_Product where 1=2");
    //    jsProductData.ServiceRecordGrid.DoSearch(strObj); /*清空表数据*/
    //    if (objStr[0].table != null && objStr[0].table.length > 0) {
    //        for (var i = 0; i < objStr[0].table.length; i++) {
    //            jsProductData.getDataMadeContorl(objStr[0].table[i]);
    //        }
    //    }
var objStr = DBReader.selectSqlForJson("SELECT ID, AttributeName as FieldName, AttributeValue as ImportMode, CNName,ProductTypeID, FieldDataType , ValueMethod , OperateConditon,ProductTypeControl FROM  T_ProductTypeAttribute where ProductTypeID =" + item.id);
    jsProductData.ServiceRecordGrid.DoSearch(objStr);
    $("#hideProductTypeId").val(item.id);
}

/*增加行*/
jsProductData.AddGridRow = function() {
    if ($.trim($("#hideProductTypeId").val()) != "") {
        var newRowObj = jsProductData.ServiceRecordGrid.addRow(0);
        var initValue = [{}];
        jsProductData.ServiceRecordGrid.setRowData(newRowObj, initValue);
        newRowObj = null;
        initValue = null;
    } else {
        alert("不能增加行，请点击左边登记类型，选择类型！");
    }
}

/*读取数据生成控件*/
jsProductData.getDataMadeContorl = function(obj) {
    var _format = "";
    switch (obj.FieldDataType) {
        case "text":
        case "textarea":
        case "select":
        case "radio":
        case "checkbox":
            {
                _format = "text";
            } break;
        case "yyyy-MM-dd":
        case "yyyy":
        case "MM":
        case "dd":
        case "yyyy-MM-dd hh:mm:ss":
            {
                _format = "dateTime";
            } break;
        case "integer":
        case "decimal":
            {
                _format = "decimal";
            } break;
        case "telphone":
            {
                _format = "telphone";
            } break;
    }
    if (obj.FieldDataType == "text" || obj.FieldDataType == "textarea") {
        var str = '{"type":"' + obj.FieldDataType + '","title":"' + obj.CNName + '","parameter":"' + obj.FieldName + '","identity":"' + obj.FieldName + '","format":"' + _format + '","dataType":"sql"';
        switch (obj.FieldDataType) {
            case "text":

                str += ',"content":"' + escape("<input  type='text'  Field='" + obj.FieldName + "' format='varchar(50)' value=" + obj.ImportMode + " class='ipt' />") + '"';
                break;

            case "textarea":
                str += ',"content":"' + escape("<textarea  type='textarea' cols='50' rows='5' Field='" + obj.FieldName + "' style='width:90%;height:100px;' format='varchar(500)' class='multxt'>" + obj.ImportMode + "</textarea>") + '"';
                break;
        }
        str += "}";
        return str;
    } else if (obj.FieldDataType == "select" || obj.FieldDataType == "radio" || obj.FieldDataType == "checkbox") {
        //        var sel = document.getElementById("treeSel");
        //        jseOA_EditInputOrModifyControl.getSelect(sel);
        //        var controlName = "";
        //        if (App.query("controlName") != undefined) {
        //            controlName = obj.FieldDataType + controlID;
        //        }
        //        var str = '{"type":"' + obj.FieldDataType + '","title":"' + obj.CNName + '","parameter":"' + obj.FieldName + '","identity":"' + obj.FieldName + '","format":"' + _format + '","selSource":[';
        //        var controlSource = "";
        if (obj.OperateConditon == "sql") {
            return unescape(obj.ValueMethod);
            //            var ilength = sel.options.length;
            //            if (ilength > 0) {
            //                for (var i = 0; i < ilength; i++) {
            //                    if (i == 0 && obj.FieldDataType == "select") {
            //                        controlSource = "<select type='select' Field='" + obj.FieldName + "' format='varchar(50)' dataType='sql'   SelValueMode='Text' >";
            //                    }
            //                    if (obj.FieldDataType == "radio" || obj.FieldDataType == "checkbox") {
            //                        controlSource += "<input name='" + controlName + "' Field='" + obj.FieldName + "' format='varchar(50)' type='" + obj.FieldDataType + "'  value='" + sel[i].value + "'  dataType='sql' SelValueMode='Text'";
            //                        if (i == 0) {
            //                            controlSource += "checked ='checked'";
            //                        }
            //                        controlSource += "/><span>" + sel[i].text + "</span>"
            //                    } else if (obj.FieldDataType == "select") {
            //                        controlSource += "<option value='" + sel[i].value + "'>" + sel[i].text + "</option>";
            //                    }
            //                    str += '{"name":"' + sel[i].text + '","value":"' + sel[i].value + '"},';
            //                }
            //                str = str.substring(0, str.length - 1) + ']';
            //            } else {
            //                str += ']';
            //            }
            //            if ((ilength - 1) > 0 && obj.FieldDataType == "select") {
            //                controlSource += "</select>";
            //            }
            //            str += ',"content":"' + escape(controlSource) + '","dataType":"sql"}';
            //            if (App.query("action") == undefined) {
            //                ShowWindow.opener.execScript(App.query("formIdx"), "getSource('" + str + "')");
            //            } else {
            //                ShowWindow.opener.execScript(App.query("formIdx"), App.query("action").replace('@str', escape(str)));
            //            }
            //            ShowWindow.close();
            //            sel = null;
            //            controlSource = null;
            //            ilength = null;
            //            i = null;
        } else {
            try {
                var processArray = "";
                if (obj.ValueMethod != "" && obj.ValueMethod.indexOf("|") != -1) {
                    processArray = obj.ValueMethod.split("|");
                    var sqlTxt = escape(processArray[0]);
                    var txtName = processArray[1];
                    var txtValue = processArray[2];
                    str += '{"name":"' + txtName + '","value":"' + txtValue + '"}],"dataType":"process","process":"' + sqlTxt + '"}';
                    txtName = null;
                    txtValue = null;
                    sqlTxt = null;
                    return str;
                }
                return null;
            } catch (e) {
                alert("Error for getDataMadeContorl:" + e.message);
            }
        }
        str = null;
    } else if (obj.FieldDataType == "yyyy-MM-dd" || obj.FieldDataType == "yyyy" || obj.FieldDataType == "MM" || obj.FieldDataType == "dd" || obj.FieldDataType == "yyyy-MM-dd hh:mm:ss" || obj.FieldDataType == "integer" || obj.FieldDataType == "decimal") {
        var str = '{"type":"' + obj.FieldDataType + '","title":"' + obj.CNName + '","parameter":"' + obj.FieldName + '","identity":"' + obj.FieldName + '","format":"' + _format + '"';
        var isSecond = (obj.FieldDataType == "yyyy-MM-dd" ? "" : "dateFmt:'yyyy-MM-dd HH:mm:ss',");
        var today = new Date();
        var controlSource = "";
        if (obj.OperateConditon == "true") {
            //                    if (obj.FieldNameEnd == obj.FieldName) {
            //                        alert("操作错误，参数不能与结束时间参数相同！");
            //                        return;
            //                    } else {
            controlSource = "<table Field='" + obj.FieldName + "' format='datetime' class='tbTime'><tr><td><input type='text' id='date" + today.getTime() + "' Field='" + obj.FieldName + "' class='Wdate' maxlength='30' onclick=\"WdatePicker({" + isSecond + " maxDate:'#F{$dp.$D(\\\'date" + (parseInt(today.getTime()) + 1) + "\\\')}'});\"/></tr></td><tr><td><input type='text' id='date" + (parseInt(today.getTime()) + 1) + "' Field='" + obj.FieldName + "' class='Wdate' maxlength='30' onclick=\"WdatePicker({" + isSecond + "minDate:'#F{$dp.$D(\\\'date" + today.getTime() + "\\\')}'});\"/></tr></td></table>";
            str += ',"isEndTime":true,"parameterEnd":"' + obj.FieldNameEnd + '"';
            //                    }
        } else {
            str += ',"isEndTime":false';
            controlSource = "<input type='text' class='Wdate' Field='" + obj.FieldName + "' format='datetime' maxlength='30' onclick= \"WdatePicker({" + isSecond + "maxDate:'2099-10-01'})\"/>";
        }
        //        if (obj.FieldDataType == "yyyy") {
        //            controlSource = "<select Field='" + obj.FieldName + "'>";
        //            for (var i = 1900; i < 2099; i++) {
        //                controlSource += "<option value=" + i + ">" + i + "</option>";
        //            }
        //            controlSource += '</select>';
        //        }else 
        if (obj.FieldDataType == "MM") {
            controlSource = "<select Field='" + obj.FieldName + "'>";
            for (var i = 1; i < 13; i++) {
                controlSource += "<option value=" + i + ">" + i + "</option>";
            }
            controlSource += '</select>';
        }
        //        else if (obj.FieldDataType == "dd") {
        //            controlSource = "<select Field='" + obj.FieldName + "'>";
        //            for (var i = 1; i < 32; i++) {
        //                controlSource += "<option value=" + i + ">" + i + "</option>";
        //            }
        //            controlSource += '</select>';
        //        }
        else if (obj.FieldDataType == "integer") {
            controlSource = "<input type='text' Field='" + obj.FieldName + "' format='integer' class='ipt' onblur='jsCommonLogic.dataValidate(3,this); ' />";
        }
        else if (obj.FieldDataType == "decimal") {
            controlSource = "<input type='text' Field='" + obj.FieldName + "' format='decimal' class='ipt' onblur='jsCommonLogic.dataValidate(5,this); ' />";
        }
        str += ',"content":"' + escape(controlSource) + '"}';
        return str;
    } else if (obj.FieldDataType == "telphone") {
        var str = '{"type":"' + obj.FieldDataType + '","title":"' + obj.CNName + '","parameter":"' + obj.FieldName + '","identity":"' + obj.FieldName + '","format":"' + _format + '","dataType":"sql","content":"' + escape("<input contorlType='phone' type='text'   Field='" + obj.FieldName + "' format='integer' class='ipt' onblur='jsCommonLogic.dataValidate(3,this); '/>&nbsp;<img alt='拨打' style='cursor:pointer' src='images/Tel.Gif'  width='15px' height='15px' title='拨打电话'/>") + '"}';
        return str;
    } else {
        alert("此格式未开放请重新选择！");
    }
}


/*保存*/
jsProductData.SaveGridData = function() {
    try {
        var strObj = $.parseJSON("[{" + DBReader.selectSqlForJson("select * from T_ProductTypeAttribute") + "}]");
        var dataTable = strObj[0].table;
        $("tr", jsProductData.ServiceRecordGrid).each(function() {
            var entity = jsEntity.CreateEntityByTableName_access("T_ProductTypeAttribute");
            if (dataTable != undefined) {
                for (var i = 0; i < dataTable.length; i++) {
                    var dataTableName = $.trim(dataTable[i].AttributeName.toLowerCase());
                    var trName = $.trim(this.cells[1].childNodes[0].innerText.toLowerCase());
                    if (dataTableName == trName && dataTable[i].ProductTypeID == $("#hideProductTypeId").val()) {
                        entity.Fields.ProductTypeID = dataTable[i].ProductTypeID;
                        entity.Fields.AttributeName = this.cells[1].childNodes[0].innerText;
                        if (this.childNodes[2].children[0].children[0] != null) {
                            if (this.childNodes[2].children[0].children[0].tagName.toLowerCase() == "input") {
                                if (this.childNodes[2].children[0].children[0].type.toLowerCase() == "text") {
                                    var timeObj = $("#" + this.id + " input[class='.Wdate']");
                                    entity.Fields.AttributeValue = this.cells[2].children[0].children[0].value;
                                } else if (this.childNodes[2].children[0].children[0].type.toLowerCase() == "radio") {
                                    var rdoObj = $("input[name='" + this.cells[2].children[0].children[0].name + "'][checked]");
                                    entity.Fields.AttributeValue = rdoObj.val();
                                } else if (this.childNodes[2].children[0].children[0].type.toLowerCase() == "checkbox") {
                                    var rdoObj = $("input[name='" + this.cells[2].children[0].children[0].name + "'][checked]");
                                    var chk_val = "";
                                    for (var j = 0; j < rdoObj.length; j++) {
                                        if (chk_val.length == 0) {
                                            chk_val = rdoObj[j].value;
                                        } else {
                                            chk_val += "|" + rdoObj[j].value;
                                        }
                                    }
                                    entity.Fields.AttributeValue = chk_val;
                                }
                            } else {
                                entity.Fields.AttributeValue = this.cells[2].childNodes[0].children[0].value;
                            }
                        } else {
                            entity.Fields.AttributeValue = this.cells[2].childNodes[0].innerText;
                        }
                        entity.Fields.CNName = this.cells[0].childNodes[0].innerText;
                        entity.Fields.ValueMethod = this.cells[7].children[0].innerText;
                        entity.Fields.OperateConditon = this.cells[5].childNodes[0].innerText;
                        entity.Fields.ProductTypeControl = escape(this.cells[2].childNodes[0].innerHTML);
                        entity.Fields.ID = dataTable[i].ID;
                        entity.Update(entity);
                        break;
                    }
                    if (i == (dataTable.length - 1)) {
                        entity.Fields.ProductTypeID = $("#hideProductTypeId").val();
                        entity.Fields.AttributeName = this.cells[1].childNodes[0].innerText;
                        if (this.childNodes[2].children[0].children[0] != null) {
                            if (this.childNodes[2].children[0].children[0].tagName.toLowerCase() == "input") {
                                if (this.childNodes[2].children[0].children[0].type.toLowerCase() == "text") {
                                    var timeObj = $("#" + this.id + " input[class='.Wdate']");
                                    entity.Fields.AttributeValue = this.cells[2].children[0].children[0].value;
                                } else if (this.childNodes[2].children[0].children[0].type.toLowerCase() == "radio") {
                                    var rdoObj = $("input[name='" + this.cells[2].children[0].children[0].name + "'][checked]");
                                    entity.Fields.AttributeValue = rdoObj.val();
                                } else if (this.childNodes[2].children[0].children[0].type.toLowerCase() == "checkbox") {
                                    var rdoObj = $("input[name='" + this.cells[2].children[0].children[0].name + "'][checked]");
                                    var chk_val = "";
                                    for (var j = 0; j < rdoObj.length; j++) {
                                        if (chk_val.length == 0) {
                                            chk_val = rdoObj[j].value;
                                        } else {
                                            chk_val += "|" + rdoObj[j].value;
                                        }
                                    }
                                    entity.Fields.AttributeValue = chk_val;
                                }
                            } else {
                                entity.Fields.AttributeValue = this.cells[2].childNodes[0].children[0].value;
                            }
                        } else {
                            entity.Fields.AttributeValue = this.cells[2].childNodes[0].innerText;
                        }
                        entity.Fields.CNName = this.cells[0].childNodes[0].innerText;
                        entity.Fields.ValueMethod = this.cells[7].children[0].innerText;
                        entity.Fields.OperateConditon = this.cells[5].childNodes[0].innerText;
                        entity.Fields.FieldDataType = this.cells[4].childNodes[0].innerText;
                        entity.Fields.ProductTypeControl = escape(this.cells[2].childNodes[0].innerHTML);
                        entity.Insert(entity);
                        break;

                    }
                }
            } else {
                entity.Fields.ProductTypeID = $("#hideProductTypeId").val();
                entity.Fields.AttributeName = this.cells[1].childNodes[0].innerText;
                if (this.childNodes[2].children[0].children[0] != null) {
                    if (this.childNodes[2].children[0].children[0].tagName.toLowerCase() == "input") {
                        if (this.childNodes[2].children[0].children[0].type.toLowerCase() == "text") {
                            var timeObj = $("#" + this.id + " input[class='.Wdate']");
                            entity.Fields.AttributeValue = this.cells[2].children[0].children[0].value;
                        } else if (this.childNodes[2].children[0].children[0].type.toLowerCase() == "radio") {
                            var rdoObj = $("input[name='" + this.cells[2].children[0].children[0].name + "'][checked]");
                            entity.Fields.AttributeValue = rdoObj.val();
                        } else if (this.childNodes[2].children[0].children[0].type.toLowerCase() == "checkbox") {
                            var rdoObj = $("input[name='" + this.cells[2].children[0].children[0].name + "'][checked]");
                            var chk_val = "";
                            for (var j = 0; j < rdoObj.length; j++) {
                                if (chk_val.length == 0) {
                                    chk_val = rdoObj[j].value;
                                } else {
                                    chk_val += "|" + rdoObj[j].value;
                                }
                            }
                            entity.Fields.AttributeValue = chk_val;
                        }
                    } else {
                        entity.Fields.AttributeValue = this.cells[2].childNodes[0].children[0].value;
                    }
                } else {
                    entity.Fields.AttributeValue = this.cells[2].childNodes[0].innerText;
                }
                entity.Fields.CNName = this.cells[0].childNodes[0].innerText;
                entity.Fields.ValueMethod = this.cells[7].children[0].innerText;
                entity.Fields.OperateConditon = this.cells[5].childNodes[0].innerText;
                entity.Fields.FieldDataType = this.cells[4].childNodes[0].innerText;
                entity.Fields.ProductTypeControl = escape(this.cells[2].childNodes[0].innerHTML);
                entity.Insert(entity);
            }
            DBReader.DisposeEntity(entity);
            //        var RowValue = jsProductData.ServiceRecordGrid.getRowData(this, 'string');
            //        var valueObj = eval("[" + RowValue + "]");
        });
    } catch (e) {
        alert("保存失败！错误在于：" + e.message);
    }
    alert("保存成功！");
}