Exemplo n.º 1
0
        private void button_Create_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn chắc chắn muốn khởi tạo bảng điểm?", "Thông báo", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
            {
                return;
            }
            else
            {
                // Khởi tạo điểm trung bình cho những học sinh chưa khởi tạo điểm
                DataGridViewScore.DataSource = ScoreDAO.Instance.CreateAverageScore(ComboboxSubject.Text, ComboboxSemester.Text, Int32.Parse(ComboboxYear.Text), Int32.Parse(ComboboxGrade.Text));
                foreach (DataGridViewRow row in DataGridViewScore.Rows)
                {
                    if (row.Cells[0].Value == null)
                    {
                        break;
                    }
                    Score scr = new Score(Int32.Parse(row.Cells[0].Value.ToString()), ComboboxSubject.Text, ComboboxSemester.Text, Int32.Parse(ComboboxYear.Text), 0);
                    BUS.ScoreBUS.InitAverageScore(scr);
                }

                // Khởi tạo chi tiết điểm cho những học sinh chưa khởi tạo điểm chi tiết
                DataGridViewScore.DataSource = ScoreDAO.Instance.CreateScoreTable(Int32.Parse(ComboboxYear.Text), ComboboxSubject.Text, ComboboxSemester.Text, ComboboxType.Text, Int32.Parse(ComboboxFrequency.Text), Int32.Parse(ComboboxGrade.Text), ComboboxClass.Text);
                foreach (DataGridViewRow row in DataGridViewScore.Rows)
                {
                    if (row.Cells[0].Value == null)
                    {
                        break;
                    }
                    ScoreDetail scrDetail = new ScoreDetail(Int32.Parse(row.Cells[0].Value.ToString()), ComboboxSubject.Text, ComboboxSemester.Text, Int32.Parse(ComboboxYear.Text), TypeTestDAO.Instance.TypeToTypeID(ComboboxType.Text), 0, Int32.Parse(ComboboxFrequency.Text));
                    BUS.ScoreDetailBUS.InitScoreDetail(scrDetail);
                }
                DataGridViewScore.DataSource = ScoreDAO.Instance.SearchClassScore(Int32.Parse(ComboboxGrade.Text), ComboboxClass.Text,
                                                                                  ComboboxSemester.Text, ComboboxSubject.Text, ComboboxType.Text, Int32.Parse(ComboboxYear.Text), Int32.Parse(ComboboxFrequency.Text));
            }
        }
Exemplo n.º 2
0
        public async Task SaveScoreDetails(ScoreDetail scoreDetals)
        {
            var convertedValue = JsonConvert.SerializeObject(scoreDetals);

            Application.Current.Properties[Score] = convertedValue;
            await Application.Current.SavePropertiesAsync();
        }
Exemplo n.º 3
0
 public ScoreDetail FillScoreDetail()
 {
     if (!Application.Current.Properties.ContainsKey(Score))
     {
         var scoreDetail = new ScoreDetail {
             PerformedCount = 0, TodaysPerformedCount = 0, SaveDate = DateTime.Now, TotalCount = 4
         };
         return(scoreDetail);
     }
     try
     {
         var savedSettings = (string)Application.Current.Properties[Score];
         var scoreSettings = JsonConvert.DeserializeObject <ScoreDetail>(savedSettings);
         return(new ScoreDetail()
         {
             PerformedCount = scoreSettings.PerformedCount,
             SaveDate = scoreSettings.SaveDate,
             TotalCount = scoreSettings.TotalCount
         });
     }
     catch (Exception ex)
     {
         return(null);
     }
 }
