<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="customeredit.aspx.cs" Inherits="HySoft.BaseCallCenter.Web.customermanage.customeredit" %>

<!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>
    <script src="../scripts/jquery/jquery-1.3.2.min.js" type="text/javascript"></script>
    <script type="text/javascript" src="../scripts/jquery/jquery.form.js"></script>
    <script type="text/javascript" src="../scripts/jquery/jquery.validate.min.js"></script>
    <script type="text/javascript" src="../scripts/jquery/messages_cn.js"></script>
    <script type="text/javascript" src="../scripts/function.js"></script>
    <link href="../scripts/ui/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <script src="../scripts/ui/json2.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/core/base.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/ligerui.min.js" type="text/javascript"></script>
    <link href="../scripts/ui/skins/Tab/css/tab.css" rel="stylesheet" type="text/css" />
    <link href="../scripts/ui/skins/Tab/css/grid.css" rel="stylesheet" type="text/css" />
    <script src="../scripts/ui/js/plugins/ligerGrid.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/plugins/ligerLayout.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/plugins/ligerTree.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/plugins/ligerMenu.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/plugins/ligerTextBox.js" type="text/javascript"></script>
    <script src="../scripts/ui/js/plugins/ligerComboBox.js" type="text/javascript"></script>
    <link href="../scripts/ui/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
    <link href="../images/style.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        var treelist = null;
        $(function () {
            treelist = $("#drpServiceDept").ligerComboBox({
                width: 130,
                selectBoxWidth: 200,
                selectBoxHeight: 150, valueField: 'id', resize: false, treeLeafOnly: false,
                tree: {
                    url: 'ajax/customeredit.ashx?action=getservicedepttreelist',
                    width: 200,
                    height: 150,
                    checkbox: false,
                    ajaxType: 'get',
                    onSuccess: function (data) { SetTreeValue(); }
                },
                onSelected: function (newvalue) {
                    $("#hiddSeriveDeptId").val(newvalue);
                }
            });
            $("#drpProvince").ligerComboBox({
                url: 'ajax/customeredit.ashx?action=getregionlist',
                valueField: '_f_regionid',
                textField: '_f_regionname',
                autocomplete: true,
                onSelected: function (newvalue) {
                    $("#hiddProvinceId").val(newvalue);
                    $("#drpCity").ligerComboBox({
                        url: 'ajax/customeredit.ashx?action=getregionlist&regionpid=' + newvalue,
                        autocomplete: true,
                        valueField: '_f_regionid',
                        textField: '_f_regionname'
                    });
                }
            });
            $("#drpCity").ligerComboBox({
                data: null,
                valueField: '_f_regionid',
                textField: '_f_regionname',
                autocomplete: true,
                isMultiSelect: false,
                isShowCheckBox: false,
                onSelected: function (newvalue) {
                    $("#hiddCityId").val(newvalue);
                }
            });
            ////BindData("drpProductLine", "hiddProductLineId", "CPXL");
            ////BindData("drpCustomerNature", "hiddCustomerNatureId", "KHSX");
            ////BindData("drpCustomerClass", "hiddCustomerClassId", "KHDJ");
            ////BindData("drpCustomerIndustry", "hiddCustomerIndustryId", "SSHY");
            ////BindData("drpRelationShipClass", "hiddRelationShipClassId", "GXDJ");
            //BindData("txtCustomerStatus", "hiddCustomerStatus", "KHZT");
            //$("#drpAfterSaleName").ligerComboBox({
            //    url: 'ajax/customeredit.ashx?action=getaftersalelist',
            //    valueField: '_f_userid',
            //    textField: '_f_username',
            //    autocomplete: true,
            //    onSelected: function (newvalue) {
            //        $("#hiddAfterSaleNameID").val(newvalue);
            //    }
            //});
            //$("#txtSystemStartTime").ligerDateEditor();
            //$("#txtQualityGuaranteeEndTime").ligerDateEditor();
            LoadList();
        });
        function toDay() {
            var d = new Date();
            var str = d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate();
            return str;
        }
        function BindData(objid, hiddid, param) {
            $("#" + objid).ligerComboBox({
                url: 'ajax/customeredit.ashx?action=getdictionarylist&param=' + param,
                valueField: '_f_dictionaryvalueid',
                textField: '_f_name',
                autocomplete: true,
                onSelected: function (newvalue) {
                    $("#" + hiddid).val(newvalue);
                }
            });
        }
        function SetTreeValue() {
            try {
                treelist.setValue(document.getElementById("hidSeriveDeptParentId").value);
                if (document.getElementById("hidSeriveDeptParentId").value == "" || document.getElementById("hidSeriveDeptParentId").value == "0") {
                    treelist.setText("顶级分类");
                }
            }
            catch (e) {

            }
        }
        var gridlist;
        var singleClick;
        function LoadList() {
            try {
                gridlist = $("#divDataList").ligerGrid({
                    checkbox: false,
                    height: '160',
                    columns: [
                { display: 'Id', name: '_f_manid', hide: '_f_manid',width: '3%'},
                { display: '联系人', name: '_f_name', width: '10%' },
                { display: '性别', name: '_f_sex', width: '7%' },
                { display: '职务', name: '_f_duty',width:'10%' },
                { display: '手机', name: '_f_mobile', width: '10%' },
                { display: '联系电话', name: '_f_telephone', width: '10%' },
                { display: '邮箱', name: '_f_email', width: '10%' },
                { display: 'QQ', name: '_f_qq', width: '10%'},
                { display: '传真', name: '_f_fax', width: '10%'},
                { display: '备注', name: '_f_remark', width: '20%'}
                ],
                    toolbar: {
                        items: [
                    { text: '增加', click: itemclick, icon: 'add' },
                    { line: true },
                    { text: '修改', click: itemclick, icon: 'modify' },
                    { line: true },
                    { text: '删除', click: itemclick, icon: 'delete' }
                    ]
                    },
                    url: 'ajax/person.ashx?action=getpersonlist&cId=' + $("#hiddCustomerId").val(), pageSize: 2, rownumbers: true,
                    onSelectRow: function (data, rowindex, rowobj) {
                        singleClick = data._f_manid;
                    },
                    onDblClickRow: function (data, rowindex, rowobj) {
                        var vheight = $("#form1").height();
                        var vwidth = $("#form1").width() * 0.9;
                        if (vwidth > 800) { vwidth = 800; }
                        if (singleClick == "" || singleClick == undefined) {
                            alert("请选择修改行！");
                        } else {
                            $.ligerDialog.open({
                                url: 'personmodify.aspx?actionFlag=modify&personId=' + singleClick,
                                title: '修改联系人信息', height: vheight, width: vwidth, isResize: true
                            });
                        }
                    }
                });
            }
            catch (e) {
                alert(e.Message);
            }
            gridlist.changePage('first');
        }
        function LoadedFun(e) {
            tabs('#contentTab', 1);
        }
        function itemclick(item) {
            var vheight = $("#form1").height();
            var vwidth = $("#form1").width() * 0.9;
            if (vwidth > 800) { vwidth = 800; }
            if (item.icon == "add") {
                $.ligerDialog.open({
                    url: 'personmodify.aspx?actionFlag=add&cid=' + document.getElementById("hiddCustomerId").value,
                    title: '添加客户联系人信息', height: vheight, width: vwidth, isResize: true
                });
            }
            if (item.icon == "modify") {
                if (singleClick == "" || singleClick == undefined) {
                    alert("请选择修改行！");
                } else {
                    $.ligerDialog.open({
                        url: 'personmodify.aspx?actionFlag=modify&personId=' + singleClick,
                        title: '修改客户联系人信息', height: vheight, width: vwidth, isResize: true
                    });
                }
            }
            if (item.icon == "delete") {
                try {
                    //获取选择的行
                    var rows = gridlist.getSelectedRows();
                    if (rows.length > 0) {
                        $.ligerDialog.confirm('确定要批量删除选择的记录吗？', function (yes) {
                            if (yes) {
                                try {
                                    var arr = new Array();
                                    var i = 0;
                                    for (var i = 0; i < rows.length; i++) {
                                        arr[i] = rows[i]._f_manid;
                                    }
                                    $.post("ajax/person.ashx?action=delete&arrid=" + arr.toString(), function (data) {
                                        if (data == "success") {
                                            $.ligerDialog.success('删除成功');
                                            LoadList();
                                        }
                                        else {
                                            $.ligerDialog.error('删除失败');
                                        }
                                    });
                                }
                                catch (e) {
                                    alert(e.Message);
                                }
                            }
                            else {
                            }
                        });
                    }
                    else {
                        $.ligerDialog.error('没有选择要删除的联系人');
                    }
                }
                catch (e) {
                    $.ligerDialog.error(e.Message);
                }
            }
        }
        function CloseThis() {
            var dialog = frameElement.dialog;
            parent.InitList();
            dialog.close();
        }
        function SaveInfo(res) {
            switch (res) {
                case 'success':
                    $.ligerDialog.success('保存成功', function (yes) { CloseThis(); });
                    break;
                case 'warn':
                    $.ligerDialog.error('保存失败，请确认数据正确性');
                    break;
                case 'error':
                    $.ligerDialog.error('系统错误，请联系开发商');
                    break;
                default:
                    break;
            }
        }
        function validate() {
            lblCustomerName.innerHTML = "*";
            lblCustomerName.style.color = "#717171";
            lblCustomerCode.innerHTML = "*";
            lblCustomerCode.style.color = "#717171";
            if (document.getElementById("txtCustomerName").value == "") {
                lblCustomerName.innerHTML = "请填写客户名";
                lblCustomerName.style.color = "red";
                return false;
            }
            else if (document.getElementById("txtCustomerCode").value == "") {
                lblCustomerCode.innerHTML = "请填写客户编号";
                lblCustomerCode.style.color = "red";
                return false;
            }
            return true;
        }
    </script>
