public static string titleCountry(string val)
        {
            string name          = "";
            var    nameToCountry = CountryDictionary.listOfCountrie();

            if (val != "" || val != "")
            {
                //Item Value in dictionar
                name = nameToCountry.FirstOrDefault(x => x.Value == val).Key;
            }
            return(name);
        }
        //Guest Country pickers
        void guestContryDetailsPicker(string country)
        {
            GuestCountry.Items.Clear();
            //List of Countries from dictionary
            var nameToCountry = CountryDictionary.listOfCountrie();

            //Adding all countries into picker
            foreach (string countryName in nameToCountry.Keys)
            {
                GuestCountry.Items.Add(countryName);
            }

            //if values are not available on load
            if (country != "" || country != "")
            {
                //Item Value in dictionary
                string name = nameToCountry.FirstOrDefault(x => x.Value == country).Value;

                //Index of item in dictionary
                int index = nameToCountry.Values.ToList().IndexOf(name);

                //Set picker selected item index
                GuestCountry.SelectedIndex = index;

                //Set country to update guest
                guestCountry = country;
            }

            //Index of picker changed
            GuestCountry.SelectedIndexChanged += (sender, args) =>
            {
                if (GuestCountry.SelectedIndex == -1)
                {
                    guestCountry = country;
                }
                else
                {
                    //Get key value of selected item
                    string countryName = GuestCountry.Items[GuestCountry.SelectedIndex];

                    //Set picker value
                    guestCountry = nameToCountry[countryName];
                }
            };
        }
        //Update Guest Details
        async void saveButton(object sender, EventArgs e)
        {
            string validation = FieldValidation.guestSaveDetailsValidation(IdentificationMethod, IdentificationMethodNumber.Text, GuestFisrtName.Text, GuestLastName.Text, DateOfBirth, GuestContact.Text, GuestEmail.Text, City.Text, Street.Text);

            if (validation != "")
            {
                await DisplayAlert("Warning!", validation, "Ok");
            }
            else
            {
                DateTime date = DateOfBirth.Date;

                DateTime dateOfEx = PassportExpiry.Date;

                //Page loading indicator
                pageLoading();

                //Pass values to payload
                StatusChange statusChange = new StatusChange(Constants._hotel_code, Constants._reservation_id, guestIdentification, IdentificationMethodNumber.Text, guestNumber.Text, guestSalutation, GuestFisrtName.Text, GuestLastName.Text, guestGender, GuestEmail.Text, GuestContact.Text, HouseNumber.Text, Street.Text, City.Text, guestCountry, guestNationality, guestLanguage, date.ToString("s"), dateOfEx.ToString("s"));
                //PPExpiryDate expiryDateChange = new PPExpiryDate(Constants._hotel_code, Constants._reservation_id, guestNumber.Text, guestSalutation, GuestFisrtName.Text, GuestLastName.Text, IdentificationMethodNumber.Text ,dateOfEx.ToString("s"),guestIdentification,guestCountry,guestLanguage);

                //Data Posting source
                //PostServiceManager postServiceManager = new PostServiceManager();
                GuestPostManager guestPostManager = new GuestPostManager();

                string result = await guestPostManager.CreateUpdateGuest(statusChange);

                //String result = await postServiceManager.StatusChangeAsync(statusChange);
                //String result2 = await postServiceManager.SavePPExpiryAsync(expiryDateChange);

                if (result != "Reservation is locked" || result.Contains("Updated Successfully"))
                {
                    //Updateing guest details object
                    var obj = guestdetails.FirstOrDefault(x => x.guestNumber == Int32.Parse(guestNumber.Text));
                    obj.guestNumber          = Int32.Parse(guestNumber.Text);
                    obj.identificationMethod = guestIdentification;
                    obj.passportIdNumber     = IdentificationMethodNumber.Text;
                    obj.salutation           = guestSalutation;
                    obj.guestName            = GuestFisrtName.Text + " " + GuestLastName.Text;
                    obj.guestFirstName       = GuestFisrtName.Text;
                    obj.guestLastName        = GuestLastName.Text;
                    obj.gender          = guestGender;
                    obj.email           = GuestEmail.Text;
                    obj.contactNumber   = GuestContact.Text;
                    obj.houseNumber     = HouseNumber.Text;
                    obj.street          = Street.Text;
                    obj.city            = City.Text;
                    obj.nationality     = guestNationality;
                    obj.country         = guestCountry;
                    obj.language        = guestLanguage;
                    obj.guestCode       = guestCodeFromSearch;
                    obj.dateOfBirth     = date.ToString("s");
                    obj.dateOfExpiry    = dateOfEx.ToString("s");
                    obj.noOfVisitsHotel = Visitperhotel;
                    obj.noOfVisits      = Totalvisit;
                    obj.revenueTotal    = RevenueTotal;
                    obj.revenueRoom     = RevenueRoom;
                    obj.reveneuFB       = RevenueFnb;
                    obj.revenueOther    = RevenueOther;

                    var nameToCountry = CountryDictionary.listOfCountrie();
                    if (guestCountry != "" || guestCountry != "")
                    {
                        //Item Value in dictionary
                        string name = nameToCountry.FirstOrDefault(x => x.Value == guestCountry).Key;
                        obj.countryKeyValue = name;
                    }

                    Constants._guestNumber = "";
                    Constants._guestNumber = guestNumber.Text;
                    stopPageLoading();

                    //Guest details updateindicator, Reload content page
                    MessagingCenter.Send <GuestEdit, List <guestDetails> >(this, Constants._guestEdited, guestdetails);
                    await DisplayAlert("Message", result, "OK");

                    //Logger
                    new APILogger().Logger("Guest Payload :" + JsonConvert.SerializeObject(statusChange));
                    new APILogger().Logger("Guest Save Status :" + result);

                    //Close this content page
                    this.Navigation.RemovePage(this);
                }
                else
                {
                    stopPageLoading();
                    await DisplayAlert("Message", result, "OK");
                }
            }
        }
