示例#1
0
        private async void BtnGeneratePass_Clicked(object sender, EventArgs e)
        {
            try
            {
                CustomerVehiclePass resultPass = null;
                string existingnfcCardVehcile  = string.Empty;
                btnGeneratePass.IsVisible = false;
                ShowLoading(true);
                if (entryCashReceived.Text != null && entryCashReceived.Text != "0")
                {
                    decimal passAmount = (objInputMonthlyPass.TotalAmount == null || objInputMonthlyPass.TotalAmount == 0) ? (objInputMonthlyPass.Amount + objInputMonthlyPass.DueAmount) : (objInputMonthlyPass.TotalAmount + objInputMonthlyPass.DueAmount);
                    if (Convert.ToDecimal(entryCashReceived.Text) >= passAmount)
                    {
                        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 <Location> lstMultiLication = (List <Location>)App.Current.Properties["MultiSelectionLocations"];
                                    if (!string.IsNullOrEmpty(labelNFCCard.Text))
                                    {
                                        objInputMonthlyPass.CardNumber = labelNFCCard.Text;
                                    }
                                    else if (!string.IsNullOrEmpty(labelBARCode.Text))
                                    {
                                        objInputMonthlyPass.CardNumber = labelBARCode.Text;
                                    }

                                    objInputMonthlyPass.BarCode    = labelBARCode.Text;
                                    objInputMonthlyPass.IsMultiLot = true;
                                    VMMultiStationCustomerVehiclePass objvmMultiStations = new VMMultiStationCustomerVehiclePass();
                                    objvmMultiStations.CustomerVehiclePassID = objInputMonthlyPass;
                                    objvmMultiStations.LocationID            = lstMultiLication;
                                    await Task.Run(() =>
                                    {
                                        resultPass = dal_CustomerPass.CreateMultiStationCustomerPass(Convert.ToString(App.Current.Properties["apitoken"]), objvmMultiStations);
                                    });

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

                                        await Navigation.PushAsync(new PassPaymentReceiptPage(resultPass));

                                        btnGeneratePass.IsVisible = true;
                                    }
                                    else
                                    {
                                        btnGeneratePass.IsVisible = true;
                                        await DisplayAlert("Alert", "Pass creation 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)
                                    {
                                        StopNFCListening();
                                        await DisplayAlert("Alert", "Vehicle Pass created successfully", "Ok");

                                        await Navigation.PushAsync(new PassPaymentReceiptPage(resultPass));

                                        btnGeneratePass.IsVisible = true;
                                    }
                                    else
                                    {
                                        btnGeneratePass.IsVisible = true;
                                        await DisplayAlert("Alert", "Pass creation failed,Please contact Admin", "Ok");
                                    }
                                }
                            }
                            else
                            {
                                ShowLoading(false);
                                btnGeneratePass.IsVisible = true;
                                await DisplayAlert("Alert", "NFC Card already assigned to " + existingnfcCardVehcile + "", "Ok");
                            }
                        }
                    }
                    else
                    {
                        btnGeneratePass.IsVisible = true;
                        await DisplayAlert("Alert", "Please enter valid pass amount.", "Ok");
                    }
                }
                ShowLoading(false);
            }
            catch (Exception ex)
            {
                btnGeneratePass.IsVisible = true;
                dal_Exceptionlog.InsertException(Convert.ToString(App.Current.Properties["apitoken"]), "Operator App", ex.Message, "MonthlyPassCashPaymentPage.xaml.cs", "", "BtnGeneratePassReceipt_Clicked");
            }
        }
        private async void BtnContinue_Clicked(object sender, EventArgs e)
        {
            try
            {
                string existingnfcCardVehcile = string.Empty;
                string cardNumber             = string.Empty;
                ActivatePassReciptPage passPaymentReceiptPage = null;
                ShowLoading(true);
                slContinue.IsVisible = false;
                objResultCustomerVehiclePass.IssuedCard = true;
                if (!string.IsNullOrEmpty(labelNFCCard.Text))
                {
                    cardNumber = labelNFCCard.Text;
                }
                if (!string.IsNullOrEmpty(labelBARCode.Text))
                {
                    if (labelBARCode.Text.Contains(":"))
                    {
                        cardNumber = labelBARCode.Text.Replace(":", "");
                    }
                    else
                    {
                        cardNumber = labelBARCode.Text.Replace(":", "");
                    }

                    objResultCustomerVehiclePass.BarCode = cardNumber;
                }
                if (!string.IsNullOrEmpty(cardNumber))
                {
                    objResultCustomerVehiclePass.CardNumber  = cardNumber;
                    objResultCustomerVehiclePass.TotalAmount = objResultCustomerVehiclePass.PassPriceID.Price + objResultCustomerVehiclePass.PassPriceID.CardPrice;
                    objResultCustomerVehiclePass.BarCode     = labelBARCode.Text;
                    if (App.Current.Properties.ContainsKey("LoginUser") && App.Current.Properties.ContainsKey("apitoken"))
                    {
                        existingnfcCardVehcile = dal_Pass.IsValidNFCCard(Convert.ToString(App.Current.Properties["apitoken"]), labelNFCCard.Text, entryRegistrationNumber.Text);
                        if (existingnfcCardVehcile == string.Empty)
                        {
                            await Task.Run(() =>
                            {
                                User objloginuser = (User)App.Current.Properties["LoginUser"];
                                objResultCustomerVehiclePass.CreatedBy.UserID = objloginuser.UserID;
                                objResultCustomerVehiclePass = dal_Pass.ActivateCustomerVehiclePass(Convert.ToString(App.Current.Properties["apitoken"]), objResultCustomerVehiclePass);
                                passPaymentReceiptPage       = new ActivatePassReciptPage(objResultCustomerVehiclePass);
                            });

                            await Navigation.PushAsync(passPaymentReceiptPage);

                            slContinue.IsVisible = true;
                            ShowLoading(false);
                        }
                        else
                        {
                            ShowLoading(false);
                            await DisplayAlert("Alert", "NFC Card already assigned to " + existingnfcCardVehcile + "", "Ok");
                        }
                    }
                }
                else
                {
                    ShowLoading(false);
                    await DisplayAlert("Alert", "Please tap card", "Ok");
                }
            }
            catch (Exception ex)
            {
                dal_Exceptionlog.InsertException(Convert.ToString(App.Current.Properties["apitoken"]), "Operator App", ex.Message, "ActivatePassPage.xaml.cs", "", "BtnContinue_Clicked");
                ShowLoading(false);
                slContinue.IsVisible = true;
            }
        }