Пример #1
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            ScheduleTestModel mdl = new ScheduleTestModel();

            mdl.BatchID               = Guid.Parse(ddlBatchID.SelectedValue);
            mdl.TestName              = txtTestName.Text.Trim();
            mdl.TimeAllowed           = Convert.ToInt32(txtTimeAllowed.Text.Trim());
            mdl.Num_of_Questions      = Convert.ToInt32(txtNoofQuestions.Text.Trim());
            mdl.Language              = txtLanguage.Text.Trim();
            mdl.TestStartDate         = Convert.ToDateTime(txtStartDate.Text.Trim());
            mdl.TestEndDate           = Convert.ToDateTime(txtTestEndDate.Text.Trim());
            mdl.MaxMarks              = Convert.ToInt32(txtMaxMarks.Text.Trim());
            mdl.PassMarks             = Convert.ToInt32(txtPassMarks.Text.Trim());
            mdl.NumberOfSets          = Convert.ToInt32(txtNoofSets.Text.Trim());
            mdl.QuestionCount         = Convert.ToInt32(txtQuestionCount.Text.Trim());
            mdl.Language              = txtLanguage.Text.Trim();
            mdl.ConfirmAssessmentDate = Convert.ToDateTime(txtConfirmAssessmentDate.Text.Trim());
            mdl.Language              = txtLanguage.Text.Trim();
            mdl.IsNegative            = false;
            mdl.IsReattempt           = false;
            mdl.NegativePercent       = 0;
            if (hdnValue.Value != "")
            {
                mdl.ID = Guid.Parse(hdnValue.Value);
            }
            bool result = _service.InsertUpdateScheduleTestMaster(mdl);

            bindGrid();
            if (result)
            {
                Response.Write("<script>alert('Record saved successfully')</script>");
            }
        }
Пример #2
0
        public bool InsertUpdateScheduleTestMaster(ScheduleTestModel mdl)
        {
            bool isUpdate = false;

            try
            {
                if (mdl.ID == Guid.Empty)
                {
                    TestSchedule _test = new TestSchedule();
                    _test.ID                    = Guid.NewGuid();
                    _test.BatchID               = mdl.BatchID;
                    _test.TestName              = mdl.TestName;
                    _test.TimeAllowed           = mdl.TimeAllowed;
                    _test.Num_of_Questions      = mdl.Num_of_Questions;
                    _test.TestStartDate         = mdl.TestStartDate;
                    _test.TestEndDate           = mdl.TestEndDate;
                    _test.MaxMarks              = mdl.MaxMarks;
                    _test.PassMarks             = mdl.PassMarks;
                    _test.IsNegative            = mdl.IsNegative;
                    _test.NegativePercent       = mdl.NegativePercent;
                    _test.IsReattempt           = mdl.IsReattempt;
                    _test.NumberOfSets          = mdl.NumberOfSets;
                    _test.QuestionCount         = mdl.QuestionCount;
                    _test.Language              = mdl.Language;
                    _test.ConfirmAssessmentDate = mdl.ConfirmAssessmentDate;
                    _test.Mode                  = mdl.Mode;
                    _test.IsDeleted             = false;
                    _test.CreatedBy             = 1;
                    _test.CreatedDateTime       = DateTime.Now;
                    _db.TestSchedules.Add(_test);
                    _db.SaveChanges();
                    isUpdate = true;
                }
                else
                {
                    var _test = (from a in _db.TestSchedules where a.ID == mdl.ID select a).FirstOrDefault();
                    if (_test != null)
                    {
                        _test.BatchID               = mdl.BatchID;
                        _test.TestName              = mdl.TestName;
                        _test.TimeAllowed           = mdl.TimeAllowed;
                        _test.Num_of_Questions      = mdl.Num_of_Questions;
                        _test.TestStartDate         = mdl.TestStartDate;
                        _test.TestEndDate           = mdl.TestEndDate;
                        _test.MaxMarks              = mdl.MaxMarks;
                        _test.PassMarks             = mdl.PassMarks;
                        _test.IsNegative            = mdl.IsNegative;
                        _test.NegativePercent       = mdl.NegativePercent;
                        _test.IsReattempt           = mdl.IsReattempt;
                        _test.NumberOfSets          = mdl.NumberOfSets;
                        _test.QuestionCount         = mdl.QuestionCount;
                        _test.Language              = mdl.Language;
                        _test.ConfirmAssessmentDate = mdl.ConfirmAssessmentDate;
                        _test.Mode      = mdl.Mode;
                        _test.IsDeleted = false;
                        _test.UpdatedBy = 1;
                        _test.UpdatedOn = DateTime.Now;
                        _db.SaveChanges();
                        isUpdate = true;
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(isUpdate);
        }