Example #1
0
		public static void SaveLHRemind(SQLiteConnection connection,LHRemindItem item)
		{
			DataProvider dtb = new DataProvider (connection);
			if (dtb.GetLHRemind (item.IDLH,item.Date) == null) {
				dtb.AddRemindLH (item);
			}
		}
Example #2
0
		public void LoadEvent(string eventID,LHRemindItem rmItem)
		{
			try
			{
				
				if (rmItem!=null)
				{
					ItemLH= new LHRemindItem();
					ItemLH=rmItem;
				}
				else
				{
					ItemLT=new LTRemindItem();
				}

				EKEvent mySavedEvent = App.Current.EventStore.EventFromIdentifier (eventID);
				EventKitUI.EKEventEditViewController eventController =
					new EventKitUI.EKEventEditViewController ();

				eventController.EventStore = App.Current.EventStore;
				eventController.Event = mySavedEvent;

				// wire up a delegate to handle events from the controller
				eventControllerDelegate = new CreateEventEditViewDelegate (eventController);
				eventController.EditViewDelegate = eventControllerDelegate;
				isUpdate=true;
				controller.PresentViewController (eventController, true, null);
			
			}
			catch {
				BRemind.RemoveRemind (SQLite_iOS.GetConnection (), eventID);
				UIAlertView _error = new UIAlertView ("Lỗi", "Không tìm thấy Nhắc lịch đã tạo", null, "Ok", null);
				if (VCLichHoc.instance != null)
					VCLichHoc.Instance.LoadData ();
				if (VCLichHocTuan.instance != null)
					VCLichHocTuan.Instance.LoadData_Tuan (VCLichHocTuan.LoadedDate);
				if (VCLichThi.instance != null)
					VCLichThi.Instance.LoadData ();
				_error.Show ();
			}
		}
Example #3
0
		protected void LaunchCreateNewEvent ()
		{  


			// create a new EKEventEditViewController. This controller is built in an allows
			// the user to create a new, or edit an existing event.


			EKEvent newEvent = EKEvent.FromStore (App.Current.EventStore);
			// set the alarm for 10 minutes from now
			newEvent.AddAlarm (EKAlarm.FromDate ((NSDate)srtTime.AddMinutes (-60)));
			// make the event start 20 minutes from now and last 30 minutes
			newEvent.StartDate = (NSDate)srtTime;
			newEvent.EndDate = (NSDate)endTime;
			newEvent.Title = title;
			if (title.Equals("Lịch Thi")) {
				newEvent.Notes = "Môn:" + tenmh + " Phòng Thi: " + lt.PhongThi + " Ghi chú";
				ItemLT = new LTRemindItem ();
				ItemLT.EventID = newEvent.EventIdentifier;
				ItemLT.MaMH = lt.MaMH;
				ItemLT.NamHoc = lt.NamHoc;
				ItemLT.HocKy = lt.HocKy;

			} else {
				newEvent.Notes = "Môn:" + tenmh + " Phòng Học:" + ct.Phong +  " Ghi chú:";
				ItemLH = new LHRemindItem ();
				ItemLH.EventID = newEvent.EventIdentifier;
				ItemLH.Date = time;
				ItemLH.IDLH = lh.Id;
			}
			// create a new EKEventEditViewController. This controller is built in an allows
			// the user to create a new, or edit an existing event.					
			EventKitUI.EKEventEditViewController eventController =
				new EventKitUI.EKEventEditViewController ();

			// set the controller's event store - it needs to know where/how to save the event
			eventController.EventStore = App.Current.EventStore;
			eventController.Event = newEvent;

			// wire up a delegate to handle events from the controller
			eventControllerDelegate = new CreateEventEditViewDelegate (eventController);
			eventController.EditViewDelegate = eventControllerDelegate;



			// show the event controller
			controller.PresentViewController (eventController, true, null);
		}
Example #4
0
		protected void AutoCreateEventLH(string content)
		{
			try{
				tenmh = BMonHoc.GetMH (SQLite_iOS.GetConnection(),lh.MaMH).TenMH;

				srtTime=GetTime(covertToExact(time),listTimeLH[int.Parse(ct.TietBatDau)-1]);
				string timeEnd=listTimeLH[int.Parse(ct.TietBatDau)+int.Parse(ct.SoTiet)];
				switch(timeEnd)
				{
				case "09g00":
					timeEnd="08g40";
					break;
				case "14g00":
					timeEnd="13g40";
					break;

				}
				endTime=GetTime(covertToExact(time),timeEnd);
			}
			catch
			{
			}
			EKEvent newEvent = EKEvent.FromStore (App.Current.EventStore);
			// set the alarm for 10 minutes from now
			newEvent.AddAlarm (EKAlarm.FromDate ((NSDate)srtTime.AddMinutes (-60)));
			// make the event start 20 minutes from now and last 30 minutes
			newEvent.StartDate = (NSDate)srtTime;
			newEvent.EndDate = (NSDate)endTime;
			newEvent.Title = title;
			newEvent.Notes = "Môn:" + tenmh + " Phòng Học:" + ct.Phong +  " Ghi chú:"+content;
			newEvent.Calendar = App.Current.EventStore.DefaultCalendarForNewEvents;
			NSError error;
			App.Current.EventStore.SaveEvent (newEvent, EKSpan.ThisEvent,out error);
			LHRemindItem item = new LHRemindItem ();
			item.EventID = newEvent.EventIdentifier;
			item.Date = time;
			item.IDLH = lh.Id;
			BRemind.SaveLHRemind(SQLite_iOS.GetConnection (),item);
		}