</head>
<body class="mainbody" scroll="no" style="margin-top: 0px;">
    <form id="form1" runat="server">
    <div id="contentTab">
        <table class="form_table">
                <col width="85px" />
                <col />
                <col width="85px" />
                <col />
                <col width="85px" />
                <col />
                <tbody>
                    <tr>
                        <th>
                            客户名称：
                        </th>
                        <td colspan="3">
                            <asp:HiddenField ID="hiddCustomerId" runat="server" />
                            <asp:TextBox ID="txtCustomerName" runat="server" CssClass="txtInput normal" Style="width: 300px;"></asp:TextBox><label
                                id="lblCustomerName" for="txtCustomerName">*</label>
                        </td>
                        <th>
                            客户编号：
                        </th>
                        <td>
                            <asp:TextBox ID="txtCustomerCode" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox>
                            <label id="lblCustomerCode" for="txtCustomerCode">*</label>
                        </td>
                    </tr>
                     <tr>
                        <th>
                            所属客服部：
                        </th>
                        <td>
                            <div style="float:left"><asp:TextBox ID="drpServiceDept" runat="server"></asp:TextBox></div>
                            <asp:HiddenField ID="hiddSeriveDeptId" runat="server" />
                            <label id="lblServiceDept" for="drpServiceDept">*</label>
                        </td>
                        <th>
                            所属省份：
                        </th>
                        <td>
                            <asp:HiddenField ID="hiddProvinceId" runat="server" />
                            <div style="float:left"><asp:TextBox ID="drpProvince" runat="server"></asp:TextBox></div>
                            <label id="lblProvince" for="drpProvince">*</label>
                        </td>
                        <th>
                        所属市县：
                        </th>
                        <td>
                            <asp:HiddenField ID="hiddCityId" runat="server" />
                            <asp:TextBox ID="drpCity" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                      <%--<tr>
                        <th>
                             产品系列：
                        </th>
                        <td>
                            <asp:HiddenField ID="hiddProductLineId" runat="server" />
                            <asp:TextBox ID="drpProductLine" runat="server"></asp:TextBox>
                        </td>
                        <th>
                           客户属性：
                        </th>
                        <td>
                            <asp:HiddenField ID="hiddCustomerNatureId" runat="server" />
                            <asp:TextBox ID="drpCustomerNature" runat="server"></asp:TextBox>
                        </td>
                        <th>
                           客户等级：
                        </th>
                        <td>
                            <asp:HiddenField ID="hiddCustomerClassId" runat="server" />
                            <asp:TextBox ID="drpCustomerClass" runat="server"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <th>
                             所属行业：
                        </th>
                        <td>
                            <asp:HiddenField ID="hiddCustomerIndustryId" runat="server" />
                            <asp:TextBox ID="drpCustomerIndustry" runat="server"></asp:TextBox>
                        </td>
                        <th>
                           关系等级：
                        </th>
                        <td>
                            <asp:HiddenField ID="hiddRelationShipClassId" runat="server" />
                            <asp:TextBox ID="drpRelationShipClass" runat="server"></asp:TextBox>
                        </td>
                        <th>
                           售后负责人：
                        </th>
                        <td>
                            <asp:HiddenField ID="hiddAfterSaleNameID" runat="server" />
                            <asp:TextBox ID="drpAfterSaleName" runat="server"></asp:TextBox>
                        </td>
                    </tr>--%>
                </tbody>
            </table>
            <ul class="tab_nav">
            <li class="selected"><a onclick="tabs('#contentTab',0);" href="javascript:;">联系人信息</a></li>
            <li><a onclick="tabs('#contentTab',1);" href="javascript:;">基本信息</a></li>
            <li><a onclick="tabs('#contentTab',2);" href="javascript:;">备注信息</a></li>
            <li><a onclick="tabs('#contentTab',3);" href="javascript:;">扩展信息</a></li>
        </ul>
        <div class="tab_con" style="display: block; height:160px; ">
        <div id="divDataList">
            </div>
        </div>
        <div class="tab_con" style="display: none; height:160px; ">
            <table class="form_table">
                <col width="85px" />
                <col />
                <col width="85px" />
                <col />
                <col width="85px" />
                <col />
                <tbody>
                    <tr>
                        <th>
                            客户传真：
                        </th>
                        <td>
                            <asp:TextBox ID="txtFax" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox><label
                                id="Label1" for="txtName">*</label>
                        </td>
                        <th>
                            客户邮箱：
                        </th>
                        <td>
                            <asp:TextBox ID="txtEmail" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox>
                            <label id="Label2" for="txtUserCode">*</label>
                        </td>
                        <th>
                            办公电话：
                        </th>
                        <td>
                            <asp:TextBox ID="txtTelephone" runat="server" CssClass="txtInput normal"
                                Style="width: 120px;"></asp:TextBox><label id="Label3" for="txtOkPwd">*</label>
                        </td>
                    </tr>
                     <tr>
                        <th>
                            客户地址：
                        </th>
                        <td colspan="3">
                            <asp:TextBox ID="txtAddress" runat="server"  CssClass="txtInput normal"
                                Style="width: 300px;"></asp:TextBox>
                        </td>
                        <th>
                        邮政编码：
                        </th>
                        <td>
                            <asp:TextBox ID="txtPostCode" runat="server" CssClass="txtInput normal"
                                Style="width: 120px;"></asp:TextBox>
                        </td>
                    </tr>
                      <tr>
                        <th>
                             当前版本：
                        </th>
                        <td>
                            <asp:TextBox ID="txtCurrentVersion" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox>
                        </td>
                        <th>
                           开通时间：
                        </th>
                        <td>
                            <asp:TextBox ID="txtSystemStartTime" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox>
                        </td>
                        <th>
                           质保时间：
                        </th>
                        <td>
                            <asp:TextBox ID="txtQualityGuaranteeEndTime" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <th>
                             系统类型：
                        </th>
                        <td>
                            <asp:TextBox ID="txtSystemType" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox>
                        </td>
                        <th>
                           客户状态：
                        </th>
                        <td>
                            <asp:TextBox ID="txtCustomerStatus" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox>
                            <asp:HiddenField ID="hiddCustomerStatus" runat="server" />
                        </td>
                        <th>
                           设备总数：
                        </th>
                        <td>
                            <asp:TextBox ID="txtDeviceCount" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <div class="tab_con" style="display: none; height:160px; ">
            <table class="form_table">
                <col width="85px" />
                <col />
                <tbody>
                    <tr>
                        <th>
                            乘车方案：
                        </th>
                        <td>
                            <textarea
                                id="txtTrackInfo" runat="server" class="txtInput normal" style="width:330px; height:60px;" cols="20" rows="3"></textarea>
                        </td>
                    </tr>
                     <tr>
                        <th>
                            备注信息：
                        </th>
                        <td>
                            <textarea
                                id="txtNotes" runat="server" class="txtInput normal" style="width:330px; height:60px;" cols="20" rows="3"></textarea>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <div class="tab_con" style="display: none; height:160px; ">
        <table class="form_table">
                <col width="85px" />
                <col />
                <col width="85px" />
                <col />
                <col width="85px" />
                <col />
                <tbody>
                    <tr>
                        <th>
                            扩展1：
                        </th>
                        <td>
                            <asp:TextBox ID="txtExtend1" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox><label
                                id="Label4" for="txtName">*</label>
                        </td>
                        <th>
                            扩展2：
                        </th>
                        <td>
                            <asp:TextBox ID="txtExtend2" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox>
                            <label id="Label5" for="txtUserCode">*</label>
                        </td>
                        <th>
                            扩展3：
                        </th>
                        <td>
                            <asp:TextBox ID="txtExtend3" runat="server" CssClass="txtInput normal"
                                Style="width: 120px;"></asp:TextBox><label id="Label6" for="txtOkPwd">*</label>
                        </td>
                    </tr>                     
                      <tr>
                        <th>
                             扩展4：
                        </th>
                        <td>
                            <asp:TextBox ID="txtExtend4" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox>
                        </td>
                        <th>
                           扩展5：
                        </th>
                        <td>
                            <asp:TextBox ID="txtExtend5" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox>
                        </td>
                        <th>
                           扩展6：
                        </th>
                        <td>
                            <asp:TextBox ID="txtExtend6" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <th>
                             扩展7：
                        </th>
                        <td>
                            <asp:TextBox ID="txtExtend7" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox>
                        </td>
                        <th>
                           扩展8：
                        </th>
                        <td>
                            <asp:TextBox ID="txtExtend8" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox>
                        </td>
                        <th>
                           扩展9：
                        </th>
                        <td>
                            <asp:TextBox ID="txtExtend9" runat="server" CssClass="txtInput normal" Style="width: 120px;"></asp:TextBox>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <div class="foot_btn_box">
            <asp:Button ID="btnSubmit" runat="server" Text="保&nbsp;&nbsp;存" CssClass="btnSubmit"
                OnClientClick="return validate();" OnClick="btnSubmit_Click" />
        </div>
    </div>
    </form>
</body>
</html>