//------------------------------ CHECK IF VENUE IS FREE ------------------------------- public Boolean isVenueFree() { Venue newVenue = new Venue(); newVenue.setID(this.venueID); newVenue.setVenueDetails(); //define sql query String strSQL = "SELECT COUNT(E.VENUEID) From Events E Join Venues V ON E.VenueID = V.VenueID" + " WHERE EventDate = '" + this.date + "' AND E.VenueID = " + this.venueID + "AND E.EventID != " + this.id; //Declare an Oracle Connection OracleConnection conn = new OracleConnection(DBConnect.oradb); //Declare an oracle command to execute OracleCommand cmd = new OracleCommand(strSQL, conn); conn.Open(); //Declare an oracle DataAdapter OracleDataAdapter da = new OracleDataAdapter(cmd); Boolean result = false; using (OracleDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { int nxt = reader.GetInt32(0); if (nxt == 0) { result = true; } else if (nxt >= 1) { result = false; } } } conn.Close(); return(result); }
private void btnLogin_Click_1(object sender, EventArgs e) { //Validate Email & password combination if (!txtEmail.Text.Equals("") || !txtPassword.Text.Equals("")) { Customer cust = new Customer(); cust.setEmail((txtEmail.Text).ToLower()); cust.setPassword(txtPassword.Text); if (cust.isValidLogin()) { cust.setCustDetails(); pnlBook.Visible = true; txtBal.Text = Convert.ToString(cust.getBal()); txtEmail.Enabled = false; txtPassword.Enabled = false; grdEvents.Enabled = false; btnLogin.Visible = false; Event myEvent = new Event(); //gets the selected rows id myEvent.setTitle(grdEvents.Rows[grdEvents.CurrentCell.RowIndex].Cells[0].Value.ToString()); myEvent.setEventDetails(); Venue venue = new Venue(); venue.setID(myEvent.getVenueId()); venue.setVenueDetails(); lblSelectedEvent.Text = myEvent.getTitle() + " at " + venue.getName(); } else { MessageBox.Show("Your Email or Password is incorrect", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Please enter a valid Email or Password", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); txtEmail.Clear(); txtPassword.Clear(); txtEmail.Focus(); } }
private void grdEvents_CellClick(object sender, DataGridViewCellEventArgs e) { pnlLogin.Visible = true; Event myEvent = new Event(); //gets the selected rows id myEvent.setTitle(grdEvents.Rows[grdEvents.CurrentCell.RowIndex].Cells[0].Value.ToString()); myEvent.setEventDetails(); Venue venue = new Venue(); venue.setID(myEvent.getVenueId()); venue.setVenueDetails(); lblSelectedEvent.Text = myEvent.getTitle() + " at " + venue.getName(); }
private void btnRegVenue_Click_1(object sender, EventArgs e) { //Validate data entered if (!txtStreet.Text.Equals("") || !txtTown.Text.Equals("") || !txtEmail.Text.Equals("") || !txtCapacity.Text.Equals("") || !txtContactNo.Text.Equals("") || !txtEmail.Text.Equals("") || !txtPassword.Text.Equals("")) { Venue myVenue = new Venue(); myVenue.setID(Convert.ToInt32(txtVenueID.Text)); myVenue.setName(txtVenueName.Text); myVenue.setStreet(txtStreet.Text); myVenue.setTown(txtTown.Text); myVenue.setCapacity(Convert.ToInt32(txtCapacity.Text)); myVenue.setContactNo(txtContactNo.Text); myVenue.setEmail(txtEmail.Text); myVenue.setPassword(txtPassword.Text); myVenue.setStatus('y'); if (!myVenue.isRegistered()) { //Ask user to confirm DialogResult confirmation = MessageBox.Show("The new Venue details you have entered are: \n" + myVenue.toString() + "\n\nWould you like to add this venue?,", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (confirmation == DialogResult.Yes) { //Save data to Venues File myVenue.registerVenue(); //Display Confirmation Message MessageBox.Show("Venue Registered - You may now add events to the system", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); //Reset UI txtVenueName.Clear(); txtStreet.Clear(); txtTown.Clear(); txtCapacity.Clear(); txtContactNo.Clear(); txtEmail.Clear(); txtPassword.Clear(); txtVenueName.Focus(); txtVenueID.Text = Convert.ToString(Venue.getNextID()); } } else { MessageBox.Show("Venue Name already Exists", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); txtVenueName.Focus(); return; } } else { MessageBox.Show("Information Missing", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); txtStreet.Focus(); return; } }
private void btnUpdateEvent_Click_1(object sender, EventArgs e) { //validate Data if (txtTitle.Text != "" && cboTypes.SelectedIndex != -1 && txtDate.Text != "" && txtHour.Text != "" && txtMin.Text != "" && txtTickets.Text != "" && txtPrice.Text != "") { //if there are other events on same date with same venueID //Error- Clashing Events Event newEvent = new Event(); newEvent.setTitle(cboEventTitles.Text); newEvent.setEventDetails(); Venue eventVenue = new Venue(); eventVenue.setID(newEvent.getVenueId()); eventVenue.setVenueDetails(); newEvent.setTickets(Convert.ToInt32(txtTickets.Text)); //Tickets Available cannot be more than Capacity //Error - Capacity Exceeded if (newEvent.isVenueBigEnough()) { Type eventType = new Type(); eventType.setName(cboTypes.Text); eventType.setTypeDetails(); newEvent.setType(eventType.getID()); newEvent.setDate(txtDate.Text); string time; int hour = Convert.ToInt32(txtHour.Text); int mins = Convert.ToInt32(txtMin.Text); if ((hour > 0 && hour < 13) && (mins >= 0 && mins < 60)) { //If pm add 12 hours to make 24 hr format if (cboAmPm.Text.Equals("pm") && hour < 12) { hour += 12; } time = hour + ":" + txtMin.Text; newEvent.setTime(time); newEvent.setPrice(Convert.ToDouble(txtPrice.Text)); //check if event is on the same date in the same venue if (newEvent.isVenueFree()) { newEvent.setTitle(txtTitle.Text); newEvent.setDesc(txtDescription.Text); //Ask user to confirm DialogResult confirmation = MessageBox.Show("The new Event details you have entered are: \n" + newEvent.toString() + "\n\nWould you like to update the event?,", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (confirmation == DialogResult.Yes) { //if yes System save data to Events File newEvent.updateEvent(); //Email Customers with Updates MessageBox.Show("Event has been updated - Customers with existing tickets will be contacted and updated", "New Event!", MessageBoxButtons.OK, MessageBoxIcon.Information); //Reset UI cboEventTitles.SelectedIndex = -1; pnlUpdateEvent.Visible = false; txtTitle.Clear(); txtDescription.Clear(); cboTypes.SelectedIndex = -1; txtDate.Refresh(); txtHour.Clear(); txtMin.Clear(); txtTickets.Clear(); txtPrice.Clear(); } } else { MessageBox.Show("Your Venue already has an event scheduled for " + newEvent.getDate(), "Existing Event!", MessageBoxButtons.OK, MessageBoxIcon.Information); txtDate.Focus(); } } else { MessageBox.Show("Please Enter a valid time", "Invalid Time!", MessageBoxButtons.OK, MessageBoxIcon.Information); txtHour.Focus(); } } else { MessageBox.Show("For Health & Safety reasons you may NOT sell more tickets than the capacity of your Venue!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); txtTickets.Clear(); txtTickets.Focus(); } } else { MessageBox.Show("Information Missing", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }