예제 #1
0
        /// <summary>
        ///  增加一条数据
        /// </summary>
        public int Insert(Entities.ProjectTask_SurveyAnswer model)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@RecID",             SqlDbType.Int,        4),
                new SqlParameter("@PTID",              SqlDbType.VarChar,   20),
                new SqlParameter("@ProjectID",         SqlDbType.Int,        8),
                new SqlParameter("@SIID",              SqlDbType.Int,        4),
                new SqlParameter("@CreateTime",        SqlDbType.DateTime),
                new SqlParameter("@CreateUserID",      SqlDbType.Int,        4),
                new SqlParameter("@ReturnVisitCustID", SqlDbType.VarChar),
                new SqlParameter("@Status",            SqlDbType.Int),
            };
            parameters[0].Direction = ParameterDirection.Output;
            parameters[1].Value     = model.PTID;
            parameters[2].Value     = model.ProjectID;
            parameters[3].Value     = model.SIID;
            parameters[4].Value     = model.CreateTime;
            parameters[5].Value     = model.CreateUserID;
            parameters[6].Value     = model.ReturnVisitCustID;
            parameters[7].Value     = model.Status;

            SqlHelper.ExecuteNonQuery(CONNECTIONSTRINGS, CommandType.StoredProcedure, P_PROJECTTASK_SURVEYANSWER_INSERT, parameters);
            return((int)parameters[0].Value);
        }
예제 #2
0
        public Entities.ProjectTask_SurveyAnswer LoadSingleProjectTask_SurveyAnswer(DataRow row)
        {
            Entities.ProjectTask_SurveyAnswer model = new Entities.ProjectTask_SurveyAnswer();

            if (row["RecID"].ToString() != "")
            {
                model.RecID = long.Parse(row["RecID"].ToString());
            }
            model.PTID = row["PTID"].ToString();
            if (row["ProjectID"].ToString() != "")
            {
                model.ProjectID = long.Parse(row["ProjectID"].ToString());
            }
            if (row["SIID"].ToString() != "")
            {
                model.SIID = int.Parse(row["SIID"].ToString());
            }
            if (row["CreateTime"].ToString() != "")
            {
                model.CreateTime = DateTime.Parse(row["CreateTime"].ToString());
            }
            if (row["CreateUserID"].ToString() != "")
            {
                model.CreateUserID = int.Parse(row["CreateUserID"].ToString());
            }
            if (row["ReturnVisitCustID"].ToString() != "")
            {
                model.ReturnVisitCustID = row["ReturnVisitCustID"].ToString();
            }
            if (row["Status"].ToString() != "")
            {
                model.Status = int.Parse(row["Status"].ToString());
            }
            return(model);
        }
예제 #3
0
        public int UpdateCreateTimeAndStatus(SqlTransaction tran, Entities.ProjectTask_SurveyAnswer model)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@CreateTime", SqlDbType.DateTime),
                new SqlParameter("@RecID",      SqlDbType.BigInt,8),
                new SqlParameter("@Status",     SqlDbType.Int, 4)
            };
            parameters[0].Value = model.CreateTime;
            parameters[1].Value = model.RecID;
            parameters[2].Value = model.Status;
            string sql = "UPDATE dbo.ProjectTask_SurveyAnswer SET CreateTime=@CreateTime,Status=@Status WHERE RecID=@RecID";

            return(SqlHelper.ExecuteNonQuery(tran, CommandType.Text, sql, parameters));
        }
