public static void AddLH (LichHoc lt, SQLiteConnection connection)
		{
			DataProvider dtb = new DataProvider (connection);
			if (dtb.GetLH_Ma (lt.MaMH) == null) {
				dtb.AddLH (lt);
			}
		}
Exemple #2
0
		public static bool AddLH (LichHoc lh, SQLiteConnection connection)
		{
			DataProvider dtb = new DataProvider (connection);
			if (dtb.GetLH_Ma (lh.MaMH, lh.NamHoc,lh.HocKy) == null) {
				dtb.AddLH (lh);
				return true;
			}
			return 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 #4
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 #5
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 void AddLH (LichHoc lh)
		{
			_connection.Insert (lh);
			_connection.Commit ();
		}
Exemple #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;

		}
		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;}
			);
		}