Exemplo n.º 1
0
        private async void BtnGeneratePassReceipt_Clicked(object sender, EventArgs e)
        {
            try
            {
                btnGeneratePassReceipt.IsVisible = false;
                CustomerVehiclePass    resultPass             = null;
                PassPaymentReceiptPage PassPaymentReceiptPage = null;
                ShowLoading(true);
                if (DeviceInternet.InternetConnected())
                {
                    if (App.Current.Properties.ContainsKey("LoginUser") && App.Current.Properties.ContainsKey("apitoken"))
                    {
                        decimal passAmount = (objCustomerweeklyPass.TotalAmount == null || objCustomerweeklyPass.TotalAmount == 0) ? (objCustomerweeklyPass.Amount + objCustomerweeklyPass.DueAmount) : (objCustomerweeklyPass.TotalAmount + objCustomerweeklyPass.DueAmount);
                        if (Convert.ToDecimal(entryCashReceived.Text) >= passAmount)
                        {
                            await Task.Run(() =>
                            {
                                resultPass = dal_CustomerPass.CreateCustomerPass(Convert.ToString(App.Current.Properties["apitoken"]), objCustomerweeklyPass);
                                if (resultPass != null && resultPass.CustomerVehiclePassID != 0)
                                {
                                    PassPaymentReceiptPage = new PassPaymentReceiptPage(resultPass);
                                }
                            });

                            if (resultPass != null && resultPass.CustomerVehiclePassID != 0)
                            {
                                await DisplayAlert("Alert", "Vehicle Pass created successfully", "Ok");

                                await Navigation.PushAsync(PassPaymentReceiptPage);
                            }
                            else
                            {
                                await DisplayAlert("Alert", "Payment Failed,Please contact Admin", "Ok");
                            }
                        }
                        else
                        {
                            btnGeneratePassReceipt.IsVisible = true;
                            await DisplayAlert("Alert", "Please enter valid pass amount.", "Ok");
                        }
                        ShowLoading(false);
                    }
                }
                else
                {
                    ShowLoading(false);
                    await DisplayAlert("Alert", "Please check your Internet connection", "Ok");
                }
            }
            catch (Exception ex)
            {
                dal_Exceptionlog.InsertException(Convert.ToString(App.Current.Properties["apitoken"]), "Operator App", ex.Message, "WeeklyPassPaymentConfirmationPage.xaml.cs", "", "BtnGeneratePassReceipt_Clicked");
            }
        }
