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.DrugInfoFragment, container, false); table = rootView.FindViewById<TableLayout> (Resource.Id.difTableLayout); user = Common.GetCurrentUser (); project = Common.GetProject (user.username); infos = Common.GetInfos (user.username); List<Drug> allDrugs = Common.GetDrugs (user.username); if (project.drugsInWeek > 0) { DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo; int currWeek = dfi.Calendar.GetWeekOfYear (DateTime.Now, dfi.CalendarWeekRule, dfi.FirstDayOfWeek); int skip = (currWeek - project.startWeek) % (allDrugs.Count / project.drugsInWeek); drugs = (from drug in allDrugs orderby drug.id select drug ).Skip (skip * project.drugsInWeek) .Take (project.drugsInWeek) .ToList<Drug> (); } else { drugs = allDrugs; } // AttendanceResultManager.SetCurrentAttendanceResults (null); newAttendanceResults = AttendanceResultManager.GetCurrentAttendanceResults (); if ((newAttendanceResults == null) || (newAttendanceResults.Count == 0)) { newAttendanceResults = AttendanceResultManager.GenerateResults (infos, drugs, @"N"); } RefreshTable (); // Activity.Window.SetSoftInputMode (SoftInput.StateAlwaysHidden); return rootView; }
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); base.OnCreateView (inflater, container, savedInstanceState); View rootView = inflater.Inflate (Resource.Layout.Block1Fragment, container, false); pharmacyID = Arguments.GetInt (Common.PHARMACY_ID); user = Common.GetCurrentUser (); netCategories = Common.GetNetCategories (user.username); promos = Common.GetPromos (user.username); merchant = Common.GetMerchant (user.username); territory = Common.GetTerritory (user.username); pharmacy = PharmacyManager.GetPharmacy (pharmacyID); var tradenets = Common.GetTradeNets (user.username); Dictionary <int, string> tnDict = new Dictionary<int, string> (); foreach (var item in tradenets) { tnDict.Add (item.id, item.shortName); }; attendance = AttendanceManager.GetCurrentAttendance (); if (attendance == null) { attendance = AttendanceManager.GetLastAttendance (pharmacyID); if (attendance == null) { attendance = new Attendance () { pharmacy = pharmacyID, date = DateTime.Now, merchant = merchant.id }; } else { attendance.id = -1; attendance.date = DateTime.Now; } } rootView.FindViewById<TextView> (Resource.Id.b1fTradenetText).Text = tnDict [pharmacy.tradenet];//@"Аптечная Сеть"; rootView.FindViewById<TextView> (Resource.Id.b1fCityText).Text = territory.baseCity; rootView.FindViewById<TextView> (Resource.Id.b1fPharmacyNameText).Text = pharmacy.shortName; rootView.FindViewById<TextView> (Resource.Id.b1fPharmacyAddressText).Text = pharmacy.address; rootView.FindViewById<TextView> (Resource.Id.b1fCategoryInOTCText).Text = pharmacy.category_otc; rootView.FindViewById<TextView> (Resource.Id.b1fLastAttendanceText).Text = pharmacy.prev == DateTime.MinValue ? String.Empty : pharmacy.prev.ToString (@"d"); rootView.FindViewById<TextView> (Resource.Id.b1fNextAttendanceText).Text = pharmacy.next == DateTime.MinValue ? String.Empty : pharmacy.next.ToString (@"d"); rootView.FindViewById<TextView> (Resource.Id.b1fAllAttendanciesText).Text = AttendanceManager.GetStatistics(pharmacy.id); categoryNetSpinner = rootView.FindViewById<Spinner> (Resource.Id.b1fCategoryNetSpinner); ArrayAdapter adapter = new ArrayAdapter (Activity, Android.Resource.Layout.SimpleSpinnerItem, (from item in netCategories select item.key).ToArray<string>()); adapter.SetDropDownViewResource(Resource.Layout.SpinnerItem); categoryNetSpinner.Adapter = adapter; categoryNetSpinner.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) => { attendance.category_net = netCategories[e.Position].id; }; // SetValue for (int i = 0; i < netCategories.Count; i++) { if (netCategories [i].id == attendance.category_net) { categoryNetSpinner.SetSelection (i); } } telephoneEdit = rootView.FindViewById<EditText> (Resource.Id.b1fTelephoneEdit); telephoneEdit.Text = attendance.telephone; purchaserFIOEdit = rootView.FindViewById<EditText> (Resource.Id.b1fPurchaserFIOEdit); purchaserFIOEdit.Text = attendance.purchaserFIO; promosEdit = rootView.FindViewById<EditText> (Resource.Id.b1fPromosEdit); promosButton = rootView.FindViewById<Button> (Resource.Id.b1fPromosButton); promosButton.Click += (object sender, EventArgs e) => { bool[] checkedItems = new bool[promos.Count]; if (attendance.promos != null) { for (int i = 0; i < promos.Count; i++) { if(attendance.promos.Contains(promos[i].id)){ checkedItems[i] = true; tempPromos.Add(promos[i].id); } } } string[] items = (from promo in promos orderby promo.id select promo.name).ToArray<string>(); AlertDialog.Builder builder; builder = new AlertDialog.Builder(Activity); builder.SetTitle("Выбор ПРОМО-матералов"); builder.SetCancelable(false); builder.SetMultiChoiceItems(items, checkedItems, MultiListClicked); builder.SetPositiveButton(@"Сохранить", delegate { attendance.promos = tempPromos.ToArray<int>(); builder.Dispose(); RefreshPromos(); } ); builder.SetNegativeButton(@"Отмена", delegate { builder.Dispose(); }); builder.Show(); }; RefreshPromos(); pharmacistCountEdit = rootView.FindViewById<EditText> (Resource.Id.b1fPharmacistCountEdit); pharmacistCountEdit.Text = attendance.pharmacistCount.ToString (); commentEdit = rootView.FindViewById<EditText> (Resource.Id.b1fCommentEdit); commentEdit.Text = attendance.comment; RefreshControlsState (); return rootView; }
public static string GetDirForPhotos(User user) { return Path.Combine(DatabaseFileDir, user.username, @"Photos"); }
public static bool CreateDirForPhotos(User user) { string storeLocation = Path.Combine(GetDirForPhotos(user), @"photos.xml"); new FileInfo(storeLocation).Directory.Create(); return true; }
public static bool SetUser(string username, User user) { string storeLocation = Path.Combine(DatabaseFileDir, username, @"user.xml"); new FileInfo(storeLocation).Directory.Create(); var serializer = new XmlSerializer(typeof(User)); using (var writer = new StreamWriter(storeLocation)) { serializer.Serialize(writer, user); } return true; }
void RefreshMainView() { user = Common.GetCurrentUser (); if (user == null) { content.Visibility = ViewStates.Gone; upPanel.Visibility = ViewStates.Gone; botPanel.Visibility = ViewStates.Gone; pharamcyTable.Visibility = ViewStates.Gone; beforeSignIn.Visibility = ViewStates.Visible; } else { // Testing // List<Promo> promos = new List<Promo> (); // // promos.Add (new Promo { id = 1, name = @"Промо1", key = @"П1" }); // promos.Add (new Promo { id = 2, name = @"Промо2", key = @"П2" }); // promos.Add (new Promo { id = 4, name = @"Промо3", key = @"п3" }); // // Common.SetPromos (user.username, promos); // // List<NetCategory> netCategories = new List<NetCategory> (); // // netCategories.Add (new NetCategory { id = 1, name = @"КатСети1", key = @"Кат1" }); // netCategories.Add (new NetCategory { id = 2, name = @"КатСети2", key = @"Кат2" }); // netCategories.Add (new NetCategory { id = 3, name = @"КатСети3", key = @"Кат3" }); // netCategories.Add (new NetCategory { id = 4, name = @"КатСети4", key = @"Кат4" }); // // Common.SetNetCategories (user.username, netCategories); AttendanceManager.SetCurrentAttendance (null); // Testing Common.SetIsAttendanceRun (user.username, isVisitStart); content.Visibility = ViewStates.Gone; beforeSignIn.Visibility = ViewStates.Gone; // Set Up Panel upPanel.Visibility = ViewStates.Visible; botPanel.Visibility = ViewStates.Visible; upStartAttendance.Visibility = ViewStates.Gone; upEndAttendance.Visibility = ViewStates.Gone; upClose.Visibility = ViewStates.Gone; upNextBlock.Visibility = ViewStates.Gone; upPrevBlock.Visibility = ViewStates.Gone; Project project = Common.GetProject (user.username); Territory territory = Common.GetTerritory (user.username); upInfo.Visibility = ViewStates.Visible; upLogout.Visibility = ViewStates.Visible; upSync.Visibility = ViewStates.Visible; upInfo.Text = string.Format (@"ПРОЕКТ : {0}; ГОРОД : {1}", project.fullName, territory.baseCity); RefreshPharmacyTable (); } }
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; }