コード例 #1
0
        public VTSModel ConvertToVTSModel(VacationInfoModel vacationInfo)
        {
            VTSModel vtsModel = new VTSModel();

            vtsModel.Id = vacationInfo.Id;
            if (vacationInfo.Type.Value != null)
            {
                vtsModel.VacationType = vacationInfo.Type.Value;
            }
            vtsModel.StartDate = vacationInfo.StartDate;
            vtsModel.EndDate   = vacationInfo.EndDate;
            var startDate  = LocalizeMonth((new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).AddMilliseconds(vacationInfo.StartDate).ToLocalTime().ToString("MMM dd, yyyy"));
            var endDate    = LocalizeMonth((new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).AddMilliseconds(vacationInfo.EndDate).ToLocalTime().ToString("MMM dd, yyyy"));
            var _startDate = ConverterHelper.ConvertMillisecToDateTime(vacationInfo.StartDate);
            var _endDate   = ConverterHelper.ConvertMillisecToDateTime(vacationInfo.EndDate);
            var dayCount   = ConverterHelper.CalculateDuration(_startDate, _endDate);
            var days       = string.Empty;

            if (dayCount == 1)
            {
                days = _localizer.Localize("day");
            }
            else
            {
                if (dayCount > 1 && dayCount < 5)
                {
                    days = _localizer.Localize("day24");
                }
                else
                {
                    days = _localizer.Localize("days");
                }
            }
            vtsModel.Date = startDate + " - " + endDate + " (" + dayCount + " " + days + ")";
            if (vacationInfo.Status != null)
            {
                vtsModel.Status = vacationInfo.Status.Value;
            }

            if (vacationInfo.Type.Value != null)
            {
                vtsModel.VacationType = vacationInfo.Type.Value;
            }
            return(vtsModel);
        }
コード例 #2
0
ファイル: EditScreenActivity.cs プロジェクト: 5509850/vts
 private void checkDateRange()
 {
     if (_startDate != null && _endDate != null)
     {
         _vacationError.Text = (_startDate > _endDate) ? _vacationsViewModel.Localaizer.Localize("dateError") : string.Empty;
         _duration.Text      = (_startDate > _endDate) ? string.Empty : String.Format("{0} {1}", ConverterHelper.CalculateDuration(_startDate, _endDate), _vacationsViewModel.Localaizer.Localize("days"));
     }
 }
