Exemple #1
0
		public static void AddCTLH (SQLiteConnection connection, chiTietLH ct)
		{
			DataProvider dtb = new DataProvider (connection);
			if (dtb.checkCTLH (ct) == null) {
				dtb.AddCTLH (ct);
			}

		}
		public LichHocHKSource()
		{
			isHeader = true;
			tableItems = new List<chiTietLH> ();
			chiTietLH lh = new chiTietLH ();
			lh.Id = "1";
			tableItems.Add (lh);
		}
		public ScheduleReminder(Context context)
		{
			ctx = context;
			DateForCTLH = "";
			ctlh = new chiTietLH ();
			MinutesRemind =60;
			content = "";
			isSaveId = false;
		}	
		public void UpdateCell (chiTietLH ct,LichHoc lh,string soTC)
		{
			gv.Text ="Giáo Viên:"+ ct.CBGD;
			thoigian.Text = "Thời Gian:"+ct.ThoigianBD + "-" + ct.ThoigianKT;
			malop.Text = "Mã Lớp:"+lh.MaLop;
			nhommh.Text = "Nhóm Môn:"+ lh.NhomMH;
			sotc.Text= "Số TC:"+soTC;
			mamh.Text= "Mã MH:"+ lh.MaMH;

		}
Exemple #5
0
		public Task RemindALLLH(List<LichHoc> listlh,string content)
		{
			return Task.Run(()=>
				{
					RequestAccess (EKEntityType.Event, () => {
						foreach (LichHoc lh in listlh) {
							title="Lịch Học";
							List<chiTietLH> cts = BLichHoc.GetCTLH (SQLite_iOS.GetConnection (), lh.Id);
							foreach (chiTietLH ct in cts)
							{
								List<string> listNgayHoc = ApiHelper.strListTuanToArrayString (ct.Tuan);
								foreach (string s in listNgayHoc) {
									time = s;
									this.ct = ct;
									this.lh = lh;

									AutoCreateEventLH(content);
								}
							}

						}});
					
				}
			);
		}
