예제 #1
0
        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 ();

            //return base.OnCreateView (inflater, container, savedInstanceState);

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

            rlBeforeSignIn = rootView.FindViewById<RelativeLayout> (Resource.Id.ifBeforeSignInLayout);
            llAfterSignIn = rootView.FindViewById<LinearLayout> (Resource.Id.ifAfterSignInLayout);

            bSignIn = rootView.FindViewById<Button> (Resource.Id.ifSignInButton);

            bSignIn.Click += (object sender, EventArgs e) => {
                //rlBeforeSignIn.Visibility = ViewStates.Gone;
                FragmentTransaction trans = FragmentManager.BeginTransaction ();
                SigninDialog signinDialog = new SigninDialog (this.Activity);
                //signinDialog.Dialog.SetCanceledOnTouchOutside(true); //Cancelable = true;
                //signinDialog
                signinDialog.Show (trans, "dialog fragment");

            //				Resource.Drawable.

                Log.Info ("ifSignInButton", "Click");
            };

            if (user != null) {
                Log.Info ("InfoFragment", "user IS NOT NULL");

                rlBeforeSignIn.Visibility = ViewStates.Gone;

                Rout rout = new Rout (){Date = DateTime.Now};

                View userCard = inflater.Inflate (Resource.Layout.InfoCard, container, false);
                var ucTitle = userCard.FindViewById<TextView> (Resource.Id.icTitle);
                var ucTable = userCard.FindViewById<TableLayout> (Resource.Id.icInfoTable);

                ucTitle.Text = @"Пользователь";

                ucTable.AddView (GetRow(@"ID", user.id.ToString()));
                ucTable.AddView (GetRow(@"Username", user.username));
                ucTable.AddView (GetRow(@"E-mail", user.email));
                ucTable.AddView (GetRow(@"Password", user.password));

                llAfterSignIn.AddView(userCard);

                View merchantCard = inflater.Inflate (Resource.Layout.InfoCard, container, false);
                var mcTitle = merchantCard.FindViewById<TextView> (Resource.Id.icTitle);
                var mcTable = merchantCard.FindViewById<TableLayout> (Resource.Id.icInfoTable);

                mcTitle.Text = @"Представитель";

                var merchant = Common.GetMerchant (user.username);
                mcTable.AddView (GetRow(@"ID", merchant.id.ToString()));
                mcTable.AddView (GetRow(@"ФИО", merchant.lastName + @" " +merchant.firstName));
                mcTable.AddView (GetRow(@"Телефон", merchant.phone));
                mcTable.AddView (GetRow(@"Менеджер", merchant.manager.ToString()));

                llAfterSignIn.AddView(merchantCard);

                View managerCard = inflater.Inflate (Resource.Layout.InfoCard, container, false);
                var managercTitle = managerCard.FindViewById<TextView> (Resource.Id.icTitle);
                var managercTable = managerCard.FindViewById<TableLayout> (Resource.Id.icInfoTable);

                managercTitle.Text = @"Менеджер";

                var manager = Common.GetManager (user.username);
                managercTable.AddView (GetRow(@"ID", manager.id.ToString()));
                managercTable.AddView (GetRow(@"ФИО", manager.lastName + @" " +manager.firstName));
                managercTable.AddView (GetRow(@"Телефон", manager.phone));
                managercTable.AddView (GetRow(@"Начальник", manager.head.ToString()));

                llAfterSignIn.AddView(managerCard);

                View projectCard = inflater.Inflate (Resource.Layout.InfoCard, container, false);
                var projectcTitle = projectCard.FindViewById<TextView> (Resource.Id.icTitle);
                var projectcTable = projectCard.FindViewById<TableLayout> (Resource.Id.icInfoTable);

                projectcTitle.Text = @"Проект";

                var project = Common.GetProject (user.username);
                projectcTable.AddView (GetRow(@"ID", project.id.ToString()));
                projectcTable.AddView (GetRow(@"Название", project.fullName));
                projectcTable.AddView (GetRow(@"Описание", project.description));
                if (project.drugs != null) {
                    projectcTable.AddView (GetRow (@"Препараты", string.Join (", ", project.drugs)));
                } else {
                    projectcTable.AddView (GetRow (@"Препараты", @""));
                }

                llAfterSignIn.AddView(projectCard);

                View drugsCard = inflater.Inflate (Resource.Layout.InfoCard, container, false);
                var drugscTitle = drugsCard.FindViewById<TextView> (Resource.Id.icTitle);
                var drugscTable = drugsCard.FindViewById<TableLayout> (Resource.Id.icInfoTable);

                drugscTitle.Text = @"Препараты";

                var drugs = Common.GetDrugs (user.username);
                drugscTable.AddView (GetRow(@"ID", @"Наименование"));
                foreach (var drug in drugs) {
                    drugscTable.AddView (GetRow(drug.id.ToString(), drug.fullName));
                }

                llAfterSignIn.AddView(drugsCard);

                View territoryCard = inflater.Inflate (Resource.Layout.InfoCard, container, false);
                var territoryTitle = territoryCard.FindViewById<TextView> (Resource.Id.icTitle);
                var territoryTable = territoryCard.FindViewById<TableLayout> (Resource.Id.icInfoTable);

                territoryTitle.Text = @"Территория";

                var territory = Common.GetTerritory (user.username);
                territoryTable.AddView (GetRow(@"ID", territory.id.ToString()));
                territoryTable.AddView (GetRow(@"Название", territory.name));
                territoryTable.AddView (GetRow(@"Информация", territory.info));
                territoryTable.AddView (GetRow (@"Осн. город", territory.baseCity));
                var pharmacies = PharmacyManager.GetPharmacies ();
                territoryTable.AddView (GetRow (@"Кол-во аптек", pharmacies.Count.ToString()));

                llAfterSignIn.AddView(territoryCard);
            }
            //string [] planets = Resources.GetStringArray (Resource.Array.planets_array);
            //TextView txt = rootView.FindViewById<TextView> (Resource.Id.text);
            //txt.Text = @"Hi!";//planets [this.Arguments.GetInt (POSITION)];

            return rootView;
        }
