Example #1
0
        private void RefreshCursor()
        {
            RaisePropertyChanged(nameof(CursorInGrid));
            RaisePropertyChanged(nameof(ValidCommandsAtCursor));

            EditElement.RaiseCanExecuteChanged();

            AddMark.RaiseCanExecuteChanged();
            RaisePropertyChanged(nameof(CanAddMark));

            EditMark.RaiseCanExecuteChanged();
            RaisePropertyChanged(nameof(CanEditMark));

            RemoveMark.RaiseCanExecuteChanged();
            RaisePropertyChanged(nameof(CanRemoveMark));

            AddFretLabel.RaiseCanExecuteChanged();
            RaisePropertyChanged(nameof(CanAddFretLabel));

            EditFretLabel.RaiseCanExecuteChanged();
            RaisePropertyChanged(nameof(CanEditFretLabel));

            RemoveFretLabel.RaiseCanExecuteChanged();
            RaisePropertyChanged(nameof(CanRemoveFretLabel));

            AddBarre.RaiseCanExecuteChanged();
            RaisePropertyChanged(nameof(CanAddBarre));

            EditBarre.RaiseCanExecuteChanged();
            RaisePropertyChanged(nameof(CanEditBarre));

            RemoveBarre.RaiseCanExecuteChanged();
            RaisePropertyChanged(nameof(CanRemoveBarre));
        }
Example #2
0
        public List <IMSMark> AddMarks()
        {
            List <IMSMark> tmp   = new List <IMSMark>();
            int            count = 0;

            IMSMark mark;

            while (count < markets.Count)
            {
                img                   = new Image();
                img.Source            = new BitmapImage(new Uri("../images/SiteIcon.png", UriKind.Relative));
                img.Height            = 48;
                img.Width             = 38;
                tips                  = new  EditMark(markets[count].MarketName, markets[count].MarketID.ToString(), markets[count].Address, "");
                mark                  = new IMSMark(tips, CoordinateType.Logic, markLayer1);
                mark.EnableAnimation  = false;
                mark.EnableRevisedPos = true;
                Point pn = new Point(markets[count].X, markets[count].Y);
                pn           = this.mapContainer.LogicToScreen(pn.X, pn.Y);
                pn           = this.mapContainer.ScreenToLogic(pn.X, pn.Y);
                mark.X       = pn.X;
                mark.Y       = pn.Y;
                mark.OffsetX = -19;
                mark.OffsetY = -48;
                markLayer1.AddMark(mark);
                tmp.Add(mark);
                count++;
            }
            markLayer1.EnableGPUMode = true;
            return(tmp);
        }
Example #3
0
        /// <summary>
        /// 添加单个标注
        /// </summary>
        /// <param name="LogPnt"></param>
        public IMSMark AddMark(marketsInfo market)
        {
            if (this.markLayer1 == null)
            {
                MessageBox.Show("标注图层为空!");
                return(null);
            }
            img        = new Image();
            img.Source = new BitmapImage(new Uri("../images/SiteIcon.png", UriKind.Relative));
            img.Height = 48;
            img.Width  = 38;

            tips = new  EditMark(market.MarketName, market.MarketID.ToString(), market.Address, "");
            //tips(market);
            IMSMark mark = new IMSMark(tips, CoordinateType.Logic, markLayer1);

            mark.EnableAnimation  = false;
            mark.EnableRevisedPos = true;

            Point pnt = new Point(market.X, market.Y);


            mark.X       = pnt.X;
            mark.Y       = pnt.Y;
            mark.OffsetX = -19;
            mark.OffsetY = -48;
            markLayer1.AddMark(mark);

            return(mark);
        }
Example #4
0
        private void RefreshCursor()
        {
            RaisePropertyChanged("CursorInGrid");
            RaisePropertyChanged("ValidCommandsAtCursor");

            EditElement.RaiseCanExecuteChanged();

            AddMark.RaiseCanExecuteChanged();
            RaisePropertyChanged("CanAddMark");

            EditMark.RaiseCanExecuteChanged();
            RaisePropertyChanged("CanEditMark");

            RemoveMark.RaiseCanExecuteChanged();
            RaisePropertyChanged("CanRemoveMark");

            AddFretLabel.RaiseCanExecuteChanged();
            RaisePropertyChanged("CanAddFretLabel");

            EditFretLabel.RaiseCanExecuteChanged();
            RaisePropertyChanged("CanEditFretLabel");

            RemoveFretLabel.RaiseCanExecuteChanged();
            RaisePropertyChanged("CanRemoveFretLabel");

            AddBarre.RaiseCanExecuteChanged();
            RaisePropertyChanged("CanAddBarre");

            EditBarre.RaiseCanExecuteChanged();
            RaisePropertyChanged("CanEditBarre");

            RemoveBarre.RaiseCanExecuteChanged();
            RaisePropertyChanged("CanRemoveBarre");
        }
