/*************************
*功能：预提规则设定
*创建人：张振华
*时间：2010-08-16
*备注：此时间是加注释时间
*************************/

var strTableP050602 = "Tp050602";
var strDivP050602 = "divP050602";
var objRecordsP050602;  //修改时用来保存记录
var strRecordsCountP050602  //表格中记录条数
var iRowP050602 = -1;   //行索引
var iColP050602 = -1;   //列索引
var strOptrTypeP050602 = "1";   //保存标志位
var iFirstIndex = 999999999;

//大于列格式化
function formatterP050602Dy() {
    return ">";
}

//大于列格式化
function formatterP050602Xy() {
    return "<=";
}

//格式化数量
function formatterP050602Count(cellValue) {

    if (!isNaN(parseFloat(cellValue)) && cellValue != "-1") {
        return parseFloat(cellValue).toFixed(window.parent.strCountPlace);
    }
    else {
        return "&nbsp;";
    }

}

//格式化百分比
function formatterP050602Rate(cellValue) {
    if (!isNaN(parseFloat(cellValue))) {
        return parseFloat(cellValue).toFixed(window.parent.strPercentPlace) + "%";
    }
    else {
        return "&nbsp;";
    }
}

//反格式化
function unFormatterP050602Rate(cellValue) {
    return cellValue.substring(0, cellValue.length - 1);
}

//格式化金额
function formatterP050602Money(cellValue) {

    if (!isNaN(parseFloat(cellValue)) && cellValue != "-1") {
        return parseFloat(cellValue).toFixed(window.parent.strMoneyPlace);
    }
    else {
        return "&nbsp;";
    }

}

//编辑单元格之后的事件
function afterEditCell_P050602(rowId, cellname, value, iRow, iCol) {

    //    //存前一行ID
    //    var strPreRowId = iRowP050602;

    //当前单元格的索引
    iRowP050602 = iRow;
    iColP050602 = iCol;

    //单元格内控件
    var item = $("#" + rowId + " :input[name='" + cellname + "']", this);

    //位数
    var strPlace;

    //格式化位数
    switch (cellname) {
        case "start":
            if (RulesList.Type == "0") {
                //按数量
                strPlace = window.parent.strCountPlace;
            }
            else {
                //按金额
                strPlace = window.parent.strMoneyPlace;
            }
            break;
        case "end":
            if (RulesList.Type == "0") {
                //按数量
                strPlace = window.parent.strCountPlace;
            }
            else {
                //按金额
                strPlace = window.parent.strMoneyPlace;
            }
            break;
        case "ytbl":
            if (RulesList.Type == "0") {
                //按数量
                strPlace = window.parent.strMoneyPlace;
                item.autoNumeric({ mDec: strPlace, aSep: "", mNum: 10 }).focus(function () { this.select(); }).css("ime-mode", "disabled");
            }
            else {
                //按金额
                strPlace = window.parent.strPercentPlace;
                item.autoNumeric({ mDec: strPlace, aSep: "" }).focus(function () { this.select(); }).css("ime-mode", "disabled");
            }
            break;
    }

    //除预提比例其他项加控件
    if (cellname != "ytbl") {
        item.autoNumeric({ mDec: strPlace, aSep: "" }).focus(function () { this.select(); }).css("ime-mode", "disabled");
    }

    //给控件加事件
    item.change(function () { dataChangeStateP050602(true); });

    //释放内存
    item = null;
}

//保存单元格之后的事件
function afterSaveCell_P050602(rowId, cellname, value, iRow, iCol) {
    switch (cellname) {
        case "ytbl":
            //按金额时加比率列加%
            if ($("#slje", "#" + strDivP050602).combobox('getValue') == "1") {
                $("#" + strTableP050602).setCell(rowId, cellname, value + "%");
            }
            break;
        default:
    }

}

//浮动删除
function addCzHtmlP050602() {
    $("#" + strTableP050602).delegate("tr[id]:visible", "hover", function (e) {
        if (e.type == "mouseenter") {
            var strButtonHtml = "";
            strButtonHtml += "<a href=\"#\" style=\"color:red;text-decoration:none;\" onclick=\"deleteDataP050602(" + this.id + ");return false;\">删除</a> ";
            $("#" + strTableP050602).jqGrid("setCell", this.id, "cz", strButtonHtml);
        }
        else if (e.type == "mouseleave") {
            $("#" + strTableP050602).jqGrid("setCell", this.id, "cz", "&nbsp;");
        }
    });
}

