/// <summary> /// 查询面试评测要素信息 /// </summary> /// <param name="model">查询条件</param> /// <returns></returns> public static DataTable SearchCheckElemInfo(RectCheckElemModel model) { #region 查询语句 //查询SQL拼写 StringBuilder searchSql = new StringBuilder(); searchSql.AppendLine(" SELECT "); searchSql.AppendLine(" ID "); searchSql.AppendLine(" ,ISNULL(ElemName, '') AS ElemName "); searchSql.AppendLine(" ,ISNULL(Standard, '') AS Standard "); searchSql.AppendLine(" ,ISNULL(Remark, '') AS Remark "); searchSql.AppendLine(" ,CASE UsedStatus "); searchSql.AppendLine(" WHEN '0' THEN '停用' "); searchSql.AppendLine(" WHEN '1' THEN '启用' "); searchSql.AppendLine(" ELSE '' "); searchSql.AppendLine(" END AS UsedStatusName ,isnull( Convert(varchar(100),ModifiedDate,23),'') AS ModifiedDate "); searchSql.AppendLine(" FROM "); searchSql.AppendLine(" officedba.RectCheckElem "); searchSql.AppendLine(" WHERE "); searchSql.AppendLine(" CompanyCD = @CompanyCD "); #endregion //定义查询的命令 SqlCommand comm = new SqlCommand(); //添加公司代码参数 comm.Parameters.Add(SqlHelper.GetParameterFromString("@CompanyCD", model.CompanyCD)); //要素名称 if (!string.IsNullOrEmpty(model.ElemName)) { searchSql.AppendLine(" AND ElemName LIKE '%' + @ElemName + '%' "); comm.Parameters.Add(SqlHelper.GetParameterFromString("@ElemName", model.ElemName)); } //启用状态 if (!string.IsNullOrEmpty(model.UsedStatus)) { searchSql.AppendLine(" AND UsedStatus = @UsedStatus "); comm.Parameters.Add(SqlHelper.GetParameterFromString("@UsedStatus", model.UsedStatus)); } //指定命令的SQL文 comm.CommandText = searchSql.ToString(); //执行查询 return(SqlHelper.ExecuteSearch(comm)); }
/// <summary> /// 添加面试评测要素信息 /// </summary> /// <param name="model">面试评测要素信息</param> /// <returns></returns> public static bool InsertCheckElemInfo(RectCheckElemModel model) { #region 插入SQL拼写 StringBuilder insertSql = new StringBuilder(); insertSql.AppendLine(" INSERT INTO officedba.RectCheckElem "); insertSql.AppendLine(" (CompanyCD "); insertSql.AppendLine(" ,ElemName "); insertSql.AppendLine(" ,Standard "); insertSql.AppendLine(" ,Remark "); insertSql.AppendLine(" ,UsedStatus "); insertSql.AppendLine(" ,ModifiedDate "); insertSql.AppendLine(" ,ModifiedUserID) "); insertSql.AppendLine(" VALUES "); insertSql.AppendLine(" (@CompanyCD "); insertSql.AppendLine(" ,@ElemName "); insertSql.AppendLine(" ,@Standard "); insertSql.AppendLine(" ,@Remark "); insertSql.AppendLine(" ,@UsedStatus "); insertSql.AppendLine(" ,getdate() "); insertSql.AppendLine(" ,@ModifiedUserID) "); insertSql.AppendLine(" set @ElemID= @@IDENTITY "); #endregion //定义插入基本信息的命令 SqlCommand comm = new SqlCommand(); comm.CommandText = insertSql.ToString(); //设置保存的参数 SetSaveParameter(comm, model); //添加返回参数 comm.Parameters.Add(SqlHelper.GetOutputParameter("@ElemID", SqlDbType.Int)); //执行插入操作 bool isSucc = SqlHelper.ExecuteTransWithCommand(comm); //设置ID model.ID = comm.Parameters["@ElemID"].Value.ToString(); //返回更新结果 return(isSucc); }
/// <summary> /// 编辑面试评测要素信息 /// </summary> /// <param name="model">保存信息</param> /// <returns></returns> public static bool SaveRectCheckElemInfo(RectCheckElemModel model) { //获取登陆用户信息 UserInfoUtil userInfo = (UserInfoUtil)SessionUtil.Session["UserInfo"]; //设置公司代码 model.CompanyCD = userInfo.CompanyCD; //设置最后修改者 model.ModifiedUserID = userInfo.UserID; //定义返回变量 bool isSucc = false; //操作日志 LogInfoModel logModel = InitLogInfo(model.ID); //更新 if (ConstUtil.EDIT_FLAG_UPDATE.Equals(model.EditFlag)) { try { logModel.Element = ConstUtil.LOG_PROCESS_UPDATE; //执行更新操作 isSucc = RectCheckElemDBHelper.UpdateCheckElemInfo(model); } catch (Exception ex) { //输出系统日志 WriteSystemLog(userInfo, ex); } } //插入 else { try { logModel.Element = ConstUtil.LOG_PROCESS_INSERT; //执行插入操作 isSucc = RectCheckElemDBHelper.InsertCheckElemInfo(model); logModel.ObjectID = model.ID; } 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); }