Example #5
0
        /// <summary>
        /// Lấy điểm của học sinh trong lớp (năm học hiện tại)
        /// </summary>
        /// <param name="ClassID"></param>
        /// <returns></returns>
        public JsonResult GetStudentMark(int ClassID)
        {
            var             CurrentConfig   = (int)Session["ConfigID"];
            var             SubjectID       = (int)Session["SubjectID"];
            var             CurrentSemester = db.context.Settings.FirstOrDefault().Semester;
            List <EditMark> editMarks       = new List <EditMark>();
            List <int>      lstStudent      = db.MemberRepository.GetAll()
                                              .Where(c => c.LearnStatus != LearnStatus.Finished &&
                                                     c.ClassID == ClassID && CurrentConfig == c.ConfigureID && c.User.Status == UserStatus.Activated)
                                              .Select(c => c.UserID).ToList();

            foreach (int studentID in lstStudent)
            {
                bool HasMark = db.context.PointBoards
                               .Any(e => e.ClassID == ClassID &&
                                    e.StudentID == studentID && e.SubjectID == SubjectID && e.Semester == CurrentSemester);
                if (!HasMark)
                {
                    Score      emptyScore = new Score();
                    PointBoard NewMark    = new PointBoard
                    {
                        ClassID     = ClassID,
                        Score       = JsonConvert.SerializeObject(emptyScore),
                        StudentID   = studentID,
                        SubjectID   = SubjectID,
                        ConfigureID = CurrentConfig,
                        Semester    = CurrentSemester
                    };
                    db.context.PointBoards.Add(NewMark);
                    db.SaveChanges();
                }
                EditMark editItem = db.context.PointBoards
                                    .Where(c => c.ClassID == ClassID && c.ConfigureID == c.ConfigureID &&
                                           c.Semester == CurrentSemester && c.SubjectID == SubjectID && c.StudentID == studentID)
                                    .Select(c => new EditMark
                {
                    PointID     = c.ID,
                    SubjectID   = c.SubjectID,
                    StudentName = c.User.FullName,
                    TempScore   = c.Score,
                    StudentID   = c.StudentID
                }).First();
                if (editItem.TempScore != null)
                {
                    editItem.Score     = JsonConvert.DeserializeObject <Score>(editItem.TempScore);
                    editItem.TempScore = null;
                }
                editMarks.Add(editItem);
            }
            return(Json(editMarks, JsonRequestBehavior.AllowGet));
        }
 public ActionResult Edit(int id)
 {
     using (var db = new ApplicationDbContext())
     {
         var mark = (from m in db.Marks.Where(x => x.Id == id)
                     join s in db.Users.AsQueryable <AppUser>() on m.UserId equals s.Id
                     select new ShowMarks {
             Id = m.Id, Coming_Date = m.Coming_Date, Out_Date = m.Out_Date, UserName = s.UserName, UserId = s.Id
         }).FirstOrDefault();
         var list = new EditMark {
             Id = mark.Id, Coming_Date = mark.Coming_Date, Out_Date = mark.Out_Date, UserName = mark.UserName, UserId = mark.UserId
         };
         return(PartialView(list));
     }
 }
        public ActionResult Edit(EditMark model)
        {
            DateTime result;

            if (model.Out_Date != null)
            {
                if (DateTime.TryParse(model.Coming_Date.ToString(), out result) && DateTime.TryParse(model.Out_Date.ToString(), out result) && model.Coming_Date < model.Out_Date)
                {
                    using (var db = new ApplicationDbContext())
                    {
                        var editmark = db.Marks.Where(x => x.Id == model.Id).FirstOrDefault();
                        editmark.Coming_Date = model.Coming_Date;
                        editmark.Out_Date    = model.Out_Date;
                        editmark.AuthorId    = User.Identity.GetUserId <int>();
                        db.SaveChanges();
                    }
                    return(RedirectToAction("Create", new { id = model.UserId }));
                }
                else
                {
                    return(RedirectToAction("Create", new { id = model.UserId }));
                }
            }
            else
            {
                if (DateTime.TryParse(model.Coming_Date.ToString(), out result))
                {
                    using (var db = new ApplicationDbContext())
                    {
                        var editmark = db.Marks.Where(x => x.Id == model.Id).FirstOrDefault();
                        editmark.Coming_Date = model.Coming_Date;
                        editmark.Out_Date    = null;
                        editmark.AuthorId    = User.Identity.GetUserId <int>();
                        db.SaveChanges();
                    }
                    return(RedirectToAction("Create", new { id = model.UserId }));
                }
                else
                {
                    return(RedirectToAction("Create", new { id = model.UserId }));
                }
            }
        }
