Ejemplo n.º 1
0
        public ActionResult Add(int?toDoListPK)
        {
            ToDoListView toDoListView = new ToDoListView();

            if (toDoListPK != null)
            {
                IToDoListsRepository toDoListsRepository = new ToDoListsRepository(db);
                ToDoList             toDoList            = toDoListsRepository.GetToDoListByPK((int)toDoListPK);
                IWorkDonesRepository workDonesRepository = new WorkDonesRepository(db);

                toDoList.Finished = false;

                toDoListView.ConvertFrom(toDoList, toDoListView);

                var legalEntitiesSelectedValue = workDonesRepository.GetWorkDonesCreatedWithToDo((int)toDoListPK).Select(a => a.LegalEntityFK);

                ILegalEntitiesRepository legalEntitiesRepository = new LegalEntitiesRepository(db);
                toDoListView.Companies = new MultiSelectList(legalEntitiesRepository.GetValidLegalEntities().OrderBy("name ASC"), "LegalEntityPK", "Name", legalEntitiesSelectedValue);
            }
            else
            {
                ILegalEntitiesRepository legalEntitiesRepository = new LegalEntitiesRepository(db);
                toDoListView.Companies = new MultiSelectList(legalEntitiesRepository.GetValidLegalEntities().OrderBy("name ASC"), "LegalEntityPK", "Name");
            }

            return(View(toDoListView));
        }
Ejemplo n.º 2
0
        private void CheckBox2_unchecked(object sender, RoutedEventArgs e)
        {
            var dc   = (sender as FrameworkElement).DataContext;
            var item = ToDoListView.ContainerFromItem(dc) as ListViewItem;

            ViewModel.SelectedItem = item.Content as TodoItem;
            if (ViewModel.SelectedItem != null)
            {
                string sql = @"UPDATE Todo SET finish = ? WHERE Id = ?";
                using (var res = conn.Prepare(sql))
                {
                    res.Bind(1, "false");
                    res.Bind(2, ViewModel.SelectedItem.id);
                    res.Step();
                }
                //
                //  if (ViewModel.SelectedItem != null)
                //   {
                //     this.ViewModel.SelectedItem.completed = false;
                //this.ViewModel.SelectedItem = null;
                // if (Window.Current.Bounds.Width < 800)
                //        Frame.Navigate(typeof(NewPage), ViewModel);
                //   else
                //   Frame.Navigate(typeof(MainPage), ViewModel);


                //      }
            }
        }
Ejemplo n.º 3
0
        private void EditClick(object sender, RoutedEventArgs e)
        {
            var dc   = (sender as FrameworkElement).DataContext;
            var item = ToDoListView.ContainerFromItem(dc) as ListViewItem;

            ViewModel.SelectedItem = item.Content as TodoItem;
            Frame.Navigate(typeof(NewPage), ViewModel);
        }
Ejemplo n.º 4
0
        public ActionResult Add(ToDoListView toDoListView, FormCollection form)
        {
            if (ModelState.IsValid)
            {
                IToDoListsRepository toDoListsRepository = new ToDoListsRepository(db);
                ToDoList             toDoList            = new ToDoList();

                toDoListView.ConvertTo(toDoListView, toDoList);

                toDoList.UserFK       = SecurityHelper.GetUserPKFromCookie();
                toDoList.CreationDate = DateTime.Now;

                toDoListsRepository.Add(toDoList);
                toDoListsRepository.SaveChanges();

                string[] legalEntitiesSelectedValues = new string[500];
                if (form["LegalEntityPK"] != null)
                {
                    legalEntitiesSelectedValues = ((string)form["LegalEntityPK"]).Split(',');
                }
                else
                {
                    legalEntitiesSelectedValues = null;
                }

                IWorkDonesRepository workDonesRepository = new WorkDonesRepository(db);

                if (legalEntitiesSelectedValues != null)
                {
                    // Add work dones
                    foreach (string legalEntity in legalEntitiesSelectedValues)
                    {
                        WorkDone workDone = new WorkDone();

                        workDone.ToDoListFK      = toDoList.ToDoListPK;
                        workDone.LegalEntityFK   = Convert.ToInt32(legalEntity);
                        workDone.CreatedWithToDo = true;

                        workDonesRepository.Add(workDone);
                    }

                    workDonesRepository.SaveChanges();
                }

                TempData["message"] = LayoutHelper.GetMessage("INSERT", toDoList.ToDoListPK);

                return(RedirectToAction("Index", "ToDoList"));
            }
            else
            {
                ILegalEntitiesRepository legalEntitiesRepository = new LegalEntitiesRepository(db);
                toDoListView.Companies = new MultiSelectList(legalEntitiesRepository.GetValidLegalEntities().OrderBy("name ASC"), "LegalEntityPK", "Name");

                return(View(toDoListView));
            }
        }