예제 #2
0
        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);
        }
예제 #4
0
 public static string GetDirForPhotos(User user)
 {
     return Path.Combine(DatabaseFileDir, user.username, @"Photos");
 }
        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 ();

            //			currentRout = GetRout ();
            int[] ids = {1,2,3,4,5};
            currentPharmacies = (List<Pharmacy>)PharmacyManager.GetPharmacies (ids);

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

            var res = new AttendanceResult () { id = 1, attendance = 1, drug = 1, info = 1, value = @"N" };

            AttendanceResultManager.SaveAttendanceResult (res);

            var att = new Attendance (1, new DateTime (2015, 10, 28), infos, drugs, @"N");
            AttendanceManager.SaveAttendance (att);

            currentAttendances = (List<Attendance>)AttendanceManager.GetAttendances (currentPharmacies [0].id);

            List<DrugInfo> dInfos = new List<DrugInfo>();
            drugInfo = new DrugInfo(1);

            drugInfo.attendaces.Add (new Attendance (1, new DateTime (2015, 10, 29), infos, drugs) { id = ++AttID });
            drugInfo.attendaces.Add (new Attendance (1, new DateTime (2015, 10, 30), infos, drugs) { id = ++AttID });
            drugInfo.attendaces.Add (new Attendance (1, new DateTime (2015, 10, 31), infos, drugs) { id = ++AttID });

            SetDrugInfoValue (drugInfo, new DateTime (2015, 10, 29), 2, 1, 1.ToString ());

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

            string[] planets_array = Resources.GetStringArray (Resource.Array.planets_array);

            Pharmacy pharmacy = new Pharmacy { id = 1, fullName = @"ООО Аптека №1", shortName = @"Аптека  №1", address = @"Перекопская, 34" };
            string json = JsonConvert.SerializeObject (pharmacy);
            Log.Info (@"JSON_Pharm", json);
            text = rootView.FindViewById<TextView> (Resource.Id.largeText);
            //text.Text = @"Привет!!!";
            text.Text = json;

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

            RefreshTable ();

            return rootView;
            //return base.OnCreateView (inflater, container, savedInstanceState);
        }
예제 #6
0
 public static bool CreateDirForPhotos(User user)
 {
     string storeLocation = Path.Combine(GetDirForPhotos(user),  @"photos.xml");
     new FileInfo(storeLocation).Directory.Create();
     return true;
 }
예제 #7
0
        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;
        }
