private void btn_ViewRoom_Click(object sender, EventArgs e) { ViewRooms rooms = new ViewRooms(); rooms.AID = data.AID; rooms.AName = data.AName; rooms.ShowDialog(); }
private void btn_Cancel_Click(object sender, EventArgs e) { Hide(); ViewRooms form = new ViewRooms(); form.AID = AID; form.ShowDialog(); Close(); }
private void btn_ViewRoom_Click(object sender, EventArgs e) { ((Form)TopLevelControl).Hide(); ViewRooms rooms = new ViewRooms(); rooms.AID = data.AID; rooms.ShowDialog(); ((Form)TopLevelControl).Close(); }
private void btn_Save_Click(object sender, EventArgs e) { string name = tb_RName.Text.Trim(); bool isvalid = decimal.TryParse(tb_Quantity.Text.Trim(), out decimal quantity); if (!isvalid) { MessageBox.Show("Invalid Quantity Value, Please Try Again!", "Error", MessageBoxButtons.OK); return; } isvalid = decimal.TryParse(tb_Price.Text.Trim(), out decimal price); if (!isvalid) { MessageBox.Show("Invalid Price Value, Please Try Again!", "Error", MessageBoxButtons.OK); return; } price = Math.Round(price, 2); string des = tb_Description.Text.Trim(); OracleConnection myConnection = Db.Connection(); myConnection.Open(); OracleCommand myCommand = myConnection.CreateCommand(); myCommand.CommandType = CommandType.Text; myCommand.CommandText = "UPDATE ROOM SET PRICE = " + price + ", DESCRIPTION = '" + des + "', QUANTITY = " + quantity + ", RNAME = '" + name + "' WHERE ROOMTYPEID = " + room.RoomTypeID; int rowUpdated = -1; rowUpdated = myCommand.ExecuteNonQuery(); if (rowUpdated == 0) { MessageBox.Show("Room not updated", "Failed", MessageBoxButtons.OK); } else { MessageBox.Show("Room updated successfully!", "Successed", MessageBoxButtons.OK); } myConnection.Close(); Hide(); ViewRooms form = new ViewRooms(); form.AID = room.AID; form.ShowDialog(); Close(); }
private void btn_Create_Click(object sender, EventArgs e) { string RName = tb_RName.Text.Trim(); string quantity = tb_Quantity.Text.Trim(); bool isValid = decimal.TryParse(tb_Price.Text.Trim(), out decimal price); string desc = tb_Description.Text.Trim(); if (!isValid) { MessageBox.Show("Invalid Price Entered", "Error", MessageBoxButtons.OK); return; } price = Decimal.Round(price, 2); int rowUpdated = -1; OracleConnection myConnection = Db.Connection(); myConnection.Open(); OracleCommand myCommand = myConnection.CreateCommand(); myCommand.CommandType = CommandType.Text; myCommand.CommandText = "INSERT INTO ROOM (RoomTypeID,price,description,quantity,RName,AccommodationID) VALUES (roomID.nextval,'" + price + "','" + desc + "'," + quantity + ",'" + RName + "'," + AID + ")"; rowUpdated = myCommand.ExecuteNonQuery(); if (rowUpdated == 0) { MessageBox.Show("Adding a new Room failed", "Failed", MessageBoxButtons.OK); } else { MessageBox.Show("New Room added!", "Success", MessageBoxButtons.OK); } myConnection.Close(); Hide(); ViewRooms form = new ViewRooms(); form.AID = AID; form.ShowDialog(); Close(); }
private void btn_Save_Click(object sender, EventArgs e) { string newName = tb_AName.Text.Trim(); string street = tb_Street.Text.Trim(); string city = tb_City.Text.Trim(); string region = tb_Region.Text.Trim(); string desc = tb_Description.Text.Trim(); int rowUpdated = -1; OracleConnection myConnection = Db.Connection(); myConnection.Open(); OracleCommand myCommand = myConnection.CreateCommand(); myCommand.CommandType = CommandType.Text; myCommand.CommandText = "UPDATE ACCOMMODATION SET ANAME ='" + newName + "', STREET ='" + street + "', CITY ='" + city + "', REGION ='" + region + "', DESCRIPTION ='" + desc + "' WHERE AID =" + AID; rowUpdated = myCommand.ExecuteNonQuery(); if (rowUpdated == 0) { MessageBox.Show("Updating your accommodation failed", "Failed", MessageBoxButtons.OK); } else { MessageBox.Show("Your accommodation details have now been updated!", "Success", MessageBoxButtons.OK); } myConnection.Close(); Hide(); ViewRooms form = new ViewRooms(); form.AID = AID; form.ShowDialog(); Close(); }