public bool Update(int?id, TaskScoreParam taskScoreParam)
        {
            var result    = 0;
            var taskScore = Get(id);

            taskScore.Name       = taskScoreParam.Name;
            taskScore.Date       = DateTimeOffset.Now.LocalDateTime;
            taskScore.Score1     = taskScoreParam.Score1;
            taskScore.Score2     = taskScoreParam.Score2;
            taskScore.Score3     = taskScoreParam.Score3;
            taskScore.Score4     = taskScoreParam.Score4;
            taskScore.Score5     = taskScoreParam.Score5;
            taskScore.students   = _context.Students.Find(Convert.ToInt16(taskScoreParam.students));
            taskScore.employees  = _context.Employees.Find(Convert.ToInt16(taskScoreParam.employees));
            taskScore.UpdateDate = DateTimeOffset.Now.LocalDateTime;
            result = _context.SaveChanges();
            if (result > 0)
            {
                status = true;
                MessageBox.Show("Update Successfully");
            }
            else
            {
                MessageBox.Show("Update Failed");
            }
            return(status);
        }
        public bool Insert(TaskScoreParam taskScoreParam)
        {
            var result = 0;

            taskScore.Name       = taskScoreParam.Name;
            taskScore.Date       = DateTimeOffset.Now.LocalDateTime;
            taskScore.Score1     = taskScoreParam.Score1;
            taskScore.Score2     = taskScoreParam.Score2;
            taskScore.Score3     = taskScoreParam.Score3;
            taskScore.Score4     = taskScoreParam.Score4;
            taskScore.Score5     = taskScoreParam.Score5;
            taskScore.students   = _context.Students.Find(Convert.ToInt16(taskScoreParam.students));
            taskScore.employees  = _context.Employees.Find(Convert.ToInt16(taskScoreParam.employees));
            taskScore.CreateDate = DateTimeOffset.Now.LocalDateTime;
            _context.TaskScores.Add(taskScore);
            result = _context.SaveChanges();
            if (result > 0)
            {
                status = true;
                MessageBox.Show("Insert Successfully");
            }
            else
            {
                MessageBox.Show("Insert Failed");
            }
            return(status);
        }
コード例 #3
0
 public bool Insert(TaskScoreParam taskScoreParam)
 {
     if (taskScoreParam.Score1.ToString() == " ")
     {
         MessageBox.Show("Don't insert white space");
     }
     else
     {
         status = _taskScoreRepository.Insert(taskScoreParam);
     }
     return(status);
 }
コード例 #4
0
 public bool Update(int?id, TaskScoreParam taskScoreParam)
 {
     if (_taskScoreRepository.Get(id) == null)
     {
         MessageBox.Show("Sorry, your data is not found");
     }
     else if (id.ToString() == " ")
     {
         MessageBox.Show("Don't insert white space in Id");
     }
     else
     {
         if (taskScoreParam.Score1.ToString() == " ")
         {
             MessageBox.Show("Don't insert white space in Name");
         }
         else
         {
             status = _taskScoreRepository.Update(id, taskScoreParam);
         }
     }
     return(status);
 }