Example #1
0
        public JsonResult AddErrorQuestion(Question_ErrorCollection newerror, string[] qtype, string[] errorreason)
        {
            ErrorCollectionbll bll        = new ErrorCollectionbll();
            string             statuscode = "200";
            string             msg        = "";

            try
            {
                Guid pkid = Guid.NewGuid();
                newerror.PKID       = pkid;
                newerror.UserID     = user.userid;
                newerror.EditDate   = DateTime.Now;
                newerror.ErrorTimes = 1;
                newerror.status     = "0";
                bll.AddErrorQuestion(newerror);
                foreach (string item in qtype)
                {
                    Rel_Question_TypeAndError typerelation = new Rel_Question_TypeAndError();
                    typerelation.PKID  = Guid.NewGuid();
                    typerelation.QTID  = new Guid(item);
                    typerelation.QECID = pkid;
                    bll.AddRelationType(typerelation);
                }
                foreach (string item in errorreason)
                {
                    Rel_Question_ReasonAndError reasonrelation = new Rel_Question_ReasonAndError();
                    reasonrelation.PKID  = Guid.NewGuid();
                    reasonrelation.ERID  = new Guid(item);
                    reasonrelation.QECID = pkid;
                    bll.AddRelationReason(reasonrelation);
                }
            }
            catch (Exception)
            {
                statuscode = "500";
                msg        = "操作失败,请重试!";
            }
            JsonResult jr = new JsonResult {
                Data = new { statuscode, msg }
            };

            return(Json(jr, JsonRequestBehavior.AllowGet));
        }
Example #2
0
 public JsonResult SaveErrorFromTaixue(Question_ErrorCollection model, Guid[] types, Guid[] reasons)
 {
     try
     {
         model.UserID = loginId;
         ErrorCollectionbll errorCollectionbll = new ErrorCollectionbll();
         errorCollectionbll.AddErrorQuestion(model);
         foreach (var type in types)
         {
             Rel_Question_TypeAndError typeAndError = new Rel_Question_TypeAndError();
             typeAndError.PKID  = Guid.NewGuid();
             typeAndError.QECID = model.PKID;
             typeAndError.QTID  = type;
             errorCollectionbll.AddRelationType(typeAndError);
         }
         foreach (var reason in reasons)
         {
             Rel_Question_ReasonAndError resAndError = new Rel_Question_ReasonAndError();
             resAndError.PKID  = Guid.NewGuid();
             resAndError.ERID  = reason;
             resAndError.QECID = model.PKID;
             errorCollectionbll.AddRelationReason(resAndError);
         }
         var result = new
         {
             flag = true
         };
         return(Json(result, JsonRequestBehavior.AllowGet));
     }
     catch (Exception e)
     {
         var result = new
         {
             flag  = false,
             error = e.Message + "\n" + e.InnerException.ToString() + "\n" + e.StackTrace
         };
         return(Json(result, JsonRequestBehavior.AllowGet));
     }
 }