Пример #1
0
    public bool PaddingPassengerInfo()
    {
        try
        {
            DataListItem item;

            IList<TERMS.Business.Centers.SalesCenter.Passenger> Passengers = Utility.Transaction.CurrentTransactionObject.GetPassengers();

            List<TERMS.Business.Centers.SalesCenter.Passenger> OrderPassengerInfos = new List<TERMS.Business.Centers.SalesCenter.Passenger>();

            int iAdult = dlAdult.Items.Count;
            int iChild = dlChild.Items.Count;

            List<string> list = new List<string>();

            for (int i = 0; i < iAdult; i++)
            {
                item = dlAdult.Items[i];

                DateTime dateBirthday;

                try
                {
                    dateBirthday = Convert.ToDateTime(((TextBox)item.FindControl("txtAdultBirthday")).Text);

                }
                catch
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Warting", "<script language=javascript>alert('Adult " + (i + 1).ToString() + "# birthday format error.');</script>");
                    return false;
                }

                for (int index = 0; index < Passengers.Count; index++)
                {
                    string firstname = ((Label)item.FindControl("lblAdultFirstName")).Text.Trim().ToUpper();
                    string lastname = ((Label)item.FindControl("lblAdultLastName")).Text.Trim().ToUpper();
                    if (firstname == Passengers[index].FirstName.ToUpper() && lastname == Passengers[index].LastName.ToUpper())
                    {
                        Passengers[index].Birthday = dateBirthday;

                        Passengers[index].StreetAddress = ((TermsTextBox)item.FindControl("txtAdultStreet")).Text;

                        if (string.IsNullOrEmpty(Passengers[index].StreetAddress))
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Warting", "<script language=javascript>alert('Adult " + (i + 1).ToString() + "# Street format error.');</script>");
                            return false;
                        }

                        Passengers[index].CityName = ((TermsTextBox)item.FindControl("txtAdultCity")).Text;

                        if (string.IsNullOrEmpty(Passengers[index].CityName))
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Warting", "<script language=javascript>alert('Adult " + (i + 1).ToString() + "# City format error.');</script>");
                            return false;
                        }

                        Passengers[index].CountryName = ((DropDownList)item.FindControl("ddlAdultCountry")).SelectedItem.Text;   //((TermsTextBox)item.FindControl("txtAdultCountry")).Text;

                        Passengers[index].ProvinceName = ((DropDownList)item.FindControl("ddlAdultState")).SelectedItem.Text; //((TermsTextBox)item.FindControl("txtAdultState")).Text;

                        Passengers[index].Email = ((TermsTextBox)item.FindControl("txtAdultEmail")).Text;

                        Passengers[index].ZipCode = ((TermsTextBox)item.FindControl("txtAdultZipCode")).Text;

                        if (string.IsNullOrEmpty(Passengers[index].ZipCode))
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Warting", "<script language=javascript>alert('Adult " + (i + 1).ToString() + "# ZipCode format error.');</script>");
                            return false;
                        }

                        TERMS.Common.City city = new TERMS.Common.City();
                        city.Name = ((TermsTextBox)item.FindControl("txtAdultCity")).Text;
                        TERMS.Common.Address address = new TERMS.Common.Address(city, ((TermsTextBox)item.FindControl("txtAdultStreet")).Text, ((TermsTextBox)item.FindControl("txtAdultZipCode")).Text);

                        Passengers[index].Address.Add(address);
                    }
                }
            }

            for (int i = 0; i < iChild; i++)
            {
                item = dlChild.Items[i];

                for (int index = 0; index < Passengers.Count; index++)
                {
                    string firstname = ((Label)item.FindControl("lblChildFirstName")).Text.Trim().ToUpper();
                    string lastname = ((Label)item.FindControl("lblChildLastName")).Text.Trim().ToUpper();
                    if (firstname == Passengers[index].FirstName.ToUpper() && lastname == Passengers[index].LastName.ToUpper())
                    {
                        Passengers[index].StreetAddress = ((TermsTextBox)item.FindControl("txtChildStreet")).Text;

                        if (string.IsNullOrEmpty(Passengers[index].ZipCode))
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Warting", "<script language=javascript>alert('Child " + (i + 1).ToString() + "# Street format error.');</script>");
                            return false;
                        }

                        Passengers[index].CityName = ((TermsTextBox)item.FindControl("txtChildCity")).Text;

                        if (string.IsNullOrEmpty(Passengers[index].ZipCode))
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Warting", "<script language=javascript>alert('Child " + (i + 1).ToString() + "# City format error.');</script>");
                            return false;
                        }

                        Passengers[index].CountryName = ((DropDownList)item.FindControl("ddlChildCountry")).SelectedItem.Text; //((TermsTextBox)item.FindControl("txtChildCountry")).Text;

                        Passengers[index].ProvinceName = ((DropDownList)item.FindControl("ddlChildState")).SelectedValue; //((TermsTextBox)item.FindControl("txtChildState")).Text;

                        Passengers[index].Email = ((TermsTextBox)item.FindControl("txtChildEmail")).Text;

                        Passengers[index].ZipCode = ((TermsTextBox)item.FindControl("txtChildZipCode")).Text;

                        if (string.IsNullOrEmpty(Passengers[index].ZipCode))
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Warting", "<script language=javascript>alert('Child " + (i + 1).ToString() + "# ZipCode format error.');</script>");
                            return false;
                        }

                        TERMS.Common.City city = new TERMS.Common.City();
                        city.Name = ((TermsTextBox)item.FindControl("txtChildCity")).Text;
                        TERMS.Common.Address address = new TERMS.Common.Address(city, ((TermsTextBox)item.FindControl("txtChildStreet")).Text, ((TermsTextBox)item.FindControl("txtChildZipCode")).Text);

                        Passengers[index].Address.Add(address);
                    }
                }
            }
        }
        catch (Exception ex)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Warting", "<script language=javascript>alert('" + ex.Message + "');</script>");
            return false;
        }

        return true;
    }