示例#4
0
        //Guest Details
        public async void DisplayGuestDetails()
        {
            pageLoading();
            layoutHeightGuestDetails     = 0;
            layoutHeightSignatures       = 0;
            lasyoutHeighSignatureInitial = 1;
            guestNumber      = 1;
            guestNumberCount = 1;
            try
            {
                GuestNameList.ItemsSource = null;
                string result = await checkInManager.GetRemarksDetails(Constants._reservation_id);

                guestdetails = new List <guestDetails>();
                if (Constants._notAvailableSignatureAdded == false)
                {
                    guestsignature = new List <guestSignature>();
                }

                GuestSignatureList.ItemsSource = null;

                if (result != null)
                {
                    string guestNameAvailabiliyty = "";
                    string tem_resultMain         = result; //

                    //Removing ticks issue in date
                    result = result.Replace("Date(-", "Date(");
                    var output = JObject.Parse(result);

                    if (Enumerable.Count(output["d"]["results"][0]["ReservationNaviGuest"]["results"]) > 0)
                    {
                        savedSignatureCount = 0;
                        for (int i = 0; i < Enumerable.Count(output["d"]["results"][0]["ReservationNaviGuest"]["results"]); i++)
                        {
                            string guestCountryKeyValue    = string.Empty;
                            string guestSalutationKeyValue = string.Empty;
                            //Setting values to global variables
                            guestNameAvailabiliyty   = serviceDataValidation.validation(Convert.ToString(output["d"]["results"][0]["ReservationNaviGuest"]["results"][i]["Xnombre"]));
                            layoutHeightGuestDetails = layoutHeightGuestDetails + 40;
                            if (guestNameAvailabiliyty != Constants._notAvailable)
                            {
                                if (lasyoutHeighSignatureInitial == 1)
                                {
                                    layoutHeightSignatures = 187;
                                }
                                else
                                {
                                    layoutHeightSignatures = layoutHeightSignatures + 157;
                                }
                            }
                            //Signaure Manually Not added
                            if (Constants._notAvailableSignatureAdded == false)
                            {
                                if (guestNameAvailabiliyty != Constants._notAvailable)
                                {
                                    try
                                    {
                                        string result1 = await checkInManager.GetGuestSignature(guestNumberCount.ToString());

                                        if (result1 != null)
                                        {
                                            var output1 = JObject.Parse(result1);

                                            //Removing ticks error
                                            result1 = result1.Replace("Date(-", "Date(");

                                            //Converting base64 string to byte array
                                            byte[] data = Convert.FromBase64String(Convert.ToString(output1["d"]["XIMAGE"]));

                                            guestsignature.Add(new guestSignature(ImageSource.FromStream(() => new MemoryStream(data)), guestNameAvailabiliyty, "White", guestNumber, Constants._available, "Purple", ""));
                                            savedSignatureCount++;
                                        }
                                    }
                                    catch (Exception)
                                    {
                                        //Guest Signature Not Available
                                        string addSignatureImage = "SignatureImage.jpg";
                                        if (guestNameAvailabiliyty != Constants._notAvailable)
                                        {
                                            guestsignature.Add(new guestSignature(addSignatureImage,
                                                                                  guestNameAvailabiliyty, "Purple",
                                                                                  guestNumber,
                                                                                  Constants._notAvailable, "White", ""));
                                        }
                                    }
                                }
                            }
                            String dateString       = "";
                            string expiryDateString = "";

                            DateTime date = DateTime.Now;
                            try
                            {
                                string dateOfBirth = Convert.ToString(output["d"]["results"][0]["ReservationNaviGuest"]["results"][i]["Gbdat"]);

                                if (dateOfBirth != "")
                                {
                                    DateTime dt             = DateTime.Now;
                                    int      index          = i + 1;
                                    string   temp_substring = tem_resultMain.Substring(0, tem_resultMain.IndexOf("Xorden\":\"" + "0" + index + "\""));
                                    //temp_substring = temp_substring.Substring(0, temp_substring.IndexOf("Gbdat") + 20);
                                    //temp_substring = temp_substring.Substring(temp_substring.IndexOf("Gbdat"));
                                    temp_substring = temp_substring.Substring(temp_substring.LastIndexOf("Gbdat"));
                                    temp_substring = temp_substring.Substring(0, 20);
                                    //Begin of + Vinoch 15122061
                                    if (temp_substring.Contains("-"))
                                    {
                                        DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
                                        long     ms    = (long)(DateTime.Parse(dateOfBirth) - epoch).TotalMilliseconds;
                                        dateOfBirth = ms.ToString();

                                        dateOfBirth = "-" + dateOfBirth;

                                        long     milliSec  = (long)(Convert.ToDouble(dateOfBirth));
                                        DateTime startTime = new DateTime(1970, 1, 1);

                                        TimeSpan time = TimeSpan.FromMilliseconds(milliSec);
                                        dt = startTime.Add(time);
                                    }
                                    else
                                    {
                                        if (dateOfBirth != "")                //- Vinoch 1512201
                                        {
                                            dt = DateTime.Parse(dateOfBirth); // Vinoch 1512201
                                        }
                                    }

                                    //DateTime date = serviceDataValidation.dateOfBirthValidation(dateOfBirth);
                                    date       = dt;
                                    dateString = date.ToString();
                                }
                                else
                                {
                                    dateString       = "";
                                    expiryDateString = "";
                                }
                            }
                            catch (Exception)
                            {
                                dateString       = "";
                                expiryDateString = "";
                            }

                            string country = Convert.ToString(output["d"]["results"][0]["ReservationNaviGuest"]["results"][i]["Country"]);

                            var nameToCountry = CountryDictionary.listOfCountrie();
                            if (country != "" || country != "")
                            {
                                string name = nameToCountry.FirstOrDefault(x => x.Value == country).Key;
                                guestCountryKeyValue = country;
                            }
                            guestdetails.Add(new guestDetails(guestNumberCount,
                                                              Convert.ToString(output["d"]["results"][0]["ReservationNaviGuest"]["results"][i]["XtipoDocId"]),
                                                              Convert.ToString(output["d"]["results"][0]["ReservationNaviGuest"]["results"][i]["XnumeroDoc"]),
                                                              Convert.ToString(output["d"]["results"][0]["ReservationNaviGuest"]["results"][i]["Title"]),
                                                              guestNameAvailabiliyty,
                                                              Convert.ToString(output["d"]["results"][0]["ReservationNaviGuest"]["results"][i]["Name1"]),
                                                              Convert.ToString(output["d"]["results"][0]["ReservationNaviGuest"]["results"][i]["Name2"]),
                                                              Convert.ToString(output["d"]["results"][0]["ReservationNaviGuest"]["results"][i]["Parge"]),
                                                              Convert.ToString(output["d"]["results"][0]["ReservationNaviGuest"]["results"][i]["SmtpAddr"]),
                                                              Convert.ToString(output["d"]["results"][0]["ReservationNaviGuest"]["results"][i]["MobileNo"]),
                                                              Convert.ToString(output["d"]["results"][0]["ReservationNaviGuest"]["results"][i]["HouseNum1"]),
                                                              Convert.ToString(output["d"]["results"][0]["ReservationNaviGuest"]["results"][i]["Street"]),
                                                              Convert.ToString(output["d"]["results"][0]["ReservationNaviGuest"]["results"][i]["City1"]),
                                                              Convert.ToString(output["d"]["results"][0]["ReservationNaviGuest"]["results"][i]["Country"]),
                                                              guestCountryKeyValue,
                                                              Convert.ToString(output["d"]["results"][0]["ReservationNaviGuest"]["results"][i]["Xnacionalidad"]),
                                                              dateString,
                                                              expiryDateString,
                                                              Convert.ToString(output["d"]["results"][0]["ReservationNaviGuest"]["results"][i]["Langu"]),
                                                              "",
                                                              "",
                                                              "",
                                                              "",
                                                              "",
                                                              "",
                                                              ""));

                            //Increment guestnumber and guest number count by 1
                            guestNumber                  = guestNumber + 1;
                            guestNumberCount             = guestNumberCount + 1;
                            lasyoutHeighSignatureInitial = 0;
                        }

                        //Setting stack Layput heights according to the number of records
                        GuestDetails.HeightRequest       = layoutHeightGuestDetails;
                        GuestSignatureView.HeightRequest = layoutHeightSignatures;
                    }
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        //Setting guest number in label
                        GuestNumber.Text = (guestNumberCount - 1).ToString();

                        //Adding list to observable Collection
                        items = new ItemList(guestdetails);
                        GuestNameList.ItemsSource = items.Items;

                        //Set Guest Signatures. Signatures loaded from service
                        if (Constants._notAvailableSignatureAdded == false)
                        {
                            GuestSignatureList.ItemsSource = guestsignature;
                        }
                        else
                        {
                            if (Constants._reservationStatus == Constants._reservationStatusCheckedIn)
                            {
                                //checkinAndSaveButton.IsVisible = true;
                                saveSignatureButton.IsVisible = true;            //true
                                checkinButton.IsVisible       = false;
                            }
                            else if (Constants._reservationStatus == Constants._reservationStatusPending)
                            {
                                //checkinAndSaveButton.IsVisible = true;
                                saveSignatureButton.IsVisible = true;            //false
                                checkinButton.IsVisible       = true;
                            }
                        }

                        if (Constants._reservationStatus != Constants._reservationStatusCheckedIn && savedSignatureCount > 0)
                        {
                            checkinAndSaveButton.IsVisible = true;
                        }
                        else
                        {
                            checkinAndSaveButton.IsVisible = false;
                        }

                        if (savedSignatureCount == guestsignature.Count)
                        {
                            saveSignatureButton.IsVisible = false;
                        }
                    });
                }
            }
            catch (Exception e)
            {
                this.DisplayGuestDetails();
            }
            stopPageLoading();
        }