Exemplo n.º 4
0
        private ScoreDetailViewModel GetNewScoreDetailViewModel(int ScheduleId, string SetName)
        {
            var model = new ScoreDetailViewModel();
            //在属性里加了默认值,这里就不需要了
            //model.Score = new Score();
            //model.ScoreDetails = new List<ScoreDetail>();
            var schedule = db.Schedules.Find(ScheduleId);

            model.Score.ScheduleId = ScheduleId;
            model.Score.Schedule   = schedule;
            var judgeStaffid = User.Identity.Name;
            var judge        = db.Judges.Where(j => j.StaffId == judgeStaffid).FirstOrDefault();

            model.Score.JudgeId = judge.Id;
            model.Score.Judge   = judge;
            model.SetName       = SetName;
            var criterias = db.EventCriterias.Where(c => c.EventId == schedule.EventId);;

            if (!string.IsNullOrEmpty(SetName))
            {
                criterias = criterias.Where(c => c.SetName == SetName);
            }


            foreach (EventCriteria criteria in criterias)
            {
                ScoreDetail detail = new ScoreDetail();
                detail.EventCriteriaId = criteria.Id;
                detail.EventCriteria   = criteria;
                detail.Note            = criteria.Note;
                model.ScoreDetails.Add(detail);
            }

            return(model);
        }
Exemplo n.º 5
0
        public string Print()
        {
            string result = "o " + x + "," + y + " " + width + "x" + height + " " + ValueDetail + "/" + CostDetail + " " +
                            ScoreDetail.ToString("#.##") + " " + Risk.ToString("#.##");

            return(result);
        }
Exemplo n.º 6
0
        private static void assertScoreDetailOrdered(ScoreDetail actualScoreDetail, int expectedPoints, string expectedDescription, IList <Card> expectedCards)
        {
            Assert.NotNull(actualScoreDetail, "scoreDetail != null");
            Assert.AreEqual(expectedPoints, actualScoreDetail.Points, "Points");
            Assert.AreEqual(expectedDescription, actualScoreDetail.Description, "Description");

            assertAllCardsInScore(expectedCards, actualScoreDetail.Cards);
        }
Exemplo n.º 7
0
 public static void InsertNewEntiy(ScoreDetail NewScoreDetail)
 {
     using (DistributionContext context = new DistributionContext())
     {
         NewScoreDetail.c_id = Guid.NewGuid().ToString();
         context.t_score_detail.Add(NewScoreDetail);
         context.SaveChanges();
     }
 }
Exemplo n.º 8
0
 public static void UpdateEntity(ScoreDetail UpdateScoreDetail)
 {
     using (DistributionContext context = new DistributionContext())
     {
         ScoreDetail ag = context.t_score_detail.Find(UpdateScoreDetail.c_id);
         CommLogic.DeepClone <ScoreDetail>(ag, UpdateScoreDetail);
         context.SaveChanges();
     }
 }
Exemplo n.º 9
0
 public static void DeleteEntity(string ScoreDetailId)
 {
     using (DistributionContext context = new DistributionContext())
     {
         ScoreDetail DelScoreDetail = context.t_score_detail.Find(ScoreDetailId);
         context.t_score_detail.Remove(DelScoreDetail);
         context.SaveChanges();
     }
 }
Exemplo n.º 10
0
        public void Play(ScoreDetail scoreDetail)
        {
            positions = new int[numberOfTracks];

            SetTimeBetweenFrames(Convert.ToInt32(ConfigurationManager.AppSettings["Bpm"]));

            PlayScoreStart(scoreDetail.Creator);

            PlayScore(scoreDetail);

            PlayScoreEnd();
        }
Exemplo n.º 11
0
        private void PlayScore(ScoreDetail scoreDetail)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            for (var beatCount = 0; beatCount < Convert.ToInt32(ConfigurationManager.AppSettings["BarsToPlay"]) * 4; beatCount++)
            {
                Wait(stopwatch, millisecondsBetweenBeats);

                PlayNextBeat(scoreDetail);

                stopwatch.Restart();
            }
        }