Exemple #6
0
		public static async Task<List<LichHoc>> MakeDataFromXml (SQLiteConnection connection)
		{
			if (BUser.GetMainUser (connection) != null) {
				list = new List<LichHoc> ();
				var httpClient = new HttpClient ();
				httpClient.Timeout = TimeSpan.FromSeconds (20);
				Task<string> contentsTask = httpClient.GetStringAsync (UrlHelper.UrlLH(BUser.GetMainUser(connection).Id));
				string contents;

				try
				{
					contents =  await contentsTask;

				}
				catch(Exception e) {
					return null;
				}
				XDocument doc = XDocument.Parse (contents);
				//get lichthi 
				IEnumerable<XElement> childList =
					from el in doc.Root.Elements ()
					select el;
				//get attri lichthi
				int k = GetId (connection);
				DataProvider dtb = new DataProvider (connection);
				foreach (XElement node in childList) {
				
					LichHoc lichhoc = new LichHoc ();
					lichhoc = dtb.GetLH_Ma (node.Elements ().ElementAt (3).Value.Trim (),node.Elements ().ElementAt (4).Value.Trim (),node.Elements ().ElementAt (1).Value.Trim ());

					if (lichhoc != null) {
						chiTietLH ct = new chiTietLH ();
						ct.Id = lichhoc.Id;
						ct.CBGD = node.Elements ().ElementAt (0).Value.Trim ();
						ct.Phong = node.Elements ().ElementAt (6).Value.Trim ();
						ct.Thu = node.Elements ().ElementAt (11).Value.Trim ();
						ct.TietBatDau = node.Elements ().ElementAt (12).Value.Trim ();
						ct.SoTiet = node.Elements ().ElementAt (8).Value.Trim ();
						ct.ThoigianBD = node.Elements ().ElementAt (10).Value.Trim ().Substring (0, 10);
						ct.ThoigianKT = node.Elements ().ElementAt (10).Value.Trim ().Substring (12);
						ct.Tuan = convertToDate (setTKB_Tuan (node.Elements ().ElementAt (13).Value.Trim ()),ct.ThoigianBD);
						AddCTLH (connection, ct);
					} else {
						k++;
						LichHoc lh = new LichHoc ();
						MonHoc mh = new MonHoc ();

						lh.Id = k.ToString ();
						lh.MaMH = node.Elements ().ElementAt (3).Value.Trim ();
						lh.MaLop = node.Elements ().ElementAt (2).Value.Trim ();
						lh.NhomMH = node.Elements ().ElementAt (5).Value.Trim ();
						lh.HocKy = node.Elements ().ElementAt (1).Value.Trim ();
						lh.NamHoc = node.Elements ().ElementAt (4).Value.Trim ();
						mh.MaMH = lh.MaMH;
						mh.TenMH = node.Elements ().ElementAt (9).Value.Trim ();
						mh.SoTC = int.Parse (node.Elements ().ElementAt (7).Value.Trim ());

						chiTietLH ct = new chiTietLH ();
						ct.Id = k.ToString ();
						ct.CBGD = node.Elements ().ElementAt (0).Value.Trim ();
						ct.Phong = node.Elements ().ElementAt (6).Value.Trim ();
						ct.Thu = node.Elements ().ElementAt (11).Value.Trim ();
						ct.TietBatDau = node.Elements ().ElementAt (12).Value.Trim ();
						ct.SoTiet = node.Elements ().ElementAt (8).Value.Trim ();
						ct.ThoigianBD = node.Elements ().ElementAt (10).Value.Trim ().Substring (0, 10);
						ct.ThoigianKT = node.Elements ().ElementAt (10).Value.Trim ().Substring (12);
						ct.Tuan = convertToDate (setTKB_Tuan (node.Elements ().ElementAt (13).Value.Trim ()),ct.ThoigianBD);
						AddCTLH (connection, ct);

						bool done=AddLH (lh, connection);
						if (done) {
							list.Add (lh);
						}
						BMonHoc.Add (connection, mh);
					
					}


				}
				return list;
			}
			return null;
		}
		public static async Task<List<LichHoc>> MakeDataFromXml (SQLiteConnection connection)
		{
			list = new List<LichHoc> ();
			var httpClient = new HttpClient ();
			Task<string> contentsTask = httpClient.GetStringAsync("http://www.schoolapi.somee.com/api/thoikhoabieu/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
			int k = GetId (connection);
			DataProvider dtb = new DataProvider (connection);
			foreach (XElement node in childList) {
				
				LichHoc lichhoc = new LichHoc ();
				lichhoc = dtb.GetLH_Ma (node.Elements ().ElementAt (3).Value.Trim());

					if (lichhoc!=null) {
					chiTietLH ct = new chiTietLH ();
					ct.Id = lichhoc.Id;
					ct.CBGD = node.Elements ().ElementAt (0).Value.Trim ();
					ct.Phong = node.Elements ().ElementAt (6).Value.Trim ();
					ct.Thu = node.Elements ().ElementAt (11).Value.Trim ();
					ct.TietBatDau = node.Elements ().ElementAt (12).Value.Trim ();
					ct.SoTiet = node.Elements ().ElementAt (8).Value.Trim ();
					ct.ThoigianBD = node.Elements ().ElementAt (10).Value.Trim ().Substring (0, 10);
					ct.ThoigianKT = node.Elements ().ElementAt (10).Value.Trim ().Substring (12);
					ct.Tuan = node.Elements ().ElementAt (13).Value.Trim ();
					AddCTLH (connection, ct);
				} else {
					k++;
					LichHoc lh = new LichHoc ();
					MonHoc mh = new MonHoc ();

					lh.Id = k.ToString ();
					lh.MaMH = node.Elements ().ElementAt (3).Value.Trim ();
					lh.MaLop = node.Elements ().ElementAt (2).Value.Trim ();
					lh.NhomMH = node.Elements ().ElementAt (5).Value.Trim ();
					lh.HocKy = node.Elements ().ElementAt (1).Value.Trim ();
					lh.NamHoc = node.Elements ().ElementAt (4).Value.Trim ();
					mh.MaMH = lh.MaMH;
					mh.TenMH = node.Elements ().ElementAt (9).Value.Trim ();
					mh.SoTC = int.Parse (node.Elements ().ElementAt (7).Value.Trim ());

					chiTietLH ct = new chiTietLH ();
					ct.Id = k.ToString ();
					ct.CBGD = node.Elements ().ElementAt (0).Value.Trim ();
					ct.Phong = node.Elements ().ElementAt (6).Value.Trim ();
					ct.Thu = node.Elements ().ElementAt (11).Value.Trim ();
					ct.TietBatDau = node.Elements ().ElementAt (12).Value.Trim ();
					ct.SoTiet = node.Elements ().ElementAt (8).Value.Trim ();
					ct.ThoigianBD = node.Elements ().ElementAt (10).Value.Trim ().Substring (0, 10);
					ct.ThoigianKT = node.Elements ().ElementAt (10).Value.Trim ().Substring (12);
					ct.Tuan = node.Elements ().ElementAt (13).Value.Trim ();
					AddCTLH (connection, ct);
					list.Add (lh);
					AddLH (lh, connection);
					BMonHoc.Add (connection, mh);
					
				}


			}
			return list;
		}
		public int AddCTLH (chiTietLH T)
		{
			int i = _connection.Insert (T);
			_connection.Commit ();
			return i;
		}
		public chiTietLH checkCTLH (chiTietLH ct)
		{
			var query = from c in _connection.Table<chiTietLH> ()
			            where c.Id.Equals (ct.Id) && c.Thu.Equals (ct.Thu) && c.Phong.Equals (ct.Phong)
			            select c;
			return query.FirstOrDefault ();
		}
Exemple #10
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 ();
		
		}
		public Task RemindAllLH( List<LichHoc> listlh)
		{
			isSaveId = true;
			return Task.Run(()=>
				{
					foreach (LichHoc lh in listlh) {
						List<chiTietLH> cts = BLichHoc.GetCTLH (SQLite_Android.GetConnection (), lh.Id);
						foreach (chiTietLH ct in cts)
						{
							List<string> listNgayHoc = Common.strListTuanToArrayString (ct.Tuan);
							foreach (string s in listNgayHoc) {
								DateForCTLH = s;
								ctlh = ct;
								this.lh = lh;
								SetCalenDarLH ();
							}
						}

					}
					isSaveId = false;}
			);
		}