예제 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate (savedInstanceState);

            SetContentView (Resource.Layout.AddLaborPopUpLayout);
            SetCancelable (true);

            var cancel = (Button)FindViewById (Resource.Id.cancelAddLabor);
            cancel.Click += (sender, e) => Dismiss ();

            delete = (Button)FindViewById (Resource.Id.deleteAddLabor);
            delete.Enabled = !Assignment.IsHistory;
            delete.Click += (sender, e) => {
                //delete & reload
                if (CurrentLabor != null && CurrentLabor.Id != -1)
                    DeleteLabor ();
                else
                    Dismiss ();
            };

            var save = (Button)FindViewById (Resource.Id.saveAddLabor);
            save.Enabled = !Assignment.IsHistory;
            save.Click += (sender, e) => SaveLabor ();

            var addHours = (ImageButton)FindViewById (Resource.Id.addLaborHours);
            addHours.Enabled = !Assignment.IsHistory;
            addHours.Click += (sender, e) => {
                //add to the hours
                double total = hours.Text.ToDouble (CultureInfo.InvariantCulture);
                total += .5;
                CurrentLabor.Hours = TimeSpan.FromHours (total);
                hours.Text = total.ToString ("0.0");
            };

            var subtractHours = (ImageButton)FindViewById (Resource.Id.subtractLaborHours);
            subtractHours.Enabled = !Assignment.IsHistory;
            subtractHours.Click += (sender, e) => {
                //subtract the hours
                double total = hours.Text.ToDouble (CultureInfo.InvariantCulture);
                total -= .5;
                total = total < 0.0 ? 0.0 : total;
                CurrentLabor.Hours = TimeSpan.FromHours (total);
                hours.Text = total.ToString ("0.0");
            };

            type = (Spinner)FindViewById (Resource.Id.addLaborHoursType);
            type.Enabled = !Assignment.IsHistory;
            description = (EditText)FindViewById (Resource.Id.addLaborDescription);
            description.Enabled = !Assignment.IsHistory;
            hours = (TextView)FindViewById (Resource.Id.addLaborHoursText);
            hours.Enabled = !Assignment.IsHistory;

            var adapter = new LaborTypeSpinnerAdapter (laborTypes, Context, Resource.Layout.SimpleSpinnerItem);
            adapter.TextColor = Color.Black;
            type.Adapter = adapter;

            if (CurrentLabor != null)
                type.SetSelection (laborTypes.ToList ().IndexOf (CurrentLabor.Type));

            type.ItemSelected += (sender, e) => {
                var laborType = laborTypes [e.Position];
                if (CurrentLabor.Type != laborType)
                    CurrentLabor.Type = laborType;
            };
        }
예제 #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.AddLaborPopUpLayout);
            SetCancelable(true);

            var cancel = (Button)FindViewById(Resource.Id.cancelAddLabor);

            cancel.Click += (sender, e) => Dismiss();

            delete         = (Button)FindViewById(Resource.Id.deleteAddLabor);
            delete.Enabled = !Assignment.IsHistory;
            delete.Click  += (sender, e) => {
                //delete & reload
                if (CurrentLabor != null && CurrentLabor.Id != -1)
                {
                    DeleteLabor();
                }
                else
                {
                    Dismiss();
                }
            };

            var save = (Button)FindViewById(Resource.Id.saveAddLabor);

            save.Enabled = !Assignment.IsHistory;
            save.Click  += (sender, e) => SaveLabor();

            var addHours = (ImageButton)FindViewById(Resource.Id.addLaborHours);

            addHours.Enabled = !Assignment.IsHistory;
            addHours.Click  += (sender, e) => {
                //add to the hours
                double total = hours.Text.ToDouble(CultureInfo.InvariantCulture);
                total += .5;
                CurrentLabor.Hours = TimeSpan.FromHours(total);
                hours.Text         = total.ToString("0.0");
            };

            var subtractHours = (ImageButton)FindViewById(Resource.Id.subtractLaborHours);

            subtractHours.Enabled = !Assignment.IsHistory;
            subtractHours.Click  += (sender, e) => {
                //subtract the hours
                double total = hours.Text.ToDouble(CultureInfo.InvariantCulture);
                total -= .5;
                total  = total < 0.0 ? 0.0 : total;
                CurrentLabor.Hours = TimeSpan.FromHours(total);
                hours.Text         = total.ToString("0.0");
            };

            type                = (Spinner)FindViewById(Resource.Id.addLaborHoursType);
            type.Enabled        = !Assignment.IsHistory;
            description         = (EditText)FindViewById(Resource.Id.addLaborDescription);
            description.Enabled = !Assignment.IsHistory;
            hours               = (TextView)FindViewById(Resource.Id.addLaborHoursText);
            hours.Enabled       = !Assignment.IsHistory;

            var adapter = new LaborTypeSpinnerAdapter(laborTypes, Context, Resource.Layout.SimpleSpinnerItem);

            adapter.TextColor = Color.Black;
            type.Adapter      = adapter;

            if (CurrentLabor != null)
            {
                type.SetSelection(laborTypes.ToList().IndexOf(CurrentLabor.Type));
            }

            type.ItemSelected += (sender, e) => {
                var laborType = laborTypes [e.Position];
                if (CurrentLabor.Type != laborType)
                {
                    CurrentLabor.Type = laborType;
                }
            };
        }