//添加一空行
function addEmptyRowP050602() {
    if (strOptrTypeP050602 != "5") {
        $("#" + strTableP050602).addRowData(++strRecordsCountP050602 + iFirstIndex, { id: strRecordsCountP050602 });
        addCzHtmlP050602();
        resizeGridScroll(strTableP050602);
    }
}

//页面加载时添加的添加空行
function addEmptyRowsP050602() {
    for (var i = iFirstIndex; i < iFirstIndex + strRecordsCountP050602; i++) {
        if (strRecordsCountP050602 == 5 && i == iFirstIndex) {
            $("#" + strTableP050602).addRowData(i, { start: "0" });
        }
        else {
            $("#" + strTableP050602).addRowData(i, {});
        }
    }
}

//修改层的状态
function dataChangeStateP050602(bState) {
    $("#" + strDivP050602 + "_divform").data("change", bState);
}

//按数量/按金额切换时重新加载表格配置
function reLoadTable() {
    //table对象
    var objTable = $("#" + strTableP050602);

    //清楚grid数据
    objTable.clearGridData();

    //修改名字
    $(".ui-jqgrid-hbox  table th:visible .ui-jqgrid-sortable", "#gbox_" + strTableP050602).each(function () {

        var strText = $.trim($(this).text());

        if ($("#slje", "#" + strDivP050602).combobox('getValue') == "0") {
            //按数量
            if (strText == "金额（元）") {
                $(this).text("数量");
            }
            if (strText == "预提比例（%）") {
                $(this).text("预提金额（元/单位）");
            }
        }
        else {
            //按金额                                    
            if (strText == "数量") {
                $(this).text("金额（元）");
            }
            if (strText == "预提金额（元/单位）") {
                $(this).text("预提比例（%）");
            }
        }
    });

    //重新格式化
    if ($("#slje", "#" + strDivP050602).combobox('getValue') == "0") {
        objTable.setColProp("start", { formatter: formatterP050602Count });
        objTable.setColProp("ytbl", { formatter: formatterP050602Money });
        objTable.setColProp("end", { formatter: formatterP050602Count });
    }
    else {
        objTable.setColProp("start", { formatter: formatterP050602Money });
        objTable.setColProp("end", { formatter: formatterP050602Money });
        objTable.setColProp("ytbl", { formatter: formatterP050602Rate });
        objTable.setColProp("ytbl", { unformat: unFormatterP050602Rate });
    }
    //重新加载事件
    objTable.setGridParam({ afterEditCell: afterEditCell_P050602 });
    objTable.setGridParam({ afterSaveCell: afterSaveCell_P050602 });

    //重新加载数据
    loadTreeData(strTableP050602, objRecordsP050602.Records);

    //添加空行
    addEmptyRowsP050602();

    //增加删除列
    addCzHtmlP050602();

    //释放内存
    objTable = null;
}

//创建grid
function createGridP050602(strTableID, objColNames, objColModel) {

    $("#" + strTableID).jqGrid({
        datatype: "local",
        sortname: "id",
        colNames: objColNames,
        colModel: objColModel,
        data: [],
        rowNum: 9999999,
        rownumbers: true,
        autowidth: true,
        rownumWidth: 30,
        cellEdit: true,
        cellsubmit: "clientArray",
        gridview: true
    }).parent(".ui-jqgrid-bdiv").siblings();

    //增加表头‘序号’列
    $("table.ui-jqgrid-htable th:first", $("#gbox_" + strTableID)).text("序号");
}

//释放内存
function freeMemory_P050602() {
    strOptrTypeP050602 = null;
    objRecordsP050602 = null;
    strOptrTypeP050602 = null;
    iRowP050602 = null;
    iColP050602 = null;
    strRecordsCountP050602 = null;
}