コード例 #3
0
ファイル: EditScreenActivity.cs プロジェクト: 5509850/vts
        private async void FillData()
        {
            if (_vacationsViewModel == null)
            {
                return;
            }
            _vacationInfo = await _vacationsViewModel.GetVacationInfo(_id);

            if (_vacationsViewModel.IsOnlineMode && _vacationInfo == null)
            {
                bool result = await Relogin();

                if (result)
                {
                    _vacationInfo = await _vacationsViewModel.GetVacationInfo(_id);
                }
            }
            if (_vacationInfo == null)
            {
                Intent myIntent = new Intent(this, typeof(MainScreenActivity));
                SetResult(Result.FirstUser, myIntent);
                Exit();
                return;
            }
            _vacationError.Text        = string.Empty;
            _employee.Text             = _vacationInfo.Employee.FullName;
            _vacationType.Text         = _vacationInfo.Type.Value;
            _approver.Text             = _vacationInfo.Approver.FullName;
            _startDate                 = ConverterHelper.ConvertMillisecToDateTime(_vacationInfo.StartDate);
            _vacationStartDateBtn.Text = _startDate.ToString("d");
            _endDate = ConverterHelper.ConvertMillisecToDateTime(_vacationInfo.EndDate);
            _vacationEndDateBtn.Text = _endDate.ToString("d");
            _duration.Text           = String.Format("{0} {1}", ConverterHelper.CalculateDuration(_startDate, _endDate), _vacationsViewModel.Localaizer.Localize("days"));
            if (_vacationInfo.Status.Value.Equals(VacationStatus.Approved.ToString()))
            {
                _vacationStatus.SetTextColor(Android.Graphics.Color.DarkGreen);
                _approved = true;
                _vacationStartDateBtn.Enabled                    =
                    _vacationPickImageFromGallery.Enabled        =
                        _vacationImageView.Enabled               =
                            _vacationPickImageFromCamera.Enabled =
                                _vacationEndDateBtn.Enabled      = false;
            }
            else
            {
                _approved = false;
                if (_vacationInfo.Status.Value.Equals(VacationStatus.Rejected.ToString()))
                {
                    _vacationStatus.SetTextColor(Android.Graphics.Color.DarkRed);
                }
                else
                {
                    if (_vacationInfo.Status.Value.Equals(VacationStatus.Closed.ToString()))
                    {
                        _vacationStatus.SetTextColor(Android.Graphics.Color.Black);
                        _approved = true;
                        _vacationStartDateBtn.Enabled                    =
                            _vacationPickImageFromGallery.Enabled        =
                                _vacationImageView.Enabled               =
                                    _vacationPickImageFromCamera.Enabled =
                                        _vacationEndDateBtn.Enabled      = false;
                    }
                    else
                    {
                        _vacationStatus.SetTextColor(Android.Graphics.Color.Black);
                    }
                }
            }
            if (_vacationsViewModel.Image != null)
            {
                Bitmap bmp = BitmapFactory.DecodeByteArray(_vacationsViewModel.Image, 0, _vacationsViewModel.Image.Length);
                _vacationImageView.SetImageBitmap(bmp);
            }
            _vacationStatus.Text = _vacationInfo.Status.Value;
            var translate = _vacationsViewModel.Localaizer.Localize(_vacationInfo.Status.Value);

            if (!translate.Equals("N/A"))
            {
                _vacationStatus.Text = translate;
            }
            _labelEmployee.Text                = _vacationsViewModel.Employee;
            _lavelVacationType.Text            = _vacationsViewModel.VacationType;
            _labelApprover.Text                = _vacationsViewModel.Approver;
            _labelDuration.Text                = _vacationsViewModel.Duration;
            _labelVacationStatus.Text          = _vacationsViewModel.Status;
            _labelAttachments.Text             = _vacationsViewModel.Attachments;
            _vacationPickImageFromGallery.Text = _vacationsViewModel.Gallery;
            _vacationPickImageFromCamera.Text  = _vacationsViewModel.Camera;
        }
コード例 #4
0
        private async void InintAndLocalizeNewControl()
        {
            if (TypeVacation == Utils.LIST_VACATION)
            {
                GoToListVacationScreen();
                return;
            }
            if (_vacationsViewModel == null)
            {
                GoToLoginScreen();
                return;
            }
            _vacationInfo = await _vacationsViewModel.CreateDraftVacationInfo();

            if (_vacationInfo == null && _vacationsViewModel.State == UserState.Unauthorized)
            {
                GoToLoginScreen();
                return;
            }
            _vacationError.Text = string.Empty;
            switch (TypeVacation)
            {
            case Utils.VACATION_REQUEST:
            {
                _vacationInfo.Type.Key   = "VAC";
                _vacationInfo.Type.Value = "Regular (VAC)";
                break;
            }

            case Utils.SICK_REQUEST:
            {
                _vacationInfo.Type.Key   = "ILL";
                _vacationInfo.Type.Value = "Illness (ILL)";
                break;
            }

            case Utils.OVERTIME_REQUEST:
            {
                _vacationInfo.Type.Key   = "OVT";
                _vacationInfo.Type.Value = "Overtime (OVT)";
                break;
            }

            case Utils.LIVEWOP_REQUEST:
            {
                _vacationInfo.Type.Key   = "POV";
                _vacationInfo.Type.Value = "Without pay (POV)";
                break;
            }

            case Utils.EXCEPTIONAL_REQUEST:
            {
                _vacationInfo.Type.Key   = "EXV";
                _vacationInfo.Type.Value = "EXCEPTIONAL (EXV)";
                break;
            }

            default:
            {
                _vacationInfo.Type.Key   = "VAC";
                _vacationInfo.Type.Value = "Regular (VAC)";
                break;
            }
            }
            await _vacationsViewModel.UpdateDraftVacationInfo(_vacationInfo);

            _employee.Text     = _vacationInfo.Employee.FullName;
            _vacationType.Text = _vacationInfo.Type.Value;
            _approver.Text     = _vacationInfo.Approver.FullName;
            _startDate         = ConverterHelper.ConvertMillisecToDateTime(_vacationInfo.StartDate).Date;
            //_vacationStartDateBtn.MinimumDate = (NSDate)DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
            _vacationStartDateBtn.SetDate((NSDate)_startDate.Date.AddHours(2), true);
            _endDate = ConverterHelper.ConvertMillisecToDateTime(_vacationInfo.EndDate).Date;
            //_vacationEndDateBtn.MinimumDate = (NSDate)DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
            _vacationEndDateBtn.SetDate((NSDate)_endDate.Date.AddHours(2), true);
            _duration.Text            = string.Format("{0} {1}", ConverterHelper.CalculateDuration(_startDate, _endDate), Localize("days"));
            _vacationStatus.TextColor = UIColor.Black;
            if (_vacationsViewModel.Image != null)
            {
                UIImage img = ImageConverter.ToImage(_vacationsViewModel.Image);
                if (img != null)
                {
                    _vacationImage.Image = img;
                }
            }
            _vacationStatus.Text = _vacationInfo.Status.Value;
            var translate = Localize(_vacationInfo.Status.Value);

            if (!translate.Equals("N/A"))
            {
                _vacationStatus.Text = translate;
            }
            _labelEmployee.Text       = _vacationsViewModel.Employee;
            _labelVacationType.Text   = _vacationsViewModel.VacationType;
            _labelApprover.Text       = _vacationsViewModel.Approver;
            _labelDuration.Text       = _vacationsViewModel.Duration;
            _labelVacationStatus.Text = _vacationsViewModel.Status;
            _labelAttachments.Text    = _vacationsViewModel.Attachments;
            _vacationPickImageFromGallery.SetTitle(_vacationsViewModel.Gallery, UIControlState.Normal);
            _vacationPickImageFromCamera.SetTitle(_vacationsViewModel.Camera, UIControlState.Normal);
        }
