Exemple #1
0
 private void ShowJobDialogAddQuantityNumberPicker_ValueChanged(object sender, NumberPicker.ValueChangeEventArgs e)
 {
     if (e.NewVal < needToday)
     {
         showJobDialogAddQuantityNumberPicker.SetBackgroundResource(Resource.Drawable.numberPickerShapeTransparentRed);
     }
     else
     {
         showJobDialogAddQuantityNumberPicker.SetBackgroundResource(Resource.Drawable.numberPickerShapeTransparentGreen);
     }
 }
Exemple #2
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            base.OnCreateView(inflater, container, savedInstanceState);

            view = inflater.Inflate(Resource.Layout.dialog_showJob, container, false);

            database = new Database();

            int jobId = Arguments.GetInt(CHOOSEN_JOB_ID_EXTRA_NAME);

            jobs = (List <Job>)database.GetItems(this.Activity, JOB_TABLE_NAME).Result;
            job  = jobs.FirstOrDefault(j => j.Id == jobId);

            var showJobDialogEditButton = view.FindViewById <Button>(Resource.Id.showJobDialogEditButton);

            showJobDialogEditButton.Click += ShowJobDialogEditButton_Click;

            var showJobDialogDeleteButton = view.FindViewById <Button>(Resource.Id.showJobDialogDeleteButton);

            showJobDialogDeleteButton.Click += ShowJobDialogDeleteButton_Click;;

            var showJobDialogAddButton = view.FindViewById <Button>(Resource.Id.showJobDialogAddButton);

            showJobDialogAddButton.Click += ShowJobDialogAddButton_Click;

            var showJobDialogCloseButton = view.FindViewById <Button>(Resource.Id.showJobDialogCloseButton);

            showJobDialogCloseButton.Click += ShowJobDialogCloseButton_Click;

            var cancelshowJobDialogButton = view.FindViewById <Button>(Resource.Id.showJobDialogCloseButton);

            showJobDialogTitleTextView = view.FindViewById <TextView>(Resource.Id.showJobDialogTitleTextView);

            showJobDialogIsNormalizedTextView = view.FindViewById <TextView>(Resource.Id.showJobDialogIsNormalizedTextView);

            var showJobDialogNeedTodayTextView = view.FindViewById <TextView>(Resource.Id.showJobDialogNeedTodayTextView);

            showJobDialogTimeTextView = view.FindViewById <TextView>(Resource.Id.showJobDialogTimeTextView);

            showJobDialogQuantityTextView = view.FindViewById <TextView>(Resource.Id.showJobDialogQuantityTextView);

            showJobDialogChooseWorkTextView = view.FindViewById <TextView>(Resource.Id.showJobDialogChooseWorkTextView);

            showJobDialogAddQuantityNumberPicker                   = view.FindViewById <NumberPicker>(Resource.Id.showJobDialogAddQuantityNumberPicker);
            showJobDialogAddQuantityNumberPicker.MaxValue          = job.Quantity;
            showJobDialogAddQuantityNumberPicker.MinValue          = 1;
            showJobDialogAddQuantityNumberPicker.WrapSelectorWheel = false;
            showJobDialogAddQuantityNumberPicker.ValueChanged     += ShowJobDialogAddQuantityNumberPicker_ValueChanged;

            works       = (List <Work>)database.GetItems(this.Activity, WORK_TABLE_NAME).Result;
            choosenWork = works.FirstOrDefault(w => w.Id == job.WorkId);
            LinearLayout showJobDialogAddQuantityLinearLayout  = view.FindViewById <LinearLayout>(Resource.Id.showJobDialogAddQuantityLinearLayout);
            LinearLayout showJobDialogIsNormalizedLinearLayout = view.FindViewById <LinearLayout>(Resource.Id.showJobDialogIsNormalizedLinearLayout);
            LinearLayout showJobDialogNeedTodayLinearLayout    = view.FindViewById <LinearLayout>(Resource.Id.showJobDialogNeedTodayLinearLayout);

            if (job.Type == CURRENT_JOB_TYPE)
            {
                showJobDialogAddButton.Visibility = ViewStates.Gone;
                showJobDialogAddQuantityLinearLayout.Visibility = ViewStates.Gone;
                showJobDialogNeedTodayLinearLayout.Visibility   = ViewStates.Gone;
                showJobDialogEditButton.Visibility = ViewStates.Visible;
                showJobDialogIsNormalizedLinearLayout.Visibility = ViewStates.Visible;
            }
            else if (job.Type == RESERVE_JOB_TYPE)
            {
                var dailyTime = DataManager.GetDailyMinutes(this.Activity, DateTime.Now);
                needToday = DataManager.GetNeededQuantity(this.Activity, choosenWork);
                if (dailyTime < 460)
                {
                    if (needToday <= job.Quantity)
                    {
                        showJobDialogAddQuantityNumberPicker.Value = (int)Math.Round((460 - dailyTime) / choosenWork.Norm);
                    }
                    else
                    {
                        showJobDialogAddQuantityNumberPicker.Value = job.Quantity;
                    }
                    showJobDialogNeedTodayTextView.Text = needToday.ToString();
                }
                else
                {
                    showJobDialogNeedTodayTextView.Text = "0";
                }

                if (showJobDialogAddQuantityNumberPicker.MaxValue < needToday)
                {
                    showJobDialogAddQuantityNumberPicker.SetBackgroundResource(Resource.Drawable.numberPickerShapeTransparentRed);
                }
                else
                {
                    showJobDialogAddQuantityNumberPicker.SetBackgroundResource(Resource.Drawable.numberPickerShapeTransparentGreen);
                }

                showJobDialogAddButton.Visibility = ViewStates.Visible;
                showJobDialogAddQuantityLinearLayout.Visibility = ViewStates.Visible;
                showJobDialogNeedTodayLinearLayout.Visibility   = ViewStates.Visible;
                showJobDialogEditButton.Visibility = ViewStates.Gone;
                showJobDialogIsNormalizedLinearLayout.Visibility = ViewStates.Gone;
            }

            showJobDialogQuantityTextView.Text = job.Quantity.ToString();

            var          isNormalized = job.IsNormalized;
            LinearLayout showJobDialogDescriptionLinearLayout = view.FindViewById <LinearLayout>(Resource.Id.showJobDialogDescriptionLinearLayout);
            LinearLayout showJobDialogWorkIdLinearLayout      = view.FindViewById <LinearLayout>(Resource.Id.showJobDialogWorkIdLinearLayout);

            if (isNormalized == true)
            {
                showJobDialogChooseWorkTextView.Text            = choosenWork.WorkCode;
                showJobDialogIsNormalizedTextView.Text          = GetString(Resource.String.Yes);
                showJobDialogTitleTextView.Text                 = choosenWork.Name;
                showJobDialogDescriptionLinearLayout.Visibility = ViewStates.Gone;
                showJobDialogWorkIdLinearLayout.Visibility      = ViewStates.Visible;
            }
            else
            {
                showJobDialogTimeTextView.Text                  = job.Time.Value.ToString();
                showJobDialogIsNormalizedTextView.Text          = GetString(Resource.String.No);
                showJobDialogTitleTextView.Text                 = job.Description;
                showJobDialogDescriptionLinearLayout.Visibility = ViewStates.Visible;
                showJobDialogWorkIdLinearLayout.Visibility      = ViewStates.Gone;
            }

            return(view);
        }