void UpEndAttendance_Click(object sender, EventArgs e) { isVisitStart = false; Common.SetIsAttendanceRun(user.username, isVisitStart); locMgr.RemoveUpdates(this); // SAVE upPrevBlock.Visibility = ViewStates.Gone; upNextBlock.Visibility = ViewStates.Gone; FragmentManager.BeginTransaction().Remove(fragment).Commit(); fragmentNum = 1; Attendance newAttendance = AttendanceManager.GetCurrentAttendance(); List <AttendanceResult> newAttendanceResults = AttendanceResultManager.GetCurrentAttendanceResults(); List <AttendancePhoto> newAttendancePhotos = AttendancePhotoManager.GetCurrentAttendancePhotos(); // List<AttendanceGPSPoint> newAttendanceGPSPoints = AttendanceGPSPointManager.GetCurrentAttendanceGPSPoints (); int attID = AttendanceManager.SaveAttendance(newAttendance); if (newAttendanceResults != null) { AttendanceResultManager.SaveNewAttendanceResults(attID, newAttendanceResults); } if (newAttendancePhotos != null) { AttendancePhotoManager.SaveNewAttendancePhotos(attID, newAttendancePhotos); } if (attendanceGPSPoints != null) { AttendanceGPSPointManager.SaveNewAttendanceGPSPoints(attID, attendanceGPSPoints); } //Correct Pharmacy Pharmacy pharmacy = PharmacyManager.GetPharmacy(selectedPharmacyID); pharmacy.prev = DateTime.Now; pharmacy.next = DateTimeFormatInfo.CurrentInfo.Calendar.AddWeeks(pharmacy.prev, 2); PharmacyManager.SavePharmacy(pharmacy); //Clear AttendanceManager.SetCurrentAttendance(null); AttendanceResultManager.SetCurrentAttendanceResults(null); AttendancePhotoManager.SetCurrentAttendancePhotos(null); RefreshMainView(); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Use this to return your custom view for this Fragment // return inflater.Inflate(Resource.Layout.YourFragment, container, false); layoutInflater = inflater; base.OnCreateView(inflater, container, savedInstanceState); View rootView = inflater.Inflate(Resource.Layout.PhotoAddFragment, container, false); user = Common.GetCurrentUser(); photoTypes = Common.GetPhotoTypes(user.username); photoTypesDict = new Dictionary <int, PhotoType> (); foreach (var item in photoTypes) { photoTypesDict.Add(item.id, item); } photoSubTypes = Common.GetPhotoSubTypes(user.username); photoSubTypesDict = new Dictionary <int, PhotoSubType> (); foreach (var item in photoSubTypes) { photoSubTypesDict.Add(item.id, item); } newAttendancePhotos = AttendancePhotoManager.GetCurrentAttendancePhotos(); if ((newAttendancePhotos == null) || (newAttendancePhotos.Count == 0)) { newAttendancePhotos = new List <AttendancePhoto> (); } llPhotoList = rootView.FindViewById <LinearLayout> (Resource.Id.pafAddedPhotoLL); RefreshPhotoList(); spnPhotoTypes = rootView.FindViewById <Spinner> (Resource.Id.pafPhotoTypeSpinner); ArrayAdapter adapter = new ArrayAdapter(Activity, Android.Resource.Layout.SimpleSpinnerItem, (string [])(from item in photoTypes select item.name).ToArray()); adapter.SetDropDownViewResource(Resource.Layout.SpinnerItem); spnPhotoTypes.Adapter = adapter; spnPhotoTypes.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) => { int photoTypesID = photoTypes [e.Position].id; currentPhotoSubTypes = (List <PhotoSubType>)(from item in photoSubTypes where item.type == photoTypesID select item).ToList(); ArrayAdapter adapterPST = new ArrayAdapter(Activity, Android.Resource.Layout.SimpleSpinnerItem, (string [])(from item in currentPhotoSubTypes select item.name).ToArray()); adapterPST.SetDropDownViewResource(Resource.Layout.SpinnerItem); spnPhotoSubTypes.Adapter = adapterPST; }; spnPhotoSubTypes = rootView.FindViewById <Spinner> (Resource.Id.pafPhotoSubTypeSpinner); btnAddPhoto = rootView.FindViewById <Button> (Resource.Id.pafAddPhotoButton); btnAddPhoto.Click += (object sender, EventArgs e) => { if (Common.CreateDirForPhotos(user)) { string type = photoTypes[spnPhotoTypes.SelectedItemPosition].name; type = Transliteration.Front(type, TransliterationType.Gost).Substring(0, Math.Min(5, type.Length)).ToUpper(); string subtype = currentPhotoSubTypes[spnPhotoSubTypes.SelectedItemPosition].name; subtype = Transliteration.Front(subtype, TransliterationType.Gost).Substring(0, Math.Min(5, subtype.Length)).ToUpper(); string stamp = DateTime.Now.ToString(@"yyyyMMddHHmmsszz"); file = new Java.IO.File(Common.GetDirForPhotos(user), String.Format("PHOTO_{0}_{1}_{2}.jpg", type, subtype, stamp)); Intent intent = new Intent(MediaStore.ActionImageCapture); intent.PutExtra(MediaStore.ExtraOutput, Android.Net.Uri.FromFile(file)); StartActivityForResult(intent, 0); } }; return(rootView); }