//弹出层
//1:新增；2:管理画面点规则；3:修改（没产生单据）；
//4:修改有单据；5:查看；6:从管理画面中进来产生了单据
function showDialogP050602(strType, strRowId) {
    try {

        //数据库返回的结果
        var objResult;

        //清楚浮动层
        $(".operate").hide();

        //保存标志位
        strOptrTypeP050602 = strType;

        //判断标志位
        if (strOptrTypeP050602 == "2") {
            //从管理画面中进来的时候判断是否产生了单据
            objSelRowP0506 = $("#" + strTableP0506).getRowData(strRowId);
            if (objSelRowP0506.zt == "已停用") {
                objResult = ParseData(window.external.DoOptions(strTableP050601, "GetSingle", "{\"gzguid\":\"" + objSelRowP0506.gzguid + "\"}"));
                if (objResult.flag == "4") {
                    strOptrTypeP050602 = "6";
                }
                else {
                    strOptrTypeP050602 = "2";
                }
            }
            else {
                strOptrTypeP050602 = "5";
            }

        }
        else {
            //规则维护是修改的时候
            if (strOptrTypeP050601 == "2") {
                strOptrTypeP050602 = "3";
            }
            else if (strOptrTypeP050601 == "3") {
                strOptrTypeP050602 = "5";
            }
            else if (strOptrTypeP050601 == "4") {
                strOptrTypeP050602 = "4";
            }
        }

        //弹出层
        if (strOptrTypeP050602 == "5") {
            //查看的时候
            creatDiv_ShowDlgHaveTbl(strDivP050602, "规则设定", false, false, strTableP050602, "600");
        }
        else {
            //其他情况
            creatDiv_ShowDlgHaveTbl(strDivP050602, "规则设定", false, true, strTableP050602, "600");
        }

        //向弹出层里添加内容
        addContentP050602("");

        $("#" + strDivP050602).keypress(function (event) {
            if (event.keyCode == 13) {
                return false;
            }
        });
    }
    catch (e) {
        proceError("P050602", e.ToString());
    }
}