예제 #4
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public int Update(SqlTransaction sqltran, Entities.ProjectTask_SurveyAnswer model)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@PTID",              SqlDbType.VarChar,   20),
                new SqlParameter("@ProjectID",         SqlDbType.BigInt,     8),
                new SqlParameter("@SIID",              SqlDbType.Int,        4),
                new SqlParameter("@CreateTime",        SqlDbType.DateTime),
                new SqlParameter("@CreateUserID",      SqlDbType.Int,        4),
                new SqlParameter("@ReturnVisitCustID", SqlDbType.VarChar),
                new SqlParameter("@Status",            SqlDbType.Int)
            };

            parameters[0].Value = model.PTID;
            parameters[1].Value = model.ProjectID;
            parameters[2].Value = model.SIID;
            parameters[3].Value = model.CreateTime;
            parameters[4].Value = model.CreateUserID;
            parameters[5].Value = model.ReturnVisitCustID;
            parameters[6].Value = model.Status;

            return(SqlHelper.ExecuteNonQuery(sqltran, CommandType.StoredProcedure, P_PROJECTTASK_SURVEYANSWER_UPDATE, parameters));
        }
 public int UpdateCreateTimeAndStatus(SqlTransaction tran, Entities.ProjectTask_SurveyAnswer model)
 {
     return(Dal.ProjectTask_SurveyAnswer.Instance.UpdateCreateTimeAndStatus(tran, model));
 }
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(SqlTransaction sqltran, Entities.ProjectTask_SurveyAnswer model)
 {
     return(Dal.ProjectTask_SurveyAnswer.Instance.Update(sqltran, model));
 }
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(Entities.ProjectTask_SurveyAnswer model)
 {
     return(Dal.ProjectTask_SurveyAnswer.Instance.Update(model));
 }
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int Insert(Entities.ProjectTask_SurveyAnswer model)
 {
     return(Dal.ProjectTask_SurveyAnswer.Instance.Insert(model));
 }
