Esempio n. 1
0
        protected override void OnCreate(Bundle bundle)
        {
            //MainActivity _Main;

            base.OnCreate(bundle);
            // Create your application here
            SetContentView(Resource.Layout.LAddBids);

            int taskID = Intent.GetIntExtra("TaskID", -1);

            //_Main = Intent.GetType("MainActivity", null);
            //if(taskID > 0) {

            Button buttonAddBid = FindViewById <Button> (Resource.Id.btnAddBids);

            Spiner1   = FindViewById <Spinner> (Resource.Id.spinner1);
            editText1 = FindViewById <EditText> (Resource.Id.editText1);
            editText2 = FindViewById <EditText> (Resource.Id.editText2);
            editText3 = FindViewById <EditText> (Resource.Id.editText3);
            editText4 = FindViewById <EditText> (Resource.Id.editText4);
            editText5 = FindViewById <EditText> (Resource.Id.editText5);



            var Cate_List = Intent.Extras.GetStringArrayList("Cate_List") ?? new string[0];

            // Create an ArrayAdapter using the string array and a default spinner layout
            ArrayAdapter <string> adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, Cate_List);

            // Specify the layout to use when the list of choices appears
            adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            // Apply the adapter to the spinner
            Spiner1.Adapter = adapter;

            if (taskID >= 0)
            {
                var l = MainActivity.tasks [taskID];
                BidsId         = l.ID;
                editText1.Text = l.Title;
                editText2.Text = l.Text;
                editText3.Text = l.Adress;
                editText4.Text = l.Telefone;
                editText5.Text = l.Name;
                var icat = GetJSON.GetCatalogText(l.CateID);
                var cati = Cate_List.IndexOf(icat);
                Spiner1.SetSelection(cati);
            }
            buttonAddBid.Text   = (taskID == -1 ? "Добавить" : "Обновить");
            buttonAddBid.Click += (object sender, EventArgs e) =>
            {
                if (taskID >= 0)
                {
                    Update(taskID);
                }
                else
                {
                    Save();
                }
            };
        }
Esempio n. 2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

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


            ActionBar actionBar = this.ActionBar;

            actionBar.Show();

            // Get our button from the layout resource,
            // and attach an event to it
            button       = FindViewById <Button> (Resource.Id.myButton);
            prgBarMain   = FindViewById <ProgressBar> (Resource.Id.progressBarMain);
            taskListView = FindViewById <ListView> (Resource.Id.listView1);
            //if (UserId.Equals("")) {
            new GetUserIdTask(this).Execute();
            //}
            if (button != null)
            {
                button.Click += (object sender, EventArgs e) => {
                    onAddBids();
                };
            }
            // wire up task click handler
            if (taskListView != null)
            {
                taskListView.ItemLongClick += (object sender, AdapterView.ItemLongClickEventArgs e) => {
//					var taskDetails = new Intent (this, typeof (TaskDetailsScreen));
                    listMainId = e.Position;
//					taskDetails.PutExtra ("TaskID", tasks[e.Position].ID);
//					StartActivity (taskDetails);
                    //String[] mActionName ={"Посмотреть", "Изменить", "Удалить"};

                    AlertDialog.Builder builder = new AlertDialog.Builder(this);
                    builder.SetTitle("Выбирите действие");                     // заголовок для диалога

                    //builder.SetItems(mActionName, (EventHandler<DialogClickEventArgs>)null);
                    builder.SetNegativeButton("Посмотреть", (EventHandler <DialogClickEventArgs>)null);
                    builder.SetNeutralButton("Изменить", (EventHandler <DialogClickEventArgs>)null);
                    builder.SetPositiveButton("Удалить", (EventHandler <DialogClickEventArgs>)null);


                    var dialog = builder.Create();
                    dialog.Show();
                    //Ищем кнопки
                    var EditBtn   = dialog.GetButton((int)DialogButtonType.Neutral);
                    var DeleteBtn = dialog.GetButton((int)DialogButtonType.Positive);
                    var ShowBtn   = dialog.GetButton((int)DialogButtonType.Negative);
                    //Назначаем их
                    ShowBtn.Click += (sender2, args) =>
                    {
                        // Don't dismiss dialog.
                        Console.WriteLine("Действие просмотра");
                        dialog.Dismiss();
                    };
                    EditBtn.Click += (sender2, args) =>
                    {
                        // Dismiss dialog.
                        Console.WriteLine("Действие редактирования");
                        var taskDetails = new Intent(this, typeof(ActivityAddBids));
                        taskDetails.PutExtra("TaskID", listMainId);
                        if (ListCatalog == null)
                        {
                            ListCatalog = WorkEX.GetJSON.GetCatalog();
                        }
                        taskDetails.PutStringArrayListExtra("Cate_List", ListCatalog);
                        //taskDetails.PutStringArrayListExtra ("L", (IList<string>)tasks [listMainId]);
                        dialog.Dismiss();
                        StartActivity(taskDetails);
                    };
                    DeleteBtn.Click += async(sender2, args) =>
                    {
                        dialog.Dismiss();
                        prgBarMain.Visibility   = ViewStates.Visible;
                        taskListView.Visibility = ViewStates.Gone;
                        var result = await Task <bool> .Factory.StartNew(() => GetJSON.DeleteBidsByUserId(tasks [e.Position].ID));

                        new UpdateMainTask(this).Execute();
                    };
                };
            }
        }