Exemplo n.º 12
0
        private void button_Save_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Bạn chắc chắn muốn lưu bảng điểm này?", "Thông báo", MessageBoxButtons.OKCancel) == DialogResult.Cancel)
            {
                return;
            }
            else
            {
                string studentID, subjectID, semesterID, year, testID, score, frequency;
                foreach (DataGridViewRow row in DataGridViewScore.Rows)
                {
                    if (row.Cells[0].Value == null)
                    {
                        break;
                    }
                    studentID  = row.Cells[0].Value.ToString();
                    subjectID  = row.Cells[2].Value.ToString();
                    semesterID = row.Cells[3].Value.ToString();
                    year       = row.Cells[4].Value.ToString();
                    testID     = row.Cells[5].Value.ToString();
                    score      = row.Cells[6].Value.ToString();
                    if (score == "")
                    {
                        continue;
                    }
                    frequency = row.Cells[7].Value.ToString();
                    ScoreDetail scoreDetail = new ScoreDetail(Int32.Parse(studentID), subjectID, semesterID, Int32.Parse(year), testID, float.Parse(score), Int32.Parse(frequency));
                    BUS.ScoreDetailBUS.UpdateScoreDetail(scoreDetail);
                }

                // Update điểm trung bình cho từng bộ môn của từng học sinh
                List <Subject> subjects = BUS.SubjectBUS.GetListSubject();
                for (int i = 0; i < subjects.Count(); i++)
                {
                    DataTable data = StudentDAO.Instance.StudentHaveAverageScore(Int32.Parse(ComboboxYear.Text), subjects[i].iD, ComboboxSemester.Text);
                    for (int j = 0; j < data.Rows.Count; j++)
                    {
                        string temp = data.Rows[0][0].ToString();
                        Score  scr  = new Score(Int32.Parse(data.Rows[j][0].ToString()), subjects[i].iD, ComboboxSemester.Text, Int32.Parse(ComboboxYear.Text), 0);
                        BUS.ScoreBUS.UpdateAverageScore(scr);
                    }
                }
                MessageBox.Show("Lưu điểm thành công!", "Thông báo");
            }
        }
Exemplo n.º 13
0
        public ActionResult Create(ScoreDetail scoreDetail)
        {
            scoreDetail.Created = DateTime.Now;

            if (ContainsBadWords(scoreDetail.Creator))
            {
                scoreDetail.Played = DateTime.Now;
            }

            if (ModelState.IsValid)
            {
                db.ScoreDetails.Add(scoreDetail);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(scoreDetail));
        }
Exemplo n.º 14
0
        /// <summary>
        /// 更新代理商积分并增加积分明细记录
        /// </summary>
        /// <param name="AgentId"></param>
        /// <param name="ChangeScore"></param>
        /// <param name="context"></param>
        /// <param name="reason"></param>
        public static void UpdateAgentScore(string AgentId, int ChangeScore, string reason = "操作变更", DistributionContext context = null)
        {
            if (context == null)
            {
                context = new DistributionContext();
            }
            Agent ag = context.t_agent.Find(AgentId);

            ag.c_score = ag.c_score + ChangeScore;

            ScoreDetail sd = new ScoreDetail();

            sd.c_id          = Guid.NewGuid().ToString();
            sd.c_amount      = ChangeScore;
            sd.c_reason      = reason;
            sd.c_user_id     = AgentId;
            sd.c_create_date = DateTime.Now;
            context.t_score_detail.Add(sd);
            context.SaveChanges();
        }
Exemplo n.º 15
0
        public void GetHashCodeTest()
        {
            ScoreDetail target = new ScoreDetail();
            target.Score = "A";
            target.ScoreFor = "Project";
            ScoreDetail target2 = new ScoreDetail();
            target2.Score = "A";
            target2.ScoreFor = "Project";

            Assert.AreEqual(target2.GetHashCode(),target.GetHashCode());
            target2.Score = "B";
            Assert.AreNotEqual(target2.GetHashCode(), target.GetHashCode());
            target2.ScoreFor = "Student";
            Assert.AreNotEqual(target2.GetHashCode(), target.GetHashCode());
            target2.Score = "A";
            Assert.AreNotEqual(target2.GetHashCode(), target.GetHashCode());

            target.Id = 1;
            target2.ScoreFor = "Project";
            Assert.AreNotEqual(target2.GetHashCode(), target.GetHashCode());
            target2.Id = 1;
            Assert.AreEqual(target2.GetHashCode(), target.GetHashCode());
        }
