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

<!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() {

            //调用asp.net验证控件自带的js数据验证脚本对控件进行验证；
            var validationResult = Page_ClientValidate('');
            if (!validationResult) {
                return;
            }
            
            /*
            var donateType = $("#ddlDonateType").val();
            if (donateType == "1") { //自由赠送
                $("#tr_BizNo").hide();
            }
            else if (donateType == "2" || donateType == "3") {
                var bizNo = $("#txtBizNo").val();
                if ($.trim(bizNo) == "") {
                    JTongAlert('提示', '当赠送类型为‘充值赠送’或‘消费赠送’时，业务单号不能为空！', 'info');
                    return;
                }
            }
            */
            
            JTongAlertConfirm("确定赠送吗？", add);
        }

        function add() {

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

        function doAfterAdd(actResult, bizNo) {
            if (actResult) {

                if ($("#ckbNotify")[0].checked == true) {
                    ajaxExecute("get", "../notification/biztransaction_notify.aspx", { "biztype": "donatepoint", "bizno": bizNo });
                }

                resetPage();
            }
        }

        //显示操作结果；
        function showActResult(sMsg, actResult, callback, bizNo) {

            $("#btnSubmit").attr("disabled", "disabled");

            var icon = "info";
            if (!actResult) {
                icon = "error";
            }

            JTongAlert('操作结果', sMsg, icon, function () {
                if (callback != null && callback != undefined) {
                    callback(actResult, bizNo);
                }
            });
        }

        function resetPage() {

            $("#txtDonatePoints").val("");
            $("#txtBizNo").val("");        
            $("#txtRemark").val("");
            $("#ddlDonateType").focus();
        }

        function setControls() {
        
            var donateType = $("#ddlDonateType").val();
            if (donateType == "1") { //自由赠送
                $("#tr_BizNo").hide();
            } 
            else if (donateType == "2") { //充值赠送
                $("#tr_BizNo").show();
            }
            else if (donateType == "3") { //消费赠送
                $("#tr_BizNo").show();
            }
        }

        function browseBizNoList() {
            var donateType = $("#ddlDonateType").val();
            if (donateType == "2" ){ //充值赠送
                browseWalletChargeList();
            }
            else if (donateType == "3") { //消费赠送
                browseMemberConsumeList();
            }
        }

        //充值记录；
        function browseWalletChargeList() {
            $('#winBizNoList').css("display", "block");
            $('#winBizNoList').window({
                width: 750,
                height: 419,
                modal: true,
                minimizable: false,
                collapsible: false,
                title: '充值记录'
            });    
            $('#winBizNoList').html("<iframe src='../datasrc/get_walletcharge_list.aspx' style='width:100%;height:100%;border:0px;margin:0px;padding:0px;'  ></iframe>");
        }
        //从弹窗窗口中获取充值业务流水号，并关闭弹出窗口
        function takeWalletChargeInfo(bizNo) {
            $("#winBizNoList").window("close", true);
            $("#txtBizNo").val(bizNo);
        }

        //消费记录；
        function browseMemberConsumeList() {
            $('#winBizNoList').css("display", "block");
            $('#winBizNoList').window({
                width: 830,
                height: 419,
                modal: true,
                minimizable: false,
                collapsible: false,
                title: '消费收银记录'
            });
            $('#winBizNoList').html("<iframe src='../datasrc/get_charge_list.aspx' style='width:100%;height:100%;border:0px;margin:0px;padding:0px;'  ></iframe>");
        }
        //从弹窗窗口中获取消费业务流水号，并关闭弹出窗口
        function takeConsumeInfo(bizNo) {
            $("#winBizNoList").window("close", true);
            $("#txtBizNo").val(bizNo);
        }

        $(function () {

            /*
            $("#ddlDonateType").focus();
            $("#ddlDonateType").change(function () {
                $("#txtBizNo").val("");
                setControls();
            });

            setControls();
            */
        });


        //会员信息加载成功时调用的方法；            
        function doWhenMemberInfoLoadSuc(memberInfo) {

            $("#txtDonatePoints").removeAttr("disabled");
            $("#txtRemark").removeAttr("disabled");
            $("#btnSubmit").removeAttr("disabled");

            $("#txtDonatePoints").focus();
        }

        //会员信息加载失败时调用的方法；
        function doWhenMemberInfoLoadFail() {

        }

        function resetPage() {

            $("#txtDonatePoints").val("");
            $("#txtRemark").val("");

            $("#txtDonatePoints").attr("disabled", "disabled");
            $("#txtRemark").attr("disabled", "disabled");
            $("#btnSubmit").attr("disabled", "disabled");

            clearMemberInfo();
        }

        $(function () {
            if ($("#hfMemberID").val() == "") {
                $("#txtDonatePoints").attr("disabled", "disabled");
                $("#txtRemark").attr("disabled", "disabled");
                $("#btnSubmit").attr("disabled", "disabled");
            }

            //焦点控制；
            $("input").keydown(function (event) {
                if (event.keyCode == 13) {
                    var targetID = event.target.id;
                    switch (targetID) {
                        case "txtDonatePoints":
                            if ($("#txtDonatePoints").val() != "") {
                                $("#txtRemark").select();
                            }
                            break;
                        case "txtRemark":
                            save();
                            break;
                        default:
                            break;
                    }
                    return false;
                }
            });
        });

    </script>

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

<div id="wrapper" style="height:1%;overflow:hidden;">

<div class="editPageWrapper" style="width:700px;float:left;">

<div class="centerFormTitle">
   <h1><asp:Label ID="lblFormTitle" runat="server">积分赠送</asp:Label></h1>
</div>


<!--#include file="../include/memberinfo.aspx"--> 

<table cellspacing="0" cellpadding="3" class="editTable" style="margin-top:-1px;">
<%--<tr>
<td class="th">(<span class="note mustfill">*</span>)赠送类型：</td>
<td>
    <asp:DropDownList ID="ddlDonateType" runat="server" EnableViewState="false">
    </asp:DropDownList>      
</td>
</tr>
<tr id="tr_BizNo">
<td class="th">(<span class="note mustfill">*</span>)业务单号：</td>
<td>
    <VACTL:TextBox ID="txtBizNo" Runat="server"
            EnableViewState="False"
            CssClass="input"
            Width="100px"
            MaxLength="50" />  
    <input type="button" id="Button1" class="simpleBtn" onclick="browseBizNoList()" value="浏览" />    
</td>
</tr>
--%>
<tr>
<td class="th" colspan="2" style="font-weight:bold;text-align:left;">积分赠送信息</td>
</tr>
<tr>
<td class="th">当前日期：</td>
<td>    
	<% = DateTime.Now %>
</td>
</tr>
<tr>
<td class="th">操作员：</td>
<td>    
	<% = base.EmployeeName %>
</td>
</tr>
<tr>
<td class="th">(<span class="note mustfill">*</span>)赠送积分：</td>
<td>
    <VACTL:TextBox ID="txtDonatePoints" Runat="server"
            EnableViewState="False"
            CssClass="input"
            Width="100px"
            CanBeNull="No"
            RequiredFieldType="PositiveInteger"
            FieldName="赠送积分"
            MaxLength="10" />
</td>
</tr>
<tr>
<td class="th">备注：</td>
<td>    
    <VACTL:TextBox ID="txtRemark" Runat="server"
        EnableViewState="False"
        CssClass="input"
        Width="300px"
        CanBeNull="Yes"
        FieldName="备注"
        MaxLength="100"     
        />        
    <span class="note">请填写赠送积分的原因；</span>
</td>
</tr>
</table>

<table cellspacing="0" cellpadding="3" class="editTable" style="margin-top:-1px;">
<tr>
<td class="footer">

    <asp:CheckBox ID="ckbNotify" runat="server"
             Text="短信通知" />      

    <input type="button" id="btnSubmit" class="btn" style="width:100px" onclick="save()" value="赠送" />
    <input type="button" id="btnResetPage" class="btn" style="width:100px" onclick="resetPage()" value="重置" />    

    <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-->

</div><!--"wrapper.END"-->

<!--业务记录窗口-->
<div id="winBizNoList" style="display:none;"></div> 

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