Example #8
0
        /// <summary>
        /// Cập nhật bảng điểm
        /// </summary>
        /// <param name="ClassID"></param>
        /// <param name="Listmark"></param>
        /// <returns></returns>
        public JsonResult UpdateStudentMark(int ClassID, IEnumerable <EditMark> Listmark)
        {
            if (ModelState.IsValid)
            {
                var CurrentConfig   = (int)Session["ConfigID"];
                var SubjectID       = (int)Session["SubjectID"];
                var CurrentSemester = db.context.Settings.FirstOrDefault().Semester;
                foreach (var mark in Listmark)
                {
                    bool HasMark = db.context.PointBoards
                                   .Any(e => e.ClassID == ClassID &&
                                        e.StudentID == mark.StudentID && e.SubjectID == SubjectID &&
                                        e.Semester == CurrentSemester);
                    if (HasMark)
                    {
                        PointBoard CurrentMark = db.context.PointBoards
                                                 .Where(e => e.ClassID == ClassID &&
                                                        e.StudentID == mark.StudentID && e.SubjectID == SubjectID && e.ConfigureID == CurrentConfig).First();
                        var dumpData = JsonConvert.SerializeObject(mark.Score);

                        CurrentMark.Score = dumpData;

                        db.context.Entry(CurrentMark).State = EntityState.Modified;
                        db.context.SaveChanges();
                    }
                    else
                    {
                        PointBoard NewMark = new PointBoard
                        {
                            ClassID     = ClassID,
                            Score       = JsonConvert.SerializeObject(mark.Score), // mark.Score,
                            StudentID   = mark.StudentID,
                            SubjectID   = mark.SubjectID,
                            ConfigureID = CurrentConfig,
                            Semester    = CurrentSemester == Semester.HK1 ? Semester.HK1 : Semester.HK2
                        };
                        db.context.PointBoards.Add(NewMark);
                        db.SaveChanges();
                    }
                }
                // Đổ lại dữ liệu
                List <int> lstStudent = db.MemberRepository.GetAll()
                                        .Where(c => c.LearnStatus != LearnStatus.Finished &&
                                               c.ClassID == ClassID && CurrentConfig == c.ConfigureID)
                                        .Select(c => c.UserID).ToList();
                List <EditMark> editMarks = new List <EditMark>();
                foreach (int studentID in lstStudent)
                {
                    EditMark editItem = db.context.PointBoards
                                        .Where(c => c.ClassID == ClassID && c.ConfigureID == c.ConfigureID &&
                                               c.Semester == CurrentSemester && c.SubjectID == SubjectID && c.StudentID == studentID)
                                        .Select(c => new EditMark
                    {
                        SubjectID   = c.SubjectID,
                        StudentName = c.User.FullName,
                        TempScore   = c.Score,
                        StudentID   = c.StudentID
                    }).FirstOrDefault();
                    if (editItem.TempScore != null)
                    {
                        editItem.Score     = JsonConvert.DeserializeObject <Score>(editItem.TempScore);
                        editItem.TempScore = null;
                    }
                    editMarks.Add(editItem);
                }
                return(Json(new { Message = "Cập nhật thành công", Member = editMarks, Success = true }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new { Message = "Bạn nhập điểm không hợp lệ \n Điểm từ x (chưa có) và 0 đến 10", Success = false }, JsonRequestBehavior.AllowGet));
        }
Example #9
0
 private async void TSB_EditMark_Click(object sender, EventArgs e)
 {
     await EditMark?.Invoke();
 }