Exemplo n.º 16
0
        public void EqualsTest()
        {
            ScoreDetail target = new ScoreDetail();
            target.Score = "A";
            target.ScoreFor = "Project";
            ScoreDetail target2 = new ScoreDetail();
            target2.Score = "A";
            target2.ScoreFor = "Project";

            Assert.IsTrue(target.Equals(target2));
            target2.Score = "B";
            Assert.IsFalse(target.Equals(target2));
            target2.ScoreFor = "Student";
            Assert.IsFalse(target.Equals(target2));
            target2.Score = "A";
            Assert.IsFalse(target.Equals(target2));

            target.Id = 1;
            target2.ScoreFor = "Project";
            Assert.IsFalse(target.Equals(target2));
            target2.Id = 1;
            Assert.IsTrue(target.Equals(target2));
        }
        public ActionResult GetScore(Int32 correctAnswers, string totalTime, DateTime today, Int32 currentQuestion, Int32 quesId)
        {
            Int32 uid = 0;

            if (Session["UserId"] != null)
            {
                uid = Convert.ToInt32(Session["UserId"]);
                mocktestEntities1 db       = new mocktestEntities1();
                ScoreDetail       newscore = new ScoreDetail();
                newscore.QuesDetailId = quesId;
                newscore.UserId       = uid;
                newscore.Corrected    = correctAnswers;
                newscore.date         = today;
                newscore.Duration     = totalTime;
                newscore.Score        = correctAnswers;
                newscore.Attempted    = currentQuestion;
                newscore.Active       = true;

                db.ScoreDetails.Add(newscore);
                db.SaveChanges();
            }
            return(PartialView("~/Views/Home/GetScore.cshtml"));
        }
Exemplo n.º 18
0
        public void SeedToContext(Stream stream, SeedingContext context, int year)
        {
            using (stream)
            {
                using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
                {
                    CsvReader csvReader = new CsvReader(reader);
                    try
                    {
                        csvReader.SkipHeaders(6);

                        while (csvReader.Read())
                        {
                            var locationCode = csvReader.GetInt(0);
                            var locationName = csvReader.GetString(1);

                            if (!string.IsNullOrWhiteSpace(locationName))
                            {
                                Location location = new Location()
                                {
                                    PlaceName = locationName, Code = locationCode, State = null
                                };

                                location = context.Locations.AddOrUpdate(location);
                                var disadvantage = csvReader.GetInt(2);
                                var advantage    = csvReader.GetInt(4);

                                Score score = new Score()
                                {
                                    DisadvantageScore          = disadvantage,
                                    AdvantageDisadvantageScore = advantage,
                                    Year     = year,
                                    Location = location
                                };

                                score = context.Scores.AddOrUpdate(score);

                                var disadvantageDecile                  = csvReader.GetInt(3);
                                var advantageDecile                     = csvReader.GetInt(5);
                                var indexOfEconomicResourcesScore       = csvReader.GetInt(6);
                                var indexOfEconomicResourcesDecile      = csvReader.GetInt(7);
                                var indexOfEducationAndOccupationScore  = csvReader.GetInt(8);
                                var indexOfEducationAndOccupationDecile = csvReader.GetInt(9);
                                var usualResedantPopulation             = csvReader.GetDecimal(10);

                                ScoreDetail scoreDetail = new ScoreDetail()
                                {
                                    Score = score,
                                    DisadvantageDecile                  = disadvantageDecile,
                                    AdvantageDisadvantageDecile         = advantageDecile,
                                    IndexOfEconomicResourcesScore       = indexOfEconomicResourcesScore,
                                    IndexOfEconomicResourcesDecile      = indexOfEconomicResourcesDecile,
                                    IndexOfEducationAndOccupationScore  = indexOfEducationAndOccupationScore,
                                    IndexOfEducationAndOccupationDecile = indexOfEducationAndOccupationDecile,
                                    UsualResedantPopulation             = usualResedantPopulation
                                };

                                scoreDetail.Score = score;
                                context.ScoreDetails.Add(scoreDetail);
                            }
                        }
                    }
                    // Todo: Create exception class to be caught and logged the right logging
                    catch (Exception e)
                    {
                        throw new DataImportException()
                              {
                                  Year            = year,
                                  Context         = csvReader.Context,
                                  ThrownException = e
                              };
                    }
                }
            }
        }