예제 #9
0
        //问卷调查提交
        private void surveyAnswerSubmit(out string msg)
        {
            msg = string.Empty;
            judgeIsCorrect(out msg);
            if (msg != "success")
            {
                return;
            }

            #region 提交准备数据

            SurveyAnswerRoot             modelRoot          = null;
            List <Entities.SurveyAnswer> list_ESurveyAnswer = new List <Entities.SurveyAnswer>();
            ArrayList array_UserActionLog = new ArrayList();//日志

            modelRoot = (SurveyAnswerRoot)Newtonsoft.Json.JavaScriptConvert.DeserializeObject(RequestJsonSurveyAnswer, typeof(SurveyAnswerRoot));
            if (modelRoot == null)
            {
                msg = "提交的问卷数据不存在";
                return;
            }

            for (int i = 0; i < modelRoot.DataRoot.Length; i++)
            {
                Entities.SurveyAnswer model = new Entities.SurveyAnswer();

                SurveyAnswer answer = modelRoot.DataRoot[i];
                int          _spiid;
                if (int.TryParse(RequestSPIID, out _spiid))
                {
                    model.SPIID = _spiid;
                }
                if (!string.IsNullOrEmpty(RequestPTID))
                {
                    model.PTID = RequestPTID;
                }
                int _siid;
                if (int.TryParse(RequestSIID, out _siid))
                {
                    model.SIID = _siid;
                }
                int _sqid;
                if (int.TryParse(answer.SQID, out _sqid))
                {
                    model.SQID = _sqid;
                }
                int _smrtid;
                if (int.TryParse(answer.SMRTID, out _smrtid))
                {
                    model.SMRTID = _smrtid;
                }
                int _smctid;
                if (int.TryParse(answer.SMCTID, out _smctid))
                {
                    model.SMCTID = _smctid;
                }
                int _soid;
                if (int.TryParse(answer.SOID, out _soid))
                {
                    model.SOID = _soid;
                }
                model.AnswerContent = answer.AnswerContent;
                model.CreateUserID  = userID;
                model.CreateTime    = DateTime.Now;

                list_ESurveyAnswer.Add(model);

                string logStr = string.Empty;
                logStr = "调查问卷回答信息表【插入】问卷调查项目ID【" + model.SPIID + "】调查问卷ID【" + model.SIID + "】调查问卷试题ID【" + model.SQID + "】提交人【" + model.CreateUserID + "】调查问卷矩阵行ID【" + model.SMRTID + "】矩阵列ID【" + model.SMCTID + "】调查问卷选项ID【" + model.SOID + "】回答内容【" + model.AnswerContent + "】创建时间【" + model.CreateTime + "】";

                array_UserActionLog.Add(logStr);
            }

            #endregion

            #region 事务提交

            string        connectionstrings = ConfigurationUtil.GetAppSettingValue("ConnectionStrings_CC");
            SqlConnection connection        = new SqlConnection(connectionstrings);
            connection.Open();
            SqlTransaction tran = connection.BeginTransaction("SampleTransaction");
            try
            {
                //删除之前的答案
                if (!string.IsNullOrEmpty(RequestPTID))
                {
                    int _siid1;
                    if (int.TryParse(RequestSIID, out _siid1))
                    {
                        BLL.SurveyAnswer.Instance.Delete(tran, _siid1, RequestPTID);
                    }
                }



                for (int i = 0; i < list_ESurveyAnswer.Count; i++)
                {
                    BLL.SurveyAnswer.Instance.Insert(tran, list_ESurveyAnswer[i]);
                }
                for (int i = 0; i < array_UserActionLog.Count; i++)
                {
                    BLL.Util.InsertUserLog(tran, array_UserActionLog[i].ToString());
                }

                //是否答过题,默认答没答过
                bool flag = false;
                if (list_ESurveyAnswer.Count == 0)
                {
                    flag = false;
                }
                else
                {
                    for (int i = 0; i < list_ESurveyAnswer.Count; i++)
                    {
                        if (list_ESurveyAnswer[i].SOID != -2 || list_ESurveyAnswer[i].AnswerContent != "" || list_ESurveyAnswer[i].SMCTID != -2 || list_ESurveyAnswer[i].SMRTID != -2)
                        {
                            flag = true;
                        }
                    }
                }
                //答过题记录
                if (flag == true)
                {
                    //判断该项目,该任务,该问卷,是否已有答问卷记录,没有插入
                    DataTable dt = null;
                    Entities.QueryProjectTask_SurveyAnswer querey = new Entities.QueryProjectTask_SurveyAnswer();
                    querey.PTID = RequestPTID;

                    int _projectID;
                    if (int.TryParse(RequestProjectID, out _projectID))
                    {
                    }
                    querey.ProjectID = _projectID;
                    int _siid;
                    if (int.TryParse(RequestSIID, out _siid))
                    {
                    }
                    querey.SIID = _siid;
                    //int rowcount = 0;
                    //dt = BLL.ProjectTask_SurveyAnswer.Instance.GetProjectTask_SurveyAnswer(tran, querey, "", 1, 1000000, out rowcount);
                    Entities.ProjectTask_SurveyAnswer getModel = BLL.ProjectTask_SurveyAnswer.Instance.GetProjectTask_SurveyAnswerByQuery(tran, querey);
                    if (getModel == null)
                    {
                        Entities.ProjectTask_SurveyAnswer model = new Entities.ProjectTask_SurveyAnswer();
                        model.ProjectID    = _projectID;
                        model.PTID         = RequestPTID;
                        model.SIID         = _siid;
                        model.CreateTime   = System.DateTime.Now;
                        model.CreateUserID = BLL.Util.GetLoginUserID();
                        model.Status       = RequestIsSub;
                        BLL.ProjectTask_SurveyAnswer.Instance.Insert(tran, model);
                    }
                    else
                    {
                        getModel.CreateTime = DateTime.Now;
                        getModel.Status     = RequestIsSub;
                        BLL.ProjectTask_SurveyAnswer.Instance.UpdateCreateTimeAndStatus(tran, getModel);
                    }
                }
                msg = "success";

                tran.Commit();
            }
            catch (Exception ex)
            {
                BitAuto.ISDC.CC2012.BLL.Loger.Log4Net.Error("[TakingAnSurveyHandler.ashx]surveyAnswerSubmit...任务ID:" + RequestPTID + ",事务提交阶段出错:", ex);
                if (tran.Connection != null)
                {
                    tran.Rollback();
                }
                msg = ex.Message.ToString();
            }
            finally
            {
                connection.Close();
            }

            #endregion
        }