<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="chargeitem_category_edit.aspx.cs" Inherits="VA.Modules.JDingMember.goods.chargeitem_category_edit" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <!--#include virtual="/include/css/edit.aspx"-->
    <!--#include virtual="/include/js/edit.aspx"-->     
    <script type="text/javascript">
    function save(flag) {

        //调用asp.net验证控件自带的js数据验证脚本对控件进行验证；
        var validationResult = Page_ClientValidate('');
        if (!validationResult) {
            return;
        }

        var flag = "0";
        if ($("#hfKey").val() != "") {
            flag = "1";
        }

        if (flag == 0) {
            add();
        }
        else {
            update();
        }
    }

    function add() {
        var requestType = "POST";
        var url = pageName + "?act=add";  //pageName在BasePage中注册到的客户端；
        var dataType = "html";
        var data = $("form").eq(0).serialize();
        var successFN = function (data, textStatus) {
            if (data == "ok") {
                showActResult("添加成功！", true, doAfterAdd);
            } else if (data.indexOf("01|") != -1) {
                showActResult(data.substring(3), false, doAfterAdd);
            }
            else {
                showActResult("添加失败：" + data, false, doAfterAdd);
            }
        };
        ajaxRequest(requestType,
            url,
            dataType,
            data,
            successFN,
            errorFN
            );
    }

    function update() {
        var requestType = "POST";
        var url = pageName + "?act=update";
        var dataType = "html";
        var data = $("form").eq(0).serialize();
        var successFN = function (data, textStatus) {
            if (data == "ok") {
                showActResult("修改成功！", true, doAfterUpdate);
            } else if (data.indexOf("01|") != -1) {
                showActResult(data.substring(3), false, doAfterUpdate);
            }
            else {
                showActResult("修改失败：" + data, false, doAfterUpdate);
            }
        };
        ajaxRequest(requestType,
            url,
            dataType,
            data,
            successFN,
            errorFN
            );
    }

    function doAfterAdd(actResult) {
        if (actResult) {
            if (window.parent != window.self) {
                window.parent.completeReload();
            }
            resetPage();
        }
    }
    function doAfterUpdate(actResult) {
        if (actResult) {
            if (window.parent != window.self) {
                window.parent.closeFrameWindow();
                window.parent.completeReload();
            }
        }
    }

    //显示操作结果；
    function showActResult(sMsg, actResult, callback) {
        JTongModalAlert(sMsg);
        if (callback != null && callback != undefined) {
            callback(actResult);
        }
    }

    function resetPage() {

        $("#txtCategoryCode").val("");
        $("#txtCategoryName").val("");
        clearInputValidatorError();
        $("#txtCategoryCode").focus("");
    }

    $(function () {
        $("#txtCategoryCode").focus();

        $("#txtCategoryCode").keydown(function (event) {
            var keyCode = event.keyCode;
            if (keyCode == 13) {
                $("#txtCategoryName").select();
            }
        });
        $("#txtCategoryName").keydown(function (event) {
            var keyCode = event.keyCode;
            if (keyCode == 13) {
                save();
                return false;  //当页面上只有一个文本框控件时，敲击回车后要return false一下，否则会促发postback。
            }
        });
    });

    </script>
</head>
<body>
<form id="Form1" method="post" runat="server">

<div class="editPageWrapper" style="width:500px;">

<%--<div class="centerFormTitle">
   <h1>会员登记</h1>
</div>
--%>
<table cellspacing="0" cellpadding="3" class="editTable">
<tr id="trEditResult" runat="server" visible="false">
<td colspan="2" style="text-align:center;">
    <div class="editResult">
    <asp:Literal id="litEditResult" runat="server" />
    </div>
</td>
</tr>
<tr>
<td class="th">(<span class="note mustfill">*</span>)分类代码：</td>
<td>              
    <VACTL:TextBox ID="txtCategoryCode" Runat="server"
            EnableViewState="False"
            CssClass="input"
            Width="200px"
            CanBeNull="No"
            FieldName="分类代码"
            MaxLength="25" /> <span class="note">注：创建后不可修改。</span>
</td>
</tr>
<tr>
<td class="th">(<span class="note mustfill">*</span>)分类名称：</td>
<td>              
    <VACTL:TextBox ID="txtCategoryName" Runat="server"
            EnableViewState="False"
            CssClass="input"
            Width="200px"
            CanBeNull="No"
            FieldName="分类名称"
            MaxLength="25" />        
    
    <% if (base.flag == 0) { %>
    <input type="button" id="btnSubmit" class="btn" style="width:100px" onclick="save()" value="保存" />
  <%--  <input type="button" id="btnClear" class="btn" style="width:100px" onclick="resetPage()" value="重置" />--%>
    <% } else { %>
    <input type="button" id="btnSubmit" class="btn" style="width:100px" onclick="save()" value="保存" />
    <% } %>    
    
    <asp:HiddenField ID="hfKey" runat="server" />
    
    <VACTL:Hint ID="Hint1" runat="server" HintImageUrl="/app_themes/default/images/textbox" />
    <VACTL:ValidationSummary ID="ValidationSummary1" runat="server"
            DisplayMode="List"
            EnableClientScript="true" />
    
    <!--注意：这个文件一定要放到页面底部，以便覆盖asp.net验证脚本中的同名函数-->
    <script type="text/javascript" src="/scripts/utils/aspnet_validator_extend.js"></script>
</td>

</tr>
</table>

</div><!--editPageWrapper.END-->

</form>
</body>
</html>

