async void CbNLT_CheckedChange (object sender, CompoundButton.CheckedChangeEventArgs e)
		{
			progressNL.Visibility= ViewStates.Visible;
			progressNL.Indeterminate = true;
			if (cbNLT.Checked == true) {

				try{
					List<LichThi> listlt= BLichThi.GetNewestLT(SQLite_Android.GetConnection());
					Log.Debug("logsettings","Load LT Success");
					List<LichHoc> listlh= BLichHoc.GetNewestLH(SQLite_Android.GetConnection());
					Log.Debug("logsettings","Load LH Success");
					ScheduleReminder reminder = new ScheduleReminder(Activity);
					await reminder.RemindAllLH(listlh);
					await reminder.RemindAllLT(listlt);
					Toast.MakeText (Activity, "Cài đặt nhắc lịch hoàn tất", ToastLength.Long).Show();
				}
				catch {

				}

			} else {
				AlertDialog.Builder builder = new AlertDialog.Builder (
					Activity);

				// Setting Dialog Title

				builder.SetTitle (Resource.String.Alertitle); 
				builder.SetIcon (Android.Resource.Drawable.IcDialogAlert); 
				builder.SetMessage ("Bạn có muốn xoá hết nhắc lịch đã tạo không?"); 
				builder.SetPositiveButton ("Có", async (sender1, e1) => {
				ScheduleReminder reminder = new ScheduleReminder(Activity);
				await reminder.DeleteAlLRemind ();
				Toast.MakeText (Activity, "Xoá nhắc lịch hoàn tất", ToastLength.Long).Show();
				});
				builder.SetNegativeButton ("Không", (sender1, e1) => {
				});
				builder.Show(); 

				
			}
			progressNL.Indeterminate = false;
			progressNL.Visibility = ViewStates.Gone;
			var prefs = Application.Context.GetSharedPreferences("SGU APP", FileCreationMode.Private);
			var prefEditor = prefs.Edit();
			prefEditor.PutBoolean("Remind",cbNLT.Checked);
			prefEditor.Commit();
		}
		public async void LoadData()
		{
			progress.Visibility = ViewStates.Visible;
			progress.Indeterminate = true;
			list = new List<LichThi>();
			if (Common.checkNWConnection (Activity) == true && autoupdate == true&&isfirst) {
				var newlistlt= BLichThi.MakeDataFromXml (SQLite_Android.GetConnection ());
				List<LichThi> newListLT= await newlistlt;
				if (newListLT == null) {
					Toast.MakeText (Activity, "Xảy ra lỗi trong quá trình cập nhật dữ liệu từ server", ToastLength.Long).Show ();
				} else {
					if (check) {
						ScheduleReminder reminder = new ScheduleReminder (Activity);
						await reminder.RemindAllLT (newListLT);
					}
				}
			}
			list = BLichThi.GetNewestLT (SQLite_Android.GetConnection ()); 
			//list = BLichThi.getAll (SQLite_Android.GetConnection ());
			if (list.Count > 0) {
				linear.Visibility = ViewStates.Visible;
				txtNotify.Visibility = ViewStates.Gone;
				LichThiAdapter adapter = new LichThiAdapter (Activity, list);
				rootView.FindViewById<TextView> (Resource.Id.txtHocKy).Text = "Học Kỳ " + list [0].HocKy + " Năm Học " + list [0].NamHoc;
				listView.Adapter = adapter;
				isfirst = false;
			}
			else {
				linear.Visibility = ViewStates.Gone;
				txtNotify.Visibility = ViewStates.Visible;
				txtNotify.Text = "Hiện tại lịch thi chưa có dữ liệu. Xin vui lòng thử lại sau!!!";
			}
			progress.Visibility = ViewStates.Gone;
			progress.Indeterminate = false;

		}
Exemple #3
0
		public static async Task<string> LoadDataFromSV(Context ctx)
		{
			try
			{
			var newlistlh= BLichHoc.MakeDataFromXml (SQLite_Android.GetConnection ());
			List<LichHoc> newListLH= await newlistlh;
			var newlistlt= BLichThi.MakeDataFromXml (SQLite_Android.GetConnection ());
			List<LichThi> newListLT= await newlistlt;
			var dtKS=await BDiemThi.MakeDataFromXml (SQLite_Android.GetConnection ());
			var hpKS= await BHocPhi.MakeDataFromXml (SQLite_Android.GetConnection ());
			try{
					DrawerActivity drAc=(DrawerActivity)ctx;
					drAc.SelectItem(drAc.previousItemChecked);
			}catch
			{
			}
			var prefs = Application.Context.GetSharedPreferences("SGU APP", FileCreationMode.Private);              
			var checkRemind = prefs.GetBoolean ("Remind",false);
			if ( checkRemind)
			{
			ScheduleReminder reminder = new ScheduleReminder(ctx);
					if (newListLH!=null) await reminder.RemindAllLH(newListLH);
					if (newListLT!=null) await reminder.RemindAllLT(newListLT);

			Toast.MakeText (ctx, "Cài đặt nhắc lịch cho dữ liệu mới thành công", ToastLength.Long).Show();
			}
			if (dtKS!=null&&hpKS!=null&&newListLH!=null&&newListLT!=null)
			{
					Toast.MakeText (ctx, "Cập nhật dữ liệu thành công", ToastLength.Long).Show();
					return "load success ";
			}	
				else
			{
				Toast.MakeText (ctx, "Xảy ra lỗi trong quá trình tải dữ liệu", ToastLength.Long).Show();
					return "load failed ";
			}

			
			
			}
			catch {
				Toast.MakeText (ctx, "Xảy ra lỗi trong quá trình tải dữ liệu, vui lòng thử lại sau", ToastLength.Long).Show();
				return "load failed";
			}



		}