//添加弹出层内容
function addContentP050602() {

    //常用变量定义
    var config = ParseData(window.external.DoOptions(strTableP050602, "GetTableConfig", "{}"));
    var objSlje = [{ "dm": "0", "mc": "按数量" }, { "dm": "1", "mc": "按金额"}];
    var strForm;
    var i = 0;
    var item;
    objRecordsP050602 = { Records: [] };

    //第一此进来时从数据库取值,其他时候用全局变量RulesList的值
    if (RulesList.Rules.length == 0 && strOptrTypeP050602 != "1") {
        //从数据库中取值
        objRecordsP050602 = ParseData(window.external.DoOptions(strTableP050602, "GetList", "{\"gzguid\":\"" + objSelRowP0506.gzguid + "\"}"));
    }

    //从管理画面中进来的时候取按数量/按金额，预提方式的值
    if (strOptrTypeP050602 != "1" && RulesList.Rules.length == 0) {
        RulesList.Type = objSelRowP0506.slje
    }

    //转化格式可以被表格加载
    if (RulesList.Rules.length != 0) {
        for (i = 0; i < RulesList.Rules.length; i++) {
            var strRecord = { "dy": ">", "start": "", "xy": "<=", "cz": "", "ytbl": "", "end": "", "mxguid": "" };
            strRecord.ytbl = RulesList.Rules[i].rate;
            strRecord.start = RulesList.Rules[i].sData;
            strRecord.end = RulesList.Rules[i].eData;
            objRecordsP050602.Records.push(strRecord);
        }
    }

    //添加弹出层信息
    strForm = "<ul>";
    for (i = 0; i < config.pageHeader.length; i++) {

        Item = config.pageHeader[i];
        if (Item.hidden == true) {
            continue;
        }
        if (Item.edittype == "text") {
            strForm += "<li class='inp_70'>";
            strForm += Item.xsmc + "：";
            strForm += "<input type='text'  name='" + Item.index + "' ";
            strForm += " value=''  ";
            strForm += " id='" + Item.index + "'>";
            strForm += "</li>";
        }
        else if (Item.edittype == "select") {
            strForm += "<li>";
            strForm += Item.xsmc + "：";
            strForm += "<select name='" + Item.index + "' id='" + Item.index + "'";
            strForm += " class='easyui-combobox' >";
            strForm += "</select>";
            strForm += "</li>";
        }
        else if (Item.edittype == "checkbox") {
            strForm += "<li class=\"unline\">";
            strForm += Item.xsmc + "：";
            strForm += "<input type='checkbox'   name='" + Item.index + "' ";
            strForm += " value=''  ";
            strForm += " id='" + Item.index + "'>";
            strForm += "分段预提";
            strForm += "</li>";
        }
    }
    strForm += "</ul>";
    strForm += "<table id=" + strTableP050602 + "></table>";
    strForm += "</br>";
    $("#" + strDivP050602 + "_divform").append(strForm);

    //数量金额
    $("#slje", "#" + strDivP050602).combobox({
        width: _iWidth150,
        listWidth: _iWidth150,
        textField: "mc",
        valueField: "dm",
        editable: false,
        onChange: function (newValue, oldValue) {
            dataChangeStateP050602(true);
        },
        onSelect: function (Record) {
            if (Record.dm != undefined) {
                //RulesList.Type = Record.dm;
                objRecordsP050602.Records = [];
                //RulesList.Rules = [];
                strRecordsCountP050602 = 5;
                reLoadTable();
            }
        },
        enterDown: function () {
            //RulesList.Type = $("#slje", "#" + strDivP050602).combobox("getValue") ;
            objRecordsP050602.Records = [];
            //RulesList.Rules = [];
            strRecordsCountP050602 = 5;
            reLoadTable();
        }
    });
    objSlje[RulesList.Type].selected = true;
    $("#slje", "#" + strDivP050602).combobox('loadData', objSlje);

    //表格对象
    var objTable = $("#" + strTableP050602);

    //修改的时候，如果规则是按数量，
    //预提对象选择按销售回款的问题。
    if ((strOptrTypeP050602 == "3" || strOptrTypeP050602 == "4") && $("#ytfs", "#" + strDivP050601).combobox("getValue") == "1" && RulesList.Type != "1") {

        $("#slje", "#" + strDivP050602).combobox("setValue", "1");
        $("#slje", "#" + strDivP050602).combobox('disable');

    }

    //加载列配置，0是数量1是金额
    if ($("#slje", "#" + strDivP050602).combobox('getValue') == "0") {
        config.colNames[0] = "大于";
        config.colNames[1] = "数量";
        config.colNames[2] = "小于";
        config.colNames[3] = "数量";
        config.colNames[4] = "预提金额（元/单位）";
    }
    else {
        config.colNames[0] = "大于";
        config.colNames[1] = "金额（元）";
        config.colNames[2] = "小于";
        config.colNames[3] = "金额（元）";
        config.colNames[4] = "预提比例（%）";
    }

    //创建表格，设定高度
    createGridP050602(strTableP050602, config.colNames, config.colModel);
    $("#" + strTableP050602).setGridHeight(141);

    //加载表格属性
    objTable.setColProp("dy", { formatter: formatterP050602Dy });
    objTable.setColProp("xy", { formatter: formatterP050602Xy });

    if ($("#slje", "#" + strDivP050602).combobox('getValue') == "0") {
        objTable.setColProp("start", { formatter: formatterP050602Count });
        objTable.setColProp("ytbl", { formatter: formatterP050602Money });
        objTable.setColProp("end", { formatter: formatterP050602Count });
    }
    else {
        objTable.setColProp("start", { formatter: formatterP050602Money });
        objTable.setColProp("end", { formatter: formatterP050602Money });
        objTable.setColProp("ytbl", { formatter: formatterP050602Rate });
        objTable.setColProp("ytbl", { unformat: unFormatterP050602Rate });
    }

    //加载表格事件
    objTable.setGridParam({ afterEditCell: afterEditCell_P050602 });
    objTable.setGridParam({ afterSaveCell: afterSaveCell_P050602 });

    //根据标志位取不同的信息
    switch (strOptrTypeP050602) {

        case "1":
        case "2":
            //从管理画面中进来，该条数据没产生单据
        case "3":
            //修改的时候，该条数据没产生单据
            break;
        case "4":
            //修改的时候，该条数据产生单据
            //$("#slje", "#" + strDivP050602).combobox('disable');
            //$("#celj", "#" + strDivP050602).attr("disabled", false);
            break;
        case "5":
            //查看的时候不能编辑
            objTable.setColProp("start", { editable: false });
            objTable.setColProp("end", { editable: false });
            objTable.setColProp("ytbl", { editable: false });
            $("#slje", "#" + strDivP050602).combobox('disable');
            $("#celj", "#" + strDivP050602).attr("disabled", true);
            break;
        case "6":
            //管理画面中进来，该条数据产生单据了
            // $("#slje", "#" + strDivP050602).combobox('disable');
            //$("#celj", "#" + strDivP050602).attr("disabled", true);
            break;
        default:

    }

    //加载数据，空行
    if (objRecordsP050602.Records == "{}") {
        objRecordsP050602.Records = [];
    }

    if ((strOptrTypeP050602 == "3" || strOptrTypeP050602 == "4") && $("#ytfs", "#" + strDivP050601).combobox("getValue") == "1" && RulesList.Type != "1") {
        strRecordsCountP050602 = 5;
    }
    else {

        //加载数据
        loadTreeData(strTableP050602, objRecordsP050602.Records);

        //判断记录数
        strRecordsCountP050602 = objRecordsP050602.Records.length > 5 ? objRecordsP050602.Records.length : (5 - objRecordsP050602.Records.length);

        //数量金额状态
        if (strOptrTypeP050602 != "5" && strOptrTypeP050602 != "6" && strOptrTypeP050602 != "2" && $("#ytfs", "#" + strDivP050601).combobox('getValue') == "1") {
            $("#slje", "#" + strDivP050602).combobox('disable');
        }

        //加载数据
        if (strOptrTypeP050602 != "1") {
            if (objSelRowP0506.celj == "False") {
                $("#celj", "#" + strDivP050602)[0].checked = false;
            }
            else {
                $("#celj", "#" + strDivP050602)[0].checked = true;
            }
        }

        //规则维护画面进来的时候，加载头部信息
        if (RulesList.Rules.length != 0) {
            $("#celj", "#" + strDivP050602)[0].checked = RulesList.CumToTotal;
        }

        //从管理画面中进来
        if (strOptrTypeP050602 == "6" || strOptrTypeP050602 == "2") {
            if (objSelRowP0506.ytfs == "1") {
                $("#slje", "#" + strDivP050602).combobox('disable');
            }
        }

    }

    //添加空行
    if (strRecordsCountP050602 <= 5) {
        addEmptyRowsP050602();
    }

    //除停用外操作列增加删除项
    if (strOptrTypeP050602 != "5") {
        addCzHtmlP050602();
    }

    //给层加状态
    $(":input", $("#" + strDivP050602 + "_divform")).change(function () {
        $("#" + strDivP050602 + "_divform").data("change", true);
    });
    $("#" + strDivP050602 + "_divform").data("change", false);

    //移除多余按钮
    $(".btn02", "#" + strDivP050602).remove();
    $(".btn03 a", "#" + strDivP050602).css("margin-left", "-55");

    //设置层序
    $(".layoutpanel").css("z-index", "50000009");

    //调整表格
    resizeGridScroll(strTableP050602);

    //表格头部新增按钮
    $(".ui-jqgrid-htable th:visible:last").html('<img id="btnAddP050602"  style="cursor:pointer"  title="添加行" src="../../Content/Default/images/edit_add.gif" onclick="addEmptyRowP050602(); "/>');

    //释放内存
    objTable = null;
}

