private void btn_Sched_Click(object sender, EventArgs e) { ReservationCalendarForm resCalendar = new ReservationCalendarForm(); resCalendar.reftomain = this; resCalendar.Show(); this.Hide(); }
public int verifyCustomerInfoAndCreateReservation(CustomerInfo Customer, ReservationInfo ResNow, ReservationCalendarForm calendar) { string query = "SELECT * FROM customer WHERE name=@name"; using (MySqlCommand cmd = new MySqlCommand(query, conn)) { // Execute Scalar returns the first column of the first row cmd.Parameters.AddWithValue("@name", Customer.Name); conn.Open(); int CustomerExists = Convert.ToInt32(cmd.ExecuteScalar()); if (CustomerExists > 0) { MessageBox.Show("customer with the same name exist please choose " + "another name"); } else { // user clicked no try { CustomerDataService customerData = new CustomerDataService(); //insert into customer long lastInsertedCustomer = customerData.InsertIntoCustomer(Customer.Name, Customer.Company, Customer.Address, Customer.Phone, Customer.Email, Customer.Passport, Customer.Nationality, Customer.Gender, Customer.BirthDate, Customer.BirthPlace, Customer.Comment); ResNow.CustomerId = Convert.ToInt32(lastInsertedCustomer); long lastInsertReservation = AddReservation(Convert.ToInt32(ResNow.RoomId), ResNow.CustomerId, ResNow.Desc, ResNow.StartDate, ResNow.EndDate, 0, ResNow.TotalPrice, ResNow.LenghtOfStay, ResNow.RoomRate); if ((ResNow.StartDate.Year == ResNow.EndDate.Year) && (ResNow.StartDate.Month == ResNow.EndDate.Month)) { //ReservationCalendarForm calendar = new ReservationCalendarForm(); RoomDataService roomDataService = new RoomDataService(); RoomInfo selectedRoom = new RoomInfo(); selectedRoom = roomDataService.getRoomInfoById(Convert.ToInt32(ResNow.RoomId)); string myRoomId = selectedRoom.RoomId; calendar.findFirstcell(ResNow.StartDate, ResNow.EndDate, lastInsertReservation, ResNow.RoomId); //calendar.createb( } MessageBox.Show(lastInsertReservation.ToString() + "last inserted"); return(Convert.ToInt32(lastInsertReservation)); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } MessageBox.Show("not good"); return(0); } }