Esempio n. 1
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            ExamBLL examBLL = new ExamBLL();

            RailExam.Model.Exam exam = new RailExam.Model.Exam();

            string strID   = string.Empty;
            string strMode = ViewState["mode"].ToString();

            if (strMode == "Insert")
            {
                exam.CategoryId   = int.Parse(hfCategoryId.Value);
                exam.ExamName     = txtExamName.Text;
                exam.Memo         = txtMemo.Text;
                exam.CreatePerson = PrjPub.CurrentLoginUser.EmployeeName;
                if (rbExamMode1.Checked)
                {
                    exam.ExamModeId = 1;
                }
                else
                {
                    exam.ExamModeId = 2;
                }

                exam.IsAutoScore    = chAutoScore.Checked;
                exam.CanSeeAnswer   = chSeeAnswer.Checked;
                exam.CanSeeScore    = chSeeScore.Checked;
                exam.IsPublicScore  = chPublicScore.Checked;
                exam.IsUnderControl = chUD.Checked;
                exam.paperId        = 0;
                exam.MaxExamTimes   = 1;
                exam.MinExamTimes   = 0;
                exam.BeginTime      = DateTime.Parse(dateBeginTime.DateValue.ToString());
                exam.EndTime        = DateTime.Parse(dateEndTime.DateValue.ToString());
                exam.ExamTypeId     = 1;
                exam.CreateTime     = DateTime.Now;
                exam.Description    = txtDescription.Text;
                exam.ExamTime       = int.Parse(txtExamTime.Text);
                exam.StatusId       = 1;

                exam.AutoSaveInterval = 0;
                exam.OrgId            = PrjPub.CurrentLoginUser.StationOrgID;

                int id = examBLL.AddExam(exam);
                strID = id.ToString();

                Response.Redirect("ExamManageSecond.aspx?mode=" + strMode + "&id=" + strID);
            }
            else if (strMode == "Edit")
            {
                strID = Request.QueryString.Get("id");

                exam.ExamName = txtExamName.Text;
                exam.Memo     = txtMemo.Text;
                exam.ExamId   = int.Parse(strID);
                exam.ExamTime = int.Parse(txtExamTime.Text);
                if (rbExamMode1.Checked)
                {
                    exam.ExamModeId = 1;
                }
                else
                {
                    exam.ExamModeId = 2;
                }

                exam.BeginTime = DateTime.Parse(dateBeginTime.DateValue.ToString());
                exam.EndTime   = DateTime.Parse(dateEndTime.DateValue.ToString());

                exam.IsAutoScore    = chAutoScore.Checked;
                exam.CanSeeAnswer   = chSeeAnswer.Checked;
                exam.CanSeeScore    = chSeeScore.Checked;
                exam.IsPublicScore  = chPublicScore.Checked;
                exam.IsUnderControl = chUD.Checked;
                exam.MaxExamTimes   = 1;
                exam.MinExamTimes   = 0;

                exam.ExamTypeId       = 1;
                exam.Description      = txtDescription.Text;
                exam.AutoSaveInterval = 0;
                examBLL.UpdateExam(exam);

                ExamResultBLL reBll = new ExamResultBLL();

                IList <RailExam.Model.ExamResult> examResults = reBll.GetExamResultByExamID(int.Parse(strID));
                if (examResults.Count > 0)
                {
                    Response.Redirect("SelectEmployeeDetail.aspx?mode=" + strMode + "&id=" + strID);
                }
                else
                {
                    Response.Redirect("ExamManageSecond.aspx?mode=" + strMode + "&id=" + strID);
                }
            }
            else
            {
                strID = Request.QueryString.Get("id");
                ExamResultBLL reBll = new ExamResultBLL();

                IList <RailExam.Model.ExamResult> examResults = reBll.GetExamResultByExamID(int.Parse(strID));
                if (examResults.Count > 0)
                {
                    Response.Redirect("SelectEmployeeDetail.aspx?mode=" + strMode + "&id=" + strID);
                }
                else
                {
                    Response.Redirect("ExamManageSecond.aspx?mode=" + strMode + "&id=" + strID);
                }
            }
        }