@{
    ViewBag.Title = "";
    Layout = "~/Views/Shared/_LayoutTable.cshtml";
}
<style type="text/css">
    table tr td:first-child {
        text-align: right;
        width: 30%;
    }
</style>
<div class="wrapper wrapper-content" style="width: inherit;">
    <div class="ibox float-e-margins" style="width:inherit;">
        <table class="table table-bordered table-striped table-hover">
            <tr>
                <td>代理商编号</td>
                <td>
                    <input type="text"  id="usercode"   style="width: 400px">
                </td>
            </tr>
            <tr>
                <td>公司名称</td>
                <td>
                    <input type="text"  id="userfullname"   style="width: 400px">
                </td>
            </tr>
            <tr>
                <td>联系人</td>
                <td>
                    <input type="text" id="person"   style="width: 400px">
                </td>
            </tr>
            <tr>
                <td>联系电话</td>
                <td>
                    <input type="text"  id="persontel"   style="width: 400px">
                </td>
            </tr>
            <tr>
                <td>用户数</td>
                <td>
                    <select   name="zcnum" style="width: 200px" id="zcnum">
                        <option value="30">30</option>
                        <option value="50">50</option>
                        <option value="100">100</option>
                        <option value="200">200</option>
                        <option value="500">500</option>
                        <option value="1000">1000</option>
                        <option value="1500">1500</option>
                        <option value="2000">2000</option>
                        <option value="0">无限</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>类型</td>
                <td>
                    <select   name="zctype" id="zctype" style="width: 200px">
                        <option value="0001000001">增加</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>付费方式</td>
                <td>
                    <select   name="regtype" id="regtype" style="width: 200px">
                        <option value="0000200007">买断</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>省份</td>
                <td>
                    <select   name="Province" id="Province" style="width:160px;float:left">
                        <option>—请选择—</option>
                    </select>
                    <select   name="City" id="City" style="width:160px;float:left">
                        <option>—请选择—</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>管家婆版本</td>
                <td>
                    &nbsp;&nbsp;
                    <input type="radio" value="HYFZ" name="radios" id="banbenfz" />服装系列
                    <input type="radio" value="TYHH" name="radios" id="banbenhh" />辉煌系列
                    <input type="radio" value="TYFX" name="radios" id="banbenfx" />分销系列
                    <input type="radio" value="TYCM" name="radios" id="banbencm" />财贸系列
                    <input type="radio" value="HYSP" name="radios" id="banbensp" />食品系列
                    <input type="radio" value="HYQF" name="radios" id="banbenqf" />千方系列
                </td>
            </tr>
            <tr>

                <td></td>
                <td>
                    <button id="btnSave" class="btn btn-default">提交</button>&nbsp;&nbsp;&nbsp;
                    <button id="btnActivation" class="btn btn-default">激活</button>
                </td>
            </tr>
        </table>
    </div>
</div>
<script type="text/javascript">
        //保存按钮
        $("#btnSave").click(function () {
            //是否拍照
            var chkObjs = null;
            var obj = document.getElementsByName("radios")
            for (var i = 0; i < obj.length; i++) { //遍历Radio
                if (obj[i].checked) {
                    chkObjs = obj[i].value;
                }
            }
            $.ajax({
                url: "../DealerEdition/SaveRegSoftware",
                dataType: "text",
                data: {
                    usercode: $("#usercode").val(),
                    userfullname: $("#userfullname").val(),
                    person: $("#person").val(),
                    persontel: $("#persontel").val(),
                    zcnum: $("#zcnum").val(),
                    zctype: $("#zctype").val(), //注册类型
                    regtype: $("#regtype").val(), //付费方式
                    province: $("#Province").val(),
                    city: $("#City").val(),
                    chkObjs: chkObjs
                },
                type: "post",
                success: function (data) {
                    //新增或修改成功后刷新table
                    parent.layer.msg(data, { icon: 1, time: 2000 });
                    parent.$('#RegisteTable').bootstrapTable("refresh");
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                },
                error: function (data) {
                    layer.msg(data, { icon: 2, time: 2000 });
                }
            })
        })
        //激活按钮
        $("#btnActivation").click(function () {
            //是否拍照
            var chkObjs = null;
            var obj = document.getElementsByName("radios")
            for (var i = 0; i < obj.length; i++) { //遍历Radio
                if (obj[i].checked) {
                    chkObjs = obj[i].value;
                }
            }
            $.ajax({
                url: "../DealerEdition/jihuosavedata",
                dataType: "text",
                data: {
                    usercode: $("#usercode").val(),
                    userfullname: $("#userfullname").val(),
                    person: $("#person").val(),
                    persontel: $("#persontel").val(),
                    zcnum: $("#zcnum").val(),
                    zctype: $("#zctype").val(), //注册类型
                    regtype: $("#regtype").val(), //付费方式
                    province: $("#Province").val(),
                    city: $("#City").val(),
                    chkObjs: chkObjs
                },
                type: "post",
                success: function (data) {
                    //新增或修改成功后刷新table
                    parent.layer.msg(data, { icon: 1, time: 2000 });
                    parent.$('#RegisteTable').bootstrapTable("refresh");
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                },
                error: function (data) {
                    layer.msg(data, { icon: 2, time: 2000 });
                }
            })
        })
        $(function () {
            $.ajax({
                url: "../DealerEdition/GetProvincelist",
                type: "get",
                datatype: "Json",
                async: false,
                success: function (data) {
                    $.each(data, function (i, item) {
                        $("<option></option>").val(item["PID"]).text(item["ProvinceName"]).appendTo($("#Province"));
                    })
                }
            });
            DataBind();
            $("#Province").change(function () {
                GetCity();
            });
        });
        function DataBind() {
            $.ajax({
                url: "../DealerEdition/GetDealerRegusers",
                type: "post",
                datatype: "Json",
                success: function (data) {
                    if (data != null && data != undefined) {
                        data = JSON.parse(data.substring(1, data.length - 1));
                        $("#usercode").val(data["Cusercode"]);
                        $("#userfullname").val(data["Company"]);
                        $("#person").val(data["Person"]);
                        $("#persontel").val(data["Tel"]);
                        $("#zcnum").val(data["Usercount"]);
                        $("#zctype").val(data["RegisterType"]); //注册类型
                        $("#regtype").val(data["Payfor"]); //付费方式
                        $("#Province").val(data["Sheng"]);
                        $("input[name='radios'][value='" + data["banben"] + "']").attr("checked", true);
                        GetCity();
                        $("#City").val(data["Shi"]);
                     
                    }
                }
            })
        }
        function GetCity() {
            $("#City").empty();
            $.ajax({
                url: "../DealerEdition/GetCitylist",
                data:{
                    pid: $("#Province").val() 
                },
                type: "get",
                datatype: "Json",
                async: false,
                success: function (data) {
                    $.each(data, function (i, item) {
                        $("<option></option>").val(item["Value"]).text(item["Text"]).appendTo($("#City"));
                    })
                }
            });
        }
</script>