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

            View rootView = inflater.Inflate(Resource.Layout.MainFragment, container, false);

            text = rootView.FindViewById<TextView> (Resource.Id.largeText);

            user = Common.GetCurrentUser ();

            if (user == null) {
                text.Text = @"НЕТ ПРЕПАРАТОВ ИЛИ СОБИРАЕМОЙ ИНФОРМАЦИИ";
                text.SetTextAppearance (Activity, Resource.Style.text_danger);

                miAddAtt.SetEnabled (false);
                return rootView;
            }

            merchant = Common.GetMerchant (user.username);

            currentPharmacies = (List<Pharmacy>)PharmacyManager.GetPharmacies (string.Empty, 20);

            infos = Common.GetInfos (user.username);

            drugs = Common.GetDrugs (user.username);

            table = rootView.FindViewById<TableLayout> (Resource.Id.mfFullContent);

            spnSelectedPharmacy = rootView.FindViewById<Spinner> (Resource.Id.mfSelectedPharmacySpinner);

            ArrayAdapter adapter = new ArrayAdapter (Activity, Android.Resource.Layout.SimpleSpinnerItem, PharmacyManager.ToArray (currentPharmacies));

            spnSelectedPharmacy.Adapter = adapter;

            spnSelectedPharmacy.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) => {
                selectedPharmacy = currentPharmacies [e.Position].id;

                currentAttendances = (List<Attendance>)AttendanceManager.GetAttendances (selectedPharmacy);

                RefreshTable();
            };

            spnSelectedPharmacy.SetSelection (0);

            //			RefreshTable ();

            return rootView;
            //return base.OnCreateView (inflater, container, savedInstanceState);
        }
        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);
            user = Common.GetCurrentUser ();
            merchant = Common.GetMerchant (user.username);
            //			currentRout = GetRout ();
            //			int[] ids = {1,2,3,4,5};
            //			currentPharmacies = (List<Pharmacy>)PharmacyManager.GetPharmacies (ids);

            currentPharmacies = (List<Pharmacy>)PharmacyManager.GetPharmacies (string.Empty, 20);

            infos = Common.GetInfos (user.username);

            //			infos = new List<Info>();
            //			infos.Add (new Info {id = 2, name = @"Кол-во" });
            //			infos.Add (new Info {id = 4, name = @"Розница" });
            //			infos.Add (new Info {id = 6, name = @"Заказано" });

            drugs = Common.GetDrugs (user.username);

            //			AttendanceResultManager.DeleteAttendanceResult (1);
            ////			var att = new Attendance (1, new DateTime (2015, 10, 28), infos, drugs, @"N");
            //			var att = new Attendance() { id = 1, date = new DateTime (2015, 10, 28), pharmacy = 1 };
            //			AttendanceManager.SaveAttendance (att);
            //
            //			var res = AttendanceResultManager.GenerateResults(infos, drugs, @"N");
            //			AttendanceResultManager.SaveNewAttendanceResults (att.id, res);

            View rootView = inflater.Inflate(Resource.Layout.MainFragment, container, false);

            text = rootView.FindViewById<TextView> (Resource.Id.largeText);
            text.Text = @"НЕТ ПРЕПАРАТОВ ИЛИ СОБИРАЕМОЙ ИНФОРМАЦИИ";
            text.SetTextAppearance (Activity, Resource.Style.text_danger);

            table = rootView.FindViewById<TableLayout> (Resource.Id.mfFullContent);

            spnSelectedPharmacy = rootView.FindViewById<Spinner> (Resource.Id.mfSelectedPharmacySpinner);

            ArrayAdapter adapter = new ArrayAdapter (Activity, Android.Resource.Layout.SimpleSpinnerItem, PharmacyManager.ToArray (currentPharmacies));

            spnSelectedPharmacy.Adapter = adapter;

            spnSelectedPharmacy.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) => {
                selectedPharmacy = currentPharmacies [e.Position].id;

                currentAttendances = (List<Attendance>)AttendanceManager.GetAttendances (selectedPharmacy);

                RefreshTable();
            };

            spnSelectedPharmacy.SetSelection (0);

            //			RefreshTable ();

            return rootView;
            //return base.OnCreateView (inflater, container, savedInstanceState);
        }
Exemple #3
0
        public static bool SetMerchant(string username, Merchant merchant)
        {
            string storeLocation = Path.Combine(DatabaseFileDir, username, @"merchant.xml");
            new FileInfo(storeLocation).Directory.Create();
            var serializer = new XmlSerializer(typeof(Merchant));
            using (var writer = new StreamWriter (storeLocation)) {
                serializer.Serialize(writer, merchant);
            }

            return true;
        }