Zbiór zmian 842 dla trunk/Wierszowki
- Data:
- 2009-10-02 13:15:40 (17 years ago)
- Lokalizacja:
- trunk/Wierszowki
- Pliki:
-
- 13 dodane
- 29 zmodyfikowane
-
Wierszowki.Model/Linq/Author.cs (zmodyfikowane) (1 diff)
-
Wierszowki.Model/Linq/Info.cs (dodane)
-
Wierszowki.Model/Linq/UpdateData.cs (dodane)
-
Wierszowki.Model/Linq/User.cs (zmodyfikowane) (1 diff)
-
Wierszowki.Model/Linq/WierszowkiDataContext.cs (zmodyfikowane) (4 diffs)
-
Wierszowki.Model/Wierszowki.Core.csproj (zmodyfikowane) (2 diffs)
-
Wierszowki.Services/DataAnnotationsValidationRunner.cs (zmodyfikowane) (1 diff)
-
Wierszowki.Services/MagazineItemService.cs (zmodyfikowane) (6 diffs)
-
Wierszowki.Web/Content/Site.css (zmodyfikowane) (7 diffs)
-
Wierszowki.Web/Content/print.css (zmodyfikowane) (2 diffs)
-
Wierszowki.Web/Controllers/MagazineController.cs (zmodyfikowane) (1 diff)
-
Wierszowki.Web/Controllers/MagazineItemController.cs (zmodyfikowane) (5 diffs)
-
Wierszowki.Web/Controllers/ReportController.cs (zmodyfikowane) (5 diffs)
-
Wierszowki.Web/Controllers/UserController.cs (zmodyfikowane) (7 diffs)
-
Wierszowki.Web/Helpers/SelectExtension.cs (zmodyfikowane) (1 diff)
-
Wierszowki.Web/Models/AllViewData.cs (dodane)
-
Wierszowki.Web/Models/ConfirmViewData.cs (dodane)
-
Wierszowki.Web/Models/DeleteViewData.cs (dodane)
-
Wierszowki.Web/Models/MagazineItemViewData.cs (zmodyfikowane) (1 diff)
-
Wierszowki.Web/Models/OperationType.cs (dodane)
-
Wierszowki.Web/Models/UpdateViewData.cs (dodane)
-
Wierszowki.Web/Models/UserConfirmViewData.cs (dodane)
-
Wierszowki.Web/Scripts/jquery-1.2.6.js (dodane)
-
Wierszowki.Web/Scripts/jquery-1.2.6.min.js (dodane)
-
Wierszowki.Web/Scripts/jquery.validate.js (dodane)
-
Wierszowki.Web/Scripts/xVal.AspNetNative.js (dodane)
-
Wierszowki.Web/Scripts/xVal.jquery.validate.js (dodane)
-
Wierszowki.Web/Views/Author/Index.aspx (zmodyfikowane) (1 diff)
-
Wierszowki.Web/Views/MagazineItem/Confirm.aspx (zmodyfikowane) (2 diffs)
-
Wierszowki.Web/Views/MagazineItem/Create.aspx (zmodyfikowane) (4 diffs)
-
Wierszowki.Web/Views/MagazineItem/Delete.aspx (zmodyfikowane) (3 diffs)
-
Wierszowki.Web/Views/MagazineItem/Edit.aspx (zmodyfikowane) (4 diffs)
-
Wierszowki.Web/Views/Report/All.aspx (zmodyfikowane) (4 diffs)
-
Wierszowki.Web/Views/Report/Authors.aspx (zmodyfikowane) (2 diffs)
-
Wierszowki.Web/Views/Report/Index.aspx (zmodyfikowane) (2 diffs)
-
Wierszowki.Web/Views/Shared/Error.aspx (zmodyfikowane) (1 diff)
-
Wierszowki.Web/Views/Shared/Site.Master (zmodyfikowane) (1 diff)
-
Wierszowki.Web/Views/User/Confirm.aspx (zmodyfikowane) (1 diff)
-
Wierszowki.Web/Views/User/Index.aspx (zmodyfikowane) (1 diff)
-
Wierszowki.Web/Views/Web.config (zmodyfikowane) (1 diff)
-
Wierszowki.Web/Web.config (zmodyfikowane) (1 diff)
-
Wierszowki.Web/Wierszowki.Web.csproj (zmodyfikowane) (7 diffs)
Legenda:
- Bez zmian
- Dodane
- Usunięte
-
trunk/Wierszowki/Wierszowki.Model/Linq/Author.cs
r752 r842 8 8 public partial class Author : AuthorValidation, IIdentifiable 9 9 { 10 public string FullName { get { return FirstName + " " + LastName; } }10 public string FullName { get { return LastName + " " + FirstName; } } 11 11 } 12 12 } -
trunk/Wierszowki/Wierszowki.Model/Linq/User.cs
r823 r842 8 8 public partial class User : UserValidation, IIdentifiable 9 9 { 10 public string FullName { get { return FirstName + " " + LastName; } }10 public string FullName { get { return LastName + " " + FirstName; } } 11 11 } 12 12 } -
trunk/Wierszowki/Wierszowki.Model/Linq/WierszowkiDataContext.cs
r814 r842 9 9 public Author GetAuthorById(int id) 10 10 { 11 return Authors.Single (a => a.Id == id);11 return Authors.SingleOrDefault(a => a.Id == id); 12 12 } 13 13 … … 23 23 return Users.ToList(); 24 24 } 25 public List<Issue> GetIssue() 26 { 27 return Issues.ToList(); 28 } 25 29 26 30 public User GetUserById(int id) 27 31 { 28 return Users.Single (u => u.Id == id);32 return Users.SingleOrDefault(u => u.Id == id); 29 33 } 30 34 31 35 public User GetUserByLogin(string login) 32 36 { 33 return Users.Single (u => u.Login == login);37 return Users.SingleOrDefault(u => u.Login == login); 34 38 } 35 39 … … 58 62 } 59 63 60 public IQueryable<Issue> FindIssuesByMagazineId(int magazineId )64 public IQueryable<Issue> FindIssuesByMagazineId(int magazineId, int addId) 61 65 { 62 66 var startDate = DateTime.Now.AddMonths(-3); 63 67 var endDate = DateTime.Now.AddMonths(1); 64 65 var query = from i in Issues 66 where i.MagazineId == magazineId 67 && i.Date >= startDate 68 && i.Date <= endDate 69 select i; 70 return query; 68 if (addId != 0) 69 { 70 var query = from i in Issues 71 where (i.Id == addId) || 72 (i.MagazineId == magazineId && i.Date >= startDate && i.Date <= endDate ) 73 select i; 74 return query; 75 } 76 else 77 { 78 var query = from i in Issues 79 where i.MagazineId == magazineId 80 && i.Date >= startDate 81 && i.Date <= endDate 82 select i; 83 return query; 84 } 71 85 } 72 86 73 public IQueryable<Issue> FindIssuesByMagazineItemId(int issueId )87 public IQueryable<Issue> FindIssuesByMagazineItemId(int issueId, int addId) 74 88 { 75 89 var issue = Issues.Single(i => i.Id == issueId); 76 return FindIssuesByMagazineId(issue.MagazineId );90 return FindIssuesByMagazineId(issue.MagazineId, addId); 77 91 } 78 92 … … 151 165 InsertUser(user); 152 166 } 167 153 168 } 154 169 } -
trunk/Wierszowki/Wierszowki.Model/Wierszowki.Core.csproj
r752 r842 61 61 <Compile Include="Interfaces\IUserRepository.cs" /> 62 62 <Compile Include="Linq\Author.cs" /> 63 <Compile Include="Linq\Info.cs" /> 63 64 <Compile Include="Linq\Issue.cs" /> 64 65 <Compile Include="Linq\LinqRepository.cs" /> 65 66 <Compile Include="Linq\MagazineItem.cs" /> 66 67 <Compile Include="Linq\Report.cs" /> 68 <Compile Include="Linq\UpdateData.cs" /> 67 69 <Compile Include="Linq\User.cs" /> 68 70 <Compile Include="Linq\Wierszowki.cs"> … … 81 83 <DependentUpon>Settings.settings</DependentUpon> 82 84 </Compile> 83 <Compile Include=" Validation\AuthorValidation.cs" />84 <Compile Include=" Validation\MagazineItemValidation.cs" />85 <Compile Include=" Validation\UserValidation.cs" />85 <Compile Include="Linq\Validation\AuthorValidation.cs" /> 86 <Compile Include="Linq\Validation\MagazineItemValidation.cs" /> 87 <Compile Include="Linq\Validation\UserValidation.cs" /> 86 88 </ItemGroup> 87 89 <ItemGroup> -
trunk/Wierszowki/Wierszowki.Services/DataAnnotationsValidationRunner.cs
r752 r842 12 12 { 13 13 public static IEnumerable<ErrorInfo> GetErrors(object instance) 14 { 15 return from prop in TypeDescriptor.GetProperties(instance).Cast<PropertyDescriptor>() 14 { 15 List<ErrorInfo> errors = new List<ErrorInfo>(); 16 17 IEnumerable<PropertyDescriptor> properties = TypeDescriptor.GetProperties(instance).Cast<PropertyDescriptor>(); 18 foreach (PropertyDescriptor prop in properties) { 19 IEnumerable<ValidationAttribute> attributes = prop.Attributes.OfType<ValidationAttribute>(); 20 21 int empty = 2; 22 object pom = prop.GetValue(instance); 23 if (pom != null) 24 { 25 object typek = pom.GetType(); 26 if (pom.GetType().Name == "Int32") 27 { 28 empty = Convert.ToInt32(pom); 29 } 30 } 31 foreach (ValidationAttribute attribute in attributes) { 32 if (!attribute.IsValid(prop.GetValue(instance)) || empty == 0) { 33 errors.Add(new ErrorInfo(prop.Name, attribute.FormatErrorMessage(string.Empty), instance)); 34 } 35 } 36 } 37 return errors; 38 /* return from prop in TypeDescriptor.GetProperties(instance).Cast<PropertyDescriptor>() 16 39 from attribute in prop.Attributes.OfType<ValidationAttribute>() 17 40 where !attribute.IsValid(prop.GetValue(instance)) 18 41 select new ErrorInfo(prop.Name, attribute.FormatErrorMessage(string.Empty), instance); 42 */ 19 43 } 20 44 } -
trunk/Wierszowki/Wierszowki.Services/MagazineItemService.cs
r823 r842 33 33 public void Create(MagazineItem magazineItem, string currentUser) 34 34 { 35 35 36 var errors = DataAnnotationsValidationRunner.GetErrors(magazineItem); 36 37 if (errors.Any()) … … 38 39 throw new RulesException(errors); 39 40 } 40 var errors1 = new List<ErrorInfo>();41 errors1 = ShowError(magazineItem);42 if (errors1.Count() > 0) throw new RulesException(errors1.AsEnumerable());43 44 41 var user = _userRepository.FindOne(u => u.Login == currentUser); 45 42 var now = DateTime.Now; … … 52 49 53 50 } 54 55 private List<ErrorInfo> ShowError(MagazineItem magazineItem)56 {57 var errors1 = new List<ErrorInfo>();58 if (magazineItem.IssueId <= 0)59 {60 ErrorInfo e1 = new ErrorInfo("Magazine", "Proszę wybrać gazetę!");61 errors1.Add(e1);62 ErrorInfo e = new ErrorInfo("IssueId", "Proszę wybrać numer wydania!");63 errors1.Add(e);64 }65 return errors1;66 }67 68 51 public void Update(MagazineItem magazineItem, string currentUser) 69 52 { … … 71 54 if (errors.Any()) 72 55 throw new RulesException(errors); 73 74 var errors1 = new List<ErrorInfo>();75 errors1 = ShowError(magazineItem);76 if (errors1.Count() > 0) throw new RulesException(errors1.AsEnumerable());77 78 56 79 57 var user = _userRepository.FindOne(u => u.Login == currentUser); … … 91 69 magazineItemToUpdate.UpdatedBy = user.Id; 92 70 magazineItemToUpdate.UpdatedOn = now; 93 94 71 _repository.Update(magazineItemToUpdate); 95 72 } 96 public voidDelete(MagazineItem magazineItem)73 public MagazineItem Delete(MagazineItem magazineItem) 97 74 { 98 75 var magazineItemToDelete = _repository.FindOne(magazineItem.Id); … … 101 78 _repository.Delete(magazineItemToDelete); 102 79 } 80 return magazineItemToDelete; 103 81 } 104 82 } -
trunk/Wierszowki/Wierszowki.Web/Content/Site.css
r752 r842 92 92 .reportTable, .reportTable td, .reportTable table 93 93 { 94 border:none; 95 } 96 94 border: none; 95 text-align: left; 96 background-color: #F5F5F5; 97 } 97 98 #header 98 99 { … … 230 231 border: 1px solid #CCC; 231 232 } 232 233 select,textarea 234 { 235 width: 200px; 236 } 233 237 /* TABLE 234 238 ----------------------------------------------------------*/ … … 238 242 border: solid 1px #e8eef4; 239 243 border-collapse: collapse; 244 } 245 table select 246 { 247 width: 180px; 240 248 } 241 249 … … 245 253 border: solid 1px #e8eef4; 246 254 text-align: right; 255 vertical-align: top; 247 256 } 248 257 … … 250 259 { 251 260 padding: 6px 5px; 252 text-align: left;261 text-align: center; 253 262 background-color: #e8eef4; 254 263 border: solid 1px #e8eef4; 255 264 } 256 257 265 /* MISC 258 266 ----------------------------------------------------------*/ … … 339 347 { 340 348 width: 100%; 341 border-bottom: solid 1px #ccc; 349 border-bottom: solid 1px #ccc; 342 350 padding: 5px 0 5px 5px; 343 351 } … … 502 510 cursor: default; 503 511 } 512 /*Komunikaty na stronie Error.aspx*/ 513 .error_info 514 { 515 font-size: 14px; 516 font-weight: bold; 517 color: Gray; 518 } 519 .st1 520 { 521 font-size: 16px; 522 font-weight: bold; 523 color: Gray; 524 } 525 .st1 span 526 { 527 font-size: 14px; 528 font-weight: normal; 529 } -
trunk/Wierszowki/Wierszowki.Web/Content/print.css
r752 r842 218 218 border: solid 1px #000; 219 219 text-align: right; 220 vertical-align: top; 220 221 } 221 222 … … 225 226 text-align: left; 226 227 background-color: #fff; 227 border: solid 1px #000; 228 border: solid 1px #000; 229 text-align: center; 228 230 } 229 231 -
trunk/Wierszowki/Wierszowki.Web/Controllers/MagazineController.cs
r752 r842 25 25 magazineId = id.Value; 26 26 27 var issues = _context.FindIssuesByMagazineId(magazineId );27 var issues = _context.FindIssuesByMagazineId(magazineId,0); 28 28 29 29 var selectListItems = new List<SelectListItem> -
trunk/Wierszowki/Wierszowki.Web/Controllers/MagazineItemController.cs
r823 r842 6 6 using Wierszowki.Services; 7 7 using xVal.ServerSide; 8 using System.Collections.Generic; 9 using Wierszowki.Core.Interfaces; 8 10 9 11 namespace Wierszowki.Controllers … … 40 42 try 41 43 { 42 _service.Create(magazineItem, ControllerContext.HttpContext.User.Identity.Name); 44 _service.Create(magazineItem, ControllerContext.HttpContext.User.Identity.Name); 43 45 ModelState.Clear(); 44 46 } … … 47 49 ex.AddModelStateErrors(ModelState, "magazineItem"); 48 50 } 49 51 50 52 if (ModelState.IsValid) 51 53 { 52 return RedirectToAction("Confirm", _context.Authors.Single(a => a.Id == magazineItem.AuthorId)); 54 Info inf = InitInfo("1", 0, 0, 0); 55 var confirmViewData = new ConfirmViewData(); 56 confirmViewData = InitConfirmViewData(_context.Authors.Single(a => a.Id == magazineItem.AuthorId), OperationType.Create, inf); 57 return View("Confirm", confirmViewData); 53 58 } 54 59 var viewData = InitMagazineItemViewData(); 55 60 viewData.MagazineItem = magazineItem; 56 57 return View(viewData); 61 62 return View(viewData); 58 63 } 59 64 … … 65 70 66 71 [Authorize] 67 public ActionResult Edit(int id) 68 { 69 var viewData = InitMagazineItemViewData(); 70 var magazineItem = _service.Find(id); 72 public ActionResult Edit(string id, string powrot, string month, string year, string user_id) 73 { 74 int id1 = 0; 75 int month1 = (month != null) ? Convert.ToInt32(month) : 0; 76 int year1 = (year != null) ? Convert.ToInt32(year) : 0; 77 int user1 = (user_id != null) ? Convert.ToInt32(user_id) : 0; 78 try 79 { 80 id1 = (id != null) ? Convert.ToInt32(id) : 0; 81 } 82 catch 83 { 84 } 85 var viewData = InitMagazineItemViewData(); 86 var magazineItem = _service.Find(id1); 71 87 72 88 if (magazineItem == null) 73 89 { 74 ViewData["message"] = "null"; 75 return View("Confirm"); 76 } 77 90 Info inf = InitInfo(powrot, month1, year1, user1); 91 var confirmViewData = new ConfirmViewData(); 92 93 if (id != "") //nie znaleziono w bazie wierszowki o zadanym id 94 { 95 confirmViewData = InitConfirmViewData(null, OperationType.WrongId, inf); 96 } 97 else //nie podano numeru id 98 { 99 confirmViewData = InitConfirmViewData(null, OperationType.NullId, null); 100 } 101 return View("Confirm", confirmViewData); 102 } 78 103 viewData.MagazineItem = magazineItem; 79 104 viewData.Magazine = magazineItem.Issue.Magazine; 80 105 viewData.Issue = magazineItem.Issue; 81 viewData.IssueList = new SelectList(_context.FindIssuesByMagazineItemId(magazineItem.Issue.Id), "Id", "Number"); 106 viewData.Info = InitInfo(powrot, month1, year1, user1); 107 108 var startDate = DateTime.Now.AddMonths(-3); 109 var endDate = DateTime.Now.AddMonths(1); 110 var issueList = _context.GetIssue().Where(i => i.Date >= startDate && i.Date <= endDate && i.MagazineId == magazineItem.Issue.MagazineId).OrderBy(i => i.Date).ToList(); 111 112 int start_number = issueList[0].Number; 113 int AddId = 0; 114 if (magazineItem.Issue.Number < start_number) 115 { 116 viewData.SmallerMagazineNumber = 1; 117 AddId = magazineItem.Issue.Id; 118 } 119 viewData.IssueList = new SelectList(_context.FindIssuesByMagazineItemId(magazineItem.Issue.Id, AddId), "Id", "Number"); 82 120 return View(viewData); 83 121 } 84 122 [Authorize] 85 123 [AcceptVerbs(HttpVerbs.Post)] 86 public ActionResult Update(MagazineItem magazineItem) 87 { 88 try 89 { 90 //var service = new MagazineItemService(); 124 public ActionResult Update(MagazineItem magazineItem, Info info) 125 { 126 try 127 { 91 128 _service.Update(magazineItem, ControllerContext.HttpContext.User.Identity.Name); 92 129 ModelState.Clear(); … … 99 136 if (ModelState.IsValid) 100 137 { 101 var author = _context.Authors.Single(a => a.Id == magazineItem.AuthorId); 102 return RedirectToAction("Confirm", author); 103 } 104 var viewData = InitMagazineItemViewData(); 105 viewData.MagazineItem = magazineItem; 106 return View(viewData); 107 } 108 138 var confirmViewData = new ConfirmViewData(); 139 confirmViewData = InitConfirmViewData(_context.Authors.Single(a => a.Id == magazineItem.AuthorId), OperationType.Update, info); 140 return View("Confirm", confirmViewData); 141 } 142 var magazine = _service.Find(magazineItem.Id); 143 var viewData = InitMagazineItemViewData(); 144 viewData.Info = info;//InitInfo(info.powrot, info.month, info.year, info.user_id); 145 viewData.MagazineItem = magazine; 146 return View("Edit", viewData); 147 } 148 private Info InitInfo(string p, int m, int y, int u) 149 { 150 Info inf = new Info(); 151 inf.powrot = p; 152 inf.month = m; 153 inf.year = y; 154 inf.user_id = u; 155 return inf; 156 } 109 157 private MagazineItemViewData InitMagazineItemViewData() 110 158 { 111 159 var viewData = new MagazineItemViewData 112 { 113 MagazineItem = new MagazineItem(), 114 AuthorList = new SelectList(_context.Authors.ToList(), "Id", "FullName"), 115 MagazineList = new SelectList(_context.Magazines.ToList(), "Id", "NickName"), 116 IssueList = new SelectList(_context.FindIssuesByMagazineId(0), "Id", "Name"), 117 ItemTypeList = new SelectList(_context.ItemTypes.ToList(), "Id", "Name") 118 }; 160 { 161 MagazineItem = new MagazineItem(), 162 AuthorList = new SelectList(_context.Authors.OrderBy(a => a.LastName).ToList(), "Id", "FullName"), 163 MagazineList = new SelectList(_context.Magazines.ToList(), "Id", "NickName"), 164 IssueList = new SelectList(_context.FindIssuesByMagazineId(0, 0), "Id", "Name"), 165 ItemTypeList = new SelectList(_context.ItemTypes.ToList(), "Id", "Name"), 166 SmallerMagazineNumber = 0, 167 Info = new Info() 168 }; 119 169 return viewData; 120 170 } 121 171 [Authorize] 122 public ActionResult Delete(int id) 123 { 124 return View("Delete"); 172 public ActionResult Delete(string id, string powrot, string month, string year, string user_id) 173 { 174 int id1 = 0; 175 try 176 { 177 id1 = (id != null) ? Convert.ToInt32(id) : 0; 178 } 179 catch 180 { 181 } 182 var deleteViewData = new DeleteViewData(); 183 int month1 = (month != null) ? Convert.ToInt32(month) : 0; 184 int year1 = (year != null) ? Convert.ToInt32(year) : 0; 185 int user1 = (user_id != null) ? Convert.ToInt32(user_id) : 0; 186 deleteViewData.Info = InitInfo(powrot, month1, year1, user1); 187 return View("Delete", deleteViewData); 125 188 } 126 189 [Authorize] 127 190 [AcceptVerbs(HttpVerbs.Post)] 128 public ActionResult Delete(MagazineItem magazineItem) 129 { 130 _service.Delete(magazineItem); 131 if (magazineItem.AuthorId == 0){ 132 ViewData["message"] = "null"; 133 return View("Confirm"); 134 } 135 ViewData["message"] = "delete"; 136 return View("Confirm"); 137 191 public ActionResult Delete(MagazineItem magazineItem, Info info) 192 { 193 var magazineItemToDelete = _service.Delete(magazineItem); 194 var confirmViewData = new ConfirmViewData(); 195 if (magazineItemToDelete == null) 196 { 197 confirmViewData = InitConfirmViewData(null, OperationType.WrongId, info); 198 } 199 else 200 { 201 confirmViewData = InitConfirmViewData(magazineItemToDelete.Author, OperationType.Delete, info); 202 } 203 return View("Confirm", confirmViewData); 204 } 205 private ConfirmViewData InitConfirmViewData(Author author, OperationType c_type, Info inf) 206 { 207 var viewData = new ConfirmViewData 208 { 209 Author = author, 210 akcja = c_type, 211 info = inf 212 }; 213 return viewData; 138 214 } 139 215 } -
trunk/Wierszowki/Wierszowki.Web/Controllers/ReportController.cs
r823 r842 8 8 using Wierszowki.Core.Linq; 9 9 using Wierszowki.Models; 10 using System.Globalization; 10 11 11 12 namespace Wierszowki.Controllers … … 35 36 36 37 var viewData = new ReportViewData 37 {38 Authors = _context.GetAuthors().OrderBy(a => a.FullName).ToList(),39 EmploymentTypeList = new SelectList(_context.GetEmploymentTypes().ToList(),"Id","Name"),40 UserList = new SelectList(_context.GetUsers().OrderBy(u => u.FirstName).ToList(),"Id","FullName")41 };38 { 39 Authors = _context.GetAuthors().OrderBy(a => a.FullName).ToList(), 40 EmploymentTypeList = new SelectList(_context.GetEmploymentTypes().ToList(),"Id","Name"), 41 UserList = new SelectList(_context.GetUsers().OrderBy(u => u.FullName).ToList(),"Id","FullName") 42 }; 42 43 return View(viewData); 43 44 } … … 45 46 public ActionResult All(int year, int month, int user) 46 47 { 47 var items = _repository.Find(m => m.Date.Month == month && m.Date.Year == year && m.CreatedBy == user) 48 var allViewData = new AllViewData(); 49 string error = ""; 50 string naglowek = ""; 51 52 if (user <= 0) 53 { 54 error = "Nie mo¿na wywietliæ wierszówek. Spróbuj jeszcze raz. "; 55 allViewData = InitAllViewData("", error, null, null); 56 return View("Error",allViewData); 57 } 58 var name = ""; 59 var items = new List<MagazineItem>(); 60 if (user > 0) 61 { 62 var u = _context.GetUserById(user); 63 if (u != null) 64 { 65 name = u.FullName; 66 items = _repository.Find(m => m.Date.Month == month && m.Date.Year == year && m.CreatedBy == user) 48 67 .OrderByDescending(m => m.UpdatedOn).ToList(); 49 return View(items); 68 69 if (items.Count <= 0) 70 { 71 error = "Brak wierszówek dla tego u¿ytkownika."; 72 allViewData = InitAllViewData("", error, null, null); 73 return View("Error", allViewData); 74 } 75 } 76 else 77 { 78 //U¿ytkownik bo taki nie istnieje 79 error = "Nie mo¿na wyswietliæ wierszówek, gdy¿ u¿ytkownik nie istnieje. "; 80 allViewData = InitAllViewData("", error, null, null); 81 return View("Error", allViewData); 82 } 83 DateTime dat = new DateTime(1, 1, 1); 84 dat = dat.AddYears(year-1); 85 dat = dat.AddMonths(month-1); 86 87 naglowek = "<div class='st1'>Wierszówki z " + dat.ToString("MM/yyyy", CultureInfo.CreateSpecificCulture("en-US")) + "</div>"; 88 if ( name != "") 89 { 90 naglowek += "<div class='st1'>Wprowadzaj¹cy: <span>" + name + "</span></div>"; 91 } 92 } 93 Info inf = new Info(); 94 inf.powrot = "2"; 95 inf.month = month; 96 inf.year = year; 97 inf.user_id = user; 98 99 allViewData = InitAllViewData(naglowek, error, inf, items); 100 return View("All", allViewData); 50 101 } 51 102 52 103 public ActionResult ToPrice() 53 104 { 105 string naglowek = "Wierszówki do wyceny"; 106 string error = ""; 107 var allViewData = new AllViewData(); 108 Info inf = new Info(); 109 inf.powrot = "1"; 54 110 var items = _repository.Find(m => m.Price <= 0).ToList(); 55 return View("All", items); 111 if ( items.Count <= 0 ) 112 { 113 error = "Brak wierszówek do wyceny."; 114 allViewData = InitAllViewData(naglowek, error, null, null); 115 return View("Error", allViewData); 116 } 117 allViewData = InitAllViewData(naglowek, "", inf, items); 118 return View("All", allViewData); 56 119 } 57 120 … … 69 132 70 133 var viewData = new AuthorCardViewData 71 {72 FullName = magazineItems[0].Author.FullName,73 Date = magazineItems[0].Date,74 MagazineItems = new Dictionary<string, List<MagazineItem>>()75 };134 { 135 FullName = magazineItems[0].Author.FullName, 136 Date = magazineItems[0].Date, 137 MagazineItems = new Dictionary<string, List<MagazineItem>>() 138 }; 76 139 foreach (var magazineItem in magazineItems) 77 140 { … … 123 186 return View("AuthorsByMagazines", viewData); 124 187 } 188 private AllViewData InitAllViewData(string str, string er, Info inf, List<MagazineItem> list) 189 { 190 var viewData = new AllViewData 191 { 192 naglowek = str, 193 error = er, 194 info = inf, 195 magazine = list 196 }; 197 return viewData; 198 } 125 199 } 126 200 } -
trunk/Wierszowki/Wierszowki.Web/Controllers/UserController.cs
r823 r842 1 using System; 1 2 using System.Linq; 2 3 using System.Web.Mvc; … … 6 7 using Wierszowki.Services.Interfaces; 7 8 using xVal.ServerSide; 9 using Wierszowki.Models; 10 using System.Collections.Generic; 8 11 9 12 namespace Wierszowki.Controllers … … 52 55 53 56 if (ModelState.IsValid) 54 return View("Confirm", user); 55 57 { 58 var userConfirmViewData = new UserConfirmViewData(); 59 userConfirmViewData = InitUserConfirmViewData("Potwierdzenie dodania u¿ytkownika", "", OperationType.Create, user); 60 return View("Confirm", userConfirmViewData); 61 } 56 62 return View(user); 57 63 } … … 62 68 return View(user); 63 69 } 70 64 71 [Authorize] 65 72 [AcceptVerbs(HttpVerbs.Get)] … … 67 74 { 68 75 User user = _service.Find(id); 76 string errorInfo = ""; 69 77 if (user != null) 70 78 { … … 77 85 else 78 86 { 79 ViewData["message"] = "error_user"; 80 return View("Confirm"); 87 var userConfirmViewData = new UserConfirmViewData(); 88 errorInfo = "Nie mo¿na edytowaæ u¿ytkownika, gdy¿ login ró¿ni siê od zalogowanego!!!"; 89 userConfirmViewData = InitUserConfirmViewData("Edycja u¿ytkownika", errorInfo, OperationType.ErrorLogin, null); 90 return View("Confirm", userConfirmViewData); 81 91 } 82 83 92 } 84 ViewData["message"] = "error"; 85 return View("Confirm"); 93 var userConfirmViewData1 = new UserConfirmViewData(); 94 errorInfo = "Nie mo¿na edytowaæ u¿ytkownika, gdy¿ u¿ytkownik o takim id nie istnieje !!!"; 95 userConfirmViewData1 = InitUserConfirmViewData("Edycja u¿ytkownika", errorInfo, OperationType.ErrorUser, null); 96 return View("Confirm", userConfirmViewData1); 86 97 } 87 98 … … 101 112 102 113 if (ModelState.IsValid) 103 return View("Confirm", user); 104 105 114 { 115 var userConfirmViewData = new UserConfirmViewData(); 116 userConfirmViewData = InitUserConfirmViewData("Potwierdzenie edycji u¿ytkownika", "", OperationType.Update, user); 117 return View("Confirm", userConfirmViewData); 118 } 106 119 return View(user); 120 } 121 private UserConfirmViewData InitUserConfirmViewData(string naglowek, string error, OperationType u_type, User user) 122 { 123 var viewData = new UserConfirmViewData 124 { 125 Naglowek = naglowek, 126 ErrorInfo= error, 127 Akcja = u_type, 128 User = user 129 }; 130 return viewData; 107 131 } 108 132 } -
trunk/Wierszowki/Wierszowki.Web/Helpers/SelectExtension.cs
r752 r842 33 33 return sb.ToString(); 34 34 } 35 35 36 } 36 37 } -
trunk/Wierszowki/Wierszowki.Web/Models/MagazineItemViewData.cs
r752 r842 17 17 public SelectList IssueList { get; set; } 18 18 public SelectList ItemTypeList { get; set; } 19 public int SmallerMagazineNumber { get; set; } 20 public Info Info { get; set; } 19 21 } 20 22 } -
trunk/Wierszowki/Wierszowki.Web/Views/Author/Index.aspx
r752 r842 45 45 46 46 <p> 47 <%= Html.ActionLink("Dodaj autora", "Create") %>47 <%=Html.ActionLink("Powrót", "Index", "Home") %> | <%= Html.ActionLink("Dodaj autora", "Create") %> 48 48 </p> 49 <p> 50 <%=Html.ActionLink("Powrót", "Index", "Home") %> 51 </p> 52 49 53 50 </asp:Content> -
trunk/Wierszowki/Wierszowki.Web/Views/MagazineItem/Confirm.aspx
r823 r842 1 <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Wierszowki. Core.Linq.Author>" %>2 1 <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Wierszowki.Models.ConfirmViewData>" %> 2 <%@ Import Namespace ="Wierszowki.Models" %> 3 3 <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> 4 4 Potwierdzenie dodania wierszówki … … 6 6 <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> 7 7 <% 8 if (ViewData ["message"] == "delete")8 if (ViewData.Model.akcja == OperationType.Delete) 9 9 { 10 10 %> 11 <h4>Pomylnie usuniêto wierszówkê!</h4> 12 <% 13 } 14 else if(ViewData["message"] == "null"){ 15 %> 16 <h6>Nie mo¿na wykonaæ operacji. B³êdny numer id!!! </h6> 11 <h2>Pomylnie usuniêto wierszówkê!</h2> 17 12 <% } 18 else 13 else if (ViewData.Model.akcja == OperationType.WrongId) 19 14 { 20 15 %> 21 <h2>Pomylnie dodano/zaktualizowano wierszówkê dla: <%= Html.Encode(ViewData.Model.FirstName + " " + ViewData.Model.LastName)%></h2> 16 <h2>Nie mo¿na wykonaæ operacji. B³êdny numer id!!! </h2> 17 <% } 18 else if (ViewData.Model.akcja == OperationType.NullId) 19 { 20 %> 21 <h2>Nie mo¿na wykonaæ operacji, gdy¿ nie podano numeru id wierszówki!!! </h2> 22 <% } 23 else if (ViewData.Model.akcja == OperationType.Update) 24 { 25 %> 26 <h2>Pomylnie zaktualizowano wierszówkê dla: <%= Html.Encode(ViewData.Model.Author.FirstName + " " + ViewData.Model.Author.LastName)%></h2> 22 27 <% 23 28 } 29 else if (ViewData.Model.akcja == OperationType.Create) 30 { 24 31 %> 25 <div> 26 <%=Html.ActionLink("Powrót", "Index", "Report") %> 32 <h2>Pomylnie dodano wierszówkê dla: <%= Html.Encode(ViewData.Model.Author.FirstName + " " + ViewData.Model.Author.LastName)%></h2> 33 <% 34 } 35 36 %> 37 <div> 38 <% 39 if (ViewData.Model.info != null) 40 { 41 if (ViewData.Model.info.powrot == "2" && (ViewData.Model.akcja == OperationType.Delete || ViewData.Model.akcja == OperationType.Update)) 42 { 43 var sciezka = "All/" + ViewData.Model.info.year + "/" + ViewData.Model.info.month + "/" + ViewData.Model.info.user_id; 44 %> 45 <%=Html.ActionLink("Powrót", sciezka, "Report")%> | 46 <%=Html.ActionLink("Raporty", "Index", "Report")%> 47 <% 48 } 49 else if (ViewData.Model.info.powrot == "1" && (ViewData.Model.akcja == OperationType.Delete || ViewData.Model.akcja == OperationType.Update)) 50 { 51 %> 52 <%=Html.ActionLink("Powrót", "ToPrice", "Report")%> | 53 <%=Html.ActionLink("Strona G³ówna", "Index", "Home")%> 54 <% 55 } 56 } 57 if (ViewData.Model.akcja == OperationType.Create) 58 { 59 %> 60 <%=Html.ActionLink("Powrót", "Index", "Home")%> | 61 <%=Html.ActionLink("Dodaj now¹ wierszówkê", "Create", "MagazineItem")%> 62 <% 63 } 64 else if (ViewData.Model.akcja == OperationType.WrongId || ViewData.Model.akcja == OperationType.NullId) 65 { 66 %> 67 <%=Html.ActionLink("Strona G³ówna", "Index", "Home")%> 68 <% 69 } 70 %> 27 71 </div> 28 72 </asp:Content> -
trunk/Wierszowki/Wierszowki.Web/Views/MagazineItem/Create.aspx
r785 r842 1 1 <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Wierszowki.Models.MagazineItemViewData>" %> 2 2 <%@ Import namespace="Wierszowki.Core.Validation"%> 3 3 <asp:Content ID="js" ContentPlaceHolderID="jsContent" runat="server"> 4 4 <script src="../../Scripts/jquery-1.3.1.js" type="text/javascript"></script> … … 10 10 <script src="../../Scripts/spiffy.js" type="text/javascript"></script> 11 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> 12 14 </asp:Content> 13 15 … … 17 19 18 20 <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> 19 <script type="text/javascript"> 20 $(function() { 21 $("#Magazine").change(function() { 22 var magazineId = $("#Magazine > option:selected").attr("value"); 23 var urlAction = "<%= Url.Action("FindIssuesById", "Magazine") %>"; 24 urlAction = urlAction + "/" + magazineId; 25 $.getJSON(urlAction, function(data) { 26 $("#MagazineItem_IssueId").addItems(data); 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" 27 34 }); 28 }); 29 }); 30 </script> 31 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> 32 82 <h2>Dodaj wierszówkê</h2> 33 <%= Html.ValidationSummary("Proszê poprawiæ b³êdy i spróbowaæ ponownie.") %> 34 35 <div> 36 <div id="messages"></div> 37 <% using (Html.BeginForm("Create", "MagazineItem", Model.MagazineItem)) 38 { %> 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 %> 39 87 <fieldset> 40 88 <legend>Nowa wierszówka</legend> 41 89 <div class="formitem"> 42 90 <label for="MagazineItem.AuthorId">Autor:</label> 43 <%= Html.DropDownList("MagazineItem.AuthorId", ViewData.Model.AuthorList, "-- proszê wybraæ --")%> 44 <%= Html.ValidationMessage("MagazineItem.AuthorId", "*")%> 91 <%= Html.DropDownList("AuthorId", ViewData.Model.AuthorList, "-- proszê wybraæ --")%> 92 <%= Html.ValidationMessage("AuthorId", "*")%> 93 <br /> 45 94 </div> 46 95 <div class="formitem"> … … 48 97 <%= Html.DropDownList("Magazine", ViewData.Model.MagazineList, "-- proszê wybraæ --")%> 49 98 <%= Html.ValidationMessage("Magazine", "*")%> 99 <br /> 50 100 </div> 51 101 <div class="formitem"> 52 102 <label for="MagazineItem.IssueId">Wydanie:</label> 53 <%= Html.DropDownList("MagazineItem.IssueId", ViewData.Model.IssueList, "-- proszê wybraæ --")%> 54 <%= Html.ValidationMessage("MagazineItem.IssueId", "*")%> 103 <%= Html.DropDownList("IssueId", ViewData.Model.IssueList, "-- proszê wybraæ --")%> 104 <%= Html.ValidationMessage("IssueId", "*")%> 105 <br /> 55 106 </div> 56 107 <div class="formitem"> 57 108 <label for="MagazineItem.ItemTypeId">Typ:</label> 58 <%= Html.DropDownList("MagazineItem.ItemTypeId", ViewData.Model.ItemTypeList, "-- proszê wybraæ --")%> 59 <%= Html.ValidationMessage("MagazineItem.ItemTypeId", "*")%> 109 <%= Html.DropDownList("ItemTypeId", ViewData.Model.ItemTypeList, "-- proszê wybraæ --")%> 110 <%= Html.ValidationMessage("ItemTypeId", "*")%> 111 <br /> 60 112 </div> 61 113 <div class="formitem"> 62 114 <label for="MagazineItem.Date">Miesi¹c:</label> 63 <%= Html.TextBox("MagazineItem.Date", Model.MagazineItem.Date, new { Class = "date-pick" })%> 64 <%= Html.ValidationMessage("MagazineItem.Date", "*")%> 115 <%= Html.TextBox("Date", ViewData.Model.MagazineItem.Date, new { Class = "date-pick" })%> 116 <%= Html.ValidationMessage("Date", "*")%> 117 <br /> 65 118 </div> 66 119 67 120 <div class="formitem"> 68 121 <label for="MagazineItem.Caption">Tytu³:</label> 69 <%= Html.TextBox("MagazineItem.Caption", Model.MagazineItem.Caption, new { title = "Proszê wprowadziæ tytu³ artyku³u." })%> 70 <%= Html.ValidationMessage("MagazineItem.Caption", "*")%> 122 <%= Html.TextBox("Caption", ViewData.Model.MagazineItem.Caption, new { title = "Proszê wprowadziæ tytu³ artyku³u." })%> 123 <%= Html.ValidationMessage("Caption", "*")%> 124 <br /> 71 125 </div> 72 126 <div class="formitem"> 73 127 <label for="MagazineItem.Description">Opis:</label> 74 <%= Html.TextArea("MagazineItem.Description", Model.MagazineItem.Description, new { title = "Proszê wprowadziæ opis artyku³u." })%> 128 <%= Html.TextArea("Description", ViewData.Model.MagazineItem.Description, new { title = "Proszê wprowadziæ opis artyku³u." })%> 129 <br /> 75 130 </div> 76 131 <div class="formitem"> 77 132 <label for="MagazineItem.Price">Wycena:</label> 78 <%= Html.TextBox("MagazineItem.Price", Model.MagazineItem.Price.ToString("#0.00"), new { title = "Proszê wprowadziæ wycenê artyku³u." })%> 79 <%= Html.ValidationMessage("MagazineItem.Price", "*")%> 133 <%= Html.TextBox("Price", ViewData.Model.MagazineItem.Price)%> 134 <%= Html.ValidationMessage("Price", "*")%> 135 <br /> 80 136 </div> 81 137 <div class="formitem"> 82 138 <label for="MagazineItem.Bonus">Bonus:</label> 83 <%= Html.TextBox("MagazineItem.Bonus", Model.MagazineItem.Bonus.ToString("#0.00"), new { title = "Proszê wprowadziæ bonus do wyceny artyku³u." })%> 84 <%= Html.ValidationMessage("MagazineItem.Bonus", "*")%> 139 <%= Html.TextBox("Bonus", ViewData.Model.MagazineItem.Bonus)%> 140 <%= Html.ValidationMessage("Bonus", "*")%> 141 <br /> 85 142 </div> 86 <div class="submit">87 <input type="submit" value="Dodaj" />143 <div> 144 <input type="submit" value="Dodaj" name="dodaj" id="dodaj"/> 88 145 </div> 89 146 </fieldset> 90 <% }%>147 <% Html.EndForm();%> 91 148 </div> 92 149 <div> 93 150 <%=Html.ActionLink("Powrót", "Index", "Home") %> 151 <%=Html.ClientSideValidation<MagazineItemValidation>("MagazineItem")%> 94 152 </div> 95 153 </asp:Content> -
trunk/Wierszowki/Wierszowki.Web/Views/MagazineItem/Delete.aspx
r823 r842 1 <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Wierszowki.Models. MagazineItemViewData>" %>1 <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Wierszowki.Models.DeleteViewData>" %> 2 2 3 3 <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> … … 6 6 7 7 <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> 8 9 <% using (Html.BeginForm("Delete","MagazineItem")) 8 <% 9 RouteValueDictionary routeValues = ViewContext.RouteData.Values; 10 routeValues.Add("powrot", Model.Info.powrot); 11 routeValues.Add("month", Model.Info.month); 12 routeValues.Add("year", Model.Info.year); 13 routeValues.Add("user_id", Model.Info.user_id); 14 15 16 17 using (Html.BeginForm("Delete","MagazineItem", routeValues,FormMethod.Post)) 10 18 { %> 11 19 <h2>Czy napewno chcesz usun¹æ wierszówkê??? </h2> … … 13 21 <input type="submit" value="Usuñ" /> 14 22 </div> 15 <br /> 16 <% } %>17 <div>18 < %=Html.ActionLink("Powrót", "Index", "Home") %>19 </div>23 <br /> 24 <div> 25 <%=Html.ActionLink("Powrót", "Index", "Report") %> 26 </div> 27 <% } %> 20 28 </asp:Content> 21 29 -
trunk/Wierszowki/Wierszowki.Web/Views/MagazineItem/Edit.aspx
r785 r842 1 1 <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Wierszowki.Models.MagazineItemViewData>" %> 2 2 <%@ Import namespace="Wierszowki.Core.Validation"%> 3 3 <asp:Content ID="js" ContentPlaceHolderID="jsContent" runat="server"> 4 4 <script src="../../Scripts/jquery-1.3.1.js" type="text/javascript"></script> … … 10 10 <script src="../../Scripts/spiffy.js" type="text/javascript"></script> 11 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> 12 14 </asp:Content> 13 15 14 16 <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> 15 Dodaj wierszówkê17 Edytuj wierszówkê 16 18 </asp:Content> 17 19 18 20 <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> 19 <script type="text/javascript"> 20 $(function() { 21 $("#Magazine_Id").change(function() { 22 var magazineId = $("#Magazine_Id > option:selected").attr("value"); 23 var urlAction = "<%= Url.Action("FindIssuesById", "Magazine") %>"; 24 urlAction = urlAction + "/" + magazineId; 25 $.getJSON(urlAction, function(data) { 26 $("#MagazineItem_IssueId").addItems(data); 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 }); 27 30 }); 28 }); 29 }); 30 </script> 31 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> 32 81 <h2>Edytuj wierszówkê</h2> 33 82 <%= Html.ValidationSummary("Proszê poprawiæ b³êdy i spróbowaæ ponownie.") %> … … 35 84 <div> 36 85 <div id="messages"></div> 37 <% using (Html.BeginForm("Update", "MagazineItem", Model.MagazineItem)) 38 { %> 86 <% 87 using (Html.BeginForm("Update", "MagazineItem", FormMethod.Post, new { id = "myform" })) 88 { %> 39 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)%> 40 94 <legend>Dane wierszówki</legend> 41 95 <%= Html.Hidden("MagazineItem.Id", Model.MagazineItem.Id)%> 42 96 <div class="formitem"> 43 97 <label for="MagazineItem.AuthorId">Autor:</label> 44 <%= Html.DropDownList("MagazineItem.AuthorId", ViewData.Model.AuthorList, "-- proszê wybraæ --")%>98 <%= Html.DropDownList("MagazineItem.AuthorId", Model.AuthorList, "-- proszê wybraæ --")%> 45 99 <%= Html.ValidationMessage("MagazineItem.AuthorId", "*")%> 100 <br /> 46 101 </div> 47 102 <div class="formitem"> 48 103 <label for="Magazine">Gazeta:</label> 49 <%= Html.DropDownList("Magazine.Id", ViewData.Model.MagazineList, "-- proszê wybraæ --")%>104 <%= Html.DropDownList("Magazine.Id",Model.MagazineList, "-- proszê wybraæ --")%> 50 105 <%= Html.ValidationMessage("Magazine.Id", "*")%> 51 </div> 106 <br /> 107 </div> 52 108 <div class="formitem"> 53 <label for="MagazineItem.IssueId">Wydanie :</label>54 <%= Html.DropDownList("MagazineItem.IssueId", ViewData.Model.IssueList, "-- proszê wybraæ --")%>109 <label for="MagazineItem.IssueId">Wydanie</label> 110 <%= Html.DropDownList("MagazineItem.IssueId", Model.IssueList, "-- proszê wybraæ --")%> 55 111 <%= Html.ValidationMessage("MagazineItem.IssueId", "*")%> 112 <br /> 56 113 </div> 57 114 <div class="formitem"> 58 115 <label for="MagazineItem.ItemTypeId">Typ:</label> 59 <%= Html.DropDownList("MagazineItem.ItemTypeId", ViewData.Model.ItemTypeList, "-- proszê wybraæ --")%>116 <%= Html.DropDownList("MagazineItem.ItemTypeId", Model.ItemTypeList, "-- proszê wybraæ --")%> 60 117 <%= Html.ValidationMessage("MagazineItem.ItemTypeId", "*")%> 118 <br /> 61 119 </div> 62 120 <div class="formitem"> … … 64 122 <%= Html.TextBox("MagazineItem.Date", Model.MagazineItem.Date, new { Class = "date-pick" })%> 65 123 <%= Html.ValidationMessage("MagazineItem.Date", "*")%> 66 </div>67 124 <br /> 125 </div> 68 126 <div class="formitem"> 69 127 <label for="MagazineItem.Caption">Tytu³:</label> 70 <%= Html.TextBox("MagazineItem.Caption", Model.MagazineItem.Caption , new { title = "Proszê wprowadziæ tytu³ artyku³u." })%>128 <%= Html.TextBox("MagazineItem.Caption", Model.MagazineItem.Caption )%> 71 129 <%= Html.ValidationMessage("MagazineItem.Caption", "*")%> 130 <br /> 72 131 </div> 73 132 <div class="formitem"> 74 133 <label for="MagazineItem.Description">Opis:</label> 75 <%= Html.TextArea("MagazineItem.Description", Model.MagazineItem.Description, new { title = "Proszê wprowadziæ opis artyku³u." })%> 134 <%= Html.TextArea("MagazineItem.Description", Model.MagazineItem.Description )%> 135 <%= Html.ValidationMessage("MagazineItem.Description", "*")%> 136 <br /> 76 137 </div> 77 138 <div class="formitem"> 78 139 <label for="MagazineItem.Price">Wycena:</label> 79 <%= Html.TextBox("MagazineItem.Price", Model.MagazineItem.Price.ToString("#0.00") , new { title = "Proszê wprowadziæ wycenê artyku³u." })%>140 <%= Html.TextBox("MagazineItem.Price", Model.MagazineItem.Price.ToString("#0.00"))%> 80 141 <%= Html.ValidationMessage("MagazineItem.Price", "*")%> 142 <br /> 81 143 </div> 82 144 <div class="formitem"> 83 145 <label for="MagazineItem.Bonus">Bonus:</label> 84 <%= Html.TextBox("MagazineItem.Bonus", Model.MagazineItem.Bonus.ToString("#0.00") , new { title = "Proszê wprowadziæ bonus do wyceny artyku³u." })%>146 <%= Html.TextBox("MagazineItem.Bonus", Model.MagazineItem.Bonus.ToString("#0.00"))%> 85 147 <%= Html.ValidationMessage("MagazineItem.Bonus", "*")%> 148 <br /> 86 149 </div> 87 150 <div class="submit"> 88 <input type="submit" value="Aktualizuj" />151 <input type="submit" name="edit" value="Aktualizuj" /> 89 152 </div> 90 153 </fieldset> 91 <% } %>154 <% } %> 92 155 </div> 93 156 <div> 94 157 <%=Html.ActionLink("Powrót", "Index", "Home") %> 158 <%=Html.ClientSideValidation<MagazineItemValidation>("MagazineItem")%> 95 159 </div> 96 160 </asp:Content> -
trunk/Wierszowki/Wierszowki.Web/Views/Report/All.aspx
r823 r842 1 <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage< IEnumerable<Wierszowki.Core.Linq.MagazineItem>>" %>1 <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Wierszowki.Models.AllViewData>" %> 2 2 3 3 <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> 4 Wierszówki do wyceny4 Wierszówki 5 5 </asp:Content> 6 6 7 7 <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> 8 <h2>Wierszówki do wyceny</h2> 8 <% if (ViewData.Model.naglowek != null){ %> 9 <h2><%= ViewData.Model.naglowek %></h2> 10 <% } %> 9 11 <table> 10 12 <tr> … … 22 24 <th>Ostatnia aktualizacja</th> 23 25 </tr> 24 25 <% foreach (var item in Model) { %>26 26 27 <% int number = 0; 28 foreach (var item in ViewData.Model.magazine) { 29 number += 1; 30 %> 27 31 <tr> 28 32 <td> 29 <%= Html.ActionLink("Edycja", "Edit", "MagazineItem", new { id=item.Id }, null) %> 33 <% 34 if (ViewData.Model.info.powrot == "1") 35 { 36 %> 37 <%= Html.ActionLink("Edycja", "Edit", "MagazineItem", new { id = item.Id, powrot = "1", month = ViewData.Model.info.month, year = ViewData.Model.info.year, user_id = ViewData.Model.info.user_id }, null)%> 38 <% 39 } 40 else if (ViewData.Model.info.powrot == "2") 41 { 42 %> 43 <%= Html.ActionLink("Edycja", "Edit", "MagazineItem", new { id = item.Id, powrot = "2", month = ViewData.Model.info.month, year = ViewData.Model.info.year, user_id = ViewData.Model.info.user_id }, null)%> 44 <% 45 } 46 %> 30 47 </td> 31 48 <td> 32 <%= Html.ActionLink("Usuñ", "Delete", "MagazineItem", new { id=item.Id }, null) %> 49 <% 50 if (ViewData.Model.info.powrot == "1") 51 { 52 %> 53 <%= Html.ActionLink("Usuñ", "Delete", "MagazineItem", new { id = item.Id, powrot="1", month = ViewData.Model.info.month, year = ViewData.Model.info.year, user_id = ViewData.Model.info.user_id }, null)%> 54 <% 55 } 56 else if (ViewData.Model.info.powrot == "2") 57 { 58 %> 59 <%= Html.ActionLink("Usuñ", "Delete", "MagazineItem", new { id = item.Id, powrot="2", month = ViewData.Model.info.month, year = ViewData.Model.info.year, user_id = ViewData.Model.info.user_id }, null)%> 60 <% 61 } 62 %> 33 63 </td> 34 64 <td> 35 65 <%= Html.Encode(item.Date.ToString("yyyy-MM")) %> 36 66 </td> 37 <td >67 <td width="85px"> 38 68 <%= Html.Encode(item.Author.FullName) %> 39 69 </td> 40 <td >70 <td width="62px"> 41 71 <%= Html.Encode(item.Issue.Identifier)%> 42 72 </td> 43 <td >73 <td width="48px"> 44 74 <%= Html.Encode(item.ItemType.Name) %> 45 75 </td> 46 <td >76 <td width="150px"> 47 77 <%= Html.Encode(item.Caption) %> 48 78 </td> 49 <td >79 <td width="140px"> 50 80 <%= Html.Encode(item.Description) %> 51 81 </td> … … 59 89 <%= Html.Encode(item.CreatedByUser.Login) %> 60 90 </td> 61 <td >91 <td width="140px"> 62 92 <%= Html.Encode(item.UpdatedOn) %> 63 93 </td> … … 68 98 </table> 69 99 <p> 70 <%= Html.ActionLink("Powrót", "Index", "Report") %> 100 <% 101 if (ViewData.Model.info.powrot == "1") 102 { 103 %> 104 <%= Html.ActionLink("Powrót", "Index", "Home")%> | 105 <% 106 } 107 else 108 { 109 %> 110 <%= Html.ActionLink("Powrót", "Index", "Report")%> | 111 <% 112 } 113 %> 114 Liczba wierszówek: <%=number%> 71 115 </p> 72 116 -
trunk/Wierszowki/Wierszowki.Web/Views/Report/Authors.aspx
r752 r842 26 26 <tr> 27 27 <td> 28 <%= Html.Encode(item.FirstName + " " + item.LastName)%> 28 <%= Html.Encode(item.FirstName + " " + item.LastName)%> 29 29 </td> 30 30 <td> … … 35 35 </td> 36 36 <td> 37 <%= Html.Encode(String.Format("{0:F}", item.Total)) %>37 <%= Html.Encode(String.Format("{0:F}", item.Total))%> 38 38 </td> 39 39 </tr> -
trunk/Wierszowki/Wierszowki.Web/Views/Report/Index.aspx
r823 r842 9 9 <h2>Raporty</h2> 10 10 <h3>Proszê wybraæ raport:</h3> 11 <table class="reportTable" >11 <table class="reportTable" cellpadding=4 cellspacing=4> 12 12 <tr> 13 13 <td style="text-align:left; vertical-align:top;"> … … 176 176 </tr> 177 177 </table> 178 <%= Html.ActionLink("Strona g³ówna", "Index", "Home")%> 178 179 </asp:Content> -
trunk/Wierszowki/Wierszowki.Web/Views/Shared/Error.aspx
r752 r842 1 <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<System.Web.Mvc.HandleErrorInfo>" %>1 <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Wierszowki.Models.AllViewData>" %> 2 2 3 <asp:Content ID="errorTitle" ContentPlaceHolderID="TitleContent" runat="server"> 4 Error 3 <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> 4 Wierszówki 5 </asp:Content> 6 <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> 7 <p class="error_info"><%=ViewData.Model.error %></p> 5 8 </asp:Content> 6 9 7 <asp:Content ID="errorContent" ContentPlaceHolderID="MainContent" runat="server">8 <h2>9 Sorry, an error occurred while processing your request.10 </h2>11 </asp:Content> -
trunk/Wierszowki/Wierszowki.Web/Views/Shared/Site.Master
r752 r842 8 8 <asp:ContentPlaceHolder ID="cssContent" runat="server" /> 9 9 <link href="~/Content/Site.css" rel="stylesheet" type="text/css" /> 10 <link href="~/Content/print.css" media="print" rel="stylesheet" type="text/css" /> 10 <link href="~/Content/print.css" media="print" rel="stylesheet" type="text/css" /> 11 11 </head> 12 12 <body> -
trunk/Wierszowki/Wierszowki.Web/Views/User/Confirm.aspx
r823 r842 1 <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Wierszowki. Core.Linq.User>" %>2 1 <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Wierszowki.Models.UserConfirmViewData>" %> 2 <%@ Import Namespace ="Wierszowki.Models" %> 3 3 <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> 4 Potwierdzenie dodania u¿ytkownika4 <%= Model.Naglowek %> 5 5 </asp:Content> 6 6 7 7 <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> 8 <%if (ViewData["message"] == "error_user") 9 { 10 %> 11 <h4>Nie mo¿na edytowaæ u¿ytkownika, gdy¿ login ró¿ni siê od zalogowanego!!!</h4> 12 <% 13 } 14 else if (ViewData["message"] == "error") 15 { 16 %> 17 <h6>Nie mo¿na edytowaæ u¿ytkownika, gdy¿ u¿ytkownik o takim id nie istnieje !!!</h6> 18 <% 19 } 20 else 21 { 22 %> 23 <h2>Pomylnie dodano/zaktualizowano u¿ytkownika: <%= Html.Encode(ViewData.Model.FirstName + " " + ViewData.Model.LastName) %></h2> 24 <% 25 } 26 %> 8 9 <%if (ViewData.Model.ErrorInfo != "") 10 { 11 %> 12 <p class="error_info"> 13 <%=ViewData.Model.ErrorInfo%> 14 </p> 15 <% 16 } 17 else 18 { 19 if (ViewData.Model.Akcja == OperationType.Update) 20 { 21 %> 22 <h2>Pomylnie zaktualizowano u¿ytkownika: <%= Html.Encode(ViewData.Model.User.FullName)%></h2> 23 <% 24 } 25 else if (ViewData.Model.Akcja == OperationType.Create) 26 { 27 %> 28 <h2>Pomylnie dodano u¿ytkownika: <%= Html.Encode(ViewData.Model.User.FullName)%> %></h2> 29 <% 30 } 31 } 32 %> 27 33 <div> 28 34 <%=Html.ActionLink("Powrót do listy u¿ytkowników", "Index") %> -
trunk/Wierszowki/Wierszowki.Web/Views/User/Index.aspx
r752 r842 45 45 46 46 <p> 47 <%= Html.ActionLink("Dodaj nowego u¿ytkownika", "Create") %> 47 <%= Html.ActionLink("Strona Glówna","Index", "Home") %> | 48 <%= Html.ActionLink("Dodaj nowego u¿ytkownika", "Create") %> 48 49 </p> 49 50 </asp:Content> -
trunk/Wierszowki/Wierszowki.Web/Views/Web.config
r752 r842 22 22 <add assembly="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" /> 23 23 </controls> 24 <namespaces> 25 <!-- leave rest as-is --> 26 <add namespace="xVal.Html"/> 27 </namespaces> 24 28 </pages> 25 29 </system.web> -
trunk/Wierszowki/Wierszowki.Web/Web.config
r752 r842 27 27 providerName="System.Data.SqlClient" /> 28 28 <add name="Wierszowki.Properties.Settings.WierszowkiConnectionString" 29 connectionString="Data Source= sql.ct.com.pl;Initial Catalog=Wierszowki;Persist Security Info=True;User ID=wwwadmin;Password=adm1648;" />29 connectionString="Data Source=10.0.0.30;Initial Catalog=Wierszowki;Persist Security Info=True;User ID=sa;Password=POLzax;" /> 30 30 </connectionStrings> 31 31 <system.web> -
trunk/Wierszowki/Wierszowki.Web/Wierszowki.Web.csproj
r823 r842 74 74 <Compile Include="Controllers\ReportController.cs" /> 75 75 <Compile Include="Helpers\SelectExtension.cs" /> 76 <Compile Include="Models\AllViewData.cs" /> 76 77 <Compile Include="Models\AuthorCardViewData.cs" /> 78 <Compile Include="Models\ConfirmViewData.cs" /> 79 <Compile Include="Models\DeleteViewData.cs" /> 77 80 <Compile Include="Models\FormsAuthenticationService.cs" /> 78 81 <Compile Include="Models\Interfaces\IFormsAuthentication.cs" /> … … 86 89 </Compile> 87 90 <Compile Include="Models\AuthorViewData.cs" /> 91 <Compile Include="Models\UserConfirmViewData.cs" /> 88 92 <Compile Include="Models\MagazineItemViewData.cs" /> 93 <Compile Include="Models\OperationType.cs" /> 89 94 <Compile Include="Models\ReportViewData.cs" /> 90 95 <Compile Include="Properties\AssemblyInfo.cs" /> … … 100 105 <Content Include="Default.aspx" /> 101 106 <Content Include="Global.asax" /> 107 <Content Include="Views\Scripts2\additional-methods.js" /> 108 <Content Include="Views\Scripts2\jquery-1.2.6.js" /> 109 <Content Include="Views\Scripts2\jquery-1.2.6.min.js" /> 110 <Content Include="Views\Scripts2\jquery.validate.js" /> 111 <Content Include="Views\Scripts2\MicrosoftAjax.debug.js" /> 112 <Content Include="Views\Scripts2\MicrosoftAjax.js" /> 113 <Content Include="Views\Scripts2\MicrosoftMvcAjax.debug.js" /> 114 <Content Include="Views\Scripts2\MicrosoftMvcAjax.js" /> 115 <Content Include="Views\Scripts2\xVal.AspNetNative.js" /> 116 <Content Include="Views\Scripts2\xVal.jquery.validate.js" /> 102 117 <Content Include="Scripts\date.js" /> 103 118 <Content Include="Scripts\jHelper.js" /> 119 <Content Include="Scripts\jquery-1.2.6.js" /> 120 <Content Include="Scripts\jquery-1.2.6.min.js" /> 104 121 <Content Include="Scripts\jquery-1.3.1-vsdoc.js" /> 105 122 <Content Include="Scripts\jquery-1.3.1.js" /> … … 109 126 <Content Include="Scripts\jquery.datePicker.js" /> 110 127 <Content Include="Scripts\jquery.form.js" /> 128 <Content Include="Scripts\jquery.validate.js" /> 111 129 <Content Include="Scripts\spiffy.js" /> 130 <Content Include="Scripts\xVal.AspNetNative.js" /> 131 <Content Include="Scripts\xVal.jquery.validate.js" /> 112 132 <Content Include="Views\Account\Login.aspx" /> 113 133 <Content Include="Views\Author\Confirm.aspx" /> … … 118 138 <Content Include="Views\MagazineItem\Delete.aspx" /> 119 139 <Content Include="Views\MagazineItem\Edit.aspx" /> 120 <Content Include="Views\MagazineItem\Create.aspx" />121 140 <Content Include="Views\Report\AuthorCard.aspx" /> 122 141 <Content Include="Views\Report\AuthorCardNotFound.aspx" /> … … 126 145 <Content Include="Views\Report\All.aspx" /> 127 146 <Content Include="Views\Report\Index.aspx" /> 147 <Content Include="Views\Shared\Error.aspx" /> 128 148 <Content Include="Views\User\Confirm.aspx" /> 129 149 <Content Include="Views\User\Create.aspx" /> … … 138 158 <Content Include="Views\Home\About.aspx" /> 139 159 <Content Include="Views\Home\Index.aspx" /> 140 <Content Include="Views\Shared\Error.aspx" />141 160 <Content Include="Views\Shared\LogOnUserControl.ascx" /> 142 161 <Content Include="Views\Shared\Site.Master" />
