<%@ Page Title="" Language="C#" MasterPageFile="~/Styles/MasterPage/MasterPage_Edit.master" AutoEventWireup="true" CodeFile="YingFu_Edit.aspx.cs" Inherits="Base_YingFu_YingFu_Edit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <script type="text/javascript">
        var action = '<%=xview["action"]%>';
        var owner = '<%=Request["owner"]%>';
        function Save() {
            <%=xview["Script_GetInput"] %>
            if (digest == "") {
                //parent.AlertNO('请输入摘要!');
                //return;
            }
            if (add_date == "") {
                parent.AlertNO('请输入发生日期!');
                return;
            }
            if (amount == "") {
                parent.AlertNO('请输入金额!');
                return;
            }
            if (vd_id == "" && vd_name != "") {
                parent.AlertNO('手输供应商名称后要选择一下才能保存到!');
                return;
            }
            if (cus_id == "" && cus_name != "") {
                parent.AlertNO('手输工地名称后要选择一下才能保存到!');
                return;
            }
            if (ele_id == "" && ele_name != "") {
                parent.AlertNO('手输员工名称后要选择一下才能保存到!');
                return;
            }
            if (cst_id == "" && cst_name != "") {
                parent.AlertNO('手输费用类型后要选择一下才能保存到!');
                return;
            }
            if(cus_name==""){
                cus_id="";
            }
            if(vd_name==""){
                vd_id="";
            }
            if(ele_name==""){
                ele_id="";
            }
            if(cst_name==""){
                cst_id="";
            }
            var action = '<%=xview["action"]%>';
            parent.ShowLoadingMask(); //显示遮罩
            $.ajax({
                type: "POST",
                contentType: "application/json",
                url: 'YingFu_Service.asmx/Save',
                data: "{action:'" + action + "',owner:'" + owner + "',<%=xview["Script_SaveJSON"]%>}",
                dataType: 'json',
                success: function (result) {
                    parent.HideLoadingMask(); //关闭遮罩
                    var r = result.d;
                    if (r == "success") {
                        if(action == "Add"){
                            asyncbox.confirm('保存成功!\n是否要继续新增？','提示',function(buttonResult){
　　　                            if(buttonResult == 'ok'){
　　　　　                            window.location.reload();
　　　                            }else{
                                    parent.search_grid();
                                    CloseDivWin(); //关闭窗口
　　　                            }
                            });
                        }else{
                            parent.search_grid();
                            asyncbox.success('保存成功!','提示',function(buttonResult){
                                CloseDivWin(); //关闭窗口
                            });
                        }
                    } else {
                        parent.AlertNO(r);
                    }
                }
            });
        }
    </script>
    <!--工具栏-->
    <div class="list_menu_bar">
        <a plain="true" class="easyui-linkbutton" iconcls="icon-save" onclick="Save()" style='<%=au.AuthView("Ling_YingFu_Edit")%>'>保存</a>
        <a plain="true" class="easyui-linkbutton" onclick="parent.DesignModuleFormat('Ling_YingFu_Input');CloseDivWin();">格式</a>
    </div>
    <div style="width:500px;height:460px;overflow:auto;">
        <div class="edit_area" style="width:500px;height:460px;">
        <%=xview["input_ui"]%>
        </div>
    </div>
    <script type="text/javascript">
        //初始化页面
        function init_page() {
            FastSearch_Customer(); //查询客户
            FastSearch_Vendor(); //查询供应商
            FastSearch_Employee(); //查询员工
            FastSearch_Cost(); //查询费用
            <%if(action.Equals("Update")){ %>
                $F("cus_name").value = '<%=m.customer==null?"":m.customer.cus_name%>';
                $F("vd_name").value = '<%=m.vendor==null?"":m.vendor.vd_name%>';
                $F("ele_name").value = '<%=m.employee==null?"":m.employee.ele_name%>';
                $F("cst_name").value = '<%=m.cost==null?"":m.cost.cst_name%>';
            <%} %>
            if(action == "Add"){
                $F("add_date").value = '<%=xview["login_date"]%>';
            }


        }
        init_page();

        //通过主键_获取供应商
        function SearchService_Vendor(vd_id) {
            $.ajax({
                type: "POST",
                contentType: "application/json",
                url: '../../Base/Vendor/Vendor_Service.asmx/Get',
                data: "{vd_id:'" + vd_id + "'}",
                dataType: 'json',
                success: function (result) {
                    $("#vd_id").val(result.d.vd_id);
                    $("#vd_name").val(result.d.vd_name);
                    $("#digest").val(result.d.sdefine1);
                }
            });
        }
        

    </script>
</asp:Content>

