1: Lấy thông qua lệnh get jquery
var id_dh= urlGetValuePara("idDH"); // get giá trị trên url
var url_go="/adminxml/Query_Do.aspx?name=BanHang_iif/tbBanHang_get_by_ID&out=json&idHD="+id_dh;
//alert(id_dh); //test
// alert(url_go); //test
$.get(url_go, function(data, status){
//== set
//alert( JSON.stringify(data )); //test
if(data.Q1.length>0)
{
// alert(data.Q1[0].TongCongTien);
$("#TongCongTien").val(data.Q1[0].TongCongTien );
}
//$.each(data.Q1, function (index, itemData) {
//alert( itemData.TenCot);
//}); //each
}); //get
2: Lấy thông qua gán Query vào Form
- Vào tạo 1 Query có tên BanHang trong file QLBH.xml
<Query>
<ID>Q1</ID>
<Src>12</Src>
<Type>Sql</Type>
<Cmd>Select * From tbHangHoa</Cmd>
</Query>
<Query>
<ID>Q2</ID>
<Src>12</Src>
<Type>Sql</Type>
<Cmd>Select * From tbbanHang</Cmd>
</Query>
- Vào cấu hình Form gán tên Query vào QLBH/BanHang
- Sau đó thêm lệnh phần body hay file html nếu đã include vào body
<iif-F>
<Source><type:query/>#</>0</Source>
<ItemF>
+ <%i=TenHangHoa=i%><br>
</ItemF>
</iif-F>
<iif-F>
<Source><type:query/>#</>1</Source>
<ItemF>
+ <%i=TenKhachHang=i%><br>
</ItemF>
</iif-F>
0 là table thứ 1 ở Query đã tạo
1 là table thứ 2 ở Query đã tạo
Khi dùng trong HTML của From bắt buộc phải có vị trí query
<Source><type:query/>#</>0</Source>
3. Lấy không cần gán query vào cấu hình form
<iif-F>
<Source><type:query/>NhanVien</>0</Source>
<ItemF>
+ <%i=HoTen=i%><br>
</ItemF>
</iif-F>
-- Tham khảo định dạng hiện thị số / ngày
4: Lấy qua angular
Tạo 1 Query
<div ng-app="myApp" ng-controller="myCtrl">
<ul>
<li ng-repeat="x in Data_DonHang">
Số: {{x.So}}
</li>
</ul>
</div>
<script type="text/javascript">
var app = angular.module("myApp", []);
app.controller('myCtrl', function($scope, $http,$timeout){
$scope.loadDonHang = function () {
$(".alert_load_data").html("Load đơn hàng...");
$http({
method : "GET",
url : "Query_Do.aspx?name=BanHang_iif/DonHang&out=json"
}).then(
function mySuccess(response)
{
// alert( response.data);
$scope.Data_DonHang = response.data.Q1;
//Nếu Query nhiều table thì thêm $scope.Data_X = response.data.Q2;
$(".alert_load_data").hide();
}, function myError(response)
{
alert(response.statusText);
}
); //end then
$(".alert_load_data").html("");
} // end $scope.loadDonHang
$scope.loadDonHang();
//End CODE
});//end app.controller
</script>
Một số mẫu hay dùng angular
Tham khảo: /iif-admin/xu-ly-query-bien-ket-qua-tra-ve
$scope.Load_data_X = function (x) {
//************************
if( !Check_iif_Before_CallServer()) return;
loadding_show();
var url= "__URL___";
$http({
method : "GET",
url : url
}).then(function mySuccess(response)
{
const _iif_DBS = new iif_DBS(response.data);
_iif_DBS.getReturnProc();
_iif_DBS.getSuccess_Has(2);
//nếu không lỗi gọi hàm parent
if( !_iif_DBS.getErr_Has(1) )
window.parent.angular.element( window.parent.document.getElementById('mainIIF_angu')).scope().call_from_Popup_ChungTu_DoiKhuVucXong('');
}, function myError(response)
{
alert( "LỖI:"+ response.statusText );
}
);
} //Load_data_X
$scope.Load_data_X = function () {
//************************
if( !Check_iif_Before_CallServer()) return;
loadding_show();
var url= "__URL___";
var objData={};
objData.Key_ChungTu="x";
$http({
method : "POST",
data: objData,
url : url
}).then(function mySuccess(response)
{
const _iif_DBS = new iif_DBS(response.data);
_iif_DBS.getReturnProc();
_iif_DBS.getSuccess_Has(2);
//nếu không lỗi gọi hàm parent
if( !_iif_DBS.getErr_Has(1) )
window.parent.angular.element( window.parent.document.getElementById('mainIIF_angu')).scope().call_from_Popup_ChungTu_DoiKhuVucXong('');
}, function myError(response)
{
alert( "LỖI:"+ response.statusText );
}
);
} //Load_data_X
Cách lấy dữ liệu Query sử dụng cho Form html