예제 #8
0
        public void selectPosition(int position, AdapterView.ItemClickEventArgs e)
        {
            Bundle args = new Bundle ();

            //			if (fragment is InfoFragment) {
            //				username = fragment.Arguments.GetString (InfoFragment.USERNAME);
            //			}

            string navMenuKey = navMenu.Keys [position];

            switch (navMenuKey) {
                case MainMenu.SIGN:
                    if (user != null) {
                        user = null;
                        Common.SetCurrentUser (user);
                        RefreshFullMenu ();
                        fragment = new InfoFragment ();
                        fragment.Arguments = args;
                    } else {
                        user = Common.GetCurrentUser ();
                        RefreshFullMenu ();
                        fragment = new InfoFragment ();
                        fragment.Arguments = args;
                    }
                    break;
                case MainMenu.MAIN:
                    fragment = new MainFragment ();
                    break;
                case MainMenu.PHARMACY:
                    fragment = new PharmacyFragment ();
                    break;
                case MainMenu.INFO:
                    fragment = new InfoFragment ();
                    fragment.Arguments = args;
            //				((InfoFragment)fragment).OnSuc
                    break;
                case MainMenu.ROUT:
                    fragment = new RoutFragment ();
                    fragment.Arguments = args;
                    break;
            case MainMenu.SYNC:
                fragment = new SyncFragment ();
                fragment.Arguments = args;
                break;
                default:
                    fragment = new MyFragment();

                    args.PutInt (MyFragment.POSITION, position);
                    fragment.Arguments = args;
                    break;
            }
            //			Toast.MakeText(this, menuList.ToString(), ToastLength.Short).Show();

            this.FragmentManager.BeginTransaction ().Replace (Resource.Id.content_frame, fragment).Commit();

            leftDrawer.SetItemChecked (position, true);

            ActionBar.Title = navMenu[navMenuKey];//planetTitles [position];

            drawerLayout.CloseDrawer (leftDrawer);
        }
예제 #9
0
        public static string[] GetItems(User user)
        {
            if (user != null) {
                menuDict [SIGN] = user.username + @"(Выход)";
            } else {
                menuDict [SIGN] = @"Вход";
            }

            RefreshMenuItems ();

            return menuItems;
        }
예제 #10
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);

            RequestWindowFeature (WindowFeatures.ActionBar);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);
            ActionBar.NavigationMode = ActionBarNavigationMode.Standard;
            planetTitles = Resources.GetStringArray (Resource.Array.planets_array);
            //MainMenu mainMenu = new MainMenu();
            //MainMenu.GetMenu ().Values.CopyTo (planetTitles, 0);

            navMenu = MainMenu.GetMenu ();

            leftDrawer = FindViewById<ListView> (Resource.Id.left_drawer);

            //			user = new User {username = @"Zvezdova", email = @"*****@*****.**"};

            user = Common.GetCurrentUser ();

            RefreshFullMenu ();

            //leftDrawer.AddView (lv);

            //LayoutInflater.Inflate (Resource.Layout.MerchantInfo, leftDrawer, true);

            leftDrawer.ItemClick += delegate(object sender, AdapterView.ItemClickEventArgs e) {
                selectPosition(e.Position, e);
            };

            //LayoutInflater inflater = (LayoutInflater)this.BaseContext.GetSystemService (Context.LayoutInflaterService);

            //View view = inflater.Inflate (Resource.Layout.MerchantInfo, null, true);

            //leftDrawer.AddHeaderView (view);

            drawerLayout = FindViewById<DrawerLayout> (Resource.Id.drawer_layout);
            drawerToggle = new ActionBarDrawerToggle (
                this,
                drawerLayout,
                Resource.Drawable.ic_drawer,
                Resource.String.drawer_open,
                Resource.String.drawer_close
            );

            drawerLayout.SetDrawerListener (drawerToggle);

            /**
             *  Необходимо для работы иконки в качестве переключателя
             */
            ActionBar.SetDisplayHomeAsUpEnabled (true);
            ActionBar.SetHomeButtonEnabled (true);

            if (bundle == null) {
                if (user == null) {
                    selectPosition (navMenu.IndexOfKey (MainMenu.INFO), null);
                } else {
                    selectPosition (navMenu.IndexOfKey (MainMenu.MAIN), null);
                }
            }
        }