/// <summary> /// 编辑考试记录信息 /// </summary> /// <param name="model">保存信息</param> /// <returns></returns> public static bool SaveTestInfo(EmployeeTestModel model) { //获取登陆用户信息 UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"]; //设置公司代码 model.CompanyCD = userInfo.CompanyCD; model.ModifiedUserID = userInfo.UserID; //定义返回变量 bool isSucc = false; //操作日志 LogInfoModel logModel = InitLogInfo(model.TestNo); //更新 if (ConstUtil.EDIT_FLAG_UPDATE.Equals(model.EditFlag)) { try { logModel.Element = ConstUtil.LOG_PROCESS_UPDATE; //执行更新操作 isSucc = EmployeeTestDBHelper.UpdateEmployeeTestInfo(model); } catch (Exception ex) { //输出系统日志 WriteSystemLog(userInfo, ex); } } //插入 else { try { logModel.Element = ConstUtil.LOG_PROCESS_INSERT; //执行插入操作 isSucc = EmployeeTestDBHelper.InsertEmployeeTestInfo(model); } catch (Exception ex) { //输出系统日志 WriteSystemLog(userInfo, ex); } } //更新成功时 if (isSucc) { //设置操作成功标识 logModel.Remark = ConstUtil.LOG_PROCESS_SUCCESS; } //更新不成功 else { //设置操作成功标识 logModel.Remark = ConstUtil.LOG_PROCESS_FAILED; } //登陆日志 LogDBHelper.InsertLog(logModel); return isSucc; }
/// <summary> /// 添加考试记录信息 /// </summary> /// <param name="model">考试信息</param> /// <returns></returns> public static bool InsertEmployeeTestInfo(EmployeeTestModel model) { #region 插入SQL拼写 StringBuilder insertSql = new StringBuilder(); insertSql.AppendLine(" INSERT INTO officedba.EmployeeTest "); insertSql.AppendLine(" (CompanyCD "); insertSql.AppendLine(" ,TestNo "); insertSql.AppendLine(" ,Title "); insertSql.AppendLine(" ,Teacher "); insertSql.AppendLine(" ,StartDate "); insertSql.AppendLine(" ,EndDate "); insertSql.AppendLine(" ,Addr "); insertSql.AppendLine(" ,TestContent "); insertSql.AppendLine(" ,TestResult "); insertSql.AppendLine(" ,Remark "); insertSql.AppendLine(" ,Status "); insertSql.AppendLine(" ,Attachment "); insertSql.AppendLine(" ,AttachmentName "); insertSql.AppendLine(" ,AbsenceCount "); insertSql.AppendLine(" ,ModifiedDate "); insertSql.AppendLine(" ,ModifiedUserID) "); insertSql.AppendLine(" VALUES "); insertSql.AppendLine(" (@CompanyCD "); insertSql.AppendLine(" ,@TestNo "); insertSql.AppendLine(" ,@Title "); insertSql.AppendLine(" ,@Teacher "); insertSql.AppendLine(" ,@StartDate "); insertSql.AppendLine(" ,@EndDate "); insertSql.AppendLine(" ,@Addr "); insertSql.AppendLine(" ,@TestContent "); insertSql.AppendLine(" ,@TestResult "); insertSql.AppendLine(" ,@Remark "); insertSql.AppendLine(" ,@Status "); insertSql.AppendLine(" ,@Attachment "); insertSql.AppendLine(" ,@AttachmentName "); insertSql.AppendLine(" ,@AbsenceCount "); insertSql.AppendLine(" ,getdate() "); insertSql.AppendLine(" ,@ModifiedUserID) "); #endregion //定义更新基本信息的命令 SqlCommand comm = new SqlCommand(); comm.CommandText = insertSql.ToString(); //设置保存的参数 SetSaveParameter(comm, model); //定义更新列表 ArrayList lstInsert = new ArrayList(); //添加基本信息更新命令 lstInsert.Add(comm); //考核结果 EditResultInfo(lstInsert, model.ScoreList, model.TestNo, model.CompanyCD, model.ModifiedUserID); //执行更新操作并返回更新结果 return SqlHelper.ExecuteTransWithArrayList(lstInsert); }
/// <summary> /// 更新考试记录信息 /// </summary> /// <param name="model">保存信息</param> /// <returns></returns> public static bool UpdateEmployeeTestInfo(EmployeeTestModel model) { #region 更新SQL拼写 StringBuilder updateSql = new StringBuilder(); updateSql.AppendLine(" UPDATE officedba.EmployeeTest "); updateSql.AppendLine(" SET "); updateSql.AppendLine(" Title = @Title "); updateSql.AppendLine(" ,Teacher = @Teacher "); updateSql.AppendLine(" ,StartDate = @StartDate "); updateSql.AppendLine(" ,EndDate = @EndDate "); updateSql.AppendLine(" ,Addr = @Addr "); updateSql.AppendLine(" ,TestContent = @TestContent "); updateSql.AppendLine(" ,TestResult = @TestResult "); updateSql.AppendLine(" ,Remark = @Remark "); updateSql.AppendLine(" ,Status = @Status "); updateSql.AppendLine(" ,Attachment = @Attachment "); updateSql.AppendLine(" ,AttachmentName = @AttachmentName "); updateSql.AppendLine(" ,AbsenceCount = @AbsenceCount "); updateSql.AppendLine(" ,ModifiedDate = getdate() "); updateSql.AppendLine(" ,ModifiedUserID = @ModifiedUserID "); updateSql.AppendLine(" WHERE "); updateSql.AppendLine(" CompanyCD = @CompanyCD "); updateSql.AppendLine(" AND TestNo = @TestNo "); #endregion //定义更新基本信息的命令 SqlCommand comm = new SqlCommand(); comm.CommandText = updateSql.ToString(); //设置保存的参数 SetSaveParameter(comm, model); //定义更新列表 ArrayList lstUpdate = new ArrayList(); //添加基本信息更新命令 lstUpdate.Add(comm); //登陆或者更新进度安排信息 EditResultInfo(lstUpdate, model.ScoreList, model.TestNo, model.CompanyCD, model.ModifiedUserID); //执行更新操作并返回更新结果 return SqlHelper.ExecuteTransWithArrayList(lstUpdate); }
/// <summary> /// 保存时基本信息参数设置 /// </summary> /// <param name="comm">命令</param> /// <param name="model">保存信息</param> private static void SetSaveParameter(SqlCommand comm, EmployeeTestModel model) { //设置参数 comm.Parameters.Add(SqlHelper.GetParameterFromString("@CompanyCD", model.CompanyCD));//公司代码 comm.Parameters.Add(SqlHelper.GetParameterFromString("@TestNo", model.TestNo));//考试编号 comm.Parameters.Add(SqlHelper.GetParameterFromString("@Title", model.Title));//主题 comm.Parameters.Add(SqlHelper.GetParameterFromString("@Teacher", model.Teacher));//考试负责人ID(对应员工表ID) comm.Parameters.Add(SqlHelper.GetParameterFromString("@StartDate", model.StartDate));//开始时间 comm.Parameters.Add(SqlHelper.GetParameterFromString("@EndDate", model.EndDate));//结束时间 comm.Parameters.Add(SqlHelper.GetParameterFromString("@Addr", model.Addr));//考试地点 comm.Parameters.Add(SqlHelper.GetParameterFromString("@TestContent", model.TestContent));//考试内容摘要 comm.Parameters.Add(SqlHelper.GetParameterFromString("@TestResult", model.TestResult));//考试结果 comm.Parameters.Add(SqlHelper.GetParameterFromString("@Remark", model.Remark));//备注 comm.Parameters.Add(SqlHelper.GetParameterFromString("@Status", model.Status));//考试状态(0未开始,1已结束) comm.Parameters.Add(SqlHelper.GetParameterFromString("@Attachment", model.PageAttachment));//附件 comm.Parameters.Add(SqlHelper.GetParameterFromString("@AttachmentName", model.AttachmentName));//附件名称 comm.Parameters.Add(SqlHelper.GetParameterFromString("@AbsenceCount", model.AbsenceCount));//缺考人数 comm.Parameters.Add(SqlHelper.GetParameterFromString("@ModifiedUserID", model.ModifiedUserID));//更新用户ID }