Пример #1
0
        private void btnUpload_Click(object sender, EventArgs e)
        {
            try
            {
                var level = LevelService.GetLevelId((string)ddlLevel2.SelectedValue);

                if (level.SectionModels != null && level.SectionModels.Count > 0)
                {
                    if (TextHelper.ContainsValue(new List <string>
                    {
                        beResultTemplate.Value
                    }))
                    {
                        lblError.Text = @"Result data is not selected";
                        return;
                    }

                    var dataRows = FileHelper.GetDataFromFile(beResultTemplate.Value);
                    var models   = new List <ResultSingleStudentTemplateDownloadModel>();

                    var rowIndex = 2;
                    foreach (var row in dataRows)
                    {
                        try
                        {
                            var institutionModel = new ResultSingleStudentTemplateDownloadModel()
                            {
                                CourseCode = row["CourseCode"].ToString(),
                                Score      = Convert.ToInt32(row["Score"].ToString()),
                            };
                            models.Add(institutionModel);
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }

                    gridSingleStudentResult.DataSource = models;
                    _resultTemplateDownloadModels      = models;
                    MatricNumber = AspNetUserService.GetStudentId((string)ddlMatricNumber.SelectedValue);
                    gridSingleStudentResult.Enabled             = true;
                    gridSingleStudentResult.AutoSizeColumnsMode = GridViewAutoSizeColumnsMode.Fill;
                    SemesterId = SemesterService.GetSemesterId((string)ddlSemester2.SelectedValue);
                    LevelId    = level.Id;
                }
                else
                {
                    MessageBox.Show(@"Ensure that LEVEL selected has a SESSION attached to it.", "Upload Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception ex)
            {
                _logger.Error("Error Message: " + ex.Message.ToString(), ex);
                MessageBox.Show($@"Message: {ex.Message}{Environment.NewLine}Stack Message: {ex.StackTrace}", $@"Error Message from {typeof(SingleStudentSemesterResult)}");
            }
        }
        private bool CheckScore(ResultSingleStudentTemplateDownloadModel resultSingleCourseTemplateDownloadModel)
        {
            if (resultSingleCourseTemplateDownloadModel.Score <= 0 || resultSingleCourseTemplateDownloadModel.Score > 100)
            {
                var dialog = this.ShowMessageBox(
                    $@"Course score cant be {
                            resultSingleCourseTemplateDownloadModel.Score
                        }, it should be in the range of 1-100, Could you like to update the value", "Result Processing",
                    MessageBoxButtons.OKCancel, RadMessageIcon.Info);
                if (dialog == DialogResult.OK)
                {
                    return(true);
                }
            }

            return(false);
        }