public NoteControl(User user, NoteViewModel model) { InitializeComponent(); this.User = user; Model = model; this.DataContext = model; txtNote.SelectionChanged += new RoutedEventHandler(txtNote_SelectionChanged); }
/// <summary> /// NoteBubbleAnimation Constructor. /// </summary> /// <param name="nVM">Linked with the NoteViewModel</param> /// <param name="s">The current SessionViewModel</param> public NoteAnimation(NoteViewModel nVM, SessionViewModel s) : base() { sessionVM = s; noteVM = nVM; SVItem = nVM.SVItem; ParentSV = nVM.ParentSV; NothingAtThisPlace = true; SVItem.ContainerManipulationCompleted += new ContainerManipulationCompletedEventHandler(touchLeave); SVItem.PreviewTouchDown += new EventHandler<TouchEventArgs>(SVItem_PreviewTouchDown); }
public ActionResult Edit(int id) { var uow = UnitOfWorkProvider.GetCurrent(); var notesRepository = new IntKeyedRepository<Note>(uow.Session); var note = notesRepository.Get(id); var noteViewModel = new NoteViewModel() { Id = note.Id, Text = note.Text }; return View(noteViewModel); }
public PartialViewResult AddNote(NoteViewModel viewModel) { if (!ModelState.IsValid) { throw new Exception(); } var note = new Note() { Text = viewModel.Text, Title = viewModel.Title, Date = viewModel.Date, AssetId = viewModel.AssetId }; _noteRepo.Add(note); _noteRepo.SaveChanges(); return PartialView("_Note", viewModel); }
public ActionResult Create(NoteViewModel noteViewModel) { var uow = UnitOfWorkProvider.GetCurrent(); if (ModelState.IsValid) { var note = new Note() { Text = noteViewModel.Text }; var notesRepository = new IntKeyedRepository<Note>(uow.Session); notesRepository.Add(note); return RedirectToAction("Index"); } return RedirectToAction("New"); }
public IActionResult EditNote(int id) { Note note = _context.Notes.Include(x => x.Author).Include(x => x.AcceptedUsersEmails).FirstOrDefault(x => x.Id == id); if (!note.Author.Login.Equals(User.Identity.Name)) { return(RedirectToAction("Denied")); } else { NoteViewModel model = new NoteViewModel(); model.Id = id; model.Title = note.Title; model.Description = note.Description; model.IsForEveryone = note.IsForEveryone; string emails = ""; foreach (Email email in note.AcceptedUsersEmails) { emails += email.EmailAddress + ";"; } model.Emails = emails; return(View(model)); } }
public ActionResult Notes(int id, string mode) { NoteViewModel noteViewModel = new NoteViewModel { PasteNote = _dal.GetPasteNote(id), NoteTags = _dal.GetTagsForNote(id).ToList<Tag>() }; if (noteViewModel.PasteNote == null) return View("NotFound"); if (String.Equals(mode, "Raw", StringComparison.CurrentCultureIgnoreCase)) return View("Raw", noteViewModel.PasteNote); return View("Note", noteViewModel); }
/// <summary> /// Event occured when the NoteBubble finished its move (to the right place) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void moveCenter_Completed(object sender, EventArgs e) { Converter converter = new Converter(); DisplayPreviewGrid(false); noteBubbleVM.SVItem.Center = bubbleCenter; for (int i = 0; i < sessionVM.NotesOnStave.Count && NothingAtThisPlace; i++) { if ((int)((virtualCenter.X - 120.0) / 60.0) == sessionVM.NotesOnStave[i].Note.Position && !sessionVM.NotesOnStave[i].Picked && converter.getOctave(virtualCenter.Y) == sessionVM.NotesOnStave[i].Note.Octave && converter.getPitch(virtualCenter.Y) == sessionVM.NotesOnStave[i].Note.Pitch && ((bubbleDroppedTopStave && sessionVM.Session.StaveTop.Notes.Contains(sessionVM.NotesOnStave[i].Note)) || (!bubbleDroppedTopStave && sessionVM.Session.StaveBottom.Notes.Contains(sessionVM.NotesOnStave[i].Note)))) { if (noteBubbleVM.NoteBubble.Note.Duration == NoteValue.alteration) { NothingAtThisPlace = false; noteVM = sessionVM.NotesOnStave[i]; } else { sessionVM.NotesOnStave[i].Animation.BackToBubbleFormat(true); NothingAtThisPlace = true; } } else NothingAtThisPlace = true; } int positionNote = (int)((virtualCenter.X - 120.0) / 60.0); double betweenStave = (350 - GlobalVariables.ManipulationGrid.ElementAtOrDefault(noteBubbleVM.NoteBubble.Note.Position + 2)) * (sessionVM.SessionSVI.ActualHeight / 1080); bool isUp = (bubbleCenter.Y < betweenStave); if (NothingAtThisPlace) { NoteViewModel noteViewModel = new NoteViewModel(bubbleCenter, noteBubbleVM.NoteBubble.Note, sessionVM.Notes, sessionVM); if (!noteViewModel.Note.Sharp && !noteViewModel.Note.Flat) { if (isUp) { sessionVM.Session.StaveTop.CurrentInstrument.PlayNote(noteViewModel.Note); sessionVM.Session.StaveTop.AddNote(noteViewModel.Note, positionNote); } else { sessionVM.Session.StaveBottom.CurrentInstrument.PlayNote(noteViewModel.Note); sessionVM.Session.StaveBottom.AddNote(noteViewModel.Note, positionNote); } sessionVM.Bubbles.Items.Remove(noteBubbleVM.SVItem); sessionVM.NbgVM.NoteBubbleVMs.Remove(noteBubbleVM); sessionVM.Notes.Items.Add(noteViewModel.SVItem); sessionVM.NotesOnStave.Add(noteViewModel); } } else { //If the NoteBubbleViewModel is a (#) or (b) if (noteBubbleVM.NoteBubble.Note.Sharp || noteBubbleVM.NoteBubble.Note.Flat) { bool changeline = false; if (noteBubbleVM.NoteBubble.Note.Sharp) changeline = noteVM.Note.UpSemiTone(); if (noteBubbleVM.NoteBubble.Note.Flat) changeline = noteVM.Note.DownSemiTone(); double y = converter.getCenterY(isUp, noteVM.Note); if (y < 80) { if (noteBubbleVM.NoteBubble.Note.Sharp) noteVM.Note.DownSemiTone(); if (noteBubbleVM.NoteBubble.Note.Flat) noteVM.Note.UpSemiTone(); canAnimate = true; Animate(); } else { y *= sessionVM.SessionSVI.ActualHeight / 1080.0; sessionVM.NbgVM.NoteBubbleVMs.Remove(noteBubbleVM); sessionVM.Bubbles.Items.Remove(noteBubbleVM.SVItem); sessionVM.Notes.Items.Remove(noteVM.SVItem); sessionVM.NotesOnStave.Remove(noteVM); noteVM = new NoteViewModel(new Point(bubbleCenter.X, y), noteVM.Note, sessionVM.Notes, sessionVM); if (isUp) { sessionVM.Session.StaveTop.RemoveNote(noteVM.Note); sessionVM.Session.StaveTop.CurrentInstrument.PlayNote(noteVM.Note); sessionVM.Session.StaveTop.AddNote(noteVM.Note, positionNote); } else { sessionVM.Session.StaveBottom.RemoveNote(noteVM.Note); sessionVM.Session.StaveBottom.CurrentInstrument.PlayNote(noteVM.Note); sessionVM.Session.StaveBottom.AddNote(noteVM.Note, positionNote); } sessionVM.Notes.Items.Add(noteVM.SVItem); sessionVM.NotesOnStave.Add(noteVM); } } else { canAnimate = true; Animate(); } } }
public Note AddNote(NoteViewModel model) { if (Queryable().Any(x => x.Code.ToLower().Contains(model.Code.ToLower()) && x.Delete == false)) { throw new Exception("Đã tồn tại mã phiếu"); } else { var result = new Note(); var User = _userRepository.Find(HttpContext.Current.User.Identity.GetUserId()) ?? _userRepository.GetAll().FirstOrDefault(); result.User = _userRepository.Find(HttpContext.Current.User.Identity.GetUserId()); result.CreatedDate = DateTime.Now; result.LastModifiedDate = DateTime.Now; result.Noted = model.Noted; result.ProductType = model.ProductType; result.Details = new List <NoteDetail>(); foreach (var item in model.Details) { result.Details.Add(new NoteDetail() { Product = _product.Queryable().Where(p => p.Id == item.ProductId).FirstOrDefault(), Price = item.Price, Quantity = item.Quantity, Unit = _product.Queryable().Where(p => p.Id == item.ProductId).FirstOrDefault().Unit, User = _userRepository.Find(HttpContext.Current.User.Identity.GetUserId()), CreatedDate = DateTime.Now, LastModifiedDate = DateTime.Now, Noted = item.Noted }); } result.Total = model.Details.Sum(x => x.Quantity * x.Price); if (model.SourceId == null) { result.Code = "NK" + DateTime.Now.ToString("yy") + DateTime.Now.ToString("MM") + (Queryable().Where(mi => mi.Source.Id == null && mi.CreatedDate.Month == DateTime.Now.Month && mi.CreatedDate.Year == DateTime.Now.Year).Count() + 1).ToString("D3"); result.Source = null; result.Destination = _warehouse.Queryable().Where(d => d.Id == model.DestinationId).FirstOrDefault(); result.Index = Queryable().Where(de => de.Source.Id == null).Count() + 1; result.MonthIndex = Queryable().Where(mi => mi.Source.Id == null && mi.CreatedDate.Month == DateTime.Now.Month && mi.CreatedDate.Year == DateTime.Now.Year).Count() + 1; } else if (model.DestinationId == null) { result.Code = "XK" + DateTime.Now.ToString("yy") + DateTime.Now.ToString("MM") + (Queryable().Where(mi => mi.Destination.Id == null && mi.CreatedDate.Month == DateTime.Now.Month && mi.CreatedDate.Year == DateTime.Now.Year).Count() + 1).ToString("D3"); result.Source = _warehouse.Queryable().Where(s => s.Id == model.SourceId).FirstOrDefault(); result.Destination = null; result.Index = Queryable().Where(de => de.Destination.Id == null).Count() + 1; result.MonthIndex = Queryable().Where(mi => mi.Destination.Id == null && mi.CreatedDate.Month == DateTime.Now.Month && mi.CreatedDate.Year == DateTime.Now.Year).Count() + 1; } else { result.Code = "CK" + DateTime.Now.ToString("yy") + DateTime.Now.ToString("MM") + (Queryable().Where(mi => mi.Destination.Id != null && mi.Source.Id != null && mi.CreatedDate.Month == DateTime.Now.Month && mi.CreatedDate.Year == DateTime.Now.Year).Count() + 1).ToString("D3"); result.Source = _warehouse.Queryable().Where(s => s.Id == model.SourceId).FirstOrDefault(); result.Destination = _warehouse.Queryable().Where(d => d.Id == model.DestinationId).FirstOrDefault(); result.Index = Queryable().Where(de => de.Destination.Id != null && de.Source.Id != null).Count() + 1; result.MonthIndex = Queryable().Where(mi => mi.Destination.Id != null && mi.Source.Id != null && mi.CreatedDate.Month == DateTime.Now.Month && mi.CreatedDate.Year == DateTime.Now.Year).Count() + 1; if (model.ProductType == Inventory.Core.Enum.ProductType.New) { var debtNote = new DebtNote(); debtNote.Code = "OWED" + DateTime.Now.ToString("yy") + DateTime.Now.ToString("MM") + (_debtnote.Queryable().Where(x => x.IsOwed == true && x.CreatedDate.Month == DateTime.Now.Month && x.CreatedDate.Year == DateTime.Now.Year).Count() + 1).ToString("D3"); debtNote.Index = _debtnote.Queryable().Where(x => x.IsOwed == true).Count() + 1; debtNote.MonthIndex = _debtnote.Queryable().Where(x => x.IsOwed == true && x.CreatedDate.Month == DateTime.Now.Month && x.CreatedDate.Year == DateTime.Now.Year).Count() + 1; debtNote.User = _userRepository.Find(HttpContext.Current.User.Identity.GetUserId()) ?? _userRepository.GetAll().FirstOrDefault(); debtNote.CreatedDate = DateTime.Now; debtNote.LastModifiedDate = DateTime.Now; debtNote.Total = model.Details.Sum(x => x.Quantity * x.Price); debtNote.IsOwed = true; debtNote.PaymentType = _paymenttype.Queryable().Where(t => t.Name.Equals("Tiền mặt")).FirstOrDefault(); debtNote.PayWarehouse = _warehouse.Find(model.DestinationId); _debtnote.Insert(debtNote); _debtnote.SaveChanges(); } } Insert(result); return(result); } }
public ActionResult CheckProductInStock(NoteViewModel model) { Request.RequestContext.HttpContext.Response.AddHeader("Access-Control-Allow-Origin", "*"); var DeNote = _note.Queryable().Include(x => x.Details.Select(t => t.Product)).Where(x => (x.Source.Id != null) && (x.Source.Id == model.SourceId) && x.Delete.Equals(false)).Select(x => new NoteViewModel() { Id = x.Id, SourceWarehouse = x.Source.Name, Details = x.Details.Select(y => new NoteDetailViewModel() { Id = y.Id, ProductName = y.Product.ProductName, Quantity = y.Quantity }).ToList() }); var ReNote = _note.Queryable().Include(x => x.Details.Select(t => t.Product)).Where(x => (x.Destination.Id != null) && x.Delete.Equals(false)) .Select(x => new NoteViewModel() { Id = x.Id, DestinationWarehouse = x.Destination.Name, Details = x.Details.Select(y => new NoteDetailViewModel() { Id = y.Id, ProductName = y.Product.ProductName, Quantity = y.Quantity }).ToList() }); var ReDetails = new List <StockViewModel>(); var DeDetails = new List <StockViewModel>(); foreach (var item in DeNote) { foreach (var smallitem in item.Details) { DeDetails.Add(new StockViewModel() { ProductName = smallitem.ProductName, Warehouse = item.SourceWarehouse, Quantity = smallitem.Quantity }); } } foreach (var item in ReNote) { foreach (var smallitem in item.Details) { ReDetails.Add(new StockViewModel() { ProductName = smallitem.ProductName, Warehouse = item.DestinationWarehouse, Quantity = smallitem.Quantity }); } } var filterDeNote = DeDetails.Where(x => x.Warehouse != null).GroupBy(x => x.Warehouse).Select(x => new { warehouse = x.Key, listItem = x.GroupBy(y => y.ProductName).Select(y => new { productname = y.Key, quantity = y.Sum(t => t.Quantity) }).ToList() }); var filterReNote = ReDetails.Where(x => x.Warehouse != null).GroupBy(x => x.Warehouse).Select(x => new { warehouse = x.Key, listItem = x.GroupBy(y => y.ProductName).Select(y => new { productname = y.Key, quantity = y.Sum(t => t.Quantity) }).ToList() }); var currentStorage = new List <StockGroupViewModel>(); foreach (var item in filterReNote) { var currentStorageItem = new StockGroupViewModel(); currentStorageItem.Warehouse = item.warehouse; if (filterDeNote.Where(x => x.warehouse == item.warehouse).Any()) { var gooditem = filterDeNote.Where(x => x.warehouse == item.warehouse).FirstOrDefault(); foreach (var smallitem in item.listItem) { var detailItem = new StockDetailViewModel(); if (gooditem.listItem.Where(t => t.productname == smallitem.productname).Any()) { var caughtDetail = gooditem.listItem.Where(t => t.productname == smallitem.productname).FirstOrDefault(); detailItem.ProductName = smallitem.productname; detailItem.Quantity = smallitem.quantity - caughtDetail.quantity; currentStorageItem.StockList.Add(detailItem); } else { detailItem.ProductName = smallitem.productname; detailItem.Quantity = smallitem.quantity; currentStorageItem.StockList.Add(detailItem); } } currentStorage.Add(currentStorageItem); } else { foreach (var smallitem in item.listItem) { var detailItem = new StockDetailViewModel(); detailItem.ProductName = smallitem.productname; detailItem.Quantity = smallitem.quantity; currentStorageItem.StockList.Add(detailItem); } currentStorage.Add(currentStorageItem); } } var flagWrong = false; var WrongName = ""; var requestWarehouse = _warehouse.Find((Guid)model.SourceId).Name; var matchWarehouse = currentStorage.Where(x => x.Warehouse == requestWarehouse).FirstOrDefault(); if (matchWarehouse != null) { foreach (var item in model.Details) { var productName = _product.Find((Guid)item.ProductId).ProductName; if (!matchWarehouse.StockList.Where(x => x.ProductName == productName).Any()) { flagWrong = true; WrongName = productName; break; } else { var quantity = matchWarehouse.StockList.Where(x => x.ProductName == productName).FirstOrDefault().Quantity; if (item.Quantity > quantity) { flagWrong = true; WrongName = productName; break; } } } } else { flagWrong = true; WrongName = requestWarehouse; } if (flagWrong == true) { var objects = new { result = "Kho không đủ số lượng sản phẩm " + WrongName }; return(Json(objects, JsonRequestBehavior.AllowGet)); } else { var objects = new { result = "Ok" }; return(Json(objects, JsonRequestBehavior.AllowGet)); } }
async void Save_Clicked(object sender, EventArgs e) { _viewModel = (NoteViewModel)BindingContext; _viewModel.Save(); await Navigation.PopAsync(); }
public ActionResult Category(int id, int?p, int?commend, int?f, string order) { var category = MyService.GetCategoryById(id); var currenturl = WebUtils.GetCateUrl(category); var webPath = MyService.GetCategoryPathUrl(category.Path); var pager = new Pager { PageNo = p ?? 1 }; switch (category.Type) { case 2: var re = MyService.GetVArticles(0, id, 0); if (re.Any()) { var varticle = re.ToList()[0]; var singleViewModel = new SingleViewModel { WebTitle = category.CateName, WebPath = webPath, CurrentUrl = currenturl, ArticleInfo = varticle, Category = category }; return(View(WebUtils.GetViewName(category.CustomView, "Single"), singleViewModel)); } return(View("Error")); case 4: var albumsViewModel = new AlbumsViewModel { WebTitle = category.CateName, WebPath = webPath, CurrentUrl = currenturl, Category = category, Albums = MyService.GetAlbums(id), }; return(View(WebUtils.GetViewName(category.CustomView, "Albums"), albumsViewModel)); case 6: var note = new NoteModel { CategoryId = id, NoteId = 0, DataType = 1, UserId = UserInfo == null ? 0 : UserInfo.userid, UserName = UserInfo == null ? string.Empty : UserInfo.username }; pager.PageSize = Configinfo.NotePagerCount; var orderType = string.IsNullOrEmpty(order) ? "desc" : order; if (f != null && f > 0) { pager = MyService.GetFloorNoteByOrderId(pager, id, (long)f, orderType); } else { pager = MyService.GetFloorNotePaging(pager, id, orderType); } var noteViewModel = new NoteViewModel { WebTitle = category.CateName, WebPath = webPath, CurrentUrl = currenturl, Note = note, NoteList = new NoteListViewModel { NotePagerInfo = pager }, NoteOrderType = orderType, Category = category }; return(View(WebUtils.GetViewName(category.CustomView, "Note"), noteViewModel)); default: var iscommend = commend ?? 0; pager.PageSize = Configinfo.CatePagerCount; pager = category.SubCount > 0 ? MyService.GetArticlePaging(pager, 0, id, MyService.GetCategoryIds(id), iscommend, order) : MyService.GetArticlePaging(pager, 0, id, iscommend, order: order, articleListType: "category"); var categoryViewModel = new CategoryViewModel { WebTitle = category.CateName, WebPath = webPath, CurrentUrl = currenturl, IsCommend = iscommend, CateId = id, ArticlePagerInfo = pager, Category = category }; var articleListParasInfo = new AjaxArticleListParamsModel { ArticleListType = "category", CategoryId = id, Commend = iscommend, Order = order }; ViewBag.ArticleListParasInfo = articleListParasInfo; return(View(WebUtils.GetViewName(category.CustomView, "Category"), categoryViewModel)); } }
public NotePage(NoteViewModel vm) { InitializeComponent(); ViewModel = vm; this.BindingContext = ViewModel; }
public static Note Map(NoteViewModel viewModel) { var model = mapper.Map(viewModel); model.UserId = viewModel.UserId; return model; }
public NoteList(int userId) { UserId = userId; InitializeComponent(); DataContext = new NoteViewModel(UserId); }
public ActionResult UploadNote() { Request.RequestContext.HttpContext.Response.AddHeader("Access-Control-Allow-Origin", "*"); Request.RequestContext.HttpContext.Response.AddHeader("Access-Control-Allow-Headers", "*"); if (Request.Files.Count > 0) { try { var NoteList = new List <NoteViewModel>(); // Get all files from Request object string firstfname = ""; string fname; HttpFileCollectionBase files = Request.Files; for (int i = 0; i < files.Count; i++) { HttpPostedFileBase file = files[i]; // Checking for Internet Explorer if (Request.Browser.Browser.ToUpper() == "IE" || Request.Browser.Browser.ToUpper() == "INTERNETEXPLORER") { string[] testfiles = file.FileName.Split(new char[] { '\\' }); fname = testfiles[testfiles.Length - 1]; } else { fname = file.FileName; } // Get the complete folder path and store the file inside it. fname = Path.Combine(Server.MapPath("~/Uploads/"), fname); firstfname = fname; file.SaveAs(fname); } using (XLWorkbook wb = new XLWorkbook(firstfname)) { var ws = wb.Worksheet(1); var sheet = wb.Worksheet(1).RowsUsed(); var usedColumn = wb.Worksheet(1).ColumnsUsed(); var ExceptRow = 1; foreach (var dataRow in sheet) { var Note = new NoteViewModel(); if (ExceptRow == 1) { ExceptRow++; } else { var NoteType = ws.Cell(1, 1).Value.ToString(); switch (NoteType) { case "NK": { Note.Code = "NK" + DateTime.Now.ToString("yy") + DateTime.Now.ToString("MM") + (_note.Queryable().Where(mi => mi.Source.Id == null && mi.CreatedDate.Month == DateTime.Now.Month && mi.CreatedDate.Year == DateTime.Now.Year).Count() + 1).ToString("D3"); Note.Source = null; var destCode = dataRow.Cell("A").Value.ToString(); Note.DestinationId = _warehouse.Queryable().Where(x => x.WarehouseCode.Equals(destCode)).Select(x => x.Id).FirstOrDefault(); Note.DestinationWarehouse = _warehouse.Queryable().Where(x => x.WarehouseCode.Equals(destCode)).Select(x => x.Name).FirstOrDefault(); Note.Details = new List <NoteDetailViewModel>(); for (int i = 2; i < usedColumn.Count(); i++) { if (!(dataRow.Cell(i).Value.ToString() == "")) { var detail = new NoteDetailViewModel(); var NumberProduct = (double)dataRow.Cell(i).Value; var detailCode = ws.Cell(1, i).Value.ToString(); var price = _product.Queryable().Where(p => p.ProductName.Equals(detailCode)).Select(p => p.Price).FirstOrDefault(); detail.Price = price; detail.Quantity = (int)NumberProduct; detail.ProductId = _product.Queryable().Where(p => p.ProductName.Equals(detailCode)).Select(p => p.Id).FirstOrDefault(); detail.ProductName = _product.Queryable().Where(p => p.ProductName.Equals(detailCode)).Select(p => p.ProductName).FirstOrDefault(); detail.Unit = _product.Queryable().Where(p => p.ProductName.Equals(detailCode)).Select(p => p.Unit).FirstOrDefault(); Note.Details.Add(detail); } } Note.Noted = ws.Cell(ExceptRow, usedColumn.Count()).Value.ToString(); Note.Total = Note.Details.Sum(x => x.Price * x.Quantity); NoteList.Add(Note); ExceptRow++; break; } case "XK": { Note.Code = "XK" + DateTime.Now.ToString("yy") + DateTime.Now.ToString("MM") + (_note.Queryable().Where(mi => mi.Destination.Id == null && mi.CreatedDate.Month == DateTime.Now.Month && mi.CreatedDate.Year == DateTime.Now.Year).Count() + 1).ToString("D3"); var sourceCode = dataRow.Cell("A").Value.ToString(); Note.SourceId = _warehouse.Queryable().Where(s => s.WarehouseCode.Equals(sourceCode)).Select(s => s.Id).FirstOrDefault(); Note.Destination = null; Note.SourceWarehouse = _warehouse.Queryable().Where(s => s.WarehouseCode.Equals(sourceCode)).Select(s => s.Name).FirstOrDefault(); Note.Details = new List <NoteDetailViewModel>(); for (int i = 2; i < usedColumn.Count(); i++) { if (!(dataRow.Cell(i).Value.ToString() == "")) { var detail = new NoteDetailViewModel(); var NumberProduct = (double)dataRow.Cell(i).Value; var detailCode = ws.Cell(1, i).Value.ToString(); var price = _product.Queryable().Where(p => p.ProductName.Equals(detailCode)).Select(p => p.Price).FirstOrDefault(); detail.Price = price; detail.Quantity = (int)NumberProduct; detail.ProductId = _product.Queryable().Where(p => p.ProductName.Equals(detailCode)).Select(p => p.Id).FirstOrDefault(); detail.ProductName = _product.Queryable().Where(p => p.ProductName.Equals(detailCode)).Select(p => p.ProductName).FirstOrDefault(); detail.Unit = _product.Queryable().Where(p => p.ProductName.Equals(detailCode)).Select(p => p.Unit).FirstOrDefault(); Note.Details.Add(detail); } } Note.Noted = ws.Cell(ExceptRow, usedColumn.Count()).Value.ToString(); Note.Total = Note.Details.Sum(x => x.Price * x.Quantity); NoteList.Add(Note); ExceptRow++; break; } case "CK": { break; } } } } //using (MemoryStream stream = new MemoryStream()) //{ // wb.SaveAs(stream); // return File(stream.ToArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "PhieuNhapKho.xlsx"); //} } // Returns message that successfully uploaded return(Json(NoteList, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json("Error occurred. Error details: " + ex.Message)); } } else { return(Json("No files selected.")); } }
/// <inheritdoc/> public override void ShowInView(IHtmlView htmlView, KeyValueList <string, string> variables, Navigation redirectedFrom) { base.ShowInView(htmlView, variables, redirectedFrom); ISettingsService settingsService = Ioc.GetOrCreate <ISettingsService>(); _repositoryService.LoadRepositoryOrDefault(out NoteRepositoryModel noteRepository); variables.TryGetValue(ControllerParameters.SearchFilter, out _startingSearchFilter); // Get the note from the repository Guid noteId = new Guid(variables[ControllerParameters.NoteId]); NoteModel note = noteRepository.Notes.FindById(noteId); ICryptor cryptor = new Cryptor(NoteModel.CryptorPackageName, Ioc.GetOrCreate <ICryptoRandomService>()); _viewModel = new NoteViewModel( Ioc.GetOrCreate <INavigationService>(), Ioc.GetOrCreate <ILanguageService>(), Ioc.GetOrCreate <ISvgIconService>(), Ioc.GetOrCreate <IThemeService>(), Ioc.GetOrCreate <IBaseUrlService>(), null, _repositoryService, Ioc.GetOrCreate <IFeedbackService>(), settingsService, cryptor, noteRepository.Safes, noteRepository.CollectActiveTags(), note); SetHtmlViewBackgroundColor(htmlView); VueBindingShortcut[] shortcuts = new[] { new VueBindingShortcut("f", "ToggleSearchDialogCommand") { Ctrl = true }, new VueBindingShortcut(VueBindingShortcut.KeyEscape, "CloseSearchDialogCommand"), new VueBindingShortcut(VueBindingShortcut.KeyHome, "ScrollToTop") { Ctrl = true }, new VueBindingShortcut(VueBindingShortcut.KeyEnd, "ScrollToBottom") { Ctrl = true }, }; VueBindings = new VueDataBinding(_viewModel, View, shortcuts); VueBindings.DeclareAdditionalVueData("PrettyTimeAgoVisible", "true"); VueBindings.DeclareAdditionalVueData("Header1Active", "false"); VueBindings.DeclareAdditionalVueData("Header2Active", "false"); VueBindings.DeclareAdditionalVueData("Header3Active", "false"); VueBindings.DeclareAdditionalVueData("BoldActive", "false"); VueBindings.DeclareAdditionalVueData("ItalicActive", "false"); VueBindings.DeclareAdditionalVueData("ListOrderedActive", "false"); VueBindings.DeclareAdditionalVueData("ListBulletActive", "false"); VueBindings.DeclareAdditionalVueData("CodeActive", "false"); VueBindings.DeclareAdditionalVueData("QuoteActive", "false"); VueBindings.DeclareAdditionalVueData("UnderlineActive", "false"); VueBindings.DeclareAdditionalVueData("StrikeActive", "false"); VueBindings.DeclareAdditionalVueMethod("ToggleSearchDialogCommand", "toggleSearchDialog();"); VueBindings.DeclareAdditionalVueMethod("CloseSearchDialogCommand", "showSearchDialog(false);"); VueBindings.DeclareAdditionalVueMethod("ScrollToTop", "scrollToTop();"); VueBindings.DeclareAdditionalVueMethod("ScrollToBottom", "scrollToBottom();"); VueBindings.UnhandledViewBindingEvent += UnhandledViewBindingEventHandler; VueBindings.ViewLoadedEvent += ViewLoadedEventHandler; _viewModel.VueDataBindingScript = VueBindings.BuildVueScript(); VueBindings.StartListening(); string html = _viewService.GenerateHtml(_viewModel); View.LoadHtml(html); }
public ViewResult Create() { var model = new NoteViewModel(); return(View(model)); }
public async Task <IActionResult> Add([FromServices] IHostingEnvironment env, NoteViewModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } string filename = string.Empty; if (model.Attachment != null) { filename = Path.Combine("file", Guid.NewGuid().ToString() + Path.GetExtension(model.Attachment.FileName)); using (var stream = new FileStream(Path.Combine(env.WebRootPath, filename), FileMode.CreateNew)) { model.Attachment.CopyTo(stream); } } await _noteRepository.AddAsync(new Note { Title = model.Title, Content = model.Content, CreateDate = model.CreateDate, TypeId = model.Type, Password = model.Password, Attachment = filename }); return(RedirectToAction(nameof(Index))); }
public void Initialize() { mockNoteRepository = new Mock <IRepository <Note> >(); noteViewModel = new NoteViewModel(mockNoteRepository.Object); }
void EffacerNote(NoteViewModel noteVm) { EtatCalendrier.EffacerNote(noteVm); }
private bool ContainsTag(NoteViewModel model, string text) { return(model.Tags.Any(t => t.Text.Contains(text))); }
public SelectedNoteChanged(NoteViewModel note) { SelectedNote = note; }
private NoteDto MapViewModelToDto(NoteViewModel noteViewModel) { return(mapper.Map <NoteDto>(noteViewModel)); }
private void CommandBinding_ExecuteDeleteNote(object sender, ExecutedRoutedEventArgs e) { NoteViewModel noteVm = (NoteViewModel)e.Parameter; sequencer.Notes.DeleteNote(noteVm); }
public IActionResult New() { NoteViewModel vm = _noteViewModelFactory.Create(); return(View(vm)); }
public ViewController() : base() { using (var scope = App.Container.BeginLifetimeScope()) { _viewModel = scope.Resolve <NoteViewModel> (); } }
private async void LoadDataAsync(int noteId) { note = await noteManager.Get(noteId); this.BindingContext = note; }
public async Task <JsonResult> AddNote(NoteViewModel model) { await UnitOfWork.CustomerRepository.AddNote(model.Text, model.UserId); return(Json(new { success = true })); }
public void PrepareTags(NoteViewModel vm) { vm.AvailableTags = _tagService.GetAll().Select(t => t.Title).ToArray(); }
private void AdjustVelocity(NoteViewModel note, int deltaVelocity) { int newVelocity = note.Velocity + deltaVelocity; note.Velocity = (byte)Math.Max(MinVerticalValue, Math.Min(newVelocity, MaxVerticalValue)); }
public NoteEditedEventArgs(NoteViewModel noteViewModel) { _noteViewModel = noteViewModel; }
private string GetNoteFilePath(NoteViewModel note) { return(location + '\\' + note.Title + NotesFileExtension); }
public NoteDeletedEventArgs(NoteViewModel noteViewModel) { _noteViewModel = noteViewModel; }
public EditNotePage(NoteViewModel noteViewModel) { InitializeComponent(); BindingContext = _viewModel = noteViewModel; }
public NoteSavedEventArgs(NoteViewModel noteViewModel) { _noteViewModel = noteViewModel; }
private void SearchBtn_Click(object sender, RoutedEventArgs e) { var model = new NoteViewModel(); string query = "SELECT Id FROM Notes WHERE "; for (int i = 0; i < 11; i++) { if (search_checks[i].IsChecked == true) { query += search_queries[i][search_combos[i].SelectedIndex]; query += " AND "; } } if (TextCheck.IsChecked == true) { query += $"(WeatherNote LIKE '%{TextTxt.Text}%' OR WaterNote LIKE '%{TextTxt.Text}%' OR NoteString LIKE '%{TextTxt.Text}%') AND "; } if (LocationCheck.IsChecked == true) { query += $"Location_id = {(int)LocationTb.Tag} AND "; } if (RainfallCheck.IsChecked == true) { query += "Rainfall=1 AND "; } if (SpecyCheck.IsChecked == true) { if (TrophySpecyCheck.IsChecked == true) { query += $"(Id IN (SELECT Note_id FROM Trophies WHERE Specy_id={((Specy)SpecyCombo.SelectedItem).Id})) AND ))"; } else { query += $"(Id IN (SELECT Note_id FROM Catches WHERE Specy_id={((Specy)SpecyCombo.SelectedItem).Id}) OR " + $"Id IN (SELECT Note_id FROM Trophies WHERE Specy_id={((Specy)SpecyCombo.SelectedItem).Id})) AND "; } } if (TackleCheck.IsChecked == true) { if (string.IsNullOrEmpty(TackleParamTxt.Text)) { query += $"Id IN (SELECT Note_id FROM NoteTackles WHERE Tackle_id={(int)TackleTb.Tag}) AND "; } else { query += $"Id IN (SELECT Note_id FROM NoteTackles WHERE Tackle_id={(int)TackleTb.Tag} AND Parameter LIKE '%{TackleParamTxt.Text}%') AND "; } } if (CatchCountCheck.IsChecked == true) { query += $"CatchCount BETWEEN {(int)(FromCatchCountUpDown.Value ?? 0)} AND {(int)(ToCatchCountUpDown.Value ?? 0)} AND "; } try { query = query.Substring(0, query.LastIndexOf(" AND")); query += " ORDER BY date(Date) ASC"; NoteListBox2.DataContext = model; //NoteListBox2.Items.Clear(); model.SQL(query); //model.Refresh(); //notes.ForEach(v => NoteListBox2.Items.Add(model.Notes.FirstOrDefault(n => n.Id == v.Id))); } catch { MessageBox.Show("Ошибка в параметрах поиска!"); } if (NoteListBox2.Items.Count > 0) { SearchExcelBtn.IsEnabled = true; } else { SearchExcelBtn.IsEnabled = false; } }
private void SelectedNoteChangedEventHandler(NoteViewModel selectedNote) { string script = string.Format("selectNote('{0}');", selectedNote?.Id.ToString()); View.ExecuteJavaScript(script); }