Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @using WebMatrix.Data
- @{
- Validation.Add("Prioriteit", Validator.Range(1, 10, "Getal moet tussen de 1 en 10 zijn."));
- Validation.RequireField("Prioriteit", "Dit veld mag niet leeg zijn!");
- Validation.RequireField("CadeauItem", "Dit veld mag niet leeg zijn!");
- Database db;
- using (db = Database.Open("Todo"))
- {
- if (!Request.QueryString["KoopID"].IsEmpty() && Request.QueryString["KoopID"].IsInt())
- {
- int updateid = Request.QueryString["KoopID"].AsInt();
- string update = "UPDATE Wishlist SET Gekocht = '1' WHERE GiftID = @0";
- db.Execute(update, updateid);
- }
- if (!Request.QueryString["VerwijderID"].IsEmpty() && Request.QueryString["VerwijderID"].IsInt())
- {
- int VerwijderID = Request.QueryString["VerwijderID"].AsInt();
- string verwijder = "DELETE FROM Wishlist WHERE GiftID = @0";
- db.Execute(verwijder, VerwijderID);
- }
- if (IsPost && Validation.IsValid())
- {
- string CadeauItem = Request.Form["CadeauItem"];
- string Prioriteit = Request.Form["Prioriteit"];
- var LoginID = Session["cadeaucode"];
- string insert = "INSERT INTO Wishlist (CadeauItem, Prioriteit, LoginID) VALUES (@0, @1, @2)";
- db.Execute(insert, CadeauItem, Prioriteit, LoginID);
- }
- }
- var lijstje = "SELECT CadeauItem, Prioriteit, LoginID, Gekocht, GiftID FROM Wishlist where LoginID = @0 ORDER BY Prioriteit DESC";
- var records = db.Query(lijstje, Session["cadeaucode"]);
- }
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- @RenderPage("head.cshtml")
- </head>
- <body>
- @RenderPage("nav.cshtml")
- <section>
- @if (Session["LoggedIn"] != null)
- {
- <h3>Uw cadeaucode is: @Session["cadeaucode"].</h3>
- <div class="container">
- <div class="row justify-content-center">
- <div class="login col-lg-3">
- <form class="justify-content-center" method="post">
- <div class="form-group">
- <input class="form-control" type="text" name="CadeauItem" placeholder="Cadeautje" />
- @Html.ValidationMessage("CadeauItem")
- </div>
- <div class="form-group">
- <input class="form-control" type="number" name="Prioriteit" placeholder="Prioriteit (1 - 10)" />
- @Html.ValidationMessage("Prioriteit")
- <label>10 is heel graag, 1 is dat je het graag wilt</label>
- </div>
- <input class="btn btn-outline-primary" value="Toevoegen" type="submit" />
- </form>
- </div>
- </div>
- </div>
- <table class="table">
- <tr>
- <th style="width: 33%">Naam cadeau</th>
- <th style="width: 33%">Prioriteit cadeau (1-10)</th>
- <th style="width: 33%">Reeds gekocht?</th>
- <th>Verwijderen?</th>
- </tr>
- </table>
- foreach (var record in records)
- {
- <table class="table">
- <tr>
- <td style="width: 33%">@record.CadeauItem</td>
- <td style="width: 33%">@record.Prioriteit</td>
- @if (@record.Gekocht == true)
- {
- <td style="width: 33%">Gekocht</td>
- }
- else
- {
- <td style="width: 33%">Niet gekocht</td>
- }
- <td style="width: 33%"><a href="~/wishlist.cshtml?VerwijderID=@record.GiftID" class="btn btn-outline-primary" role="button">Verwijder</a></td>
- </tr>
- </table>
- }
- }
- else
- {
- <h4>Vul hier het wenslijst nummer in, die u van het bruidspaar hebt gekregen:</h4>
- <div class="container">
- <div class="row justify-content-center">
- <div class="login col-lg-3">
- <form class="justify-content-center" method="get">
- <div class="form-group">
- <input class="form-control" type="number" name="WishlistID" placeholder="Wenslijst nummer" />
- </div>
- <input class="btn btn-outline-primary" value="Bevestig" type="submit" />
- </form>
- </div>
- </div>
- </div>
- if (!Request.QueryString["WishlistID"].IsEmpty())
- {
- string searchcode = Request.QueryString["WishlistID"];
- var search_command = "SELECT GiftID, CadeauItem, Prioriteit, LoginID, Gekocht FROM Wishlist where LoginID = @0 AND Gekocht = 0 ORDER BY Prioriteit DESC";
- var selectedData = db.Query(search_command, searchcode);
- <table class="table">
- <tr>
- <th style="width: 33%">Naam cadeau</th>
- <th style="width: 33%">Prioriteit cadeau (1-10)</th>
- <th>Gekocht?</th>
- </tr>
- </table>
- foreach (var record in selectedData)
- {
- <table class="table">
- <tr>
- <td style="width: 33%">@record.CadeauItem</td>
- <td style="width: 33%">@record.Prioriteit</td>
- <td style="width: 33%"><a href="~/wishlist.cshtml?KoopID=@record.GiftID" class="btn btn-outline-primary" role="button">Gekocht</a></td>
- </tr>
- </table>
- }
- }
- }
- </section>
- @RenderPage("footer.cshtml")
- </body>
- </html>
Add Comment
Please, Sign In to add comment