//通过主键_获取部门
function SearchService_Department(dep_id) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: '../../Base/Department/Department_Service.asmx/Get',
        data: "{dep_id:'" + dep_id + "'}",
        dataType: 'json',
        success: function (result) {
            $("#dep_id").val(result.d.dep_id);
            $("#dep_name").val(result.d.dep_name);
        }
    });
}
//通过主键_获取部门(单据表体用)
function SearchService_D_Department(dep_id) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: '../../Base/Department/Department_Service.asmx/Get',
        data: "{dep_id:'" + dep_id + "'}",
        dataType: 'json',
        success: function (result) {
            $("#d_dep_id").val(result.d.dep_id);
            $("#d_dep_name").val(result.d.dep_name);
        }
    });
}
//通过主键_获取员工
function SearchService_Employee(ele_id) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: '../../Base/Employee/Employee_Service.asmx/Get',
        data: "{ele_id:'" + ele_id + "'}",
        dataType: 'json',
        success: function (result) {
            $("#ele_id").val(result.d.ele_id);
            $("#ele_name").val(result.d.ele_name);
        }
    });
}
//通过主键_获取仓库
function SearchService_Warehouse(wh_id) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: '../../Base/Warehouse/Warehouse_Service.asmx/Get',
        data: "{wh_id:'" + wh_id + "'}",
        dataType: 'json',
        success: function (result) {
            $("#wh_id").val(result.d.wh_id);
            $("#wh_name").val(result.d.wh_name);
        }
    });
}
//通过主键_获取仓库(单据表体用)
function SearchService_D_Warehouse(wh_id) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: '../../Base/Warehouse/Warehouse_Service.asmx/Get',
        data: "{wh_id:'" + wh_id + "'}",
        dataType: 'json',
        success: function (result) {
            $("#d_wh_id").val(result.d.wh_id);
            $("#d_wh_name").val(result.d.wh_name);
        }
    });
}
//通过主键_获取存货分类
function SearchService_InventoryClass(ic_id) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: '../../Base/Inventory/InventoryClass_Service.asmx/Get',
        data: "{ic_id:'" + ic_id + "'}",
        dataType: 'json',
        success: function (result) {
            $("#ic_id").val(result.d.ic_id);
            $("#ic_code").val(result.d.ic_code);
            $("#ic_name").val(result.d.ic_name);
        }
    });
}
//通过主键_获取客户分类
function SearchService_CustomerClass(cc_id) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: '../../Base/Customer/CustomerClass_Service.asmx/Get',
        data: "{cc_id:'" + cc_id + "'}",
        dataType: 'json',
        success: function (result) {
            $("#cc_id").val(result.d.cc_id);
            $("#cc_code").val(result.d.cc_code);
            $("#cc_name").val(result.d.cc_name);
        }
    });
}
//通过主键_获取供应商分类
function SearchService_VendorClass(vc_id) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: '../../Base/Vendor/VendorClass_Service.asmx/Get',
        data: "{vc_id:'" + vc_id + "'}",
        dataType: 'json',
        success: function (result) {
            $("#vc_id").val(result.d.vc_id);
            $("#vc_code").val(result.d.vc_code);
            $("#vc_name").val(result.d.vc_name);
        }
    });
}
//通过主键_获取客户
function SearchService_Customer(cus_id) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: '../../Base/Customer/Customer_Service.asmx/Get',
        data: "{cus_id:'" + cus_id + "'}",
        dataType: 'json',
        success: function (result) {
            $("#cus_id").val(result.d.cus_id);
            $("#cus_code").val(result.d.cus_code);
            $("#cus_name").val(result.d.cus_name);
        }
    });
}
//通过主键_获取币种
function SearchService_Currency(crc_id) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: '../../Base/Currency/Currency_Service.asmx/Get',
        data: "{crc_id:'" + crc_id + "'}",
        dataType: 'json',
        success: function (result) {
            $("#crc_id").val(result.d.crc_id);
            $("#crc_name").val(result.d.crc_name);
            var rate = 1;
            if (result.d.exchange_rate != null)
                rate = result.d.exchange_rate;
            $("#exchange_rate").val(rate);
        }
    });
}
//通过主键_获取供应商
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);
        }
    });
}
//通过主键_获取收发类型
function SearchService_IOType(iot_id) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: '../../Base/IOType/IOType_Service.asmx/Get',
        data: "{iot_id:'" + iot_id + "'}",
        dataType: 'json',
        success: function (result) {
            $("#iot_id").val(result.d.iot_id);
            $("#iot_code").val(result.d.iot_code);
            $("#iot_name").val(result.d.iot_name);
        }
    });
}
//通过主键_获取销售类型
function SearchService_SaleType(st_id) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: '../../Base/SaleType/SaleType_Service.asmx/Get',
        data: "{st_id:'" + st_id + "'}",
        dataType: 'json',
        success: function (result) {
            $("#st_id").val(result.d.st_id);
            $("#st_name").val(result.d.st_name);
        }
    });
}
//通过主键_获取采购类型
function SearchService_PurchaseType(pt_id) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: '../../Base/PurchaseType/PurchaseType_Service.asmx/Get',
        data: "{pt_id:'" + pt_id + "'}",
        dataType: 'json',
        success: function (result) {
            $("#pt_id").val(result.d.pt_id);
            $("#pt_name").val(result.d.pt_name);
        }
    });
}

