Example #1
0
 private async void ExecuteLogoutCommandAsync()
 {
     try
     {
         //await _navigationService.NavigateAsync("/LoginPage");
         //await _navigationService.NavigateAsync("NavigationPage/LoginPage");
         RememberMe.Set("isDatabaseUpdate", false);
         var status = await _navigationService.GoBackAsync();
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Example #2
0
        public override void OnNavigatedTo(INavigationParameters parameters)
        {
            bool IsSyncDatabse = (Boolean)RememberMe.Get("isSyncDatabse", true);

            //if (ConfigurationCommon.App_Online)
            //{
            Xamarin.Forms.Device.BeginInvokeOnMainThread(async() =>
            {
                await Task.Delay(1000);
                if (IsSyncDatabse && ConfigurationCommon.App_Online)
                {
                    InitData.SyncHeaderDetailsInServer();
                    RememberMe.Set("isSyncDatabse", false);
                    await Xamarin.Forms.Application.Current.SavePropertiesAsync();
                }
                InitData.GetAllInitData();
            });
            //}
        }
Example #3
0
        public async void AddNew_Command()
        {
            if (SampleSize == 0)
            {
                await App.Current.MainPage.DisplayAlert("Alert ", "Please Enter Sample Size!", "ok");
            }
            else if (SelectedSize == null)
            {
                await App.Current.MainPage.DisplayAlert("Alert", "Please select Size Description!", "ok");
            }
            else if (SelectedOppening == null)
            {
                await App.Current.MainPage.DisplayAlert("Alert", "Please select Oppening!", "ok");
            }
            else if (SelectedPackageCondition == null)
            {
                await App.Current.MainPage.DisplayAlert("Alert", "Please select Package Condition!", "ok");
            }
            else if (Weight == 0)
            {
                await App.Current.MainPage.DisplayAlert("Alert", "Please Enter Weight!", "ok");
            }
            else if (PhysicalCount == 0)
            {
                await App.Current.MainPage.DisplayAlert("Alert", "Please Enter Physical Count!", "ok");
            }
            else if (Temperature == 0)
            {
                await App.Current.MainPage.DisplayAlert("Alert", "Please Enter Temperature!", "ok");
            }
            else if (Brix == 0)
            {
                await App.Current.MainPage.DisplayAlert("Alert", "Please Enter Brix!", "ok");
            }
            else if (Firmness == 0)
            {
                await App.Current.MainPage.DisplayAlert("Alert", "Please Enter Firmness!", "ok");
            }
            else
            {
                try
                {
                    UserDialogs.Instance.ShowLoading("Loading...");
                    RememberMe.Set("isSyncDatabse", true);
                    await Xamarin.Forms.Application.Current.SavePropertiesAsync();

                    InspectionDetailsRequestDTO inspectionRequestDTO = new InspectionDetailsRequestDTO()
                    {
                        Id = InspectionDetailsID,
                        InspectionHeaderId = InspectionHeaderID,
                        SizeId             = (int)SelectedSize.Id,
                        //SizeId = 3,
                        SampleSize         = SampleSize,
                        Weight             = Weight,
                        PhysicalCount      = PhysicalCount,
                        OpeningApperenceId = (int)SelectedOppening.Id,
                        //OpeningApperenceId = 2,
                        Temperature        = Temperature,
                        Brix               = Brix,
                        Firmness           = Firmness,
                        SkinDamage         = SkinDamage,
                        Color              = Color,
                        PackageConditionId = (int)SelectedPackageCondition.Id,
                        //PackageConditionId = 1,
                        Comment      = Comment,
                        QualityScore = QualityScore
                    };
                    Model.InspectionDetailTable inspectionDetailTable = new Model.InspectionDetailTable
                    {
                        Id = 0,
                        InspectionHeaderId = inspectionRequestDTO.InspectionHeaderId,
                        SizeId             = inspectionRequestDTO.SizeId,
                        SampleSize         = inspectionRequestDTO.SampleSize,
                        Weight             = inspectionRequestDTO.Weight,
                        PhysicalCount      = inspectionRequestDTO.PhysicalCount,
                        OpeningApperenceId = inspectionRequestDTO.OpeningApperenceId,
                        Temperature        = inspectionRequestDTO.Temperature,
                        Brix               = inspectionRequestDTO.Brix,
                        Firmness           = inspectionRequestDTO.Firmness,
                        SkinDamage         = inspectionRequestDTO.SkinDamage,
                        Color              = inspectionRequestDTO.Color,
                        PackageConditionId = inspectionRequestDTO.PackageConditionId,
                        Comment            = inspectionRequestDTO.Comment,
                        QualityScore       = inspectionRequestDTO.QualityScore,
                    };

                    if (ConfigurationCommon.App_Online)
                    {
                        var result = await webServiceManager.RegistrationInspectionDetailsAsync(inspectionRequestDTO).ConfigureAwait(true);;
                        if (result.IsSuccess && result.Data.StatusCode == 0)
                        {
                            if (InspectionDetailsID > 0)
                            {
                                HeaderAsync(inspectionDetailTable, result.Data.Id, false);
                            }
                            else
                            {
                                HeaderAsync(inspectionDetailTable, result.Data.Id, true);
                            }
                            // save data
                            await App.Current.MainPage.DisplayAlert("Alert", "Inspection Details has been Saved!", "ok");

                            if (DashBoardViewModel.CheckNewInspection)
                            {
                                await _navigationService.GoBackToRootAsync();
                            }
                            else
                            {
                                await _navigationService.GoBackAsync();
                            }
                        }
                        else
                        {
                            await App.Current.MainPage.DisplayAlert("Alert", result.Data.Status, "ok");
                        }
                    }
                    else
                    {
                        int MaxHeaderCode = 0;
                        if (InspectionDetailsID == 0)
                        {
                            var data = await InitData.HeaderRepo.GetMaxCode(x => x.Id, false);

                            MaxHeaderCode = (int)data.Id + 1;
                        }
                        else
                        {
                            MaxHeaderCode = InspectionDetailsID;
                        }
                        if (InspectionDetailsID > 0)
                        {
                            inspectionDetailTable.ModifiedAt = DateTime.Now;
                            inspectionDetailTable.Updated    = true;
                            HeaderAsync(inspectionDetailTable, MaxHeaderCode, false);

                            await App.Current.MainPage.DisplayAlert("Alert", "Inspection Details has been Saved!", "ok");

                            if (DashBoardViewModel.CheckNewInspection)
                            {
                                await _navigationService.GoBackAsync();

                                await _navigationService.GoBackAsync();

                                //await _navigationService.GoBackToRootAsync();
                            }
                            else
                            {
                                await _navigationService.GoBackAsync();
                            }
                        }
                        else
                        {
                            inspectionDetailTable.CreatedAt = DateTime.Now;
                            inspectionDetailTable.NewEntry  = true;
                            HeaderAsync(inspectionDetailTable, MaxHeaderCode, true);
                            await App.Current.MainPage.DisplayAlert("Alert", "Inspection Details has been Saved!", "ok");

                            if (DashBoardViewModel.CheckNewInspection)
                            {
                                await _navigationService.GoBackToRootAsync();
                            }
                            else
                            {
                                await _navigationService.GoBackAsync();
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    UserDialogs.Instance.HideLoading();
                    throw ex;
                }
                finally
                {
                    UserDialogs.Instance.HideLoading();
                }
            }
        }
Example #4
0
        public async void AddNew_Command()
        {
            if (SelectedCompany == null)
            {
                await App.Current.MainPage.DisplayAlert("Alert ", "Please Select Company Name!", "ok");
            }
            else if (string.IsNullOrEmpty(Invoice))
            {
                await App.Current.MainPage.DisplayAlert("Alert", "Please Enter Invoice!", "ok");
            }
            else if (SelectedProduct == null)
            {
                await App.Current.MainPage.DisplayAlert("Alert ", "Please Select Product Name!", "ok");
            }
            else if (SelectedVariety == null)
            {
                await App.Current.MainPage.DisplayAlert("Alert ", "Please Select Variety Name!", "ok");
            }
            else if (SelectedBrand == null)
            {
                await App.Current.MainPage.DisplayAlert("Alert", "Please Select Brand Name!", "ok");
            }
            else if (SelectedCountryofOrigin == null)
            {
                await App.Current.MainPage.DisplayAlert("Alert", "Please Select CountryofOrigin Name!", "ok");
            }
            else if (TotalBoxQua == 0)
            {
                await App.Current.MainPage.DisplayAlert("Alert", "Please Enter Total Box Quantities!", "ok");
            }
            else if (TempOnCaja == 0)
            {
                await App.Current.MainPage.DisplayAlert("Alert", "Please Enter Temp On Caja!", "ok");
            }
            else if (TempOnTermografo == 0)
            {
                await App.Current.MainPage.DisplayAlert("Alert", "Please Enter Temp On Termografo!", "ok");
            }
            else if (SelectedPalletizingCondition == null)
            {
                await App.Current.MainPage.DisplayAlert("Alert", "Please Select Palletizing Condition!", "ok");
            }
            else
            {
                try
                {
                    UserDialogs.Instance.ShowLoading("Loading...");
                    RememberMe.Set("isSyncDatabse", true);
                    await Xamarin.Forms.Application.Current.SavePropertiesAsync();

                    InspectionHeadersRequestDTO inspectionHeaderRequestDTO = new InspectionHeadersRequestDTO()
                    {
                        Id                     = _InspectionHeader != null ? _InspectionHeader.Id : 0,
                        CompanyId              = (int)SelectedCompany.Id,
                        InspectionDate         = DateTime.Now,
                        UserId                 = Convert.ToInt32(RememberMe.Get("userID")),
                        Invoice                = Invoice,
                        ProducerId             = (int)SelectedProduct.Id,
                        VarietyId              = (int)SelectedVariety.Id,
                        BrandId                = (int)SelectedBrand.Id,
                        CountryofOriginId      = (int)SelectedCountryofOrigin.Id,
                        TotalBoxQuantities     = TotalBoxQua,
                        TempOnCaja             = TempOnCaja,
                        TempOnTermografo       = TempOnTermografo,
                        PalletizingConditionId = (int)SelectedPalletizingCondition.Id,
                    };
                    Model.InspectionHeaderTable inspectionHeaderTable = new Model.InspectionHeaderTable
                    {
                        Id                     = 0,
                        CompanyId              = inspectionHeaderRequestDTO.CompanyId,
                        InspectionDate         = inspectionHeaderRequestDTO.InspectionDate,
                        UserId                 = inspectionHeaderRequestDTO.UserId,
                        Invoice                = inspectionHeaderRequestDTO.Invoice,
                        ProducerId             = inspectionHeaderRequestDTO.ProducerId,
                        VarietyId              = inspectionHeaderRequestDTO.VarietyId,
                        BrandId                = inspectionHeaderRequestDTO.BrandId,
                        CountryofOriginId      = inspectionHeaderRequestDTO.CountryofOriginId,
                        TotalBoxQuantities     = inspectionHeaderRequestDTO.TotalBoxQuantities,
                        TempOnCaja             = inspectionHeaderRequestDTO.TempOnCaja,
                        TempOnTermografo       = inspectionHeaderRequestDTO.TempOnTermografo,
                        PalletizingConditionId = inspectionHeaderRequestDTO.PalletizingConditionId,
                    };

                    if (ConfigurationCommon.App_Online)
                    {
                        var result = await webServiceManager.RegistrationInspectionHeaderAsync(inspectionHeaderRequestDTO).ConfigureAwait(true);;
                        if (result.IsSuccess && result.Data.StatusCode == 0)
                        {
                            await App.Current.MainPage.DisplayAlert("Alert", "Inspection Header has been Saved!", "ok");

                            int InspectionID = _InspectionHeader != null ? _InspectionHeader.Id : 0;
                            var parameters   = new NavigationParameters();
                            if (InspectionID > 0)
                            {
                                HeaderAsync(inspectionHeaderTable, result.Data.Id, false);
                                parameters.Add("HeaderID", result.Data.Id);
                                await _navigationService.NavigateAsync("InspectionDetailsListPage", parameters);
                            }
                            else
                            {
                                UserDialogs.Instance.ShowLoading();
                                HeaderAsync(inspectionHeaderTable, result.Data.Id, true);
                                parameters.Add("HeaderID", result.Data.Id);
                                parameters.Add("ScreenRight", "New Detail Inspection");
                                await _navigationService.NavigateAsync("AddNewDetailsInspectionPage", parameters);

                                UserDialogs.Instance.HideLoading();
                            }
                        }
                        else
                        {
                            await App.Current.MainPage.DisplayAlert("Alert", result.Data.Status, "ok");
                        }
                    }
                    else
                    {
                        int MaxHeaderCode = 0;
                        if (inspectionHeaderRequestDTO.Id == 0)
                        {
                            var data = await InitData.HeaderRepo.GetMaxCode(x => x.Id, false);

                            MaxHeaderCode = (int)data.Id + 1;
                        }
                        else
                        {
                            MaxHeaderCode = inspectionHeaderRequestDTO.Id;
                        }

                        if (inspectionHeaderRequestDTO.Id > 0)
                        {
                            HeaderAsync(inspectionHeaderTable, MaxHeaderCode, false);

                            await App.Current.MainPage.DisplayAlert("Alert", "Inspection Header has been Saved!", "Ok");

                            var parameters = new NavigationParameters();
                            if (MaxHeaderCode > 0)
                            {
                                parameters.Add("HeaderID", MaxHeaderCode);
                                await _navigationService.NavigateAsync("InspectionDetailsListPage", parameters);
                            }
                        }
                        else
                        {
                            HeaderAsync(inspectionHeaderTable, MaxHeaderCode, true);

                            await App.Current.MainPage.DisplayAlert("Alert", "Inspection Header has been Saved!", "Ok");

                            var parameters = new NavigationParameters();
                            if (MaxHeaderCode > 0)
                            {
                                parameters.Add("HeaderID", MaxHeaderCode);
                                await _navigationService.NavigateAsync("InspectionDetailsListPage", parameters);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    UserDialogs.Instance.HideLoading();
                    throw ex;
                }
                finally
                {
                    UserDialogs.Instance.HideLoading();
                }
            }
        }
        public async void Login_Command()
        {
            if (UserId == null || userid == "")
            {
                await App.Current.MainPage.DisplayAlert("Alert ", "Please Enter EmailID", "ok");
            }
            else if (Password == null || Password == "")
            {
                await App.Current.MainPage.DisplayAlert("Alert", "Please Enter Password", "ok");
            }
            else if (Color.Red == EmailColor)
            {
                await App.Current.MainPage.DisplayAlert("Alert", "Email is not in correct format!", "ok");
            }
            else if (ConfigurationCommon.App_Online)
            {
                try
                {
                    UserDialogs.Instance.ShowLoading("Loading...");
                    if (ConfigurationCommon.App_Online)
                    {
                        UsersRequestDTO clientRequestDTO = new UsersRequestDTO()
                        {
                            Email   = UserId,
                            UserPwd = Password,
                            //ApplicationId = ConfigurationCommon.ApplicationId,
                            //DeviceToken = RememberMe.Get("PushDeviceToken").ToString(),
                            //DeviceName = Device.RuntimePlatform,
                        };
                        var result = await webServiceManager.LoginAsync(clientRequestDTO).ConfigureAwait(true);;
                        if (result.IsSuccess && string.IsNullOrEmpty(result.Data.Status))
                        {
                            UserData = new User()
                            {
                                CompanyId = result.Data._Users.CompanyId,
                                //ApplicationId = result.Data._Users.ApplicationId,
                                UserRoleId = result.Data._Users.UserRoleId,
                                Id         = result.Data._Users.Id
                            };
                            RememberMe.Set("userID", result.Data._Users.Id);
                            RememberMe.Set("CmpID", result.Data._Users.CompanyId);
                            RememberMe.Set("UserRoleId", result.Data._Users.CompanyId);
                            //if (IsSwitchedToggled)
                            //{
                            RememberMe.Set("username", this.UserId);
                            RememberMe.Set("password", this.Password);
                            //}
                            RememberMe.Set("isSwitchedToggled", IsSwitchedToggled);
                            RememberMe.Set("isDatabaseUpdate", false);
                            await _navigationService.NavigateAsync("DashboardPage");

                            await Xamarin.Forms.Application.Current.SavePropertiesAsync();
                        }
                        else
                        {
                            App.Current.MainPage.DisplayAlert("Alert ", result.Data.Status, "ok");
                        }
                    }
                }
                catch (Exception ex)
                {
                    UserDialogs.Instance.HideLoading();
                    throw ex;
                }
                //finally
                //{
                //  UserDialogs.Instance.HideLoading();
                //}
            }
            else
            {
                if (UserId != Convert.ToString(RememberMe.Get("username")))
                {
                    await App.Current.MainPage.DisplayAlert("Alert", "Please Enter valid EmailID!", "ok");
                }
                else if (Password != Convert.ToString(RememberMe.Get("password")))
                {
                    await App.Current.MainPage.DisplayAlert("Alert", "Please Enter valid Password!", "ok");
                }
                else
                {
                    RememberMe.Set("isSwitchedToggled", IsSwitchedToggled);
                    await _navigationService.NavigateAsync("DashboardPage");

                    await Xamarin.Forms.Application.Current.SavePropertiesAsync();
                }
            }
        }