Exemplo n.º 19
0
        public async Task <ScoreDetail> GetScoreSummaries(Guid ownerId, Guid scoreId)
        {
            var(data, hashSet) = await GetDynamoDbScoreDataAsync(ownerId, scoreId);

            return(ScoreDetail.Create(data, hashSet));
        }
Exemplo n.º 20
0
        public void SeedToContext()
        {
            var importFileLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + $"/Seeding/SeedData/{ImportFileName}";

            try
            {
                using (var stream = new FileStream(importFileLocation, FileMode.Open))
                    using (var reader = new StreamReader(stream, Encoding.UTF8))
                    {
                        var csvReader = new CsvReader(reader, CultureInfo.InvariantCulture);
                        csvReader.SkipRecords(6);

                        while (csvReader.Read())
                        {
                            csvReader.TryGetField <int>(0, out int locationCode);

                            csvReader.TryGetField <string>(1, out var locationName);

                            if (!string.IsNullOrWhiteSpace(locationName))
                            {
                                var location = new Location()
                                {
                                    PlaceName = locationName, Code = locationCode, State = null
                                };

                                _dotIdContext.Locations.Add(location);
                                csvReader.TryGetField <int>(2, out var disadvantage);
                                csvReader.TryGetField <int>(4, out var advantage);

                                var score = new Score()
                                {
                                    DisadvantageScore          = disadvantage,
                                    AdvantageDisadvantageScore = advantage,
                                    //Todo: this should not be hard coded
                                    Year     = 2016,
                                    Location = location
                                };

                                _dotIdContext.Scores.Add(score);

                                csvReader.TryGetField <int>(3, out var disadvantageDecile);
                                csvReader.TryGetField <int>(5, out var advantageDecile);

                                csvReader.TryGetField <int>(6, out var indexOfEconomicResourcesScore);
                                csvReader.TryGetField <int>(7, out var indexOfEconomicResourcesDecile);
                                csvReader.TryGetField <int>(8, out var indexOfEducationAndOccupationScore);
                                csvReader.TryGetField <int>(9, out var indexOfEducationAndOccupationDecile);
                                csvReader.TryGetField <decimal>(10, out var usualResedantPopulation);

                                ScoreDetail scoreDetail = new ScoreDetail()
                                {
                                    Score = score,
                                    DisadvantageDecile                  = disadvantageDecile,
                                    AdvantageDisadvantageDecile         = advantageDecile,
                                    IndexOfEconomicResourcesScore       = indexOfEconomicResourcesScore,
                                    IndexOfEconomicResourcesDecile      = indexOfEconomicResourcesDecile,
                                    IndexOfEducationAndOccupationScore  = indexOfEducationAndOccupationScore,
                                    IndexOfEducationAndOccupationDecile = indexOfEducationAndOccupationDecile,
                                    UsualResedantPopulation             = usualResedantPopulation
                                };

                                scoreDetail.Score = score;
                                _dotIdContext.ScoreDetails.Add(scoreDetail);
                            }
                        }
                        _dotIdContext.SaveChanges();
                    }
            }
            // Todo: Create exception class to be caught and logged the right logging
            catch (Exception e)
            {
            }
        }
Exemplo n.º 21
0
 // Create score detail
 public static void InitScoreDetail(ScoreDetail scoreDetail)
 {
     Console.WriteLine("Create score student id: " + scoreDetail.IdStudent + " -Subject id: " + scoreDetail.IdSubject);
     DAO.ScoreDetailDAO.Instance.InitScoreDetail(scoreDetail);
     Console.WriteLine("Update score success!");
 }
