public bool Insert(BookingTicket_Model bookingTicket_Model) { bool result = false; query = "INSERT INTO `bookedtickets`(`Book_By`,`Cinema_name`,`Theather`,`Movie_Name`,`time`,`seat_number`,`price`,`bookedon`)" + "VALUES(@Book_By,@Cinema_name,@Theather,@Movie_Name,@time,@seat_number,@price,@bookedon)"; using (MySqlCommand cmd = new MySqlCommand(query, conn)) { cmd.Parameters.Add("@Book_By", bookingTicket_Model.Book_By); cmd.Parameters.Add("@Cinema_name", bookingTicket_Model.Cinema_Name); cmd.Parameters.Add("@Theather", bookingTicket_Model.Theather); cmd.Parameters.Add("@Movie_Name", bookingTicket_Model.Movie_Name); cmd.Parameters.Add("@time", bookingTicket_Model.Time); cmd.Parameters.Add("@seat_number", bookingTicket_Model.Seat_Number); cmd.Parameters.Add("@price", bookingTicket_Model.Price); cmd.Parameters.Add("@bookedon", bookingTicket_Model.BookOn); try { conn.Open(); cmd.ExecuteNonQuery(); conn.Close(); return(result = true); } catch (Exception ex) { Console.WriteLine(ex); return(result); } } }
private void btn_update_Click(object sender, EventArgs e) { BookingTicket_Model = new BookingTicket_Model(); if (PerformValidation(groupBox1)) { ATB(); bool DialogDel = MessageBox.Show("Are you sure to EDIT this Data", "EDIT", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes; if (DialogDel) { bookingticketCRUD = new BookingTicket_CRUDService(); if (bookingticketCRUD.Update(BookingTicket_Model)) { MessageBox.Show("Data UPDATED !!"); this.Close(); } else { MessageBox.Show("Data FAILED UPDATED !!"); this.Close(); } } else { MessageBox.Show("Wrong Password !!"); } ((FrmEditBookingTickets)f).displaydatagrid(); } }
public void LoadForm() { BookingTicket_Model = new BookingTicket_Model(); txt_BookBy.Text = ((FrmEditBookingTickets)f).txt_BookBy.Text; txt_CinemaName.Text = ((FrmEditBookingTickets)f).txt_CinemaName.Text; txt_Theather.Text = ((FrmEditBookingTickets)f).txt_Theather.Text; txt_MovieName.Text = ((FrmEditBookingTickets)f).txt_MovieName.Text; txt_Time.Text = ((FrmEditBookingTickets)f).txt_Time.Text; txt_SeatNumber.Text = ((FrmEditBookingTickets)f).txt_SeatNumber.Text; txt_Price.Text = ((FrmEditBookingTickets)f).txt_Price.Text; txt_BookOn.Text = ((FrmEditBookingTickets)f).txt_BookOn.Text; }
public void ATB() { BookingTicket_Model = new BookingTicket_Model(); BookingTicket_Model.Book_By = txt_BookBy.Text; BookingTicket_Model.Cinema_Name = txt_CinemaName.Text; BookingTicket_Model.Theather = txt_Theather.Text; BookingTicket_Model.Movie_Name = txt_MovieName.Text; BookingTicket_Model.Time = txt_Time.Text; BookingTicket_Model.Seat_Number = txt_SeatNumber.Text; BookingTicket_Model._Price = txt_Price.Text; BookingTicket_Model.BookOn = txt_BookOn.Text; }
public bool Update(BookingTicket_Model bookingTicket_Model) { bool result = false; try { DBCon = new DBConnection(); query = string.Format(@"UPDATE `bookedtickets` SET `Book_By` = '{0}', `cinema_name` = '{1}', `theather` = '{2}', `movie_name` = '{3}', `time` = '{4}', `seat_number` = '{5}', `price` = '{6}', `bookedon` = '{7}' WHERE `ticket_bookid` = '{8}';", bookingTicket_Model.Book_By, bookingTicket_Model.Cinema_Name, bookingTicket_Model.Theather, bookingTicket_Model.Movie_Name, bookingTicket_Model.Time, bookingTicket_Model.Seat_Number, bookingTicket_Model.Price, bookingTicket_Model.BookOn, bookingTicket_Model.Ticket_bookId); DBCon.ConnectionOpen(); cmd = new MySqlCommand(query, DBCon.Connection); result = cmd.ExecuteNonQuery() == 1; DBCon.ConnectionClose(); } catch (Exception ex) { Console.WriteLine(ex); } return(result); }