コード例 #1
0
        protected void Grid1_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            string resultID   = ((HiddenField)Grid1.Rows[e.RowIndex].FindControl("hfID")).Value;
            string employeeID = ((HiddenField)Grid1.Rows[e.RowIndex].FindControl("hfExamineeID")).Value;
            string score      = ((TextBox)Grid1.Rows[e.RowIndex].FindControl("txtScore")).Text;

            RandomExamResultBLL objResultBll = new RandomExamResultBLL();

            if (resultID == "0")
            {
                RandomExamResult objResult = new RandomExamResult();
                objResult.OrganizationId  = Convert.ToInt32(ViewState["ExamOrgID"]);
                objResult.RandomExamId    = Convert.ToInt32(ViewState["ExamID"]);
                objResult.ExamineeId      = Convert.ToInt32(employeeID);
                objResult.BeginDateTime   = DateTime.Now;
                objResult.EndDateTime     = DateTime.Now;
                objResult.CurrentDateTime = DateTime.Now;
                objResult.ExamTime        = 0;
                objResult.AutoScore       = 0;
                objResult.Score           = Convert.ToDecimal(score);
                objResult.CorrectRate     = Convert.ToDecimal(score);
                objResult.IsPass          = Convert.ToDecimal(score) >= 60 ? true : false;
                objResult.StatusId        = 2;
                objResultBll.AddRandomExamResult(objResult);
            }
            else
            {
                RandomExamResult objResult = objResultBll.GetRandomExamResult(Convert.ToInt32(resultID));
                objResult.Score       = Convert.ToDecimal(score);
                objResult.CorrectRate = Convert.ToDecimal(score);
                objResult.IsPass      = Convert.ToDecimal(score) >= 60 ? true : false;
                objResultBll.UpdateRandomExamResultOther(objResult);
            }

            Grid1.EditIndex = -1;
            BindGrid();
        }