private async void onItemCreateButtonClicked(object sender, EventArgs e)
		{	
			var packageName =Application.Context.PackageName.ToString();
			int position = VacationInfoCreateTabsFragment._viewPager.CurrentItem;
			int viewId =_container.Context.Resources.GetIdentifier ("view_"+position, "id" ,packageName);

			View currentView = _container.FindViewById (viewId);

			TextView ItemError = currentView.FindViewById<TextView> (Resource.Id.ItemError);
			TextView ItemType = currentView.FindViewById<TextView> (Resource.Id.ItemType);
			Button ItemStartDateBtn = currentView.FindViewById<Button> (Resource.Id.ItemStartDateBtn);
			Button ItemEndDateBtn = currentView.FindViewById<Button> (Resource.Id.ItemEndDateBtn);

			DateTime startDate = DateTime.Parse(ItemStartDateBtn.Text);
			DateTime endDate = DateTime.Parse(ItemEndDateBtn.Text);

			if (startDate > endDate) {
				ItemError.SetTextColor (Android.Graphics.Color.DarkRed);
				ItemError.Visibility = ViewStates.Visible;
			} else {

				VTSModelSingleton.VTSModel.VacationType = ItemType.Text;
				VTSModelSingleton.VTSModel.StartDate = (long)(startDate - new DateTime (1970, 1, 1)).TotalMilliseconds;
				VTSModelSingleton.VTSModel.EndDate = (long)(endDate - new DateTime (1970, 1, 1)).TotalMilliseconds;
				VTSModelSingleton.VTSModel.Status = "redCircle.png";

				ModelConverter converter = new ModelConverter ();
				VTSModelSingleton.VTSModel.Date = converter.ConvertDateToString (VTSModelSingleton.VTSModel.StartDate, VTSModelSingleton.VTSModel.EndDate);

				if (_imageUri != null) {
					PlatformConverter platformConverter = new PlatformConverter (_container.Context);
					VTSModelSingleton.VTSModel.Image = platformConverter.GetByteByURI (_imageUri);
				}

				await ViewDispose ();

				Intent myIntent = new Intent (_container.Context, typeof(MainActivity));
				myIntent.PutExtra ("Type", "Create");
				((Activity)_container.Context).SetResult (Result.Ok, myIntent);
				((Activity)_container.Context).Finish();
			}
		}
Пример #2
0
		private async void onVacationUpdateButtonClicked(object sender, EventArgs e)
		{	
			if (_startDate > _endDate) {
				_vacationError.SetTextColor (Android.Graphics.Color.DarkRed);
				_vacationError.Visibility = ViewStates.Visible;

			} else {
				VTSModelSingleton.VTSModel.StartDate = (long)(_startDate - new DateTime (1970, 1, 1)).TotalMilliseconds;
				VTSModelSingleton.VTSModel.EndDate = (long)(_endDate - new DateTime (1970, 1, 1)).TotalMilliseconds;

				if (_imageUri != null) {
					PlatformConverter platformConverter = new PlatformConverter (this.ApplicationContext);
					VTSModelSingleton.VTSModel.Image = platformConverter.GetByteByURI (_imageUri);
				}

				ModelConverter modelConverter = new ModelConverter ();
				VTSModelSingleton.VTSModel.Date = modelConverter.ConvertDateToString (VTSModelSingleton.VTSModel.StartDate, VTSModelSingleton.VTSModel.EndDate);

				Intent myIntent = new Intent (this, typeof(MainActivity));
				SetResult (Result.Ok, myIntent);

				Finish ();
				await ViewDispose ();
			}
		}