Exemplo n.º 1
0
 /// <summary>
 ///  增加一条数据
 /// </summary>
 public int Insert(SqlTransaction sqltran, Entities.SurveyAnswer model)
 {
     SqlParameter[] parameters =
     {
         new SqlParameter("@RecID",                SqlDbType.Int,          4),
         new SqlParameter("@SPIID",                SqlDbType.Int,          4),
         new SqlParameter("@SIID",                 SqlDbType.Int,          4),
         new SqlParameter("@SQID",                 SqlDbType.Int,          4),
         new SqlParameter("@SMRTID",               SqlDbType.Int,          4),
         new SqlParameter("@SMCTID",               SqlDbType.Int,          4),
         new SqlParameter("@SOID",                 SqlDbType.Int,          4),
         new SqlParameter("@AnswerContent",        SqlDbType.NVarChar,  2000),
         new SqlParameter("@CreateTime",           SqlDbType.DateTime),
         new SqlParameter("@CreateUserID",         SqlDbType.Int,          4),
         new SqlParameter("@PTID",                 SqlDbType.VarChar,     20),
         new SqlParameter("@ReturnVisitCRMCustID", SqlDbType.VarChar)
     };
     parameters[0].Direction = ParameterDirection.Output;
     parameters[1].Value     = model.SPIID;
     parameters[2].Value     = model.SIID;
     parameters[3].Value     = model.SQID;
     parameters[4].Value     = model.SMRTID;
     parameters[5].Value     = model.SMCTID;
     parameters[6].Value     = model.SOID;
     parameters[7].Value     = model.AnswerContent;
     parameters[8].Value     = model.CreateTime;
     parameters[9].Value     = model.CreateUserID;
     parameters[10].Value    = model.PTID;
     parameters[11].Value    = model.ReturnVisitCRMCustID;
     SqlHelper.ExecuteNonQuery(sqltran, CommandType.StoredProcedure, P_SURVEYANSWER_INSERT, parameters);
     return((int)parameters[0].Value);
 }
Exemplo n.º 2
0
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public int Update(SqlTransaction sqltran, Entities.SurveyAnswer model)
        {
            SqlParameter[] parameters =
            {
                new SqlParameter("@RecID",         SqlDbType.Int,          4),
                new SqlParameter("@SPIID",         SqlDbType.Int,          4),
                new SqlParameter("@SIID",          SqlDbType.Int,          4),
                new SqlParameter("@SQID",          SqlDbType.Int,          4),
                new SqlParameter("@SMRTID",        SqlDbType.Int,          4),
                new SqlParameter("@SMCTID",        SqlDbType.Int,          4),
                new SqlParameter("@SOID",          SqlDbType.Int,          4),
                new SqlParameter("@AnswerContent", SqlDbType.NVarChar,  2000),
                new SqlParameter("@CreateTime",    SqlDbType.DateTime),
                new SqlParameter("@CreateUserID",  SqlDbType.Int, 4)
            };
            parameters[0].Value = model.RecID;
            parameters[1].Value = model.SPIID;
            parameters[2].Value = model.SIID;
            parameters[3].Value = model.SQID;
            parameters[4].Value = model.SMRTID;
            parameters[5].Value = model.SMCTID;
            parameters[6].Value = model.SOID;
            parameters[7].Value = model.AnswerContent;
            parameters[8].Value = model.CreateTime;
            parameters[9].Value = model.CreateUserID;

            return(SqlHelper.ExecuteNonQuery(sqltran, CONNECTIONSTRINGS, CommandType.StoredProcedure, P_SURVEYANSWER_UPDATE, parameters));
        }
Exemplo n.º 3
0
        private Entities.SurveyAnswer LoadSingleSurveyAnswer(DataRow row)
        {
            Entities.SurveyAnswer model = new Entities.SurveyAnswer();

            if (row["RecID"].ToString() != "")
            {
                model.RecID = int.Parse(row["RecID"].ToString());
            }
            if (row["SPIID"].ToString() != "")
            {
                model.SPIID = int.Parse(row["SPIID"].ToString());
            }
            if (row["SIID"].ToString() != "")
            {
                model.SIID = int.Parse(row["SIID"].ToString());
            }
            if (row["SQID"].ToString() != "")
            {
                model.SQID = int.Parse(row["SQID"].ToString());
            }
            if (row["SMRTID"].ToString() != "")
            {
                model.SMRTID = int.Parse(row["SMRTID"].ToString());
            }
            if (row["SMCTID"].ToString() != "")
            {
                model.SMCTID = int.Parse(row["SMCTID"].ToString());
            }
            if (row["SOID"].ToString() != "")
            {
                model.SOID = int.Parse(row["SOID"].ToString());
            }
            model.AnswerContent = row["AnswerContent"].ToString();
            if (row["CreateTime"].ToString() != "")
            {
                model.CreateTime = DateTime.Parse(row["CreateTime"].ToString());
            }
            if (row["CreateUserID"].ToString() != "")
            {
                model.CreateUserID = int.Parse(row["CreateUserID"].ToString());
            }
            return(model);
        }
Exemplo n.º 4
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
        }
Exemplo n.º 5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(SqlTransaction sqltran, Entities.SurveyAnswer model)
 {
     return(Dal.SurveyAnswer.Instance.Update(sqltran, model));
 }
Exemplo n.º 6
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public int Update(Entities.SurveyAnswer model)
 {
     return(Dal.SurveyAnswer.Instance.Update(model));
 }
Exemplo n.º 7
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public void Insert(SqlTransaction sqltran, Entities.SurveyAnswer model)
 {
     Dal.SurveyAnswer.Instance.Insert(sqltran, model);
 }
Exemplo n.º 8
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public void Insert(Entities.SurveyAnswer model)
 {
     Dal.SurveyAnswer.Instance.Insert(model);
 }
Exemplo n.º 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;
                }
                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
            {
                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());
                }

                msg = "success";

                tran.Commit();
            }
            catch (Exception ex)
            {
                if (tran.Connection != null)
                {
                    tran.Rollback();
                }
                msg = ex.Message.ToString();
            }
            finally
            {
                connection.Close();
            }

            #endregion
        }