Example #5
0
		public void AddRemindLH (LHRemindItem T)
		{
			_connection.Insert (T);
			_connection.Commit ();

		}
		public  void SetCalenDarLH()
		{
			TimeForCalendar time=new TimeForCalendar();
			TimeForCalendar timeend=new TimeForCalendar();
			chiTietLH ct=ctlh;

			listTimeLH= new List<string> {"07g00","07g50","09g00","09g50","10g40","12g00","12g50","13g40","14g50","15g40","17g00","17g50"
				,"18g40","19g30"};
			

			ContentValues eventValues = new ContentValues();
			string tenmh = "";
			int min=0;

			try{
				tenmh = BMonHoc.GetMH (SQLite_Android.GetConnection(),lh.MaMH).TenMH;
				min=int.Parse(ct.SoTiet)*50;
				time= new TimeForCalendar(DateForCTLH,listTimeLH[int.Parse(ct.TietBatDau)-1]);
				string timeEnd=listTimeLH[int.Parse(ct.TietBatDau)+int.Parse(ct.SoTiet)-1];
				switch(timeEnd)
				{
				case "09g00":
					timeEnd="08g40";
					break;
				case "14g00":
					timeEnd="13g40";
					break;
				case "12g00":
					timeEnd="11g30";
					break;
				case "17g00":
					timeEnd="16g30";
					break;
				}
				timeend= new TimeForCalendar(DateForCTLH,timeEnd);
				
				}
			catch{
			}
			eventValues.Put(CalendarContract.Events.InterfaceConsts.CalendarId, 1);
			eventValues.Put(CalendarContract.Events.InterfaceConsts.Title, "Nhắc Lịch Học");
			eventValues.Put(CalendarContract.Events.InterfaceConsts.Description, "Bạn Có Lịch Học Môn "+tenmh+" Ghi chú: "+content);
			eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtstart, GetDateTimeMS(time.yr,time.month,time.day,time.hr,time.min));
			eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtend,GetDateTimeMS(time.yr,time.month,time.day,timeend.hr,timeend.min));
			eventValues.Put(CalendarContract.Events.InterfaceConsts.AllDay,"0");
			eventValues.Put(CalendarContract.Events.InterfaceConsts.HasAlarm, "1");
			eventValues.Put(CalendarContract.Events.InterfaceConsts.EventTimezone,"GMT+7:00");
			eventValues.Put(CalendarContract.Events.InterfaceConsts.EventEndTimezone,"GMT+7:00");

			ContentValues remindervalues = new ContentValues();
			remindervalues.Put(CalendarContract.Reminders.InterfaceConsts.Minutes,MinutesRemind);
			remindervalues.Put (CalendarContract.Reminders.InterfaceConsts.Method, (int)Android.Provider.RemindersMethod.Alert);

			string id = checkHaveRemind (false);// return eventID if have 
			if (id != null ) {
				ctx.ContentResolver.Update (CalendarContract.Events.ContentUri,eventValues,
					CalendarContract.Events.InterfaceConsts.Id + " =? ", new String[] { id });
				remindervalues.Put (CalendarContract.Reminders.InterfaceConsts.EventId, id);
				ctx.ContentResolver.Update(CalendarContract.Reminders.ContentUri,remindervalues,
					CalendarContract.Reminders.InterfaceConsts.EventId + " =? ", new String[] { id });
				isInsert = false;
			}
			else{
				var eventUri = ctx.ContentResolver.Insert (CalendarContract.Events.ContentUri, eventValues);
				string eventID = eventUri.LastPathSegment;
				LHRemindItem item = new LHRemindItem ();
				item.EventID = eventID;
				item.Date = DateForCTLH;
				item.IDLH = lh.Id;
				//item.Mess = content;
				//item.Minute = MinutesRemind;
				BRemind.SaveLHRemind(SQLite_Android.GetConnection (),item);
				isInsert = true;
				remindervalues.Put(CalendarContract.Reminders.InterfaceConsts.EventId,eventID);
				var reminderURI= ctx.ContentResolver.Insert(CalendarContract.Reminders.ContentUri,remindervalues);
			}

		}