예제 #1
0
		public static async Task<List<LichThi>> MakeDataFromXml(SQLiteConnection connection)
		{
			list = new List<LichThi> ();
			var httpClient = new HttpClient ();
			Task<string> contentsTask = httpClient.GetStringAsync("http://www.schoolapi.somee.com/api/lichthi/3111410094");
			string contents = await contentsTask;
			XDocument doc = XDocument.Parse (contents);

			//get lichthi 
			IEnumerable<XElement> childList =
				from el in doc.Root.Elements()
				select el;
			//get attri lichthi
			foreach (XElement node in childList)
			{
				
				LichThi lt = new LichThi();
				lt.GhepThi = node.Elements().ElementAt(0).Value.Trim();
				lt.GioBD = node.Elements().ElementAt(1).Value.Trim();
				MonHoc mh = new MonHoc();
				lt.MaMH = node.Elements().ElementAt(3).Value.Trim();
				mh.MaMH = lt.MaMH;
				mh.TenMH=node.Elements().ElementAt(8).Value.Trim();
				lt.NgayThi = node.Elements().ElementAt(4).Value.Trim();
				lt.PhongThi = node.Elements().ElementAt(5).Value.Trim();
				lt.SoLuong = int.Parse(node.Elements().ElementAt(6).Value.Trim());
				lt.SoPhut = int.Parse(node.Elements().ElementAt(7).Value.Trim());
				lt.ToThi = node.Elements().ElementAt(9).Value.Trim();
				list.Add(lt);
				BMonHoc.Add(connection,mh);
				AddLT(lt,connection);
			}
			return list;
		}
예제 #2
0
		public static void AddLT(LichThi lt,SQLiteConnection connection )
		{
			DataProvider dtb = new DataProvider (connection);
			if (dtb.GetLT (lt.MaMH) == null) {
				dtb.AddLT (lt);
			}
		}
예제 #3
0
		public LichThiSource()
		{
			tableItems = new List<LichThi> ();
			isHeader = true;
			LichThi lt = new LichThi ();
			lt.MaMH = "000";
			tableItems.Add (lt);
		}
예제 #4
0
		public static int AddLT(LichThi lt,SQLiteConnection connection )
		{
			DataProvider dtb = new DataProvider (connection);
			if (dtb.GetLT (lt.MaMH,lt.NamHoc,lt.HocKy) == null) {
				dtb.AddLT (lt);
				return 1;
			}
			return 0;
		}
예제 #5
0
		public static async Task<List<LichThi>> MakeDataFromXml(SQLiteConnection connection)
		{
			if (BUser.GetMainUser (connection) != null) {
				list = new List<LichThi> ();
				var httpClient = new HttpClient ();
				httpClient.Timeout = TimeSpan.FromSeconds (20);
				Task<string> contentsTask = httpClient.GetStringAsync (UrlHelper.UrlLT(BUser.GetMainUser(connection).Id));
				string contents;
				try{
					contents = await contentsTask;
				}
				catch {
					return null;
				}
				XDocument doc = XDocument.Parse (contents);

				//get lichthi 
				IEnumerable<XElement> childList =
					from el in doc.Root.Elements ()
					select el;
				//get attri lichthi
				foreach (XElement node in childList) {
				
					LichThi lt = new LichThi ();
					lt.GhepThi = node.Elements ().ElementAt (0).Value.Trim ();
					lt.GioBD = node.Elements ().ElementAt (1).Value.Trim ();
					lt.HocKy = node.Elements ().ElementAt (3).Value.Trim ();
					lt.NamHoc = node.Elements ().ElementAt (5).Value.Trim ();
					MonHoc mh = new MonHoc ();
					lt.MaMH = node.Elements ().ElementAt (4).Value.Trim ();
					mh.MaMH = lt.MaMH;
					mh.TenMH = node.Elements ().ElementAt (10).Value.Trim ();
					lt.NgayThi = node.Elements ().ElementAt (6).Value.Trim ();
					lt.PhongThi = node.Elements ().ElementAt (7).Value.Trim ();
					lt.SoLuong = int.Parse (node.Elements ().ElementAt (8).Value.Trim ());
					lt.SoPhut = int.Parse (node.Elements ().ElementAt (9).Value.Trim ());
					lt.ToThi = node.Elements ().ElementAt (11).Value.Trim ();

					BMonHoc.Add (connection, mh);
					int i=AddLT (lt, connection);
					if (i == 1) {
						list.Add (lt);
					}
				}
				return list;
			}return null;
		}
예제 #6
0
		public Task RemindAllLT( List<LichThi> listlt)
		{

			return Task.Run(()=>
				{
					
						RequestAccess (EKEntityType.Event, () => {
							foreach (LichThi lt in listlt) {
								this.lt = lt;
							title="Lịch Thi";
							AutoCreateEventLT ();
						}
					});
				}

				);
		}
예제 #7
0
		public void AddLT (LichThi T)
		{
			_connection.Insert (T);
			_connection.Commit ();

		}
예제 #8
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;

		}
예제 #9
0
		public Task RemindAllLT( List<LichThi> listlt)
		{
			isSaveId = true;
			return Task.Run(()=>
				{
					foreach (LichThi lt in listlt) {
						this.lt = lt;
						SetCalenDarLT ();
					}
					isSaveId = false;
				});
		}