| 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 | Edytuj wierszówkê
|
|---|
| 18 | </asp:Content>
|
|---|
| 19 |
|
|---|
| 20 | <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
|
|---|
| 21 | <script type="text/javascript">
|
|---|
| 22 | $(function() {
|
|---|
| 23 | $("#Magazine_Id").change(function() {
|
|---|
| 24 | var magazineId = $("#Magazine_Id > option:selected").attr("value");
|
|---|
| 25 | var urlAction = "<%= Url.Action("FindIssuesById", "Magazine") %>";
|
|---|
| 26 | urlAction = urlAction + "/" + magazineId;
|
|---|
| 27 | $.getJSON(urlAction, function(data) {
|
|---|
| 28 | $("#MagazineItem_IssueId").addItems(data);
|
|---|
| 29 | });
|
|---|
| 30 | });
|
|---|
| 31 | jQuery.validator.setDefaults({
|
|---|
| 32 | success: "valid"
|
|---|
| 33 | });
|
|---|
| 34 | jQuery.validator.addMethod("DateCorrectFormat", function(data, element) {
|
|---|
| 35 | return data.match(/^(19|20)\d\d(-)(0[1-9]|1[012])$/);
|
|---|
| 36 | }, "Podaj prawid³ow¹ datê i format (0000-00).");
|
|---|
| 37 |
|
|---|
| 38 | jQuery.validator.addMethod("RangePrice", function(cena, element) {
|
|---|
| 39 | return cena.match(/^((0)|(0[,]\d\d)|([1-9]\d[,]\d\d)|([1-9]\d\d[,]\d\d)|([1]{1}[0]{3}[,][0]{2}))$/);
|
|---|
| 40 | },"Wymagany format to 0,00 , a wartoæ nie mo¿e byæ wiêksza ni¿ 1000.");
|
|---|
| 41 |
|
|---|
| 42 | $("#myform").validate({
|
|---|
| 43 | rules: {
|
|---|
| 44 | "MagazineItem.AuthorId": { required: true },
|
|---|
| 45 | "MagazineItem.IssueId": { required: true, min:1 },
|
|---|
| 46 | "MagazineItem.ItemTypeId": { required: true },
|
|---|
| 47 | "MagazineItem.Date": { required: true, DateCorrectFormat: true },
|
|---|
| 48 | "MagazineItem.Caption": { required: true, maxlength: 255 },
|
|---|
| 49 | "MagazineItem.Description": { maxlength: 255 },
|
|---|
| 50 | "MagazineItem.Bonus": { required: true, RangePrice: true},
|
|---|
| 51 | "MagazineItem.Price": { required: true, RangePrice: true}
|
|---|
| 52 | },
|
|---|
| 53 | messages: {
|
|---|
| 54 | "MagazineItem.AuthorId": { required: "Proszê wybraæ autora." },
|
|---|
| 55 | "MagazineItem.IssueId": { required: "Proszê wybraæ numer wydania.", min: "Prosze wybraæ numer wydania. Musisz najpierw wybraæ Gazetê." },
|
|---|
| 56 | "MagazineItem.ItemTypeId": { required: "Proszê wybraæ typ wierszówki." },
|
|---|
| 57 | "MagazineItem.Date": { required: "Proszê wprowadziæ miesi¹c."},
|
|---|
| 58 | "MagazineItem.Caption": { required: "Proszê wprowadziæ tytu³ wierszówki.", maxlength: "Tytu³ jest za d³ugi." },
|
|---|
| 59 | "MagazineItem.Description": { maxlength:"Opis jest za d³ugi."},
|
|---|
| 60 | "MagazineItem.Bonus": { required: "Proszê wprowadziæ bonus dla wierszówki."},
|
|---|
| 61 | "MagazineItem.Price": { required: "Proszê wprowadziæ wycenê wierszówki."}
|
|---|
| 62 | }
|
|---|
| 63 | });
|
|---|
| 64 | $("#myform").change(function() {
|
|---|
| 65 | $("#myform").valid();
|
|---|
| 66 | });
|
|---|
| 67 | });
|
|---|
| 68 | </script>
|
|---|
| 69 | <style type="text/css">
|
|---|
| 70 | select,input { border: 1px solid black;}
|
|---|
| 71 | select.error, input.error { border: 1px solid red; }
|
|---|
| 72 | br { clear: both; }
|
|---|
| 73 |
|
|---|
| 74 | label.error {
|
|---|
| 75 | background: url('http://dev.jquery.com/view/trunk/plugins/validate/demo/images/unchecked.gif') no-repeat;
|
|---|
| 76 | padding-left: 18px;
|
|---|
| 77 | margin-left: 270px;
|
|---|
| 78 | margin-top: 3px;
|
|---|
| 79 | }
|
|---|
| 80 | </style>
|
|---|
| 81 | <h2>Edytuj wierszówkê</h2>
|
|---|
| 82 | <%= Html.ValidationSummary("Proszê poprawiæ b³êdy i spróbowaæ ponownie.") %>
|
|---|
| 83 |
|
|---|
| 84 | <div>
|
|---|
| 85 | <div id="messages"></div>
|
|---|
| 86 | <%
|
|---|
| 87 | using (Html.BeginForm("Update", "MagazineItem", FormMethod.Post, new { id = "myform" }))
|
|---|
| 88 | { %>
|
|---|
| 89 | <fieldset>
|
|---|
| 90 | <%= Html.Hidden("Info.user_id", Model.Info.user_id)%>
|
|---|
| 91 | <%= Html.Hidden("Info.powrot", Model.Info.powrot)%>
|
|---|
| 92 | <%= Html.Hidden("Info.month", Model.Info.month)%>
|
|---|
| 93 | <%= Html.Hidden("Info.year", Model.Info.year)%>
|
|---|
| 94 | <legend>Dane wierszówki</legend>
|
|---|
| 95 | <%= Html.Hidden("MagazineItem.Id", Model.MagazineItem.Id)%>
|
|---|
| 96 | <div class="formitem">
|
|---|
| 97 | <label for="MagazineItem.AuthorId">Autor:</label>
|
|---|
| 98 | <%= Html.DropDownList("MagazineItem.AuthorId", Model.AuthorList, "-- proszê wybraæ --")%>
|
|---|
| 99 | <%= Html.ValidationMessage("MagazineItem.AuthorId", "*")%>
|
|---|
| 100 | <br />
|
|---|
| 101 | </div>
|
|---|
| 102 | <div class="formitem">
|
|---|
| 103 | <label for="Magazine">Gazeta:</label>
|
|---|
| 104 | <%= Html.DropDownList("Magazine.Id",Model.MagazineList, "-- proszê wybraæ --")%>
|
|---|
| 105 | <%= Html.ValidationMessage("Magazine.Id", "*")%>
|
|---|
| 106 | <br />
|
|---|
| 107 | </div>
|
|---|
| 108 | <div class="formitem">
|
|---|
| 109 | <label for="MagazineItem.IssueId">Wydanie</label>
|
|---|
| 110 | <%= Html.DropDownList("MagazineItem.IssueId", Model.IssueList, "-- proszê wybraæ --")%>
|
|---|
| 111 | <%= Html.ValidationMessage("MagazineItem.IssueId", "*")%>
|
|---|
| 112 | <br />
|
|---|
| 113 | </div>
|
|---|
| 114 | <div class="formitem">
|
|---|
| 115 | <label for="MagazineItem.ItemTypeId">Typ:</label>
|
|---|
| 116 | <%= Html.DropDownList("MagazineItem.ItemTypeId", Model.ItemTypeList, "-- proszê wybraæ --")%>
|
|---|
| 117 | <%= Html.ValidationMessage("MagazineItem.ItemTypeId", "*")%>
|
|---|
| 118 | <br />
|
|---|
| 119 | </div>
|
|---|
| 120 | <div class="formitem">
|
|---|
| 121 | <label for="MagazineItem.Date">Miesi¹c:</label>
|
|---|
| 122 | <%= Html.TextBox("MagazineItem.Date", Model.MagazineItem.Date, new { Class = "date-pick" })%>
|
|---|
| 123 | <%= Html.ValidationMessage("MagazineItem.Date", "*")%>
|
|---|
| 124 | <br />
|
|---|
| 125 | </div>
|
|---|
| 126 | <div class="formitem">
|
|---|
| 127 | <label for="MagazineItem.Caption">Tytu³:</label>
|
|---|
| 128 | <%= Html.TextBox("MagazineItem.Caption", Model.MagazineItem.Caption )%>
|
|---|
| 129 | <%= Html.ValidationMessage("MagazineItem.Caption", "*")%>
|
|---|
| 130 | <br />
|
|---|
| 131 | </div>
|
|---|
| 132 | <div class="formitem">
|
|---|
| 133 | <label for="MagazineItem.Description">Opis:</label>
|
|---|
| 134 | <%= Html.TextArea("MagazineItem.Description", Model.MagazineItem.Description )%>
|
|---|
| 135 | <%= Html.ValidationMessage("MagazineItem.Description", "*")%>
|
|---|
| 136 | <br />
|
|---|
| 137 | </div>
|
|---|
| 138 | <div class="formitem">
|
|---|
| 139 | <label for="MagazineItem.Price">Wycena:</label>
|
|---|
| 140 | <%= Html.TextBox("MagazineItem.Price", Model.MagazineItem.Price.ToString("#0.00"))%>
|
|---|
| 141 | <%= Html.ValidationMessage("MagazineItem.Price", "*")%>
|
|---|
| 142 | <br />
|
|---|
| 143 | </div>
|
|---|
| 144 | <div class="formitem">
|
|---|
| 145 | <label for="MagazineItem.Bonus">Bonus:</label>
|
|---|
| 146 | <%= Html.TextBox("MagazineItem.Bonus", Model.MagazineItem.Bonus.ToString("#0.00"))%>
|
|---|
| 147 | <%= Html.ValidationMessage("MagazineItem.Bonus", "*")%>
|
|---|
| 148 | <br />
|
|---|
| 149 | </div>
|
|---|
| 150 | <div class="submit">
|
|---|
| 151 | <input type="submit" name="edit" value="Aktualizuj" />
|
|---|
| 152 | </div>
|
|---|
| 153 | </fieldset>
|
|---|
| 154 | <% } %>
|
|---|
| 155 | </div>
|
|---|
| 156 | <div>
|
|---|
| 157 | <%=Html.ActionLink("Powrót", "Index", "Home") %>
|
|---|
| 158 | <%=Html.ClientSideValidation<MagazineItemValidation>("MagazineItem")%>
|
|---|
| 159 | </div>
|
|---|
| 160 | </asp:Content> |
|---|