//验证
function checkFormP050602(strDialog, strType) {

    //表格对象
    var objTable = $("#" + strTableP050602);
    objTable.saveCell(iRowP050602, iColP050602);

    //行ID
    var arrIds = objTable.getDataIDs();

    //其他变量定义
    var i = 0;
    var objTr;
    var objNextTr;
    var strMsg;

    //一条数据没有事false
    var IsHasRecord = false;

    if (!$("#slje", "#" + strDivP050602).combobox('getValue')) {
        window.parent.cihoAlert(msg.gz.selSlJeNoEmpty, null, function () { $("#slje", "#" + strDivP050602).combobox("focus"); });
        return;
    }

    //循环表格判断
    for (i = 0; i < arrIds.length; i++) {

        //清除数据
        objNextTr = null;
        objTr = null;

        objTr = objTable.getRowData(arrIds[i]);
        if ((i + 1) < arrIds.length) {
            objNextTr = objTable.getRowData(arrIds[i + 1]);
        }
        var strStart = objTr.start;
        var strEnd = objTr.end;

        //初始值不能为空
        if (strStart == "" && objTr.ytbl != "") {
            if (RulesList.Type == "0") {
                strMsg = msg.other.dnh + (i + 1) + msg.gz.CountNoEmpty;
            }
            else {
                strMsg = msg.other.dnh + (i + 1) + msg.gz.MoneyNoEmpty;
            }
            window.parent.cihoAlert(strMsg);
            return false;
        }

        //比率不能为空
        if (strStart != "" && objTr.ytbl == "") {

            if (RulesList.Type == "0") {
                strMsg = msg.other.dnh + (i + 1) + msg.gz.ytJeNoEmpty;
                window.parent.cihoAlert(strMsg);
            }
            else {
                strMsg = msg.other.dnh + (i + 1) + msg.gz.ytblNoEmpty;
                window.parent.cihoAlert(strMsg);
            }
            return false;
        }

        //如果有数据
        if (strStart != "" && objTr.ytbl != "") {
            IsHasRecord = true;
        }

        //结束值必须大于开始值
        strStart = parseFloat(strStart);
        strEnd = parseFloat(strEnd);
        if (!isNaN(strStart) && !isNaN(strEnd)) {
            if (strEnd <= strStart) {
                strMsg = msg.other.dnh + (i + 1) + msg.other.EndDyStart;
                window.parent.cihoAlert(strMsg);
                return false;
            }
        }

        //下一行的开始必须和上一行的结束相等
        if (objNextTr != null && objNextTr.start != "" && objNextTr.start != objTr.end) {
            strMsg = msg.other.InetrContnu;
            window.parent.cihoAlert(strMsg);
            return false;
        }

    }

    //如果表格中一条单据没有
    if (IsHasRecord == false) {
        window.parent.cihoAlert(msg.gz.gzNoRecord);
        return false;
    }

    //释放内存
    objTable = null;

}

