﻿function autoSaveRegistryForm(name, value){
	var url = 'Ajax/Default.aspx?Mod=SaveToRegistryForm&Name=' + name + '&Value=' + value;
	AjaxRequest.get(
	{
		'url':url
		,'onLoading':function(){}
		,'onSuccess':function(req){}
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function SelectServiceAtHome(chkid){
	var act = (chkid.checked==true)?'ADD':'REMOVE';
	AjaxRequest.get(
	{
		'url':'Ajax/Default.aspx?Mod=AddOrRemoveServiceAtHome&Action=' + act + '&ServiceID=' + chkid.value
		,'onLoading':function(){}
		,'onSuccess':function(req){var mycart = document.getElementById('mycart'); mycart.innerHTML=req.responseText;}
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}

function updateDoctorWorkStatus(doctorid, img){
	AjaxRequest.get(
	{
		'url':'Ajax/Default.aspx?Mod=UpdateDoctorWorkStatus&DoctorID=' + doctorid
		,'onLoading':function(){ img.src='Images/loading.gif';}
		,'onSuccess':function(req){img.src=req.responseText;}
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}

function updatePayServiceStatus(phieuthuid, img){
	AjaxRequest.get(
	{
		'url':'Ajax/Default.aspx?Mod=UpdatePayServiceStatus&PhieuThuID=' + phieuthuid
		,'onLoading':function(){ img.src='Images/loading.gif';}
		,'onSuccess':function(req){img.src=req.responseText;}
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function updatePatientRegisterStatus(registrationid, img){
	AjaxRequest.get(
	{
		'url':'Ajax/Default.aspx?Mod=UpdatePatientRegisterStatus&RegistrationID=' + registrationid
		,'onLoading':function(){ img.src='Images/loading.gif';}
		,'onSuccess':function(req){img.src=req.responseText;}
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function autoSavePatientRegister(name, value){
	var url = 'Ajax/Default.aspx?Mod=SaveToPatientRegister&Name=' + name + '&Value=' + value;
	AjaxRequest.get(
	{
		'url':url
		,'onLoading':function(){}
		,'onSuccess':function(req){}
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function syncContactAppointment(hovatenid, diachiid, dienthoaiid, tenlienheid, diachilienheid, dienthoailienheid){
	var txtHoVaTen = document.getElementById(hovatenid);
	var txtDiaChi = document.getElementById(diachiid);
	var txtDienThoai = document.getElementById(dienthoaiid);
	var txtTenLienHe = document.getElementById(tenlienheid);
	var txtDiaChiLienHe = document.getElementById(diachilienheid);
	var txtDienThoaiLienHe = document.getElementById(dienthoailienheid);
	
	autoSaveAppointment('TenLienHe', Url.encode(txtHoVaTen.value));
	autoSaveAppointment('DiaChiLienHe', Url.encode(txtDiaChi.value));
	autoSaveAppointment('DienThoaiLienHe', Url.encode(txtDienThoai.value));
	
	txtTenLienHe.value = txtHoVaTen.value;
	txtDiaChiLienHe.value = txtDiaChi.value;
	txtDienThoaiLienHe.value = txtDienThoai.value;
}
function autoSaveAppointment(name, value){
	var url = 'Ajax/Default.aspx?Mod=SaveToAppointment&Name=' + name + '&Value=' + value;
	AjaxRequest.get(
	{
		'url':url
		,'onLoading':function(){}
		,'onSuccess':function(req){}
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function selectMember(memberid){
	var url = 'Ajax/Default.aspx?Mod=SaveToAppointment&Name=ThanhVienID&Value=' + memberid;
	AjaxRequest.get(
	{
		'url':url
		,'onLoading':function(){}
		,'onSuccess':function(req){window.location=window.location;}
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function autoSaveTest(name, value){
	var url = 'Ajax/Default.aspx?Mod=SaveToTest&Name=' + name + '&Value=' + value;
	AjaxRequest.get(
	{
		'url':url
		,'onLoading':function(){}
		,'onSuccess':function(req){}
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function autoSaveTestGrid(rowid, name, value){
	var url = 'Ajax/Default.aspx?Mod=SaveToTestDetail&Index=' + rowid + '&Name=' + name + '&Value=' + value;
	AjaxRequest.get(
	{
		'url':url
		,'onLoading':function(){}
		,'onSuccess':function(req){}
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function autoSaveMedicine(name, value){
	var url = 'Ajax/Default.aspx?Mod=SaveToMedicine&Name=' + name + '&Value=' + value;
	AjaxRequest.get(
	{
		'url':url
		,'onLoading':function(){}
		,'onSuccess':function(req){}
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function autoSaveMedicineGrid(rowid, name, value){
	var url = 'Ajax/Default.aspx?Mod=SaveToMedicineDetail&Index=' + rowid + '&Name=' + name + '&Value=' + value;
	AjaxRequest.get(
	{
		'url':url
		,'onLoading':function(){}
		,'onSuccess':function(req){}
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function autoSaveInvoice(name, value){
	var url = 'Ajax/Default.aspx?Mod=SaveToInvoice&Name=' + name + '&Value=' + value;
	AjaxRequest.get(
	{
		'url':url
		,'onLoading':function(){}
		,'onSuccess':function(req){}
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function autoSaveInvoiceGrid(rowid, name, value){
	var url = 'Ajax/Default.aspx?Mod=SaveToInvoiceDetail&Index=' + rowid + '&Name=' + name + '&Value=' + value;
	AjaxRequest.get(
	{
		'url':url
		,'onLoading':function(){}
		,'onSuccess':function(req){}
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function autoSaveBill(name, value){
	var url = 'Ajax/Default.aspx?Mod=SaveToBillHeader&Name=' + name + '&Value=' + value;
	AjaxRequest.get(
	{
		'url':url
		,'onLoading':function(){}
		,'onSuccess':function(req){}
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function autoSaveBillGrid(rowid, name, value){
	var url = 'Ajax/Default.aspx?Mod=SaveToBillDetail&Index=' + rowid + '&Name=' + name + '&Value=' + value;
	AjaxRequest.get(
	{
		'url':url
		,'onLoading':function(){}
		,'onSuccess':function(req){}
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function autoSave(name, value){
	var url = 'Ajax/Default.aspx?Mod=SaveToPrescriptionHeader&Name=' + name + '&Value=' + value;
	AjaxRequest.get(
	{
		'url':url
		,'onLoading':function(){}
		,'onSuccess':function(req){}
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function autoSaveHealthService(name, value){
	var url = 'Ajax/Default.aspx?Mod=SaveToAssignHealthService&Name=' + name + '&Value=' + value;
	AjaxRequest.get(
	{
		'url':url
		,'onLoading':function(){}
		,'onSuccess':function(req){}
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function autoSaveHealthServiceResults(name, value){
	var url = 'Ajax/Default.aspx?Mod=SaveToHealthServiceResults&Name=' + name + '&Value=' + value;
	AjaxRequest.get(
	{
		'url':url
		,'onLoading':function(){}
		,'onSuccess':function(req){}
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function autoSaveHealthServiceGrid(rowid, name, value){
	var url = 'Ajax/Default.aspx?Mod=SaveToAssignHealthServiceDetail&Index=' + rowid + '&Name=' + name + '&Value=' + value;
	AjaxRequest.get(
	{
		'url':url
		,'onLoading':function(){}
		,'onSuccess':function(req){}
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function autoSaveHealthServiceResultsGrid(rowid, name, value){
	var url = 'Ajax/Default.aspx?Mod=SaveToHealthServiceResultsDetail&Index=' + rowid + '&Name=' + name + '&Value=' + value;
	AjaxRequest.get(
	{
		'url':url
		,'onLoading':function(){}
		,'onSuccess':function(req){}
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function autoSavePayService(name, value){
	var url = 'Ajax/Default.aspx?Mod=SaveToPayService&Name=' + name + '&Value=' + value;
	AjaxRequest.get(
	{
		'url':url
		,'onLoading':function(){}
		,'onSuccess':function(req){}
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function autoSavePayServiceGrid(rowid, name, value){
	var url = 'Ajax/Default.aspx?Mod=SaveToPayServiceDetail&Index=' + rowid + '&Name=' + name + '&Value=' + value;
	AjaxRequest.get(
	{
		'url':url
		,'onLoading':function(){}
		,'onSuccess':function(req){}
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function autoSaveGrid(rowid, name, value){
	var url = 'Ajax/Default.aspx?Mod=SaveToPrescriptionDetail&Index=' + rowid + '&Name=' + name + '&Value=' + value;
	AjaxRequest.get(
	{
		'url':url
		,'onLoading':function(){}
		,'onSuccess':function(req){}
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
//add
function addToPayService(phanloaiid, img, servicelistid){
	AjaxRequest.get(
	{
		'url':'Ajax/Default.aspx?Mod=AddToPayService&PhanLoaiID=' + phanloaiid
		,'onLoading':function(){ img.src='Images/loading.gif';}
		,'onSuccess':function(req){ img.src='Images/drug_basket.jpg'; document.getElementById(servicelistid).innerHTML=req.responseText; }
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function addToMedicalInvoice(drugsid, img, druglistid){
	AjaxRequest.get(
	{
		'url':'Ajax/Default.aspx?Mod=AddToMedicalInvoice&DrugsID=' + drugsid
		,'onLoading':function(){ img.src='Images/loading.gif';}
		,'onSuccess':function(req){ img.src='Images/drug_basket.jpg'; document.getElementById(druglistid).innerHTML=req.responseText; }
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function addToAssignHealthService(phanloaiid, img, servicelistid){
	AjaxRequest.get(
	{
		'url':'Ajax/Default.aspx?Mod=AddToAssignHealthService&PhanLoaiID=' + phanloaiid
		,'onLoading':function(){ img.src='Images/loading.gif';}
		,'onSuccess':function(req){ img.src='Images/cd.gif'; document.getElementById(servicelistid).innerHTML=req.responseText; }
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function addToHealthServiceResults(phanloaiid, img, servicelistid){
	AjaxRequest.get(
	{
		'url':'Ajax/Default.aspx?Mod=AddToHealthServiceResults&PhanLoaiID=' + phanloaiid
		,'onLoading':function(){ img.src='Images/loading.gif';}
		,'onSuccess':function(req){ img.src='Images/kq.gif'; document.getElementById(servicelistid).innerHTML=req.responseText; }
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function addToInvoice(drugsid, img, druglistid){
	AjaxRequest.get(
	{
		'url':'Ajax/Default.aspx?Mod=AddToInvoice&DrugsID=' + drugsid
		,'onLoading':function(){ img.src='Images/loading.gif';}
		,'onSuccess':function(req){ img.src='Images/drug_basket.jpg'; document.getElementById(druglistid).innerHTML=req.responseText; }
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function addToBill(drugsid, img, druglistid){
	AjaxRequest.get(
	{
		'url':'Ajax/Default.aspx?Mod=AddToBill&DrugsID=' + drugsid
		,'onLoading':function(){ img.src='Images/loading.gif';}
		,'onSuccess':function(req){ img.src='Images/drug_basket.jpg'; document.getElementById(druglistid).innerHTML=req.responseText; }
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function addToMedicine(drugsid, img, druglistid){
	AjaxRequest.get(
	{
		'url':'Ajax/Default.aspx?Mod=AddToMedicine&DrugsID=' + drugsid
		,'onLoading':function(){ img.src='Images/loading.gif';}
		,'onSuccess':function(req){ img.src='Images/icon_add.bmp'; document.getElementById(druglistid).innerHTML=req.responseText; }
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function addToBag(drugsid, img){
	AjaxRequest.get(
	{
		'url':'Ajax/Default.aspx?Mod=AddToBag&DrugsID=' + drugsid
		,'onLoading':function(){ img.src='Images/loading.gif';}
		,'onSuccess':function(req){ img.src='Images/icon_add.bmp'; alert('Thuốc đã được thêm vào Danh mục thuốc.'); }
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function addToMyHealthService(phanloaiid, img){
	AjaxRequest.get(
	{
		'url':'Ajax/Default.aspx?Mod=AddToHealthService&PhanLoaiID=' + phanloaiid
		,'onLoading':function(){ img.src='Images/loading.gif';}
		,'onSuccess':function(req){ img.src='Images/icon_add.bmp'; alert('Dịch vụ y tế đã được thêm vào Danh mục dịch vụ y tế của bác sỹ khám.'); }
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function addToMyHealthServices(phanloaiid, img){
	AjaxRequest.get(
	{
		'url':'Ajax/Default.aspx?Mod=AddToHealthServices&PhanLoaiID=' + phanloaiid
		,'onLoading':function(){ img.src='Images/loading.gif';}
		,'onSuccess':function(req){ img.src='Images/icon_add_green.bmp'; alert('Dịch vụ y tế đã được thêm vào Danh mục dịch vụ y tế của bác sỹ cận lâm sàng.'); }
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function addToReceptionHealthService(phanloaiid, img){
	AjaxRequest.get(
	{
		'url':'Ajax/Default.aspx?Mod=AddToReceptionHealthService&PhanLoaiID=' + phanloaiid
		,'onLoading':function(){ img.src='Images/loading.gif';}
		,'onSuccess':function(req){ img.src='Images/icon_add.bmp'; alert('Dịch vụ y tế đã được thêm vào Danh mục dịch vụ y tế.'); }
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function addToManagerHealthService(phanloaiid, img){
	AjaxRequest.get(
	{
		'url':'Ajax/Default.aspx?Mod=AddToManagerHealthService&PhanLoaiID=' + phanloaiid
		,'onLoading':function(){ img.src='Images/loading.gif';}
		,'onSuccess':function(req){ img.src='Images/icon_add.bmp'; alert('Dịch vụ y tế đã được thêm vào Danh mục dịch vụ y tế.'); }
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function addToDrugsHouseCataloge(drugsid, img){
	AjaxRequest.get(
	{
		'url':'Ajax/Default.aspx?Mod=AddToDrugsHouseCataloge&DrugsID=' + drugsid
		,'onLoading':function(){ img.src='Images/loading.gif';}
		,'onSuccess':function(req){ img.src='Images/icon_add.bmp'; alert('Thuốc đã được thêm vào Danh mục thuốc của tôi.'); }
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
function addToMarketingCataloge(drugsid, img){
	AjaxRequest.get(
	{
		'url':'Ajax/Default.aspx?Mod=AddToMarketingCataloge&DrugsID=' + drugsid
		,'onLoading':function(){ img.src='Images/loading.gif';}
		,'onSuccess':function(req){ img.src='Images/icon_add.bmp'; alert('Thuốc đã được thêm vào Danh mục thuốc của tôi.'); }
		,'onError':function(req){ alert('Error!\nStatusText='+req.statusText+'\nContents='+req.responseText);}
		}
	);
}