Exemplo n.º 22
0
        protected void BindData()
        {
            HttpCookie c*k = Request.Cookies["ftcook"];

            if (c*k != null)
            {
                ypzzpid = Convert.ToInt32(c*k["ypzzpid"]);
                kgzpid  = Convert.ToInt32(c*k["kgzpid"]);
                kaotiid = Convert.ToInt32(c*k["kaotiid"]);
            }

            List <Shiti> sls = FTInterviewBLL.ShitiManage.GetAllShitiByKaotiId(kaotiid);

            GridView1.DataSource = sls;
            GridView1.DataBind();

            if (sls.Count < 1)
            {
                submitButton.Visible = false;
                //NextButton.Visible = false;
            }

            List <Pingjiaxiangdian>  ps     = FTInterviewBLL.PingjiaxiangdianManage.GetAll();
            List <Pingjiabiaozhun>   pz     = FTInterviewBLL.PingjiabiaozhunManage.GetAll();
            List <Xiangdianbiaozhun> xdbzls = FTInterviewBLL.XiangdianBiaozhunManage.GetAll();

            xdn = ps.Count;
            bzn = pz.Count;
            sn  = sls.Count;

            if (!flag)
            {
                for (int i = 1; i <= sls.Count; i++)
                {
                    shitils.Add(i, sls[i - 1].Id);
                }
                for (int i = 1; i <= ps.Count; i++)
                {
                    xdls.Add(i, ps[i - 1]);
                }
                flag = true;
            }

            DataTable dt = new DataTable("msg");

            dt.Columns.Add("pjxd", typeof(string));
            for (int i = 1; i <= bzn; i++)
            {
                dt.Columns.Add("bz" + i, typeof(string));
            }
            for (int i = 1; i <= sn; i++)
            {
                dt.Columns.Add("ti" + i, typeof(string));
            }

            DataRow dr = dt.NewRow();

            dr["pjxd"] = "项点";
            for (int i = 1; i <= bzn; i++)
            {
                dr["bz" + i] = pz[i - 1].Content;
            }
            for (int i = 1; i <= sn; i++)
            {
                dr["ti" + i] = "第" + i + "题";
            }
            dt.Rows.Add(dr);

            foreach (Pingjiaxiangdian pd in ps)
            {
                dr         = dt.NewRow();
                dr["pjxd"] = pd.Content;
                dt.Rows.Add(dr);
            }

            ScoreDetail.DataSource = dt;
            ScoreDetail.DataBind();

            int ide = 0;

            for (int ri = 1; ri <= xdn; ri++)
            {
                for (int ci = 1; ci <= bzn; ci++)
                {
                    Label t_text = new Label();
                    t_text.Text = xdbzls[ide].MyContent;
                    ide++;
                    ScoreDetail.Rows[ri].Cells[ci].Controls.Add(t_text);
                }
            }

            for (int ri = 1; ri <= xdls.Count; ri++)
            {
                for (int ci = bzn + 1; ci < bzn + 1 + sn; ci++)
                {
                    DropDownList dl = new DropDownList();
                    dl.ID = ri + "DropDownList" + ci;

                    dl.Width = 60;
                    int     stid = shitils[ci - bzn];
                    int     xdid = xdls[ri].Id;
                    Pingfen p    = FTInterviewBLL.PingfenManage.GetPfByParameter(kgzpid, ypzzpid, stid, xdid);
                    if (p != null)
                    {
                        DataProcess.ScoreBind(dl, xdls[ri].Score, p.Score);
                    }
                    else
                    {
                        DataProcess.ScoreBind(dl, xdls[ri].Score, -1);
                    }
                    dl.Attributes.Add("onchange", "auto_submit()");

                    ScoreDetail.Rows[ri].Cells[ci].Controls.Add(dl);
                }
            }
        }
Exemplo n.º 23
0
        private void PlayNextBeat(ScoreDetail scoreDetail)
        {
            var score = scoreDetail.Score;

            SendMessage(m => BuildBeatMessage(score, m));
        }