Ejemplo n.º 1
0
        /*static void Main(string[] args)
         * {
         *  InitializeSomePeople();
         *  CollectionPersonIterator a = new CollectionPersonIterator();
         *  InitializeSomeProducts();
         *  CollectionProductIterator b = new CollectionProductIterator();
         *
         *  Algorytm alg = new Algorytm();
         *  alg.Count(CollectionPerson.ReturnList, CollectionProduct.ReturnList);
         *
         *  Console.WriteLine(a.Get());
         *  Console.WriteLine(b.Get());
         *
         *  Console.WriteLine("=======================================================");c
         *
         *
         *  Console.ReadKey();
         *  return;
         * }*/

        private static void InitializeSomeProducts()
        {
            List <double> lista = new List <double>();

            lista.Add(0.0);
            lista.Add(1.0);
            lista.Add(0.0);
            CollectionProduct.Add("Grabie", 150.0f, lista, "Narzedzia");

            lista[0] = 0.0f;
            lista[1] = 1.0f;
            lista[2] = 0.0f;
            CollectionProduct.Add("Cynamon", 150.0f, lista, "Jedzenie");

            lista[0] = 1.0f;
            lista[1] = 0.0f;
            lista[2] = 0.0f;
            CollectionProduct.Add("Widelec", 150.0f, lista, "Narzedzia");
        }
Ejemplo n.º 2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it


            Button addProductButton  = FindViewById <Button>(Resource.Id.AddProductButton);
            Button showProdutButton  = FindViewById <Button>(Resource.Id.ShowProductButton);
            Button mangamentButton   = FindViewById <Button>(Resource.Id.ManagmentButton);
            Button algorytmUseButton = FindViewById <Button>(Resource.Id.AlgorytmUseButton);

            addProductButton.Click += delegate { StartActivity(typeof(AddProductActivity)); };
            showProdutButton.Click += delegate {
                new ShowProductActivity();
                var intent = new Intent(this, typeof(ShowProductActivity));
                CollectionProductIterator a = new CollectionProductIterator();

                intent.PutStringArrayListExtra("phone_numbers", a.GetList());
                StartActivity(intent);
            };
            mangamentButton.Click   += delegate { StartActivity(typeof(ManagmentActivity)); };
            algorytmUseButton.Click += delegate { StartActivity(typeof(AlgorytmUseActivity)); };



            Button testButton = FindViewById <Button>(Resource.Id.TEST);

            testButton.Click += delegate
            {
                CollectionPerson.Add("Adrian", "*****@*****.**");
                CollectionPerson.Add("Kamil");
                CollectionPerson.Add("Basia", "*****@*****.**");
                CollectionPersonIterator a     = new CollectionPersonIterator();
                List <double>            lista = new List <double>();
                lista.Add(0.0);
                lista.Add(1.0);
                lista.Add(0.0);
                CollectionProduct.Add("Grabie", 150.0f, lista, "Narzedzia");

                lista[0] = 0.0f;
                lista[1] = 1.0f;
                lista[2] = 0.0f;
                CollectionProduct.Add("Cynamon", 150.0f, lista, "Jedzenie");

                lista[0] = 1.0f;
                lista[1] = 0.0f;
                lista[2] = 0.0f;
                CollectionProduct.Add("Widelec", 150.0f, lista, "Narzedzia");
                CollectionProductIterator b = new CollectionProductIterator();

                //Algorytm alg = new Algorytm();
                // alg.Count(CollectionPerson.ReturnList, CollectionProduct.ReturnList);

                //SmtpClientAccess.Program.SendEmail("*****@*****.**", a.Get());
            };
        }
Ejemplo n.º 3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.AddProductLayout);
            // Create your application here

            CheckBox cB0          = FindViewById <CheckBox>(Resource.Id.checkBox0);
            CheckBox cB1          = FindViewById <CheckBox>(Resource.Id.checkBox1);
            CheckBox cB2          = FindViewById <CheckBox>(Resource.Id.checkBox2);
            CheckBox cB3          = FindViewById <CheckBox>(Resource.Id.checkBox3);
            CheckBox cB4          = FindViewById <CheckBox>(Resource.Id.checkBox4);
            EditText productText  = FindViewById <EditText>(Resource.Id.ProductText);
            EditText prizeText    = FindViewById <EditText>(Resource.Id.PrizeText);
            EditText categoryText = FindViewById <EditText>(Resource.Id.CategoryText);
            Button   cancelButton = FindViewById <Button>(Resource.Id.CancelButton);
            Button   addButton    = FindViewById <Button>(Resource.Id.AddButton);

            int count = CollectionPerson.ReturnList.Count;

            if (0 == count)
            {
                addButton.Enabled = false;
            }

            switch (count)
            {
            case 5:
                cB4.Enabled    = true;
                cB4.Visibility = ViewStates.Visible;
                cB4.Text       = CollectionPerson.ReturnList[4].Nick;
                goto case 4;

            case 4:
                cB3.Enabled    = true;
                cB3.Visibility = ViewStates.Visible;
                cB3.Text       = CollectionPerson.ReturnList[3].Nick;
                goto case 3;

            case 3:
                cB2.Enabled    = true;
                cB2.Visibility = ViewStates.Visible;
                cB2.Text       = CollectionPerson.ReturnList[2].Nick;
                goto case 2;

            case 2:
                cB1.Enabled    = true;
                cB1.Visibility = ViewStates.Visible;
                cB1.Text       = CollectionPerson.ReturnList[1].Nick;
                goto case 1;

            case 1:
                cB0.Enabled    = true;
                cB0.Visibility = ViewStates.Visible;
                cB0.Text       = CollectionPerson.ReturnList[0].Nick;
                break;
            }

            List <CheckBox> checkBoxList = new List <CheckBox>()
            {
                cB0, cB1, cB2, cB3, cB4
            };



            cancelButton.Click += delegate { Finish(); };
            addButton.Click    += delegate
            {
                if (string.IsNullOrWhiteSpace(productText.Text))
                {
                    Toast.MakeText(this, "Nazwa jest wymagana !", ToastLength.Long).Show();
                }
                else if (double.Parse(prizeText.Text) < 0.01)
                {
                    Toast.MakeText(this, "Cena musi być dodatnia !", ToastLength.Long).Show();
                }
                else
                {
                    List <double> list    = new List <double>();
                    double        counter = 0;
                    foreach (int i in checkBoxList)
                    {
                        if (checkBoxList[i].Checked)
                        {
                            counter += 1;
                        }
                    }

                    if (0 == counter)
                    {
                        counter = 1 / count;
                    }
                    else
                    {
                        counter = 1 / counter;
                    }

                    foreach (int i in checkBoxList)
                    {
                        if (checkBoxList[i].Checked)
                        {
                            list.Add(counter);
                        }
                        else
                        {
                            list.Add(0.0);
                        }
                    }



                    CollectionProduct.Add(productText.Text, float.Parse(prizeText.Text), list, categoryText.Text);
                    Toast.MakeText(this, "Successful", ToastLength.Long).Show();
                    Finish();
                }
            };
        }