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; }
public TicketReservation() { InitializeComponent(); db = new AirlineDbEntities(); BindingSource(); BindDestination(); }
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 }
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..."); } }
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; } }
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(); }
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; } }
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); } }
public FlightInfo() { InitializeComponent(); db = new AirlineDbEntities(); }