Exemplo n.º 2
0
        private async void BtnGeneratePassReceipt_Clicked(object sender, EventArgs e)
        {
            try
            {
                CustomerVehiclePass    resultPass             = null;
                PassPaymentReceiptPage PassPaymentReceiptPage = null;
                if (DeviceInternet.InternetConnected())
                {
                    if (App.Current.Properties.ContainsKey("LoginUser") && App.Current.Properties.ContainsKey("apitoken"))
                    {
                        await Task.Run(() =>
                        {
                            resultPass = dal_CustomerPass.CreateCustomerPass(Convert.ToString(App.Current.Properties["apitoken"]), objCustomerweeklyPass);
                            if (resultPass != null && resultPass.CustomerVehiclePassID != 0)
                            {
                                PassPaymentReceiptPage = new PassPaymentReceiptPage(resultPass);
                            }
                        });

                        if (resultPass != null && resultPass.CustomerVehiclePassID != 0)
                        {
                            await DisplayAlert("Alert", "Vehicle Pass created successfully", "Ok");

                            await Navigation.PushAsync(PassPaymentReceiptPage);
                        }
                        else
                        {
                            await DisplayAlert("Alert", "Payment Failed,Please contact Admin", "Ok");
                        }
                    }
                }
                else
                {
                    await DisplayAlert("Alert", "Please check your Internet connection", "Ok");
                }
            }
            catch (Exception ex)
            {
                dal_Exceptionlog.InsertException(Convert.ToString(App.Current.Properties["apitoken"]), "Operator App", ex.Message, "WeeklyPassPaymentConfirmationPage.xaml.cs", "", "BtnGeneratePassReceipt_Clicked");
            }
        }
        private async void BtnGeneratePass_Clicked(object sender, EventArgs e)
        {
            try
            {
                ShowLoading(true);
                btnGeneratePass.IsVisible = false;

                string existingnfcCardVehcile = string.Empty;
                if (DeviceInternet.InternetConnected())
                {
                    CustomerVehiclePass resultPass = null;
                    if (App.Current.Properties.ContainsKey("LoginUser") && App.Current.Properties.ContainsKey("apitoken"))
                    {
                        existingnfcCardVehcile = dal_CustomerPass.IsValidNFCCard(Convert.ToString(App.Current.Properties["apitoken"]), labelNFCCard.Text, objInputMonthlyPass.CustomerVehicleID.RegistrationNumber);
                        if (existingnfcCardVehcile == string.Empty)
                        {
                            if (App.Current.Properties.ContainsKey("MultiSelectionLocations"))
                            {
                                List <Model.APIOutPutModel.Location> lstMultiLication = (List <Model.APIOutPutModel.Location>)App.Current.Properties["MultiSelectionLocations"];
                                await Task.Run(() =>
                                {
                                    objInputMonthlyPass.CardNumber = labelNFCCard.Text;
                                    if (!string.IsNullOrEmpty(labelNFCCard.Text))
                                    {
                                        objInputMonthlyPass.CardNumber = labelNFCCard.Text;
                                    }
                                    else if (!string.IsNullOrEmpty(labelBARCode.Text))
                                    {
                                        objInputMonthlyPass.CardNumber = labelBARCode.Text;
                                    }
                                    objInputMonthlyPass.IsMultiLot = true;
                                    VMMultiStationCustomerVehiclePass objvmMultiStations = new VMMultiStationCustomerVehiclePass();
                                    objvmMultiStations.CustomerVehiclePassID             = objInputMonthlyPass;
                                    objvmMultiStations.LocationID = lstMultiLication;
                                    resultPass = dal_CustomerPass.CreateMultiStationCustomerPass(Convert.ToString(App.Current.Properties["apitoken"]), objvmMultiStations);
                                });

                                if (resultPass != null && resultPass.CustomerVehiclePassID != 0)
                                {
                                    StopNFCListening();
                                    await DisplayAlert("Alert", "Vehicle Pass created successfully", "Ok");

                                    var passPaymentReceiptPage = new PassPaymentReceiptPage(resultPass);
                                    await Navigation.PushAsync(passPaymentReceiptPage);
                                }
                                else
                                {
                                    await DisplayAlert("Alert", "Payment Failed,Please contact Admin", "Ok");
                                }
                            }
                            else
                            {
                                await Task.Run(() =>
                                {
                                    objInputMonthlyPass.BarCode = labelBARCode.Text;
                                    if (!string.IsNullOrEmpty(labelNFCCard.Text))
                                    {
                                        objInputMonthlyPass.CardNumber = labelNFCCard.Text;
                                    }
                                    else if (!string.IsNullOrEmpty(labelBARCode.Text))
                                    {
                                        objInputMonthlyPass.CardNumber = labelBARCode.Text;
                                    }
                                    resultPass = dal_CustomerPass.CreateCustomerPass(Convert.ToString(App.Current.Properties["apitoken"]), objInputMonthlyPass);
                                });

                                if (resultPass != null && resultPass.CustomerVehiclePassID != 0)
                                {
                                    await DisplayAlert("Alert", "Vehicle Pass created successfully", "Ok");

                                    var passPaymentReceiptPage = new PassPaymentReceiptPage(resultPass);
                                    await Navigation.PushAsync(passPaymentReceiptPage);
                                }
                                else
                                {
                                    await DisplayAlert("Alert", "Payment Failed,Please contact Admin", "Ok");
                                }
                            }
                        }
                        else
                        {
                            ShowLoading(false);
                            await DisplayAlert("Alert", "NFC Card already assigned to " + existingnfcCardVehcile + "", "Ok");
                        }

                        ShowLoading(false);
                        btnGeneratePass.IsVisible = true;
                    }
                }
                else
                {
                    await DisplayAlert("Alert", "Please check your Internet connection", "Ok");

                    ShowLoading(false);
                    btnGeneratePass.IsVisible = true;
                }
            }
            catch (Exception ex)
            {
                btnGeneratePass.IsVisible = true;
                dal_Exceptionlog.InsertException(Convert.ToString(App.Current.Properties["apitoken"]), "Operator App", ex.Message, "MonthlyPassCashPaymentPage.xaml.cs", "", "BtnGeneratePassReceipt_Clicked");
            }
        }