<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true"
    CodeBehind="PaymentEdit.aspx.cs" Inherits="OAWeb.Sys.PaymentEdit"  ValidateRequest="false" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlace" runat="server">
    <script src="/js/jquery.form.js" type="text/javascript"></script>
    <script src="/js/jquery.validate.js" type="text/javascript"></script>
    <script src="/js/jquery.validate.extend.js" type="text/javascript"></script>
     <script language="javascript" type="text/javascript" src='<%=ResolveUrl("~/ckeditor/ckeditor.js")%>'></script>
    <style type="text/css">
        .table_form
        {
            background-color: #cccccc;
        }
        .table_form td
        {
            background-color: #ffffff;
            padding: 3px;
        }
        .table_form .right
        {
            background-color: #e2e8eb;
            width: 100px;
        }
    </style>
    <div class="page_main">
        <div class="page_content">
            <table class="data_title" cellspacing="3">
                <tr>
                    <td class="data_caption">
                        添加支付方式
                    </td>
                </tr>
            </table>
            <div class="page_op hide" style="border: solid #cccccc 1px; padding: 6px">
            </div>
            <table cellpadding="0" cellspacing="1" border="0" class="table_form">
                <tr>
                    <td class="right">
                        方式类型：
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlPayType" runat="server">
                            <asp:ListItem Value="0">预存款支付</asp:ListItem>
                            <asp:ListItem Value="1">线下支付</asp:ListItem>
                            <asp:ListItem Value="2">网上支付</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td class="right">
                        支付插件：
                    </td>
                    <td>
                        <asp:DropDownList ID="ddlPluginsCode" runat="server">
                            <asp:ListItem Value="0">请选择支付插件</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td class="right">
                        <span class="red">*</span> 方式名称：
                    </td>
                    <td>
                        <asp:TextBox ID="txtPayName" runat="server" CssClass="text width200"></asp:TextBox>
                    </td>
                </tr>
            </table>
            <div class="div_form hide">
            </div>
            <table cellpadding="0" cellspacing="1" border="0" class="table_form">
                <tr>
                    <td class="right">
                        支付费率：
                    </td>
                    <td>
                        <asp:TextBox ID="txtPayFee" runat="server" CssClass="text width40" Text="0"></asp:TextBox>
                        %
                    </td>
                </tr>
                <tr>
                    <td class="right">
                        排序号：
                    </td>
                    <td>
                        <asp:TextBox ID="txtSortCode" runat="server" CssClass="text width40" Text="1"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="right">
                        描述：
                    </td>
                    <td>
                        <asp:TextBox ID="txtRemark" runat="server" CssClass="text" Width="98%" Height="75px"
                            TextMode="MultiLine"></asp:TextBox>
                        <script type="text/javascript">
                            CKEDITOR.replace('<%=txtRemark.ClientID %>',
                    {
                        skin: 'v2',
                        width: '98%',
                        height: '239',
                        font_names: '宋体/宋体;黑体/黑体;仿宋/仿宋_GB2312;楷体/楷体_GB2312;隶书/隶书;幼圆/幼圆;微软雅黑/微软雅黑;',
                        toolbar: [
                        ['Bold', 'Italic', 'Underline', 'Strike', '-', 'NumberedList', 'BulletedList', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'Link', 'Unlink', 'Anchor', '-', 'Table', 'HorizontalRule', 'SpecialChar'],
                        ['Format', 'Font', 'FontSize', 'TextColor', 'BGColor']
                        ],
                        language: 'zh-cn'
                    })
                   
                        </script>
                    </td>
                </tr>
                <tr>
                    <td class="right">
                    </td>
                    <td>
                        <input id="btnSave" type="button" value=" 保 存 " class="btn_77px" />
                        <input id="btnClose" type="button" value=" 返 回 " onclick="art.dialog.close();return false;"
                            class="btn_77px" /><asp:HiddenField ID="hidPayConfigJSON" runat="server" />
                    </td>
                </tr>
            </table>
        </div>
    </div>
    <script type="text/javascript">
        function GetPluginForm() {
            var selectObj = $("#<%=ddlPluginsCode.ClientID %> option:selected");
            var desc = selectObj.attr("desc");
            var pic = selectObj.attr("p");
            var value = selectObj.val();
            if (value == "0") {
                $(".page_op").html("");
                $(".page_op").hide();
            }
            else {
                if (pic != "") {
                    pic = "<img src='/plugins/payment/" + value + "/" + pic + "' /><br>";
                }
                $(".page_op").html(pic + desc);
                $(".page_op").show();
            }
            $.ajax({
                type: "Get",
                url: "PaymentEdit.aspx",
                async: false,
                data: "op=LoadPluginsForm&code=" + value + "&r=" + Math.random(),
                success: function (data, textStatus) {
                    if (data == null || data == "")
                        $(".div_form").hide()
                    else {
                        $(".div_form").html(data);
                        $(".div_form").show();
                    }
                }
            });
        }
        function setPluginFormValue(jsonString, parentForm) {
            if (jsonString == null || jsonString == "") return;
            var json = eval("(" + jsonString + ")");
            var p = $(parentForm);
            $.each(json, function (n, value) {
                p.find("input[name='" + n + "']").val(value);
                p.find("select[name='" + n + "']").val(value);
            })
        }
        $(document).ready(function () {
            $("#btnSave").click(function () { 
                //把编辑值赋值到实际文本框，编辑器只在有post动作时才把值赋值给实际文本框。
                CKEDITOR.instances.<%=txtRemark.ClientID %>.updateElement(); 
                return FormPostAjax("/Sys/PaymentEdit.aspx?op=Save&Id=<%=Id %>", "ok", function () { window.location.href = 'PaymentList.aspx'; }); 
            })
            $("#<%=ddlPluginsCode.ClientID %>").change(function () {
                GetPluginForm();
            })
            GetPluginForm();
            setPluginFormValue($("#<%=hidPayConfigJSON.ClientID %>").val(), $(".div_form"));
        });
    </script>
</asp:Content>