//保存到数据库
function saveToDbP050602(strDialog, strType) {

    //table对象，所有行ID
    var objTable = $("#" + strTableP050602);
    var arrIds = objTable.getDataIDs();

    //行对象
    var objTr;

    //保存数据
    if (strOptrTypeP050602 == "2" || strOptrTypeP050602 == "6") {
        //如果是从管理画面中点击过来的直接存到数据库里

        //组字符串
        var strData = "{";
        strData += "\"gzguid\":\"" + objSelRowP0506.gzguid + "\"";
        strData += ",\"slje\":\"" + $("#slje", "#" + strDivP050602).combobox('getValue') + "\""
        strData += ",\"celj\":\"" + $("#celj", "#" + strDivP050602)[0].checked + "\"";
        strData += ",Records:[";

        //table里的字符串
        for (var i = 0; i < arrIds.length; i++) {
            //每次清空数据
            objTr = null;
            objNextTr = null;

            objTr = objTable.getRowData(arrIds[i]);
            if (objTr.start == "" || objTr.ytbl == "") {
                continue;
            }

            if (i != 0) {
                strData += ",";
            }

            strData += "{";
            strData += "\"start\":\"" + objTr.start + "\"";
            if (objTr != undefined && objTr.end != "") {
                strData += ",\"end\":\"" + objTr.end + "\"";
            }
            else {
                strData += ",\"end\":\"-1\"";
            }
            strData += ",\"ytbl\":\"" + objTr.ytbl + "\"";
            strData += "}";
        }
        strData += "]";
        strData += "}";

        //保存数据
        var objResult = ParseData(window.external.DoOptions(strTableP050602, "Edit", strData));

        //保存失败弹出提示
        if (objResult.ReturnCode != "0") {
            window.parent.cihoAlert(objResult.MSG);
            return;
        }

        //重新加载数据
        searchDataClickP0506("id", "desc");
    }
    else {
        //转化格式存到全局变量里面
        RulesList.Rules = [];
        RulesList.Type = $("#slje", "#" + strDivP050602).combobox('getValue');
        RulesList.CumToTotal = $("#celj", "#" + strDivP050602)[0].checked;
        for (var i = 0; i < arrIds.length; i++) {

            objTr = objTable.getRowData(arrIds[i]);
            var Rules = { sData: "", eData: "", rate: "" };
            if (objTr.start == "" || objTr.ytbl == "") {
                continue;
            }

            Rules.sData = objTr.start;

            if (objTr.end == "") {
                Rules.eData = "-1";
            }
            else {
                Rules.eData = objTr.end;
            }

            Rules.rate = objTr.ytbl;
            RulesList.Rules.push(Rules);

        }
    }

    cihoDlgClose(strDialog);
    $("#" + strDivP050602 + "_divform").data("change", false);

    //释放内存
    strRecordsCountP050602 = null;
    objTable = null;
}

//保存数据
function saveDataP050602(strDialog, strType) {

    //验证
    if (checkFormP050602(strDialog, strType) == false) {
        return;
    }

    //保存到数据库里
    saveToDbP050602(strDialog, strType);
}

//删除行数据
function deleteDataP050602(rowId) {
    try {
        //table对象
        var objTable = $("#" + strTableP050602);

        //保存时取消单元格编辑
        objTable.saveCell(iRowP050602, iColP050602);

        //删除
        objTable.delRowData(rowId);

        //设置滚动条
        resizeGridScroll(strTableP050602);

        $("#" + strDivP050602 + "_divform").data("change", true);

        //释放内存
        objTable = null;
    }
    catch (e) {
        proceError("P050602", e.ToString());
    }
}

