Пример #1
0
		async void SwtNLich_ValueChanged (object sender, EventArgs e)
		{
			SettingsHelper.SaveSetting ("Remind", swtNLich.On);
			progress1.Hidden = false;
			progress1.StartAnimating ();
			if (swtNLich.On) {
				try {
					List<LichThi> listlt = BLichThi.GetNewestLT (SQLite_iOS.GetConnection ());

					List<LichHoc> listlh = BLichHoc.GetNewestLH (SQLite_iOS.GetConnection ());
				
					VCHomeReminder reminder = new VCHomeReminder (this);
					await reminder.RemindALLLH (listlh, "");
					await reminder.RemindAllLT (listlt);
					progress1.StopAnimating ();
				} catch {

				}
			} else {
				bool accepted = await ShowAlert("Xoá Nhắc Lịch", "Bạn muốn xoá hết các nhắc lịch đã tạo");
				if (accepted) {
					
					VCHomeReminder reminder = new VCHomeReminder (this);
					await reminder.RemoveAllEvent ();
					BRemind.RemoveAllRM (SQLite_iOS.GetConnection ());
				}
				progress1.StopAnimating ();

			}
			try
			{
				VCLichHoc.Instance.LoadData();
				if (VCADiemThi.instance!=null) VCADiemThi.Instance.LoadData();
				if (VCLichHocTuan.instance!=null) VCLichHocTuan.Instance.LoadData_Tuan(DateTime.Today);
				if (VCLichThi.instance!=null) VCLichThi.Instance.LoadData();
				if (VCDiemThi.instance!=null) VCDiemThi.Instance.LoadData("0","0");
				if (VCHocPhi.instance!=null) VCHocPhi.Instance.LoadData();
			}
			catch{
			}
		}
Пример #2
0
		public async void LoadData()
		{
			try
			{
				progress.Hidden = false;
				progress.StartAnimating ();
				List<LichThi> list= new List<LichThi>();
				bool sync = SettingsHelper.LoadSetting ("AutoUpdate"); 
				if (sync&&isfirst)
				{
					bool accepted =false;
					while (Reachability.InternetConnectionStatus ()==NetworkStatus.NotReachable&&!accepted)
					{
						accepted = await LayoutHelper.ShowAlert("Lỗi", "Bạn cần mở kết nối để cập nhật dữ liệu mới nhất");


					}
					if (Reachability.InternetConnectionStatus ()!=NetworkStatus.NotReachable)
					{
				UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true;
					var newlistlt= BLichThi.MakeDataFromXml (SQLite_iOS.GetConnection ());
					List<LichThi> newListLT= await newlistlt;
					var checkRemind=SettingsHelper.LoadSetting("Remind");
					if (newListLT==null)
					{
						UIAlertView _error = new UIAlertView ("Lỗi", "Xảy ra lỗi trong quá trình cập nhật dữ liệu từ server", null, "Ok", null);
						_error.Show ();
					}
						else
						{
					if (checkRemind){
						VCHomeReminder remind= new VCHomeReminder(this);
						await remind.RemindAllLT(newListLT);
					}
						}
					UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false;
					}
				}
				progress.StopAnimating ();
				list= BLichThi.GetNewestLT(SQLite_iOS.GetConnection());
				if (list.Count>0)
				{
					listLT.Hidden= false;
					errorLB.Hidden=true;
					headers.Hidden=false;
					timeLT.Text="Học Kỳ "+list[0].HocKy+" Năm "+ list[0].NamHoc;
					listLT.Source=new LichThiSource(list,this);
					listLT.ReloadData();
					isfirst = false;
				}
				else
				{
					timeLT.Text="";
					listLT.Hidden= true;
					errorLB.Hidden=false;
					headers.Hidden=true;
				}
			}
			catch {
			}
		}
Пример #3
0
		public static async Task<string> LoadDataFromSV(UIViewController controller)
		{
			try
			{
				var newlistlh= BLichHoc.MakeDataFromXml (SQLite_iOS.GetConnection ());
				List<LichHoc> newListLH= await newlistlh;
				var newlistlt= BLichThi.MakeDataFromXml (SQLite_iOS.GetConnection ());
				List<LichThi> newListLT= await newlistlt;
				var dtRS=await BDiemThi.MakeDataFromXml (SQLite_iOS.GetConnection ());
				var hpRS=await BHocPhi.MakeDataFromXml (SQLite_iOS.GetConnection ());
//				var prefs = Application.Context.GetSharedPreferences("SGU APP", FileCreationMode.Private);              
//				var checkRemind = prefs.GetBoolean ("Remind",false);
				var checkRemind=SettingsHelper.LoadSetting("Remind");
				if (checkRemind)
				{
					VCHomeReminder remind= new VCHomeReminder(controller);
					if (newListLH!=null) await remind.RemindALLLH(newListLH,"");
					if (newListLT!=null) await remind.RemindAllLT(newListLT);
				}


				if (dtRS!=null&&hpRS!=null&&newListLH!=null&&newListLT!=null)
				{
					
					return "Cập nhật dữ liệu thành công";
				}	
				else
				{
					
					return "Xảy ra lỗi trong quá trình cập nhật dữ liệu";
				}
			}
			catch {
				return "Xảy ra lỗi trong quá trình cập nhật dữ liệu";
			}



		}