private Entities.SurveyPerson LoadSingleSurveyPerson(DataRow row) { Entities.SurveyPerson model = new Entities.SurveyPerson(); if (row["RecID"].ToString() != "") { model.RecID = int.Parse(row["RecID"].ToString()); } if (row["SPIID"].ToString() != "") { model.SPIID = int.Parse(row["SPIID"].ToString()); } if (row["ExamPersonID"].ToString() != "") { model.ExamPersonID = int.Parse(row["ExamPersonID"].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); }
/// <summary> /// 更新一条数据 /// </summary> public int Update(SqlTransaction sqltran, Entities.SurveyPerson model) { SqlParameter[] parameters = { new SqlParameter("@RecID", SqlDbType.Int, 4), new SqlParameter("@SPIID", SqlDbType.Int, 4), new SqlParameter("@ExamPersonID", SqlDbType.Int, 4), 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.ExamPersonID; parameters[3].Value = model.CreateTime; parameters[4].Value = model.CreateUserID; return(SqlHelper.ExecuteNonQuery(sqltran, CONNECTIONSTRINGS, CommandType.StoredProcedure, P_SURVEYPERSON_UPDATE, parameters)); }
/// <summary> /// 增加一条数据 /// </summary> public int Insert(Entities.SurveyPerson model) { SqlParameter[] parameters = { new SqlParameter("@RecID", SqlDbType.Int, 4), new SqlParameter("@SPIID", SqlDbType.Int, 4), new SqlParameter("@ExamPersonID", SqlDbType.Int, 4), new SqlParameter("@CreateTime", SqlDbType.DateTime), new SqlParameter("@CreateUserID", SqlDbType.Int, 4) }; parameters[0].Direction = ParameterDirection.Output; parameters[1].Value = model.SPIID; parameters[2].Value = model.ExamPersonID; parameters[3].Value = model.CreateTime; parameters[4].Value = model.CreateUserID; SqlHelper.ExecuteNonQuery(CONNECTIONSTRINGS, CommandType.StoredProcedure, P_SURVEYPERSON_INSERT, parameters); return((int)parameters[0].Value); }
/// <summary> /// 更新一条数据 /// </summary> public int Update(SqlTransaction sqltran, Entities.SurveyPerson model) { return(Dal.SurveyPerson.Instance.Update(sqltran, model)); }
/// <summary> /// 更新一条数据 /// </summary> public int Update(Entities.SurveyPerson model) { return(Dal.SurveyPerson.Instance.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Insert(Entities.SurveyPerson model) { return(Dal.SurveyPerson.Instance.Insert(model)); }
//保存调查项目 private void SubmitSurveyProject(out string msg) { msg = string.Empty; string errorMsg = string.Empty; #region 信息验证 int spiId = 0; if (!string.IsNullOrEmpty(SPIID)) { if (!int.TryParse(SPIID, out spiId)) { errorMsg += "不存在此调查项目!</br>"; } } if (string.IsNullOrEmpty(ProjectName.Trim())) { errorMsg += "调查名称不能为空!</br>"; } int bgId = 0; if (!int.TryParse(BGID, out bgId)) { errorMsg += "请选择所属分组!</br>"; } int scId = 0; if (!int.TryParse(SCID, out scId)) { errorMsg += "请选择分类!</br>"; } if (string.IsNullOrEmpty(Description.Trim())) { errorMsg += "调查说明不能为空!</br>"; } //if (string.IsNullOrEmpty(BusinessGroup.Trim())) //{ // errorMsg += "业务组不能为空!</br>"; //} int siId = 0; if (!int.TryParse(SIID, out siId)) { errorMsg += "请选择问卷!</br>"; } List <int> personIdArry = new List <int>(); if (string.IsNullOrEmpty(PersonIDS.Trim())) { errorMsg += "请选择调查对象!</br>"; } else { string[] strArry = PersonIDS.Split(','); foreach (string str in strArry) { int personId = -1; if (int.TryParse(str, out personId)) { personIdArry.Add(personId); } else { errorMsg += "调查对象选择有问题!</br>"; break; } } } DateTime beginTime = Entities.Constants.Constant.DATE_INVALID_VALUE; if (string.IsNullOrEmpty(BeginTime)) { errorMsg += "调查开始时间不能为空!</br>"; } else { if (!DateTime.TryParse(BeginTime, out beginTime)) { errorMsg += "调查开始时间格式不正确!</br>"; } else { if (beginTime < DateTime.Now) { errorMsg += "调查开始时间不能小于当前时间!</br>"; } } } DateTime endTime = Entities.Constants.Constant.DATE_INVALID_VALUE; if (string.IsNullOrEmpty(EndTime)) { errorMsg += "调查开始时间不能为空!</br>"; } else { if (!DateTime.TryParse(EndTime, out endTime)) { errorMsg += "调查开始时间格式不正确!</br>"; } else { if (endTime <= beginTime) { errorMsg += "调查结束时间不能小于开始时间!</br>"; } } } #endregion if (string.IsNullOrEmpty(errorMsg)) { //如果项目ID小于等于0,新增项目 if (spiId <= 0) { Entities.SurveyProjectInfo model = new Entities.SurveyProjectInfo(); model.BGID = bgId; model.BusinessGroup = BusinessGroup; model.CreateTime = DateTime.Now; model.CreateUserID = BLL.Util.GetLoginUserID(); model.Description = Description; model.Name = ProjectName; model.SCID = scId; model.SIID = siId; model.Status = 0; model.SurveyEndTime = endTime; model.SurveyStartTime = beginTime; //新增问卷项目 int recId = BLL.SurveyProjectInfo.Instance.Insert(model); //新增调查参与人 foreach (int personId in personIdArry) { Entities.SurveyPerson personModel = new Entities.SurveyPerson(); personModel.CreateTime = DateTime.Now; personModel.CreateUserID = BLL.Util.GetLoginUserID(); personModel.ExamPersonID = personId; personModel.SPIID = recId; BLL.SurveyPerson.Instance.Insert(personModel); } msg = "{Result:'success',RecID:'" + recId + "',ErrorMsg:''}"; } else { Entities.SurveyProjectInfo info = BLL.SurveyProjectInfo.Instance.GetSurveyProjectInfo(spiId); if (info != null) { if (info.SurveyStartTime <= DateTime.Now) { errorMsg += "此问卷正在调查中,无法进行编辑操作!</br>"; } else { info.BGID = bgId; info.BusinessGroup = BusinessGroup; info.Description = Description; info.Name = ProjectName; info.SCID = scId; info.SIID = siId; info.SurveyEndTime = endTime; info.SurveyStartTime = beginTime; info.ModifyTime = DateTime.Now; info.ModifyUserID = BLL.Util.GetLoginUserID(); BLL.SurveyProjectInfo.Instance.Update(info); BLL.SurveyPerson.Instance.DeleteBySPIID(spiId); foreach (int personId in personIdArry) { Entities.SurveyPerson personModel = new Entities.SurveyPerson(); personModel.CreateTime = DateTime.Now; personModel.CreateUserID = BLL.Util.GetLoginUserID(); personModel.ExamPersonID = personId; personModel.SPIID = spiId; BLL.SurveyPerson.Instance.Insert(personModel); } } } else { errorMsg += "不存在此问卷项目!</br>"; } if (string.IsNullOrEmpty(errorMsg)) { msg = "{Result:'success',RecID:'" + spiId + "',ErrorMsg:'" + errorMsg + "'}"; } else { msg = "{Result:'error',RecID:'',ErrorMsg:'" + errorMsg + "'}"; } } } else { msg = "{Result:'error',RecID:'',ErrorMsg:'" + errorMsg + "'}"; } }