private void validateButton_Click(object sender, EventArgs e) { dbIO dataHandler = new dbIO(); Transaction foundTrans = new Transaction(); foundTrans = dataHandler.findTrans(Int32.Parse(transactionTextBox.Text)); dueDateTextBox.Text = foundTrans.DueDate; rentDateTextBox.Text = foundTrans.RentDate; memberTextBox.Text = foundTrans.MemberId.ToString(); nameTextBox.Text = foundTrans.FirstName + " " + foundTrans.LastName; }
public void returnMovie(Transaction obj, Int32 id) { try { database = new OleDbConnection(connectionString); database.Open(); string queryString = "UPDATE MovieCopy SET CheckedOut = false WHERE MovieID = " + id.ToString() + ", CheckedOut = true"; string queryString2 = "DELETE FROM [Transaction] WHERE MovieID = " + id.ToString() + ", MemberID = " + obj.MemberId.ToString(); OleDbCommand cmd = new OleDbCommand(queryString, database); OleDbCommand cmd2 = new OleDbCommand(queryString2, database); count = cmd.ExecuteNonQuery(); cmd2.ExecuteNonQuery(); if (count >= 1) MessageBox.Show("Return successful!"); else MessageBox.Show("Error: Return unsuccessful!"); database.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); database.Close(); } }
public void rentMovie(Transaction obj, int id) { try { database = new OleDbConnection(connectionString); database.Open(); string queryString = "UPDATE MovieCopy SET CheckedOut = true WHERE MovieID = " + id.ToString() + ", CheckedOut = false"; string queryString2 = "INSERT INTO [Transaction] (MemberID, FirstName, LastName, MovieID, RentDate, DueDate, ReturnDate)" + " VALUES ('" + obj.Id + "', '" + obj.FirstName + "', '" + obj.LastName + "', '" + id + "', '" + obj.RentDate + "', '" + obj.DueDate + "', '" + obj.ReturnDate + "')"; OleDbCommand cmd = new OleDbCommand(queryString, database); OleDbCommand cmd2 = new OleDbCommand(queryString2, database); count = cmd.ExecuteNonQuery(); cmd2.ExecuteNonQuery(); if (count >= 1) MessageBox.Show("Rent successful!"); else MessageBox.Show("Out of Stock!"); database.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); database.Close(); } }
public List<Transaction> getTransactions() { transList.Clear(); try { database = new OleDbConnection(connectionString); database.Open(); string queryString = "SELECT * FROM [Transaction]"; OleDbCommand cmd = new OleDbCommand(queryString, database); reader = cmd.ExecuteReader(); while (reader.Read()) { Transaction temp = new Transaction(); temp.Id = Int32.Parse(reader["TransID"].ToString()); temp.MemberId = Int32.Parse(reader["MemberID"].ToString()); temp.FirstName = reader["FirstName"].ToString(); temp.LastName = reader["LastName"].ToString(); temp.RentDate = reader["RentDate"].ToString(); temp.DueDate = reader["DueDate"].ToString(); temp.ReturnDate = reader["ReturnDate"].ToString(); temp.Status = reader["Status"].ToString(); transList.Add(temp); } reader.Close(); database.Close(); return transList; } catch (Exception ex) { MessageBox.Show(ex.Message); reader.Close(); database.Close(); return transList; } }
public Transaction findTrans(int id) { Transaction temp = new Transaction(); try { database = new OleDbConnection(connectionString); database.Open(); string queryString = "SELECT * FROM [Transaction] Where ID = " + id.ToString(); OleDbCommand cmd = new OleDbCommand(queryString, database); reader = cmd.ExecuteReader(); while (reader.Read()) { temp.Id = Int32.Parse(reader["ID"].ToString()); temp.MemberId = Int32.Parse(reader["MemberID"].ToString()); temp.FirstName = reader["FirstName"].ToString(); temp.LastName = reader["LastName"].ToString(); temp.RentDate = reader["RentDate"].ToString(); temp.DueDate = reader["DueDate"].ToString(); temp.ReturnDate = reader["ReturnDate"].ToString(); temp.Status = reader["Status"].ToString(); reader.Close(); database.Close(); return temp; } MessageBox.Show("No transaction with that ID was found!"); reader.Close(); database.Close(); return temp; } catch (Exception ex) { MessageBox.Show(ex.Message); reader.Close(); database.Close(); return temp; } }
private void okButton_Click(object sender, EventArgs e) { Transaction newTrans = new Transaction(); newTrans.MemberId = Int32.Parse(memberTextBox.Text); foreach (LViewItem item in this.Document) { if (item.MemberId == Int32.Parse(memberTextBox.Text)) { newTrans.FirstName = item.FirstName; newTrans.LastName = item.LastName; } } newTrans.RentDate = rentDateTextBox.Text; newTrans.DueDate = dueDateTextBox.Text; newTrans.Status = "Open"; dbIO dataHandler = new dbIO(); dataHandler.rentGame(newTrans, Int32.Parse(memberTextBox.Text)); }