Ejemplo n.º 5
0
        private async void share_click(object sender, RoutedEventArgs e)
        {
            var dc   = (sender as FrameworkElement).DataContext;
            var item = (ToDoListView.ContainerFromItem(dc) as ListViewItem).Content as TodoItem;

            sharetitle       = item.title;
            sharedescription = "Todo's description: " + item.description;

            shareimg = await Package.Current.InstalledLocation.GetFileAsync("Assets\\2015071504.jpg");

            DataTransferManager.ShowShareUI();
        }
Ejemplo n.º 6
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            repository = new ToDoListJsonRepository();
            view       = new ToDoListView();
            //var view = new Test();

            var presenter = new ToDoListPresenter(view, repository);

            Application.Run(view);
        }
Ejemplo n.º 7
0
        void OnPageLoaded()
        {
            if (Trip == null)
            {
                // We don't have a valid trip. Go back to the home page.
                // (We may have been sent here by an old activity.)
                MainPage.RootFrame.Navigate(typeof(MainPage));
            }

            // Restore the previously selected item and bring it into view.
            if (previousSelectedIndex >= 0 && previousSelectedIndex < ToDoListView.Items.Count)
            {
                ToDoListView.SelectedIndex = previousSelectedIndex;
                ToDoListView.ScrollIntoView(ToDoListView.SelectedItem);
            }
        }
Ejemplo n.º 8
0
        private async void deleteOneItem(object sender, RoutedEventArgs e)
        {
            var dc   = (sender as FrameworkElement).DataContext;
            var item = (ToDoListView.ContainerFromItem(dc) as ListViewItem).Content as TodoItem;

            using (var statement = conn.Prepare("DELETE FROM TodoItem WHERE Id = ?"))
            {
                statement.Bind(1, item.id);
                statement.Step();
            }

            Models.TodoItem SItem = ViewModel.getItem(item.id);
            ViewModel.AllItems.Remove(SItem);//调用Remove接口
            await new MessageDialog("Delete successfully!").ShowAsync();
            Frame.Navigate(typeof(MainPage), ViewModel);
        }