//通过存货编码_获取存货信息
function SearchService_InventoryByCode(i_code) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: '../../Base/Inventory/Inventory_Service.asmx/GetIdByCode',
        data: "{i_code:'" + i_code + "'}",
        dataType: 'json',
        success: function (result) {
            var i_id = result.d;
            if (i_id != "" && i_id != 0) {
                SearchService_Inventory(i_id);
            }
        }
    });
    
}
//通过主键_获取存货
function SearchService_Inventory(i_id) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: '../../Base/Inventory/Inventory_Service.asmx/Get',
        data: "{i_id:'" + i_id + "'}",
        dataType: 'json',
        success: function (result) {
            $("#i_id").val(result.d.i_id); //存货id
            $("#i_code").val(result.d.i_code); //存货编码
            $("#i_name").val(result.d.i_name); //存货名称
            $("#standard").val(result.d.standard); //规格型号
            $("#munit").val(result.d.munit); //主单位
            $("#aunit").val(result.d.aunit); //辅计量单位
            if ($("#aunit").val() == "") {//如果辅计量单位不为空
                $("#num").attr("disabled", true); //禁止输件数
                $("#num").val(""); //清空件数
                $("#convert_rate").attr("disabled", true); //禁止输换算率
                $("#convert_rate").val(""); //清空换算率
            } else {
                $("#convert_rate").val(result.d.convert_rate); //辅计量单位
                $("#num").attr("disabled", false); //允许输件数
                $("#convert_rate").attr("disabled", false); //允许输换算率
            }
            if (result.d.on_batch == 1) {
                $("#batch").attr("disabled", false); //允许输批次
                $("#trigger_batch").css("display", "");
            } else {
                $("#batch").attr("disabled", true); //禁止输批次
                $("#batch").val("");
                $("#trigger_batch").css("display", "none");
            }
            var small_pic_url = result.d.inventory_photo.small_pic_url; //缩略图
            if (small_pic_url != null) {
                $("#inventory_photo_view").attr("src", result.d.inventory_photo.small_pic_url);
            }
            var pic_url = result.d.inventory_photo.pic_url; //原图
            if (pic_url != null) {
                $("#inventory_photo_view_href").attr("href", result.d.inventory_photo.pic_url);
            }
            $("#d_inv_sdefine1").val(result.d.sdefine1); //存货字符自定义项1
            $("#d_inv_sdefine2").val(result.d.sdefine2); //存货字符自定义项2
            $("#d_inv_sdefine3").val(result.d.sdefine3); //存货字符自定义项3
            $("#d_inv_sdefine4").val(result.d.sdefine4); //存货字符自定义项4
            $("#d_inv_sdefine5").val(result.d.sdefine5); //存货字符自定义项5
            $("#d_inv_ndefine1").val(result.d.ndefine1); //存货数值自定义项1
            $("#d_inv_ndefine2").val(result.d.ndefine2); //存货数值自定义项2
            $("#d_inv_ndefine3").val(result.d.ndefine3); //存货数值自定义项3
            $("#d_inv_ndefine4").val(result.d.ndefine4); //存货数值自定义项4
            $("#d_inv_ndefine5").val(result.d.ndefine5); //存货数值自定义项5
        }
    });
}
//通过主键_获取费用
function SearchService_Cost(cst_id) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: '../../Base/Cost/Cost_Service.asmx/Get',
        data: "{cst_id:'" + cst_id + "'}",
        dataType: 'json',
        success: function (result) {
            $("#cst_id").val(result.d.cst_id);
            $("#cst_code").val(result.d.cst_code);
            $("#cst_name").val(result.d.cst_name);
        }
    });
}

//通过主键_获取发运方式
function SearchService_ShipWay(sw_id) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: '../../Base/ShipWay/ShipWay_Service.asmx/Get',
        data: "{sw_id:'" + sw_id + "'}",
        dataType: 'json',
        success: function (result) {
            $("#sw_id").val(result.d.sw_id);
            $("#sw_name").val(result.d.sw_name);
        }
    });
}
//通过主键_获取结算方式
function SearchService_SettleStyle(ss_id) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: '../../Base/SettleStyle/SettleStyle_Service.asmx/Get',
        data: "{ss_id:'" + ss_id + "'}",
        dataType: 'json',
        success: function (result) {
            $("#ss_id").val(result.d.ss_id);
            $("#ss_name").val(result.d.ss_name);
        }
    });
}
//通过主键_获取结算账户
function SearchService_Account(ac_id) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: '../../Base/Account/Account_Service.asmx/Get',
        data: "{ac_id:'" + ac_id + "'}",
        dataType: 'json',
        success: function (result) {
            $("#ac_id").val(result.d.ac_id);
            $("#ac_name").val(result.d.ac_name);
        }
    });
}
//通过主键_获取登录用户
function SearchService_Member(uid) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: '../../System/Member/Member_Service.asmx/Get',
        data: "{uid:'" + uid + "'}",
        dataType: 'json',
        success: function (result) {
            $("#uid").val(result.d.uid);
            $("#username").val(result.d.username);
        }
    });
}
//通过主键_获取核销类型
function SearchService_CancelType(cl_type) {
    $.ajax({
        type: "POST",
        contentType: "application/json",
        url: '../../ARAP/CancelType/CancelType_Service.asmx/Get',
        data: "{cl_type:'" + cl_type + "'}",
        dataType: 'json',
        success: function (result) {
            $("#cl_type").val(result.d.cl_type);
            $("#cl_type_name").val(result.d.cl_type_name);
        }
    });
}