Example #1
0
		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;

		}
		public async void LoadData_HK ()
		{
			listView_HK.Visibility = ViewStates.Invisible;

			progress.Visibility = ViewStates.Visible;
			progress.Indeterminate = true;
			List<LichHoc> listLH = new List<LichHoc> ();
			if (Common.checkNWConnection (Activity) == true&&autoupdate==true&&isfirst) {
			
				var newlistlh = BLichHoc.MakeDataFromXml (SQLite_Android.GetConnection ());
				List<LichHoc> newListLH= await newlistlh;
				if (newListLH == 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.RemindAllLH (newListLH);
					}
				}
			}
			listLH = BLichHoc.GetNewestLH (SQLite_Android.GetConnection ());
			if (listLH.Count > 0) {
				//radioGroup.Visibility = ViewStates.Visible;
				linearLH.Visibility = ViewStates.Visible;
				linear.Visibility = ViewStates.Visible;
				txtNotify.Visibility = ViewStates.Gone;
				listCT = new List<chiTietLH> ();
				foreach (var item in listLH) {
					listCT.AddRange (BLichHoc.GetCTLH (SQLite_Android.GetConnection (), item.Id));

				}

				lbl_HK.Text = listLH [0].HocKy;
				lbl_NH.Text = listLH [0].NamHoc;
				LichHocHKAdapter adapter = new LichHocHKAdapter (Activity, listCT);
				listView_HK.Adapter = adapter;  
				isfirst = false;
			}else {
				//radioGroup.Visibility= ViewStates.Invisible;
				linearLH.Visibility = ViewStates.Gone;
				linear.Visibility = ViewStates.Gone;
				txtNotify.Visibility = ViewStates.Visible;
				txtNotify.Text = "Hiện tại lịch học chưa có dữ liệu. Xin vui lòng thử lại sau!!!";
			}
			progress.Indeterminate = false;
			progress.Visibility = ViewStates.Gone;
			listView_HK.Visibility = ViewStates.Visible;

		
		}
		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_Tuan (DateTime dateOfWeek)
		{
			try
			{
			btnTuanTruoc.Visibility= ViewStates.Invisible;
			btnTuanKe.Visibility= ViewStates.Invisible;
			listView_Tuan.Visibility = ViewStates.Invisible;
			progress.Visibility = ViewStates.Visible;
			progress.Indeterminate = true;
			List<LichHoc> listLH = new List<LichHoc> ();
				if (Common.checkNWConnection (Activity) == true && autoupdate == true&&	isfirst) {
				var newlistlh= BLichHoc.MakeDataFromXml (SQLite_Android.GetConnection ());
				List<LichHoc> newListLH= await newlistlh;
				if (newListLH == 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.RemindAllLH (newListLH);
					}
				}
			}
			listLH = BLichHoc.GetNewestLH (SQLite_Android.GetConnection ());
			listCT = new List<chiTietLH> ();
			foreach (var item in listLH) {
				List<chiTietLH> list = BLichHoc.GetCTLH (SQLite_Android.GetConnection (), item.Id).ToList ();
				foreach (var ct in list) {
					String result = checkTuan (ct.Tuan, dateOfWeek);
					if (result != "") {
						ct.Tuan = result;
						listCT.Add (ct);
						break;
					}

				}

			}
			string begining;
			string end;
			GetWeek (dateOfWeek, out begining, out end);
			lbl_TuNgay.Text = begining;
			lbl_DenNgay.Text = end;
			lbl_HK.Text = "Học Kỳ " + listLH [0].HocKy + " Năm học " + listLH [0].NamHoc;
			listCT = listCT.OrderBy (x => x.Thu).ToList();
			listView_Tuan.SetAdapter (new LichHocTuanAdapter (Activity, listCT)); 
			progress.Indeterminate = false;
			progress.Visibility = ViewStates.Gone;
			listView_Tuan.Visibility = ViewStates.Visible;
			btnTuanTruoc.Visibility= ViewStates.Visible;
			btnTuanKe.Visibility= ViewStates.Visible;
			isfirst = false;
		}
		catch {
			
		}
		}
