| 1 | <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Wierszowki.Models.MagazineItemViewData>" %>
|
|---|
| 2 | <%@ Import namespace="Wierszowki.Core.Validation"%>
|
|---|
| 3 | <asp:Content ID="js" ContentPlaceHolderID="jsContent" runat="server">
|
|---|
| 4 | <script src="../../Scripts/jquery-1.3.1.js" type="text/javascript"></script>
|
|---|
| 5 | <script src="../../Scripts/jquery-1.3.1.min.js" type="text/javascript"></script>
|
|---|
| 6 | <script src="../../Scripts/jquery.form.js" type="text/javascript"></script>
|
|---|
| 7 | <script src="../../Scripts/jquery.blockUI.js" type="text/javascript"></script>
|
|---|
| 8 | <script src="../../Scripts/date.js" type="text/javascript"></script>
|
|---|
| 9 | <script src="../../Scripts/jquery.datePicker.js" type="text/javascript"></script>
|
|---|
| 10 | <script src="../../Scripts/spiffy.js" type="text/javascript"></script>
|
|---|
| 11 | <script src="../../Scripts/jHelper.js" type="text/javascript"></script>
|
|---|
| 12 | <script src="../../Scripts/jquery.validate.js" type="text/javascript" ></script>
|
|---|
| 13 | <script src="../../Scripts/xVal.jquery.validate.js" type="text/javascript"></script>
|
|---|
| 14 | </asp:Content>
|
|---|
| 15 |
|
|---|
| 16 | <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
|
|---|
| 17 | Dodaj wierszówkê
|
|---|
| 18 | </asp:Content>
|
|---|
| 19 |
|
|---|
| 20 | <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
|
|---|
| 21 | <script type="text/javascript">
|
|---|
| 22 | $(function() {
|
|---|
| 23 |
|
|---|
| 24 | $("#Magazine").change(function() {
|
|---|
| 25 | var magazineId = $("#Magazine > option:selected").attr("value");
|
|---|
| 26 | var urlAction = "<%= Url.Action("FindIssuesById", "Magazine") %>";
|
|---|
| 27 | urlAction = urlAction + "/" + magazineId;
|
|---|
| 28 | $.getJSON(urlAction, function(data) {
|
|---|
| 29 | $("#IssueId").addItems(data);
|
|---|
| 30 | });
|
|---|
| 31 | });
|
|---|
| 32 | jQuery.validator.setDefaults({
|
|---|
| 33 | success: "valid"
|
|---|
| 34 | });
|
|---|
| 35 | jQuery.validator.addMethod("DateCorrectFormat", function(data, element) {
|
|---|
| 36 | return data.match(/^(19|20)\d\d(-)(0[1-9]|1[012])$/);
|
|---|
| 37 | }, "Podaj prawid³ow¹ datê i format (0000-00).");
|
|---|
| 38 |
|
|---|
| 39 | jQuery.validator.addMethod("RangePrice", function(cena, element) {
|
|---|
| 40 | return cena.match(/^((0([,]\d\d)?)|([1-9](\d){0,2}([,]\d\d)?)|([1]{1}[0]{3}([,][0]{2})?))$/);
|
|---|
| 41 | },"Wymagany format to 0,00 , a wartoæ nie mo¿e byæ wiêksza ni¿ 1000.");
|
|---|
| 42 |
|
|---|
| 43 | $("#myform").validate({
|
|---|
| 44 | rules: {
|
|---|
| 45 | AuthorId: { required: true },
|
|---|
| 46 | IssueId: { required: true, min:1 },
|
|---|
| 47 | ItemTypeId: { required: true },
|
|---|
| 48 | Date: { required: true, DateCorrectFormat: true },
|
|---|
| 49 | Caption: { required: true, maxlength: 255 },
|
|---|
| 50 | Description: { maxlength: 255 },
|
|---|
| 51 | Bonus: { required: true, RangePrice: true},
|
|---|
| 52 | Price: { required: true, RangePrice: true}
|
|---|
| 53 | },
|
|---|
| 54 | messages: {
|
|---|
| 55 | AuthorId: { required: "Proszê wybraæ autora." },
|
|---|
| 56 | IssueId: { required: "Proszê wybraæ numer wydania. Musisz najpierw wybraæ Gazetê.", min: "Prosze wybraæ numer wydania. Musisz najpierw wybraæ Gazetê." },
|
|---|
| 57 | ItemTypeId: { required: "Proszê wybraæ typ wierszówki." },
|
|---|
| 58 | Date: { required: "Proszê podaæ miesi¹c"},
|
|---|
| 59 | Caption: { required: "Proszê podaæ tytu³ wierszówki.", maxlength: "Tytu³ jest za d³ugi." },
|
|---|
| 60 | Description: { maxlength:"Opis jest za d³ugi."},
|
|---|
| 61 | Bonus: { required: "Proszê wprowadziæ bonus do wierszówki."},
|
|---|
| 62 | Price: { required: "Proszê wprowadziæ wycenê wierszówki."}
|
|---|
| 63 | }
|
|---|
| 64 | });
|
|---|
| 65 | $("#myform").change(function() {
|
|---|
| 66 | $("#myform").valid();
|
|---|
| 67 | });
|
|---|
| 68 | });
|
|---|
| 69 | </script>
|
|---|
| 70 | <h2>Dodaj wierszówkê</h2>
|
|---|
| 71 | <%= Html.ValidationSummary("Proszê poprawiæ b³êdy i spróbowaæ ponownie.")%>
|
|---|
| 72 | <div>
|
|---|
| 73 | <% Html.BeginForm("Create", "MagazineItem", Model.MagazineItem, FormMethod.Post, new { id = "myform" }) ;
|
|---|
| 74 | %>
|
|---|
| 75 | <fieldset>
|
|---|
| 76 | <legend>Nowa wierszówka</legend>
|
|---|
| 77 | <div class="formitem">
|
|---|
| 78 | <label for="MagazineItem.AuthorId">Autor:</label>
|
|---|
| 79 | <%= Html.DropDownList("AuthorId", ViewData.Model.AuthorList, "-- proszê wybraæ --")%>
|
|---|
| 80 | <%= Html.ValidationMessage("AuthorId", "*")%>
|
|---|
| 81 | <br />
|
|---|
| 82 | </div>
|
|---|
| 83 | <div class="formitem">
|
|---|
| 84 | <label for="Magazine">Gazeta:</label>
|
|---|
| 85 | <%= Html.DropDownList("Magazine", ViewData.Model.MagazineList, "-- proszê wybraæ --")%>
|
|---|
| 86 | <%= Html.ValidationMessage("Magazine", "*")%>
|
|---|
| 87 | <br />
|
|---|
| 88 | </div>
|
|---|
| 89 | <div class="formitem">
|
|---|
| 90 | <label for="MagazineItem.IssueId">Wydanie:</label>
|
|---|
| 91 | <%= Html.DropDownList("IssueId", ViewData.Model.IssueList, "-- proszê wybraæ --")%>
|
|---|
| 92 | <%= Html.ValidationMessage("IssueId", "*")%>
|
|---|
| 93 | <br />
|
|---|
| 94 | </div>
|
|---|
| 95 | <div class="formitem">
|
|---|
| 96 | <label for="MagazineItem.ItemTypeId">Typ:</label>
|
|---|
| 97 | <%= Html.DropDownList("ItemTypeId", ViewData.Model.ItemTypeList, "-- proszê wybraæ --")%>
|
|---|
| 98 | <%= Html.ValidationMessage("ItemTypeId", "*")%>
|
|---|
| 99 | <br />
|
|---|
| 100 | </div>
|
|---|
| 101 | <div class="formitem">
|
|---|
| 102 | <label for="MagazineItem.Date">Miesi¹c:</label>
|
|---|
| 103 | <%= Html.TextBox("Date", ViewData.Model.MagazineItem.Date, new { Class = "date-pick" })%>
|
|---|
| 104 | <%= Html.ValidationMessage("Date", "*")%>
|
|---|
| 105 | <br />
|
|---|
| 106 | </div>
|
|---|
| 107 | <div class="formitem">
|
|---|
| 108 | <label for="MagazineItem.Caption">Tytu³:</label>
|
|---|
| 109 | <%= Html.TextBox("Caption", ViewData.Model.MagazineItem.Caption, new { title = "Proszê wprowadziæ tytu³ artyku³u." })%>
|
|---|
| 110 | <%= Html.ValidationMessage("Caption", "*")%>
|
|---|
| 111 | <br />
|
|---|
| 112 | </div>
|
|---|
| 113 | <div class="formitem">
|
|---|
| 114 | <label for="MagazineItem.Description">Opis:</label>
|
|---|
| 115 | <%= Html.TextArea("Description", ViewData.Model.MagazineItem.Description, new { title = "Proszê wprowadziæ opis artyku³u." })%>
|
|---|
| 116 | <br />
|
|---|
| 117 | </div>
|
|---|
| 118 | <div class="formitem">
|
|---|
| 119 | <label for="MagazineItem.Price">Wycena:</label>
|
|---|
| 120 | <%= Html.TextBox("Price", ViewData.Model.MagazineItem.Price)%>
|
|---|
| 121 | <%= Html.ValidationMessage("Price", "*")%>
|
|---|
| 122 | <br />
|
|---|
| 123 | </div>
|
|---|
| 124 | <div class="formitem">
|
|---|
| 125 | <label for="MagazineItem.Bonus">Bonus:</label>
|
|---|
| 126 | <%= Html.TextBox("Bonus", ViewData.Model.MagazineItem.Bonus)%>
|
|---|
| 127 | <%= Html.ValidationMessage("Bonus", "*")%>
|
|---|
| 128 | <br />
|
|---|
| 129 | </div>
|
|---|
| 130 | <div>
|
|---|
| 131 | <input type="submit" value="Dodaj" name="dodaj" id="dodaj"/>
|
|---|
| 132 | </div>
|
|---|
| 133 | </fieldset>
|
|---|
| 134 | <% Html.EndForm();%>
|
|---|
| 135 | </div>
|
|---|
| 136 | <div>
|
|---|
| 137 | <%=Html.ActionLink("Powrót", "Index", "Home") %>
|
|---|
| 138 | <%=Html.ClientSideValidation<MagazineItemValidation>("MagazineItem")%>
|
|---|
| 139 | </div>
|
|---|
| 140 | </asp:Content> |
|---|