Ejemplo n.º 9
0
        private void CheckBox2_checked(object sender, RoutedEventArgs e)
        {
            //if (ViewModel.SelectedItem != null) {
            //  string sql = @"UPDATE Todo SET finish = ? WHERE Id = ?";
            //  using (var res = conn.Prepare(sql))
            //  {
            //       res.Bind(1, "true");
            //       res.Bind(2, ViewModel.SelectedItem.id);
            //        res.Step();
            //    }
            //   }
            try
            {
                var dc       = (sender as FrameworkElement).DataContext;
                var listitem = ToDoListView.ContainerFromItem(dc) as ListViewItem;
                var item     = listitem.Content as TodoItem;

                string sql = @"UPDATE Todo SET finish = ? WHERE Id = ?";
                using (var res = conn.Prepare(sql))
                {
                    res.Bind(1, "true");
                    res.Bind(2, item.id);
                    res.Step();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
            // if (ViewModel.SelectedItem != null)
            //      {

            //
            //     this.ViewModel.SelectedItem.completed = true;
            //this.ViewModel.SelectedItem = null;
            //   if (Window.Current.Bounds.Width < 800)
            //   Frame.Navigate(typeof(NewPage), ViewModel);
            //  else
            //  Frame.Navigate(typeof(MainPage), ViewModel);


            //        }
        }
Ejemplo n.º 10
0
        private async void DeleteClick(object sender, RoutedEventArgs e)
        {
            var dc   = (sender as FrameworkElement).DataContext;
            var item = ToDoListView.ContainerFromItem(dc) as ListViewItem;

            ViewModel.SelectedItem = item.Content as TodoItem;
            if (ViewModel.SelectedItem != null)
            {
                string sql = @"DELETE FROM Todo WHERE Id = ?";

                using (var res = conn.Prepare(sql))
                {
                    res.Bind(1, ViewModel.SelectedItem.id);
                    res.Step();
                    ViewModel.RemoveTodoItem(ViewModel.SelectedItem.id);

                    await new MessageDialog("Delete successfully!").ShowAsync();
                    Frame.Navigate(typeof(NotePage), ViewModel);
                }
            }
        }
Ejemplo n.º 11
0
        async private void shareOneItem(object sender, RoutedEventArgs e)
        {
            var dc   = (sender as FrameworkElement).DataContext;
            var item = (ToDoListView.ContainerFromItem(dc) as ListViewItem).Content as TodoItem;

            shareTitle       = item.title;
            shareDescription = item.description;
            //shareImgName = item.img;
            var date = item.date;

            shareDate = "\nDue date: " + date.Year + '-' + date.Month + '-' + date.Day;
            if (shareImgName == "")
            {
                shareImg = await Package.Current.InstalledLocation.GetFileAsync("Assets\\background.jpeg");
            }
            else
            {
                shareImg = await ApplicationData.Current.LocalFolder.GetFileAsync(shareImgName);
            }
            DataTransferManager.ShowShareUI();
        }
Ejemplo n.º 12
0
        private async void share_Click(object sender, RoutedEventArgs e)
        {
            var dc   = (sender as FrameworkElement).DataContext;
            var item = (ToDoListView.ContainerFromItem(dc) as ListViewItem).Content as TodoItem;

            sharetitle   = item.title;
            sharedetail  = item.details;
            shareimgname = item.imgname;
            var date = item.date;

            sharedate = "\nDue date: " + date.Year + '-' + date.Month + '-' + date.Day + " " + time.Time;
            if (shareimgname == "")
            {
                shareimg = await Package.Current.InstalledLocation.GetFileAsync("Assets\\fruit.jpg");
            }
            else
            {
                shareimg = await ApplicationData.Current.LocalFolder.GetFileAsync(shareimgname);
            }
            DataTransferManager.ShowShareUI();
        }
        protected override void SetUpView()
        {
            eventKey = GetHashCode();

            todoListNoteView         = new ToDoListNoteView(this);
            todoListView             = new ToDoListView(this);
            todoListCategoryListView = new ToDoListCategoryListView(this);
            todoListProductView      = new ToDoListProductView(this);

            todoListToolBarView = new ToolBarView {
                style = "box"
            }.FontSize(15).Height(40);
            AddView(todoListToolBarView);

            // todoListToolBarView
            //  .AddMenu("笔记", () => ChangePage(todoListNoteView.eventKey))
            //  .AddMenu("清单", () => ChangePage(todoListView.eventKey))
            //  .AddMenu("隐藏", () => ChangePage(todoListHideView.eventKey))
            //  .AddMenu("分类管理", () => ChangePage(todoListCategoryListView.eventKey))
            //  .AddMenu("已完成", () => ChangePage(todoListFinishedView.eventKey))
            //  .AddMenu("产品", () => ChangePage(todoListProductView.eventKey));
            // views.Add(todoListNoteView);
            // views.Add(todoListView);
            // views.Add(todoListHideView);
            // views.Add(todoListCategoryListView);
            // views.Add(todoListFinishedView);
            // views.Add(todoListProductView);

            AddMenu(todoListToolBarView,
                    ("笔记", todoListNoteView),
                    ("清单", todoListView),
                    ("分类管理", todoListCategoryListView),
                    ("产品", todoListProductView)
                    );


            todoListToolBarView.ForceClick(1);
        }
Ejemplo n.º 14
0
        private void uncheckBox(object sender, RoutedEventArgs e)
        {
            var  parent = VisualTreeHelper.GetParent(sender as DependencyObject);
            Line line   = VisualTreeHelper.GetChild(parent, 3) as Line;

            line.Opacity = 0;
            try
            {
                var    dc       = (sender as FrameworkElement).DataContext;
                var    listitem = ToDoListView.ContainerFromItem(dc) as ListViewItem;
                var    item     = listitem.Content as TodoItem;
                string sql      = @"UPDATE Todo SET finish = ? WHERE ID = ?";
                using (var res = conn.Prepare(sql))
                {
                    res.Bind(1, "false");
                    res.Bind(2, item.ID);
                    res.Step();
                }
            }
            catch (Exception err)
            {
                Debug.WriteLine(err.Message);
            }
        }
Ejemplo n.º 15
0
        public ActionResult Index()
        {
            IToDoListsRepository toDoListsRepository = new ToDoListsRepository(db);
            IWorkDonesRepository workDonesRepository = new WorkDonesRepository(db);
            IUsersRepository     usersRepository     = new UsersRepository(db);

            int    page       = !String.IsNullOrWhiteSpace(Request.QueryString["page"]) ? Convert.ToInt32(Request.QueryString["page"]) : 1;
            int    pageSize   = !String.IsNullOrWhiteSpace(Request.QueryString["pageSize"]) ? Convert.ToInt32(Request.QueryString["pageSize"]) : Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["ResultsPerPage"]);
            string sortOrder  = !String.IsNullOrWhiteSpace(Request.QueryString["sortOrder"]) ? Request.QueryString["sortOrder"] : "ASC";
            string sortColumn = !String.IsNullOrWhiteSpace(Request.QueryString["sortColumn"]) ? Request.QueryString["sortColumn"] : "Deadline";
            string ordering   = sortColumn + " " + sortOrder;

            ordering = ordering.Trim();

            IQueryable <ToDoListView> toDoLists = ToDoListView.GetToDoListView(toDoListsRepository.GetValid(), workDonesRepository.GetValid(), usersRepository.GetValid())
                                                  .OrderBy(ordering);

            string status = "obligations";

            if (!String.IsNullOrWhiteSpace(Request.QueryString["Status"]))
            {
                status = Request.QueryString["Status"];
            }

            ViewBag.dateFrom = Request.QueryString["dateFrom"] != null ? Request.QueryString["dateFrom"] : DateTime.Now.AddDays(-30).ToString("dd.MM.yyyy.");
            ViewBag.dateTo   = Request.QueryString["dateTo"] != null ? Request.QueryString["dateTo"] : DateTime.Now.AddDays(30).ToString("dd.MM.yyyy.");

            ViewBag.FinishedStatuses = new SelectList(GeneratorView.GenerateFinishedStauses(), "Value", "Text", status);

            if (!String.IsNullOrWhiteSpace(Request.QueryString["searchString"]))
            {
                string searchString = Request.QueryString["searchString"].ToString();
                toDoLists = toDoLists.Where(c => c.Name.Contains(searchString));
            }

            if (status == "obligations")
            {
                toDoLists = toDoLists.Where(c => c.Finished == false || c.Finished == null);
            }
            else
            {
                if (status == "finished")
                {
                    toDoLists = toDoLists.Where(c => c.Finished == true);
                }

                if (Request.QueryString["dateFrom"] != "")
                {
                    DateTime dateFromDate = new DateTime();
                    dateFromDate = DateTime.ParseExact(ViewBag.dateFrom, "dd.MM.yyyy.", null);
                    toDoLists    = toDoLists.Where(c => c.Deadline >= dateFromDate);
                }

                if (Request.QueryString["dateTo"] != "")
                {
                    DateTime dateToDate = new DateTime();
                    dateToDate = DateTime.ParseExact(ViewBag.dateTo, "dd.MM.yyyy.", null);
                    toDoLists  = toDoLists.Where(c => c.Deadline <= dateToDate);
                }
            }

            toDoLists = toDoLists.Page(page, pageSize);

            ViewData["numberOfRecords"] = toDoLists.Count();

            int numberOfPages = ((int)ViewData["numberOfRecords"] + pageSize - 1) / pageSize;

            if (page > numberOfPages)
            {
                string url = LinkHelper.getQueryStringArray(new string[] { "page" });
                return(Redirect("ToDoList?" + url + "page=" + numberOfPages));
            }
            else
            {
                return(View("Index", toDoLists.ToList()));
            }
        }
Ejemplo n.º 16
0
        public ActionResult Edit(ToDoListView toDoListView, FormCollection form)
        {
            if (ModelState.IsValid)
            {
                IToDoListsRepository toDoListsRepository = new ToDoListsRepository(db);
                ToDoList             toDoList            = toDoListsRepository.GetToDoListByPK((int)toDoListView.ToDoListPK);
                toDoListView.ConvertTo(toDoListView, toDoList);

                toDoListsRepository.SaveChanges();

                string[] legalEntitiesSelectedValues = new string[500];
                if (form["LegalEntityPK"] != null)
                {
                    legalEntitiesSelectedValues = ((string)form["LegalEntityPK"]).Split(',');
                }
                else
                {
                    legalEntitiesSelectedValues = null;
                }

                IWorkDonesRepository workDonesRepository = new WorkDonesRepository(db);

                var legalEntitiesValueFromDB = workDonesRepository.GetWorkDonesCreatedWithToDo((int)toDoListView.ToDoListPK).Select(a => a.LegalEntityFK);

                if (legalEntitiesSelectedValues != null)
                {
                    // Add work dones
                    foreach (string legalEntity in legalEntitiesSelectedValues)
                    {
                        int legalEntityFK = Convert.ToInt32(legalEntity);

                        if (!legalEntitiesValueFromDB.Contains(legalEntityFK))
                        {
                            WorkDone workDone = new WorkDone();

                            workDone.ToDoListFK      = toDoList.ToDoListPK;
                            workDone.LegalEntityFK   = legalEntityFK;
                            workDone.CreatedWithToDo = true;

                            workDonesRepository.Add(workDone);
                        }
                    }

                    workDonesRepository.SaveChanges();

                    List <WorkDone> workDones = workDonesRepository.GetWorkDonesCreatedWithToDo((int)toDoListView.ToDoListPK).ToList();

                    // delete existing
                    foreach (WorkDone workDone in workDones)
                    {
                        int legalEntityFK = (int)workDone.LegalEntityFK;

                        if (!legalEntitiesSelectedValues.ToList().Contains(legalEntityFK.ToString()))
                        {
                            workDone.Deleted = true;

                            workDonesRepository.SaveChanges();
                        }
                    }
                }

                TempData["message"] = LayoutHelper.GetMessage("UPDATE", toDoList.ToDoListPK);

                return(RedirectToAction("Index", "ToDoList"));
            }
            else
            {
                IWorkDonesRepository workDonesRepository = new WorkDonesRepository(db);

                var legalEntitiesSelectedValue = workDonesRepository.GetWorkDonesCreatedWithToDo((int)toDoListView.ToDoListPK).Select(a => a.LegalEntityFK);

                ILegalEntitiesRepository legalEntitiesRepository = new LegalEntitiesRepository(db);
                toDoListView.Companies = new MultiSelectList(legalEntitiesRepository.GetValidLegalEntities().OrderBy("name ASC"), "LegalEntityPK", "Name", legalEntitiesSelectedValue);

                return(View(toDoListView));
            }
        }