private void buttonPurchase_Click(object sender, EventArgs e) { if (clickTicket < totalTickets) { MessageBox.Show("Select remain seat"); } else { FileHandle obj1 = new FileHandle(); obj1.seatFill(flightName, seatNumber); obj1.storeInfo(seat, totalCost, flightName); DataBase DB = new DataBase(); if (flightName != null) { DB.update(flightName, totalseat - totalTickets, cabin); DB.ticketManegment(); PrintTicket print = new PrintTicket(); this.Hide(); print.ShowDialog(); this.Close(); } } }
private void buttonSearch_Click(object sender, EventArgs e) { //DataBase Db = new DataBase(); bool flag = false; if (textBoxName.Text == "" || textBoxCO.Text == "") { MessageBox.Show("Name or CareOf is empty"); flag = true; } if (comboBoxFrom.Text == comboBoxTo.Text) { MessageBox.Show("Arriaval and Destination is same"); flag = true; } else if (comboBoxFrom.Text == "" || comboBoxTo.Text == "") { MessageBox.Show("Select Arriaval and Destination"); flag = true; } int adult = 0; int children = 0; int infants = 0; if (sourcePath == null) { MessageBox.Show("Picture is empty"); flag = true; } if (comboBoxAdult.Text == "" || comboBoxChildren.Text == "" || comboBoxInfants.Text == "") { MessageBox.Show("Select The Number of Tickets"); flag = true; } else if (comboBoxAdult.Text == "More" && comboBoxChildren.Text != "More" && comboBoxInfants.Text != "More") { try { adult = Int32.Parse(textBoxAdult.Text); children = Int32.Parse(comboBoxChildren.Text); infants = Int32.Parse(comboBoxInfants.Text); } catch (Exception) { MessageBox.Show("Invalid Number Format"); flag = true; } } else if (comboBoxAdult.Text == "More" && comboBoxChildren.Text == "More" && comboBoxInfants.Text != "More") { try { adult = Int32.Parse(textBoxAdult.Text); children = Int32.Parse(textBoxChildren.Text); infants = Int32.Parse(comboBoxInfants.Text); } catch (Exception) { MessageBox.Show("Invalid Number Format"); flag = true; } } else if (comboBoxAdult.Text == "More" && comboBoxChildren.Text == "More" && comboBoxInfants.Text == "More") { try { adult = Int32.Parse(textBoxAdult.Text); children = Int32.Parse(textBoxChildren.Text); infants = Int32.Parse(textBoxInfants.Text); } catch (Exception) { MessageBox.Show("Invalid Number Format"); flag = true; } } else if (comboBoxAdult.Text == "More" && comboBoxChildren.Text != "More" && comboBoxInfants.Text == "More") { try { adult = Int32.Parse(textBoxAdult.Text); children = Int32.Parse(comboBoxChildren.Text); infants = Int32.Parse(textBoxInfants.Text); } catch (Exception) { MessageBox.Show("Invalid Number Format"); flag = true; } } else if (comboBoxAdult.Text != "More" && comboBoxChildren.Text == "More" && comboBoxInfants.Text == "More") { try { adult = Int32.Parse(comboBoxAdult.Text); children = Int32.Parse(textBoxChildren.Text); infants = Int32.Parse(textBoxInfants.Text); } catch (Exception) { MessageBox.Show("Invalid Number Format"); flag = true; } } else if (comboBoxAdult.Text != "More" && comboBoxChildren.Text != "More" && comboBoxInfants.Text == "More") { try { adult = Int32.Parse(comboBoxAdult.Text); children = Int32.Parse(comboBoxChildren.Text); infants = Int32.Parse(textBoxInfants.Text); } catch (Exception) { MessageBox.Show("Invalid Number Format"); flag = true; } } else if (comboBoxAdult.Text != "More" && comboBoxChildren.Text == "More" && comboBoxInfants.Text != "More") { try { adult = Int32.Parse(comboBoxAdult.Text); children = Int32.Parse(textBoxChildren.Text); infants = Int32.Parse(comboBoxInfants.Text); } catch (Exception) { MessageBox.Show("Invalid Number Format"); flag = true; } } else { try { adult = Int32.Parse(comboBoxAdult.Text); children = Int32.Parse(comboBoxChildren.Text); infants = Int32.Parse(comboBoxInfants.Text); } catch (Exception) { MessageBox.Show("Invalid Number Format"); flag = true; } } if (flag == false) { if (comboBoxChoose.Text == "International") { if (textBoxPassport.Text == "") { MessageBox.Show("Passport is empty"); } else { SearchFlight flight = new SearchFlight(comboBoxFrom.Text, comboBoxTo.Text, dateTimePicker1.Value.ToString("yyyy-MM-dd"), comboBoxSelectCabin.Text); flight.totalTickets = adult + children + infants; flight.adult = adult; flight.children = children; flight.infants = infants; flight.Name = textBoxName.Text; flight.CO = textBoxCO.Text; flight.passport = textBoxPassport.Text; flight.flight1 = comboBoxChoose.Text; flight.sfrom = comboBoxFrom.Text; flight.sto = comboBoxTo.Text; flight.date = dateTimePicker1.Text; flight.cabin = comboBoxSelectCabin.Text; FileHandle obj1 = new FileHandle(); obj1.storeInfo(textBoxName.Text, textBoxCO.Text, comboBoxChoose.Text, textBoxPassport.Text, comboBoxFrom.Text, comboBoxTo.Text, dateTimePicker1.Text, sourcePath, comboBoxSelectCabin.Text, adult, children, infants); this.Hide(); flight.ShowDialog(); this.Close(); } } else { SearchFlight flight = new SearchFlight(comboBoxFrom.Text, comboBoxTo.Text, dateTimePicker1.Value.ToString("yyyy-MM-dd"), comboBoxSelectCabin.Text); flight.totalTickets = adult + children + infants; flight.adult = adult; flight.children = children; flight.infants = infants; flight.Name = textBoxName.Text; flight.CO = textBoxCO.Text; flight.passport = textBoxPassport.Text; flight.flight1 = comboBoxChoose.Text; flight.sfrom = comboBoxFrom.Text; flight.sto = comboBoxTo.Text; flight.date = dateTimePicker1.Text; flight.cabin = comboBoxSelectCabin.Text; FileHandle obj1 = new FileHandle(); obj1.storeInfo(textBoxName.Text, textBoxCO.Text, comboBoxChoose.Text, "N/A", comboBoxFrom.Text, comboBoxTo.Text, dateTimePicker1.Text, sourcePath, comboBoxSelectCabin.Text, adult, children, infants); this.Hide(); flight.ShowDialog(); this.Close(); } } }