/// <summary>
 /// Create a new Passenger object.
 /// </summary>
 /// <param name="passengerId">Initial value of the PassengerId property.</param>
 /// <param name="name">Initial value of the Name property.</param>
 /// <param name="address">Initial value of the Address property.</param>
 /// <param name="email">Initial value of the Email property.</param>
 /// <param name="phone">Initial value of the Phone property.</param>
 /// <param name="city">Initial value of the City property.</param>
 /// <param name="country">Initial value of the Country property.</param>
 /// <param name="creditCardNumber">Initial value of the CreditCardNumber property.</param>
 public static Passenger CreatePassenger(global::System.String passengerId, global::System.String name, global::System.String address, global::System.String email, global::System.String phone, global::System.String city, global::System.String country, global::System.String creditCardNumber)
 {
     Passenger passenger = new Passenger();
     passenger.PassengerId = passengerId;
     passenger.Name = name;
     passenger.Address = address;
     passenger.Email = email;
     passenger.Phone = phone;
     passenger.City = city;
     passenger.Country = country;
     passenger.CreditCardNumber = creditCardNumber;
     return passenger;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Passengers EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPassengers(Passenger passenger)
 {
     base.AddObject("Passengers", passenger);
 }
        private void btnSave_Click(object sender, EventArgs e)
        {
            //validasi semua input sesuai soal
            if (txName.Text.Equals(""))
            {
                MessageBox.Show("Please fill the name");
            }
            else if (txName.Text.Length < 5)
            {
                MessageBox.Show("Name length should be at least 5 characters");
            }
            else if (txAddress.Text.Equals(""))
            {
                MessageBox.Show("Please fill the address");
            }
            else if (txEmail.Text.Equals(""))
            {
                MessageBox.Show("Please fill the email");
            }
            else if (!checkEmail())
            {
                MessageBox.Show("Wrong email format");
            }
            else if (!checkPhone())
            {
                MessageBox.Show("Please fill phone with number");
            }
            else if (txCity.Text.Equals(""))
            {
                MessageBox.Show("Please fill the city");
            }
            else if (txCountry.Text.Equals(""))
            {
                MessageBox.Show("Please fill the country");
            }
            else if (cmbCCNumber.SelectedIndex < 0)
            {
                MessageBox.Show("Please select credit card number");
            }
            else
            {
                //jika input valid, cek apakah user klik button insert/update
                if (operation.Equals("insert"))
                {
                    //jika user klik insert maka lakukan insert ke database
                    string ccnum = cmbCCNumber.SelectedItem.ToString();

                    Passenger obj = new Passenger();
                    obj.PassengerId = txId.Text;
                    obj.Address = txAddress.Text;
                    obj.Email = txEmail.Text;
                    obj.Phone = txPhone.Text;
                    obj.City = txCity.Text;
                    obj.Name = txName.Text;
                    obj.CreditCardNumber = ccnum;

                    obj.Country = txCountry.Text;

                    ent.AddToPassengers(obj);
                    ent.SaveChanges();
                }
                else if (operation.Equals("update"))
                {
                    //jika user klik update maka lakukan update ke database
                    string ccnum = cmbCCNumber.SelectedItem.ToString();

                    Passenger obj = (from x in ent.Passengers where x.PassengerId.Equals(txId.Text) select x).First();

                    obj.Address = txAddress.Text;
                    obj.Email = txEmail.Text;
                    obj.Phone = txPhone.Text;
                    obj.City = txCity.Text;
                    obj.Name = txName.Text;
                    obj.CreditCardNumber = ccnum;

                    obj.Country = txCountry.Text;

                    ent.SaveChanges();
                }
                //kembali ke state awal
                refreshTable();
                curr = 0;
                showData();
                operation = "";
                enableManipulate(false);
            }
        }