/// <summary> /// 增加一条代码集表数据 /// </summary> /// <param name="model"></param> /// <returns>插入的最新主键值</returns> public int Add(CodeSetsEntity model, string creator) { model.creator = model.lastModifier = creator; model.createTime = model.lastModifyTime = DateTime.Now; model.delFlag = false; return(codeSetsDAL.Add(model)); }
/// <summary> /// 得到一个代码集表实体 /// </summary> /// <param name="code">代码编码</param> /// <returns>代码集表实体</returns> public CodeSetsEntity GetModel(string code) { SqlParameter[] parameters = { new SqlParameter("@code", SqlDbType.VarChar, 50) }; parameters[0].Value = code; DataSet ds = SQLServerHelper.RunProcedure("uspWip_GetSingleCodeSets", parameters, "pagetable"); CodeSetsEntity model = new CodeSetsEntity(); if (ds.Tables[0].Rows.Count > 0) { var dataRow = ds.Tables[0].Rows[0]; if (dataRow["id"].ToString() != "") { model.id = int.Parse(dataRow["id"].ToString()); } model.code = dataRow["code"].ToString(); model.name = dataRow["name"].ToString(); model.note = dataRow["note"].ToString(); if (dataRow["delFlag"].ToString() != "") { if ((dataRow["delFlag"].ToString() == "1") || (dataRow["delFlag"].ToString().ToLower() == "true")) { model.delFlag = true; } else { model.delFlag = false; } } model.creator = dataRow["creator"].ToString(); if (dataRow["createTime"].ToString() != "") { model.createTime = DateTime.Parse(dataRow["createTime"].ToString()); } model.lastModifier = dataRow["lastModifier"].ToString(); if (dataRow["lastModifyTime"].ToString() != "") { model.lastModifyTime = DateTime.Parse(dataRow["lastModifyTime"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 获得代码集表数据列表 /// </summary> private List <CodeSetsEntity> DataTableToList(DataTable dt) { List <CodeSetsEntity> modelList = new List <CodeSetsEntity>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { CodeSetsEntity model; for (int n = 0; n < rowsCount; n++) { model = new CodeSetsEntity(); var dataRow = dt.Rows[n]; if (dataRow["id"].ToString() != "") { model.id = int.Parse(dataRow["id"].ToString()); } model.code = dataRow["code"].ToString(); model.name = dataRow["name"].ToString(); model.note = dataRow["note"].ToString(); if (dataRow["delFlag"].ToString() != "") { if ((dataRow["delFlag"].ToString() == "1") || (dataRow["delFlag"].ToString().ToLower() == "true")) { model.delFlag = true; } else { model.delFlag = false; } } model.creator = dataRow["creator"].ToString(); if (dataRow["createTime"].ToString() != "") { model.createTime = DateTime.Parse(dataRow["createTime"].ToString()); } model.lastModifier = dataRow["lastModifier"].ToString(); if (dataRow["lastModifyTime"].ToString() != "") { model.lastModifyTime = DateTime.Parse(dataRow["lastModifyTime"].ToString()); } modelList.Add(model); } } return(modelList); }
/// <summary> /// 增加一条代码集表数据 /// </summary> /// <param name="model">要插入的代码集表实体</param> /// <param name="transModel">事务类</param> /// <returns>插入生成的最新主键值</returns> public int Add(CodeSetsEntity model, TransactionModel transModel = null) { SqlParameter param_id = new SqlParameter(); param_id.ParameterName = "@id"; param_id.SqlDbType = SqlDbType.Int; param_id.Direction = ParameterDirection.Output; SqlParameter[] parameters = { new SqlParameter("@code", SqlDbType.NVarChar, 20), new SqlParameter("@name", SqlDbType.NVarChar, 64), new SqlParameter("@note", SqlDbType.NVarChar, 100), new SqlParameter("@delFlag", SqlDbType.Bit, 1), new SqlParameter("@creator", SqlDbType.NVarChar, 256), new SqlParameter("@createTime", SqlDbType.DateTime), new SqlParameter("@lastModifier", SqlDbType.NVarChar, 256), new SqlParameter("@lastModifyTime", SqlDbType.DateTime), param_id }; parameters[0].Value = model.code; parameters[1].Value = model.name; parameters[2].Value = model.note; parameters[3].Value = model.delFlag; parameters[4].Value = model.creator; parameters[5].Value = model.createTime; parameters[6].Value = model.lastModifier; parameters[7].Value = model.lastModifyTime; int rowsAffected; if (transModel != null) { SQLServerHelper.RunProcedure(transModel.conn, transModel.trans, "uspWip_AddCodeSets", parameters, out rowsAffected); } else { SQLServerHelper.RunProcedure("uspWip_AddCodeSets", parameters, out rowsAffected); } return((int)parameters[parameters.Length - 1].Value); }
/// <summary> /// 更新一条代码集表数据 /// </summary> /// <param name="model">要更新的代码集表实体</param> /// <param name="transModel">事务类</param> /// <returns>是否更新成功</returns> public bool Update(CodeSetsEntity model, TransactionModel transModel = null) { SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4), new SqlParameter("@code", SqlDbType.NVarChar, 20), new SqlParameter("@name", SqlDbType.NVarChar, 64), new SqlParameter("@note", SqlDbType.NVarChar, 100), new SqlParameter("@delFlag", SqlDbType.Bit, 1), new SqlParameter("@lastModifier", SqlDbType.NVarChar, 256), new SqlParameter("@lastModifyTime", SqlDbType.DateTime), }; parameters[0].Value = model.id; parameters[1].Value = model.code; parameters[2].Value = model.name; parameters[3].Value = model.note; parameters[4].Value = model.delFlag; parameters[5].Value = model.lastModifier; parameters[6].Value = model.lastModifyTime; int rowsAffected = 0; if (transModel != null) { SQLServerHelper.RunProcedure(transModel.conn, transModel.trans, "uspWip_UpdateCodeSets", parameters, out rowsAffected); } else { SQLServerHelper.RunProcedure("uspWip_UpdateCodeSets", parameters, out rowsAffected); } if (rowsAffected > 0) { return(true); } else { return(false); } }
/// <summary> /// 更新一条代码集表数据 /// </summary> /// <param name="model">要更新的代码集表实体</param> /// <returns>是否更新成功</returns> public bool Update(CodeSetsEntity model) { model.lastModifyTime = DateTime.Now; return(codeSetsDAL.Update(model)); }
public string InsertCodeSets0(CodeSetsEntity model) { return("OK"); }
/// <summary> /// 插入代码集表 /// </summary> /// <param name="model"></param> /// <returns></returns> public ReturnBody <string> InsertCodeSets(CodeSetsEntity model) { ReturnBody <string> retBody = null; ExceptionInfoEntity exception = WipLogHelper.GetExceptionInfo <CodeSetsEntity>(namespaceName, "InsertCodeSets", model); try { #region 验证 if (model == null) { exception.exceptionMsg = ResMsg.PARAMETERNOEMPTY; retBody = BLLHelpler.GetReturnBody <string>(ResCode.PARAMETERNOEMPTY, ResMsg.PARAMETERNOEMPTY, exception); return(retBody); } List <ColumnsModel> columnsList = new List <ColumnsModel>() { new ColumnsModel() { ChinaName = "代码编码", PropertyName = "code" }, new ColumnsModel() { ChinaName = "代码名称", PropertyName = "name" }, new ColumnsModel() { ChinaName = "说明", PropertyName = "note" }, new ColumnsModel() { ChinaName = "创建时间", PropertyName = "createTime", DataType = typeof(DateTime), IsNullable = true }, new ColumnsModel() { ChinaName = "修改时间", PropertyName = "lastModifyTime", DataType = typeof(DateTime), IsNullable = true }, }; ValidateResModel res = ValidateDataHelper.ValidateNullOrEmpty <CodeSetsEntity>(columnsList, model); if (res != null && !res.IsValidate) { exception.exceptionMsg = res.ValidateMsg; retBody = BLLHelpler.GetReturnBody <string>(ResCode.PARAMETERNOEMPTY, res.ValidateMsg, exception); return(retBody); } //验证重复 if (codeSetsBLL.Exists(model.code.ToString())) { exception.exceptionMsg = "数据已经存在"; retBody = BLLHelpler.GetReturnBody <string>(ResCode.FAILURE, exception.exceptionMsg, exception); return(retBody); } #endregion string creator = JwtHelp.GetCurUserName(); if (codeSetsBLL.Add(model, creator) > 0) { retBody = BLLHelpler.GetReturnBody <string>(ResCode.SUCCESS, ResMsg.SUCCESS); } else {//失败 exception.exceptionMsg = "保存数据失败"; retBody = BLLHelpler.GetReturnBody <string>(ResCode.FAILURE, exception.exceptionMsg, exception); } return(retBody); } catch (Exception ex) { WipLogHelper.GetExceptionInfoForError(ex, ref exception); retBody = BLLHelpler.GetReturnBody <string>(ResCode.FAILURE, ResMsg.FAILURE + ":" + ex.Message, exception); return(retBody); } }
public string UpdateCodeSets0(CodeSetsEntity model) { return("OK"); }