| 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)|(0[,]\d\d)|([1-9]\d[,]\d\d)|([1-9]\d\d[,]\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.", 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 dla wierszówki."},
|
|---|
| 62 | Price: { required: "Proszê wprowadziæ wycenê wierszówki."}
|
|---|
| 63 | }
|
|---|
| 64 | });
|
|---|
| 65 | $("#myform").change(function() {
|
|---|
| 66 | $("#myform").valid();
|
|---|
| 67 | });
|
|---|
| 68 | });
|
|---|
| 69 | </script>
|
|---|
| 70 | <style type="text/css">
|
|---|
| 71 | select,input { border: 1px solid black;}
|
|---|
| 72 | select.error, input.error { border: 1px solid red; }
|
|---|
| 73 | br { clear: both; }
|
|---|
| 74 |
|
|---|
| 75 | label.error {
|
|---|
| 76 | background: url('http://dev.jquery.com/view/trunk/plugins/validate/demo/images/unchecked.gif') no-repeat;
|
|---|
| 77 | padding-left: 18px;
|
|---|
| 78 | margin-left: 270px;
|
|---|
| 79 | margin-top: 3px;
|
|---|
| 80 | }
|
|---|
| 81 | </style>
|
|---|
| 82 | <h2>Dodaj wierszówkê</h2>
|
|---|
| 83 | <%= Html.ValidationSummary("Proszê poprawiæ b³êdy i spróbowaæ ponownie.")%>
|
|---|
| 84 | <div>
|
|---|
| 85 | <% Html.BeginForm("Create", "MagazineItem", Model.MagazineItem, FormMethod.Post, new { id = "myform" }) ;
|
|---|
| 86 | %>
|
|---|
| 87 | <fieldset>
|
|---|
| 88 | <legend>Nowa wierszówka</legend>
|
|---|
| 89 | <div class="formitem">
|
|---|
| 90 | <label for="MagazineItem.AuthorId">Autor:</label>
|
|---|
| 91 | <%= Html.DropDownList("AuthorId", ViewData.Model.AuthorList, "-- proszê wybraæ --")%>
|
|---|
| 92 | <%= Html.ValidationMessage("AuthorId", "*")%>
|
|---|
| 93 | <br />
|
|---|
| 94 | </div>
|
|---|
| 95 | <div class="formitem">
|
|---|
| 96 | <label for="Magazine">Gazeta:</label>
|
|---|
| 97 | <%= Html.DropDownList("Magazine", ViewData.Model.MagazineList, "-- proszê wybraæ --")%>
|
|---|
| 98 | <%= Html.ValidationMessage("Magazine", "*")%>
|
|---|
| 99 | <br />
|
|---|
| 100 | </div>
|
|---|
| 101 | <div class="formitem">
|
|---|
| 102 | <label for="MagazineItem.IssueId">Wydanie:</label>
|
|---|
| 103 | <%= Html.DropDownList("IssueId", ViewData.Model.IssueList, "-- proszê wybraæ --")%>
|
|---|
| 104 | <%= Html.ValidationMessage("IssueId", "*")%>
|
|---|
| 105 | <br />
|
|---|
| 106 | </div>
|
|---|
| 107 | <div class="formitem">
|
|---|
| 108 | <label for="MagazineItem.ItemTypeId">Typ:</label>
|
|---|
| 109 | <%= Html.DropDownList("ItemTypeId", ViewData.Model.ItemTypeList, "-- proszê wybraæ --")%>
|
|---|
| 110 | <%= Html.ValidationMessage("ItemTypeId", "*")%>
|
|---|
| 111 | <br />
|
|---|
| 112 | </div>
|
|---|
| 113 | <div class="formitem">
|
|---|
| 114 | <label for="MagazineItem.Date">Miesi¹c:</label>
|
|---|
| 115 | <%= Html.TextBox("Date", ViewData.Model.MagazineItem.Date, new { Class = "date-pick" })%>
|
|---|
| 116 | <%= Html.ValidationMessage("Date", "*")%>
|
|---|
| 117 | <br />
|
|---|
| 118 | </div>
|
|---|
| 119 |
|
|---|
| 120 | <div class="formitem">
|
|---|
| 121 | <label for="MagazineItem.Caption">Tytu³:</label>
|
|---|
| 122 | <%= Html.TextBox("Caption", ViewData.Model.MagazineItem.Caption, new { title = "Proszê wprowadziæ tytu³ artyku³u." })%>
|
|---|
| 123 | <%= Html.ValidationMessage("Caption", "*")%>
|
|---|
| 124 | <br />
|
|---|
| 125 | </div>
|
|---|
| 126 | <div class="formitem">
|
|---|
| 127 | <label for="MagazineItem.Description">Opis:</label>
|
|---|
| 128 | <%= Html.TextArea("Description", ViewData.Model.MagazineItem.Description, new { title = "Proszê wprowadziæ opis artyku³u." })%>
|
|---|
| 129 | <br />
|
|---|
| 130 | </div>
|
|---|
| 131 | <div class="formitem">
|
|---|
| 132 | <label for="MagazineItem.Price">Wycena:</label>
|
|---|
| 133 | <%= Html.TextBox("Price", ViewData.Model.MagazineItem.Price)%>
|
|---|
| 134 | <%= Html.ValidationMessage("Price", "*")%>
|
|---|
| 135 | <br />
|
|---|
| 136 | </div>
|
|---|
| 137 | <div class="formitem">
|
|---|
| 138 | <label for="MagazineItem.Bonus">Bonus:</label>
|
|---|
| 139 | <%= Html.TextBox("Bonus", ViewData.Model.MagazineItem.Bonus)%>
|
|---|
| 140 | <%= Html.ValidationMessage("Bonus", "*")%>
|
|---|
| 141 | <br />
|
|---|
| 142 | </div>
|
|---|
| 143 | <div>
|
|---|
| 144 | <input type="submit" value="Dodaj" name="dodaj" id="dodaj"/>
|
|---|
| 145 | </div>
|
|---|
| 146 | </fieldset>
|
|---|
| 147 | <% Html.EndForm();%>
|
|---|
| 148 | </div>
|
|---|
| 149 | <div>
|
|---|
| 150 | <%=Html.ActionLink("Powrót", "Index", "Home") %>
|
|---|
| 151 | <%=Html.ClientSideValidation<MagazineItemValidation>("MagazineItem")%>
|
|---|
| 152 | </div>
|
|---|
| 153 | </asp:Content> |
|---|