Example #5
0
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);
			SetContentView (Resource.Layout.Reminder_Dialog);
			Save = FindViewById<Button> (Resource.Id.btnSave);
			Del = FindViewById<Button> (Resource.Id.btnDel);
			Cancel = FindViewById<Button> (Resource.Id.btnCancel);
			Space = FindViewById<View> (Resource.Id.view_Reminder);
			edtxt_content = FindViewById<EditText> (Resource.Id.edtxt_Content);
			TextView title = FindViewById<TextView> (Resource.Id.txtTitleRM);
			TextView subject = FindViewById<TextView> (Resource.Id.txtSubjectRM);
			TextView time = FindViewById<TextView> (Resource.Id.txtTimeRM);
			TextView date = FindViewById<TextView> (Resource.Id.txtDateRM);
			edtxt_minutes = FindViewById<EditText> (Resource.Id.txt_minutes);
			bundle = Intent.GetBundleExtra ("RemindValue");
			MH = bundle.GetString ("MH");
			check = bundle.GetBoolean ("check");
			string minutes, mess;
			if (check) {
				string namhoc=bundle.GetString ("NamHoc");
				string hocky=bundle.GetString ("HocKy");
				mh = BMonHoc.GetMH (SQLite_Android.GetConnection (), MH);
				lt = BLichThi.GetLT (SQLite_Android.GetConnection (), MH,namhoc,hocky);
				title.Text = "NHẮC LỊCH THI";
				subject.Text = "Môn:" + mh.TenMH;
				date.Text = " Ngày: " + lt.NgayThi;
				time.Text = "Thời gian: " + lt.GioBD ;
				LTRemindItem item = BRemind.GetLTRemind (SQLite_Android.GetConnection (), lt.MaMH, lt.NamHoc, lt.HocKy);
				if (item != null) {
					ScheduleReminder reminder = new ScheduleReminder (this);
					reminder.GetRemind (item.EventID, out minutes, out mess);
					if (minutes != null) {
						edtxt_content.Text = mess;
						edtxt_minutes.Text = minutes;
					
					}
					else {
						NewReminder ();
					}
				}
				else {
					NewReminder ();
				}


			} else {
				tietBD = bundle.GetString ("TietBD");
				isLHT= bundle.GetBoolean ("isLHT");
				lh = BLichHoc.GetLH (SQLite_Android.GetConnection (), MH);
				mh = BMonHoc.GetMH (SQLite_Android.GetConnection (), lh.MaMH);
				isLHT = true;
				isLHT= bundle.GetBoolean ("isLHT");
				title.Text = "NHẮC LỊCH HOC";
				subject.Text = "Môn: " + mh.TenMH;


				if (isLHT) {
					ngayhoc= bundle.GetString ("NgayHoc");
					soTiet= bundle.GetString ("SoTiet");
					thu = bundle.GetString ("Thu");
					string exNgay = ngayhoc.Substring (3, 2);
					exNgay = exNgay + "/" + ngayhoc.Substring (0, 2) + "/" + ngayhoc.Substring (6, 4);
					date.Text = "Ngày: " + exNgay;
					time.Text = "Tiết: " + tietBD;
					LHRemindItem item = BRemind.GetLHRemind (SQLite_Android.GetConnection (), lh.Id, ngayhoc);
					if (item != null) {
						ScheduleReminder reminder = new ScheduleReminder (this);
						reminder.GetRemind (item.EventID, out minutes, out mess);
						if (minutes != null) {
							edtxt_content.Text = mess;
							edtxt_minutes.Text = minutes;
						
						} 
						else {
							NewReminder ();

						}
						checkBox = FindViewById<CheckBox> (Resource.Id.checkBox1);
						checkBox.Visibility = ViewStates.Visible;
					}
					else {
						NewReminder ();
						checkBox = FindViewById<CheckBox> (Resource.Id.checkBox1);
						checkBox.Visibility = ViewStates.Invisible;
					}
				}
				else {
					 
					List<LHRemindItem> list = BRemind.GetLHRemind(SQLite_Android.GetConnection (),lh.Id);
					if (list.Count > 1) {
						edtxt_content.Visibility = ViewStates.Gone;
						edtxt_minutes.Visibility = ViewStates.Gone;
						LinearLayout.LayoutParams layout = new LinearLayout.LayoutParams (0, LinearLayout.LayoutParams.MatchParent, 0.1f);
						Space.LayoutParameters = layout;
						Save.Visibility = ViewStates.Gone;
					}else {

						date.Visibility = ViewStates.Gone;
						time.Visibility = ViewStates.Gone;
						NewReminder ();
					}
				}


			}
			// 
			Save.Click += Save_Click;
			Cancel.Click += new EventHandler (btnCancel_OnClickListener);
			Del.Click += Del_Click;

		}