コード例 #5
0
        protected async void InintAndLocalizeControl()
        {
            if (_vacationsViewModel == null)
            {
                GoToLoginScreen();
                return;
            }
            _vacationInfo = await _vacationsViewModel.GetVacationInfo(ID);

            if (_vacationInfo == null && _vacationsViewModel.State == UserState.Unauthorized)
            {
                GoToLoginScreen();
                return;
            }
            _vacationError.Text = string.Empty;
            _employee.Text      = _vacationInfo.Employee.FullName;
            _vacationType.Text  = _vacationInfo.Type.Value;
            _approver.Text      = _vacationInfo.Approver.FullName;
            _startDate          = ConverterHelper.ConvertMillisecToDateTime(_vacationInfo.StartDate).Date;
            //_vacationStartDateBtn.MinimumDate = (NSDate)DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
            _vacationStartDateBtn.SetDate((NSDate)_startDate.Date.AddHours(2), true);
            _endDate = ConverterHelper.ConvertMillisecToDateTime(_vacationInfo.EndDate).Date;
            //_vacationEndDateBtn.MinimumDate = (NSDate)DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
            _vacationEndDateBtn.SetDate((NSDate)_endDate.Date.AddHours(2), true);
            _duration.Text = string.Format("{0} {1}", ConverterHelper.CalculateDuration(_startDate, _endDate), Localize("days"));
            if (_vacationInfo.Status.Value.Equals(VacationStatus.Approved.ToString()))
            {
                _approved = true;
                _vacationStatus.TextColor                    = UIColor.Green;
                _vacationStartDateBtn.Enabled                =
                    _vacationPickImageFromGallery.Enabled    =
                        _vacationPickImageFromCamera.Enabled =
                            _vacationEndDateBtn.Enabled      = false;
            }
            else
            {
                _approved = false;
                if (_vacationInfo.Status.Value.Equals(VacationStatus.Rejected.ToString()))
                {
                    _vacationStatus.TextColor = UIColor.Red;
                }
                else
                {
                    if (_vacationInfo.Status.Value.Equals(VacationStatus.Closed.ToString()))
                    {
                        _vacationStatus.TextColor = UIColor.Black;
                    }
                    else
                    {
                        _vacationStatus.TextColor = UIColor.Black;
                    }
                }
            }
            if (_vacationsViewModel.Image != null)
            {
                UIImage img = ImageConverter.ToImage(_vacationsViewModel.Image);
                if (img != null)
                {
                    _vacationImage.Image = img;
                }
            }
            _vacationStatus.Text = _vacationInfo.Status.Value;
            var translate = Localize(_vacationInfo.Status.Value);

            if (!translate.Equals("N/A"))
            {
                _vacationStatus.Text = translate;
            }
            _labelEmployee.Text       = _vacationsViewModel.Employee;
            _labelVacationType.Text   = _vacationsViewModel.VacationType;
            _labelApprover.Text       = _vacationsViewModel.Approver;
            _labelDuration.Text       = _vacationsViewModel.Duration;
            _labelVacationStatus.Text = _vacationsViewModel.Status;
            _labelAttachments.Text    = _vacationsViewModel.Attachments;
            _vacationPickImageFromGallery.SetTitle(_vacationsViewModel.Gallery, UIControlState.Normal);
            _vacationPickImageFromCamera.SetTitle(_vacationsViewModel.Camera, UIControlState.Normal);
        }
