/// <reference path="jquery-1.10.2.min.js" />
var editor;
$(function () {
    editor = CKEDITOR.replace('Data_body',
{
    filebrowserImageUploadUrl: "/ajax/Admin_AjaxUpImage.ashx?cmd=uploadImage"
});
    $("#Data_Btn").click(function (e) {
        e.preventDefault();
        var data_name = $.trim($("#Data_title").val());
        var data_simple = $.trim($("#Data_Simple").val());
        var data_cate = $.trim($("#Data_cate").children("option:selected").val());
        var data_have = $.trim($("#Data_have").children("option:selected").val());
        var Url_pic = $.trim($("#img").attr("src"));
        var data_size = $.trim($("#Data_size").val());
        var data_age = $.trim($("#Data_age").val());
        var data_grant = $.trim($("#Data_grant").children("option:selected").val());
        var data_grade = $.trim($("#Data_grade").children("option:selected").val());
        var data_port = $.trim($("#Data_port").val());
        var data_mark = $.trim($("#Data_mark").val());
        var data_popu = $.trim($("#Data_popu").val());
        var data_top = $.trim($("#Data_Top").val());
        var data_tone = $.trim($("#Data_Tone").val());
        var data_rotion = $.trim($("#Data_Rotion").val());
        var pic = $.trim($("#pic").attr("src"));
        var data_jifen = $.trim($("#Data_jifen").val());
        var data_down = $.trim($("#Data_Down").val());
        var data_dianz = $.trim($("#Data_dianz").val());
        var data_negative = $.trim($("#Data_negative").val());
        var data_name1 = $.trim($("#Data_Name1").val());
        var data_down1 = $.trim($("#Data_down1").val());
        var data_name2 = $.trim($("#Data_Name2").val());
        var data_down2 = $.trim($("#Data_down2").val());
        var data_name3 = $.trim($("#Data_Name3").val());
        var data_down3 = $.trim($("#Data_down3").val());
        var data_name4 = $.trim($("#Data_Name4").val());
        var data_down4 = $.trim($("#Data_down4").val());
        var text = editor.getData();
        if (data_name == "") {
            alert("数据名称不能为空");
            return;
        }
        if (data_cate == "") {
            alert("分类不能为空");
            return;

        } if (data_simple == "") {
            alert("数据简称不能为空");
            return;
        } if (text == "") {
            alert("数据内容不能为空");
            return;
        }

        else {
            $.post("/ajax/Admin_DateBase.ashx", { "type": 6, "data_name": data_name, "data_cate": data_cate, "data_size": data_size, "Url_pic": Url_pic, "data_age": data_age, "data_grant": data_grant, "data_port": data_port, "data_mark": data_mark, "data_popu": data_popu, "data_jifen": data_jifen, "data_down": data_down, "data_dianz": data_dianz, "data_name1": data_name1, "data_down1": data_down1, "data_name2": data_name2, "data_down2": data_down2, "data_name3": data_name3, "data_down3": data_down3, "data_name4": data_name4, "data_down4": data_down4, "text": text, "data_negative": data_negative, "data_grade": data_grade, "data_simple": data_simple, "data_have": data_have, "data_top": data_top, "data_tone": data_tone, "data_rotion": data_rotion, "pic": pic }, function (data) {
                var data = eval('(' + data + ')');
                if (data.Success = true) {
                    alert("添加成功");
                    window.location.href = "./Admin_DataList.aspx";
                } else {
                    alert("添加失败");
                }

            })




        }
    })

    $("#Data_Edit_Btn").click(function (e) {
        e.preventDefault();
        var id = $.trim($("#userid").val());
        var data_edit_id = $.trim($("#Data_Edit_Id").val())
        var data_edit_name = $.trim($("#Data_Edit_title").val());
        var data_edit_simple = $.trim($("#Data_Edit_Simple").val());
        var data_edit_cate = $.trim($("#Data_Edit_cate").children("option:selected").val());
        var data_edit_have = $.trim($("#Data_Edit_have").children("option:selected").val());
        var data_edit_cate1 = $.trim($("#Data_Edit_cate1").children("option:selected").val());
        var Url_pic = $.trim($("#img").attr("src"));
        var data_edit_size = $.trim($("#Data_Edit_size").val());
        var data_edit_age = $.trim($("#Data_Edit_age").val());
        var data_edit_ju = $.trim($("#Data_Edit_Ju").val());
        var data_edit_grant = $.trim($("#Data_Edit_grant").children("option:selected").val());
        var data_edit_grade = $.trim($("#Data_Edit_grade").children("option:selected").val());
        var data_edit_port = $.trim($("#Data_Edit_port").val());
        var data_edit_mark = $.trim($("#Data_Edit_mark").val());
        var data_edit_popu = $.trim($("#Data_Edit_popu").val());
        var data_edit_jifen = $.trim($("#Data_Edit_jifen").val());
        var data_edit_down = $.trim($("#Data_Edit_Down").val());
        var data_edit_dianz = $.trim($("#Data_Edit_dianz").val());
        var data_edit_negative = $.trim($("#Data_Edit_negative").val());
        var data_edit_status = $.trim($("#Data_Edit_Status").children("option:selected").val());
        var data_edit_top = $.trim($("#Data_Edit_Top").val());
        var data_edit_tone = $.trim($("#Data_Edit_Tone").val());
        var data_edit_rotion = $.trim($("#Data_Edit_Rotion").val());
        var pic = $.trim($("#pic").attr("src"));
        var pvc = $.trim($("#imgSelfu").attr("src"));
        var ppc = $.trim($("#imgSelfs").attr("src"));
        var date_edit_name1 = $.trim($("#Data_Edit_Name1").val());
        var data_edit_down1 = $.trim($("#Data_Edit_down1").val());
        var data_edit_name2 = $.trim($("#Data_Edit_Name2").val());
        var data_edit_down2 = $.trim($("#Data_Edit_down2").val());
        var data_edit_name3 = $.trim($("#Data_Edit_Name3").val());
        var data_edit_down3 = $.trim($("#Data_Edit_down3").val());
        var data_edit_name4 = $.trim($("#Data_Edit_Name4").val());
        var data_edit_down4 = $.trim($("#Data_Edit_down4").val());
        var text = editor.getData();
        if (data_edit_name == "") {
            alert("数据名称不能为空")
            return;
        } if (data_edit_cate == "") {
            alert("数据分类不能为空")
            return;
        } if (data_edit_simple == "") {
            alert("数据简称不能为空");
            return;
        }
        if (text == "") {
            alert("数据内容不能为空")
            return;
        } else {
            $.post("/ajax/Admin_DateBase.ashx", { "type": 8,"id":id, "data_edit_id": data_edit_id, "Url_pic": Url_pic, "data_edit_name": data_edit_name, "data_edit_cate1": data_edit_cate1, "data_edit_cate": data_edit_cate, "data_edit_size": data_edit_size, "data_edit_age": data_edit_age, "data_edit_grant": data_edit_grant, "data_edit_port": data_edit_port, "data_edit_mark": data_edit_mark, "data_edit_popu": data_edit_popu, "data_edit_jifen": data_edit_jifen, "data_edit_down": data_edit_down, "data_edit_dianz": data_edit_dianz, "data_edit_status": data_edit_status, "date_edit_name1": date_edit_name1, "data_edit_down1": data_edit_down1, "data_edit_name2": data_edit_name2, "data_edit_down2": data_edit_down2, "data_edit_name3": data_edit_name3, "data_edit_down3": data_edit_down3, "data_edit_name4": data_edit_name4, "data_edit_down4": data_edit_down4, "text": text, "data_edit_ju": data_edit_ju, "data_edit_grade": data_edit_grade, "data_edit_negative": data_edit_negative, "data_edit_simple": data_edit_simple, "data_edit_have": data_edit_have, "data_edit_top": data_edit_top, "data_edit_tone": data_edit_tone, "data_edit_rotion": data_edit_rotion,"pic":pic,"pvc":pvc,"ppc":ppc }, function (data) {
                var data = eval('(' + data + ')');
                if(data.Success=true){
                
                    alert("修改成功");
                    window.location.href = "./Admin_DataList.aspx";
                }else{
                
                    alert("修改失败");
                
                }

            })
        }
    })

    $("#Data_update_Btn").click(function (e) {
        e.preventDefault();
        var data_update_id = $.trim($("#Data_update_Id").val())
        var data_update_name = $.trim($("#Data_update_title").val());
        var data_update_simple = $.trim($("#Data_update_Simple").val());
        var data_update_cate = $.trim($("#Data_update_cate").children("option:selected").val());
        var data_update_have = $.trim($("#Data_update_have").children("option:selected").val());
        var data_update_cate1 = $.trim($("#Data_update_cate1").children("option:selected").val());
        var Url_pic = $.trim($("#img").attr("src"));
        var data_update_size = $.trim($("#Data_update_size").val());
        var data_update_age = $.trim($("#Data_update_age").val());
        var data_update_ju = $.trim($("#Data_update_Ju").val());
        var data_update_grant = $.trim($("#Data_update_grant").children("option:selected").val());
        var data_update_grade = $.trim($("#Data_update_grade").children("option:selected").val());
        var data_update_port = $.trim($("#Data_update_port").val());
        var data_update_mark = $.trim($("#Data_update_mark").val());
        var data_update_popu = $.trim($("#Data_update_popu").val());
        var data_update_jifen = $.trim($("#Data_update_jifen").val());
        var data_update_down = $.trim($("#Data_update_Down").val());
        var data_update_dianz = $.trim($("#Data_update_dianz").val());
        var data_update_negative = $.trim($("#Data_update_negative").val());
        var data_update_status = $.trim($("#Data_update_Status").children("option:selected").val());
        var data_update_top = $.trim($("#Data_update_Top").val());
        var data_update_tone = $.trim($("#Data_update_Tone").val());
        var data_update_rotion = $.trim($("#Data_update_Rotion").val());
        var pic = $.trim($("#pic").attr("src"));
        var pvc = $.trim($("#imgSelfu").attr("src"));
        var ppc = $.trim($("#imgSelfs").attr("src"));
        var date_update_name1 = $.trim($("#Data_update_Name1").val());
        var data_update_down1 = $.trim($("#Data_update_down1").val());
        var data_update_name2 = $.trim($("#Data_update_Name2").val());
        var data_update_down2 = $.trim($("#Data_update_down2").val());
        var data_update_name3 = $.trim($("#Data_update_Name3").val());
        var data_update_down3 = $.trim($("#Data_update_down3").val());
        var data_update_name4 = $.trim($("#Data_update_Name4").val());
        var data_update_down4 = $.trim($("#Data_update_down4").val());
        var text = editor.getData();
        if (data_update_name == "") {
            alert("数据名称不能为空")
            return;
        } if (data_update_cate == "") {
            alert("数据分类不能为空")
            return;
        } if (data_update_simple == "") {
            alert("数据简称不能为空");
            return;
        }
        if (text == "") {
            alert("数据内容不能为空")
            return;
        } else {
            $.post("/ajax/Admin_DateBase.ashx", { "type": "DataUpdate", "data_update_id": data_update_id, "Url_pic": Url_pic, "data_update_name": data_update_name, "data_update_cate1": data_update_cate1, "data_update_cate": data_update_cate, "data_update_size": data_update_size, "data_update_age": data_update_age, "data_update_grant": data_update_grant, "data_update_port": data_update_port, "data_update_mark": data_update_mark, "data_update_popu": data_update_popu, "data_update_jifen": data_update_jifen, "data_update_down": data_update_down, "data_update_dianz": data_update_dianz, "data_update_status": data_update_status, "date_update_name1": date_update_name1, "data_update_down1": data_update_down1, "data_update_name2": data_update_name2, "data_update_down2": data_update_down2, "data_update_name3": data_update_name3, "data_update_down3": data_update_down3, "data_update_name4": data_update_name4, "data_update_down4": data_update_down4, "text": text, "data_update_ju": data_update_ju, "data_update_grade": data_update_grade, "data_update_negative": data_update_negative, "data_update_simple": data_update_simple, "data_update_have": data_update_have, "data_update_top": data_update_top, "data_update_tone": data_update_tone, "data_update_rotion": data_update_rotion, "pic": pic, "pvc": pvc, "ppc": ppc }, function (data) {
                var data = eval('(' + data + ')');
                if (data.Success == true) {

                    alert("数据更新成功");
                    window.location.href = "./Admin_DataList.aspx";
                    return;
                }if (data.Success == false) {
                    alert("对不起，版本号一致，请更新最新版本");
                } else {
                    alert("更新失败");
                    return;
                }

            })




        }
    })













})
$(function () {
    $("#Data_Rotion,#Data_Edit_Rotion,#Data_update_Rotion").on("change", function () {
        if ($(this).val() == "1") {
            $("#Data_Rtionst").show();
        } else {
            $("#Data_Rtionst").hide();

        }

    })
})