Example #6
0
		async void Save_Click (object sender, EventArgs e)
		{
			ScheduleReminder reminder = new ScheduleReminder (this);
			if (edtxt_content.Text == "") {
				reminder.content = "0";
			}
			else reminder.content = edtxt_content.Text;
			reminder.MinutesRemind = int.Parse(edtxt_minutes.Text.Trim());
			if (check) {
				reminder.lt = lt;
				reminder.SetCalenDarLT ();
				LichThiFragment.Instance.LoadData ();
			
			} else {

				reminder.lh = lh;
				if (isLHT) {
					chiTietLH ct = new chiTietLH ();
					ct.Id = lh.Id;
					ct.TietBatDau = tietBD;
					ct.SoTiet = soTiet;
					reminder.DateForCTLH = ngayhoc;

					if (checkBox.Checked) {
						reminder.ctlh = BLichHoc.GetCTLH (SQLite_Android.GetConnection (), lh.Id,thu,tietBD);
						reminder.RemindLHTuan ();
					} else {
						reminder.ctlh = ct;
						reminder.SetCalenDarLH ();
					}
					DateTime t = DateTime.ParseExact (ngayhoc, "MM/dd/yyyy", CultureInfo.InvariantCulture);
					LichHocTuanFragment.Instance.LoadData_Tuan(t);
				} else {
					ProgressDialog dialog = new ProgressDialog (this);
					dialog.Indeterminate = false;
					dialog.SetCancelable (false);
					dialog.SetMessage ("Cài đặt nhắc lịch...");
					dialog.Show ();
					await reminder.RemindLHHK ();
					dialog.Dismiss ();
					LichHocHKFragment.Instance.LoadData_HK ();
				}
			}
			if (reminder.isInsert) {
				Toast.MakeText (this, "Cài đặt nhắc lịch thành công", ToastLength.Long).Show ();
			} else {
				Toast.MakeText (this, "Cập nhật nhắc lịch thành công", ToastLength.Long).Show ();
			}
			Cancel.CallOnClick ();
		
		}
Example #7
0
		async void Del_Click (object sender, EventArgs e)
		{
			ScheduleReminder reminder = new ScheduleReminder (this);
			List<string> listEventId = new List<string> ();
			if (check) {
				LTRemindItem item = BRemind.GetLTRemind (SQLite_Android.GetConnection (), lt.MaMH, lt.NamHoc, lt.HocKy);
				listEventId.Add (item.EventID);
			} else if (isLHT) {
				LHRemindItem item = BRemind.GetLHRemind(SQLite_Android.GetConnection (),lh.Id,ngayhoc);
				listEventId.Add (item.EventID);
			} else {
				List<LHRemindItem> list = BRemind.GetLHRemind(SQLite_Android.GetConnection (),lh.Id);
				foreach (var item in list) {
					listEventId.Add (item.EventID);
				}
			}
			ProgressDialog dialog = new ProgressDialog (this);

			dialog.Indeterminate = false;
			dialog.SetCancelable (false);
			dialog.SetMessage ("Xoá nhắc lịch...");
			dialog.Show ();
			await reminder.DeleteRemind (listEventId);
			dialog.Dismiss ();
			if (LichHocHKFragment.instance != null) {
				LichHocHKFragment.Instance.LoadData_HK ();
			}
			if (LichThiFragment.instance!=null){
				LichThiFragment.Instance.LoadData ();
			}
			if (LichHocTuanFragment.instance != null) {
				if (ngayhoc != null) {
					DateTime t = DateTime.ParseExact (ngayhoc, "MM/dd/yyyy", CultureInfo.InvariantCulture);
					LichHocTuanFragment.Instance.LoadData_Tuan (t);
				}
			}
			Toast.MakeText (this, "Xóa nhắc lịch thành công", ToastLength.Long).Show();
			Cancel.CallOnClick ();
		}
Example #8
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";
			}



		}