Exemplo n.º 1
0
        private void textBox1_TextChanged(object sender, EventArgs e)               //search in grid by keyword
        {
            AirlineDbEntities db = new AirlineDbEntities();
            var items            = db.CustomerDetails.Where(a => a.Name.Equals(textBox1.Text)).ToList();              //condition to search

            dataGridView1.DataSource = items;
        }
Exemplo n.º 2
0
 public TicketReservation()
 {
     InitializeComponent();
     db = new AirlineDbEntities();
     BindingSource();
     BindDestination();
 }
Exemplo n.º 3
0
        private void SearchCustomer_Load(object sender, EventArgs e)
        {
            AirlineDbEntities db = new AirlineDbEntities();                 //creating connection
            var items            = db.CustomerDetails.ToList();             //collecting db data in variable

            dataGridView1.DataSource = items;                               //show data in datagridview
        }
Exemplo n.º 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            AirlineDbEntities db = new AirlineDbEntities();

            if (userText.Text != string.Empty && passText.Text != string.Empty)
            {
                var user = db.Admins.Where(a => a.UserName.Equals(userText.Text)).SingleOrDefault();
                if (user != null)
                {
                    if (user.Password.Equals(passText.Text))
                    {
                        //MessageBox.Show($"Welcome {userText.Text}!");
                        MainForm mainForm = new MainForm();
                        mainForm.Show();
                    }
                    else
                    {
                        MessageBox.Show("Wrong password...");
                    }
                }
                else
                {
                    MessageBox.Show("Wrong username...");
                }
            }
            else
            {
                MessageBox.Show("Please enter username and password...");
            }
        }
Exemplo n.º 5
0
        public void setPrice()
        {
            db = new AirlineDbEntities();
            var cnt = (from o in db.Bookings
                       select o.SeatNo).Count();

            if ((120 - cnt) >= 100)
            {
                flight.FlightCharges -= 5;
            }
            else if ((120 - cnt) > 50 && (120 - cnt) < 100)
            {
                flight.FlightCharges -= 8;
            }
            else if ((120 - cnt) <= 50)
            {
                flight.FlightCharges -= 9;
            }
        }
Exemplo n.º 6
0
        private void button2_Click(object sender, EventArgs e)
        {
            db = new AirlineDbEntities();
            CustomerDetail cust = db.CustomerDetails.Where(a => a.Id == id).FirstOrDefault();

            cust.Name       = nameText.Text;
            cust.FatherName = fnameText.Text;
            cust.BirthDate  = birthDateText.Value;
            cust.Email      = emailText.Text;
            cust.Phone      = phoneText.Text;
            cust.Address    = addressText.Text;
            //db.CustomerDetails.Attach(cust);
            db.SaveChanges();
            MessageBox.Show("Customer modified!");

            th = new Thread(openNewForm);                               //close this window, and open new
            th.SetApartmentState(ApartmentState.STA);
            th.Start();
            this.Close();
        }
Exemplo n.º 7
0
 public Customer([Optional] int?Id)
 {
     InitializeComponent();
     if (Id != null)
     {
         button1.Visible = false;
         db = new AirlineDbEntities();
         CustomerDetail cust = db.CustomerDetails.Where(a => a.Id == Id).FirstOrDefault();
         id                  = cust.Id;
         nameText.Text       = cust.Name;
         fnameText.Text      = cust.FatherName;
         birthDateText.Value = Convert.ToDateTime(cust.BirthDate);
         emailText.Text      = cust.Email;
         phoneText.Text      = cust.Phone;
         addressText.Text    = cust.Address;
     }
     else
     {
         button2.Visible = false;
     }
 }
Exemplo n.º 8
0
        private void button1_Click(object sender, EventArgs e)
        {
            AirlineDbEntities db        = new AirlineDbEntities();
            CustomerDetail    customers = new CustomerDetail
            {
                Name       = nameText.Text,
                FatherName = fnameText.Text,
                BirthDate  = birthDateText.Value,
                Email      = emailText.Text,
                Phone      = phoneText.Text,
                Address    = addressText.Text
            };

            try
            {
                db.CustomerDetails.Add(customers);
                db.SaveChanges();
                MessageBox.Show("Added customer!");
            }
            catch (Exception ex)
            {
                throw new ArgumentException("Database insert exception. ", ex);
            }
        }
Exemplo n.º 9
0
 public FlightInfo()
 {
     InitializeComponent();
     db = new AirlineDbEntities();
 }