コード例 #6
0
        private async Task  FillData(View view)
        {
            _vacationsViewModel = FactorySingleton.Factory.Get <VacationsViewModel>();
            _vacationInfo       = await _vacationsViewModel.CreateDraftVacationInfo();

            view.FindViewById <TextView>(Resource.Id.ItemEmployee).Text               = _vacationInfo.Employee.FullName;
            view.FindViewById <TextView>(Resource.Id.ItemApprover).Text               = _vacationInfo.Approver.FullName;
            view.FindViewById <TextView>(Resource.Id.ItemDuration).Text               = String.Format("{0} {1}", ConverterHelper.CalculateDuration(DateTime.Now.Date, DateTime.Now.Date), _vacationsViewModel.Localaizer.Localize("days"));
            view.FindViewById <TextView>(Resource.Id.ItemStatus).Text                 = _vacationInfo.Status.Value;
            view.FindViewById <TextView>(Resource.Id.ItemEmployee).Typeface           = FontLoader.GetFontNormal((Activity)_container.Context);
            view.FindViewById <TextView>(Resource.Id.ItemType).Typeface               = FontLoader.GetFontNormal((Activity)_container.Context);
            view.FindViewById <TextView>(Resource.Id.ItemApprover).Typeface           = FontLoader.GetFontNormal((Activity)_container.Context);
            view.FindViewById <Button>(Resource.Id.ItemStartDateBtn).Typeface         = FontLoader.GetFontNormal((Activity)_container.Context);
            view.FindViewById <Button>(Resource.Id.ItemEndDateBtn).Typeface           = FontLoader.GetFontNormal((Activity)_container.Context);
            view.FindViewById <TextView>(Resource.Id.ItemDuration).Typeface           = FontLoader.GetFontNormal((Activity)_container.Context);
            view.FindViewById <TextView>(Resource.Id.ItemStatus).Typeface             = FontLoader.GetFontNormal((Activity)_container.Context);
            view.FindViewById <TextView>(Resource.Id.ItemError).Typeface              = FontLoader.GetFontNormal((Activity)_container.Context);
            view.FindViewById <Button>(Resource.Id.ItemPickImageFromGallery).Typeface = FontLoader.GetFontNormal((Activity)_container.Context);
            view.FindViewById <Button>(Resource.Id.ItemPickImageFromCamera).Typeface  = FontLoader.GetFontNormal((Activity)_container.Context);
            view.FindViewById <TextView>(Resource.Id.LabelEmployee).Typeface          = FontLoader.GetFontBold((Activity)_container.Context);
            view.FindViewById <TextView>(Resource.Id.LabelType).Typeface              = FontLoader.GetFontBold((Activity)_container.Context);
            view.FindViewById <TextView>(Resource.Id.LabelApprover).Typeface          = FontLoader.GetFontBold((Activity)_container.Context);
            view.FindViewById <TextView>(Resource.Id.LabelDuration).Typeface          = FontLoader.GetFontBold((Activity)_container.Context);
            view.FindViewById <TextView>(Resource.Id.LabelStatus).Typeface            = FontLoader.GetFontBold((Activity)_container.Context);
            view.FindViewById <TextView>(Resource.Id.LabelAttachment).Typeface        = FontLoader.GetFontBold((Activity)_container.Context);
        }