Пример #2
0
    protected void btnBooking_Click(object sender, EventArgs e)
    {
        if (!cbIsAgree.Checked)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Warting", "<script language=javascript>alert('Please read & confirm the Terms and Conditions to continue');</script>");
            return;
        }

        if (ddlState.SelectedIndex == 0)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Warting", "<script language=javascript>alert('Please select state');</script>");
            return;
        }
        try
        {
            Utility.Transaction.CurrentTransactionObject.ClearPassenger();

            string firstName = txtFrist.Text;
            string middleName = txtMiddle.Text;
            string lastName = txtLast.Text;

            System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex("^[A-Za-z.]+$");

            if (!reg.IsMatch(firstName + middleName + lastName))
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Warting", "<script language=javascript>alert('Name format error.');</script>");
                return;
            }

            if (middleName == "Middle Name")
            {
                middleName = string.Empty;
            }

            TERMS.Business.Centers.SalesCenter.Passenger adultorderPassengerInfo = new TERMS.Business.Centers.SalesCenter.Passenger(firstName, lastName, middleName, TERMS.Common.PassengerType.Adult);
            adultorderPassengerInfo.PassengerType = TERMS.Common.PassengerType.Adult;

            switch (ddlSex.SelectedValue)
            {
                case "0":
                    adultorderPassengerInfo.Salutationn = TERMS.Common.Salutation.Dr;
                    break;
                case "1":
                    adultorderPassengerInfo.Salutationn = TERMS.Common.Salutation.Miss;
                    break;
                case "2":
                    adultorderPassengerInfo.Salutationn = TERMS.Common.Salutation.Mr;
                    break;
                case "3":
                    adultorderPassengerInfo.Salutationn = TERMS.Common.Salutation.Mrs;
                    break;
                case "4":
                    adultorderPassengerInfo.Salutationn = TERMS.Common.Salutation.Ms;
                    break;
                case "99":
                    adultorderPassengerInfo.Salutationn = TERMS.Common.Salutation.None;
                    break;
                case "5":
                    adultorderPassengerInfo.Salutationn = TERMS.Common.Salutation.Rev;
                    break;
            }
            Utility.Transaction.CurrentTransactionObject.AddPassenger(adultorderPassengerInfo);
        }
        catch
        {
            return;
        }

        Contact contact = new Contact();

        string firstNameContact = txtContactFirst.Text;
        string middleNameContact = txtMiddle.Text;
        string lastNameContact = txtContactLast.Text;

        if (middleNameContact == "Middle Name")
        {
            middleNameContact = string.Empty;
        }

        contact.Person = new TERMS.Common.Person(firstNameContact, lastNameContact, middleNameContact);

        TERMS.Common.Country country = new TERMS.Common.Country();

        country.Code = this.ddlCountry.SelectedValue;

        string Phone = string.Empty;

        if (txtExt.Text.Trim().Length > 0)
        {
            Phone = txtPhone.Text.Trim() + " " + txtExt.Text.Trim();
        }
        else
        {
            Phone = txtPhone.Text.Trim();
        }

        TERMS.Common.Phone phone = new TERMS.Common.Phone(country, this.ddlState.SelectedValue, Phone, string.Empty);
        phone.ContactOptions = TERMS.Common.ContactOptions.DayTime;
        contact.Person.AddPhone(phone);

        contact.Person.Email = this.txtEmail.Text;

        TERMS.Common.City city = new TERMS.Common.City();

        city.Name = this.txtCity.Text;

        city.Country.Name = this.ddlCountry.SelectedItem.Text;
        city.ProvinceName = this.ddlState.SelectedItem.Text;

        string Address = string.Empty;

        if (txtAddress2.Text.Trim().Length > 0)
        {
            Address = txtAddress1.Text.Trim() + "-" + txtAddress2.Text.Trim();
        }
        else
        {
            Address = txtAddress1.Text.Trim();
        }

        TERMS.Common.Address address = new TERMS.Common.Address(city, Address, txtZip.Text.Trim());

        contact.Person.AddAddress(address);

        if (Utility.Transaction.CurrentTransactionObject.GetContacts() != null && Utility.Transaction.CurrentTransactionObject.GetContacts().Count > 0)
        {
            Utility.Transaction.CurrentTransactionObject.ClearContact();
        }

        Utility.Transaction.CurrentTransactionObject.AddContact(contact);

        VehcileOrderItem vehcileorderitem = new VehcileOrderItem(new PackageProfile("Car"));

        VehcileMerchandise m_SaleMerchandise = (VehcileMerchandise)this.OnSearch();

        for (int i = 0; i < m_SaleMerchandise.Items.Count; i++)
        {
            VehcileMaterial vehcilematerial = (TERMS.Business.Centers.ProductCenter.Components.VehcileMaterial)m_SaleMerchandise.Items[i];

            if (vehcilematerial.VendorCode == VendorCode && vehcilematerial.Vehciles.MakeModelCode == CarCode)
            {
                vehcileorderitem.Vehcile = vehcilematerial;
            }
        }

        Utility.Transaction.CurrentTransactionObject.Items.Add(vehcileorderitem);

        this.NewVehcileSendEamilControl1.AddItems();
        //this.Response.Redirect("~/Page/Common/SaveOrderWaiting.aspx" + "?ConditionID=" + Request.Params["ConditionID"] + "&VendorCode=" + VendorCode + "&CarCode=" + CarCode);
        ClientScript.RegisterStartupScript(this.GetType(), "Searching", "<script>OnSearch();</script>");
    }