/// <summary> /// 增加一条数据 /// </summary> public int Add(BWJS.Model.NLLoanConfig model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into dbo.[NLLoanConfig]("); strSql.Append("RecordCreateTime,KeyType,KeyName,KeyVal,Description,CreatUserID,RecordUpdateUserID,RecordIsDelete,RecordUpdateTime"); strSql.Append(") values ("); strSql.Append("@RecordCreateTime,@KeyType,@KeyName,@KeyVal,@Description,@CreatUserID,@RecordUpdateUserID,@RecordIsDelete,@RecordUpdateTime"); strSql.Append(") "); strSql.Append(";select SCOPE_IDENTITY()"); SqlParameter[] parameters = { new SqlParameter("@IsDeleted", model.IsDeleted), new SqlParameter("@TypeName", model.TypeName), new SqlParameter("@KeyName", model.KeyName), new SqlParameter("@KeyVal", model.KeyVal), new SqlParameter("@KeyDesc", model.KeyDesc), new SqlParameter("@CreateId", model.CreateId), new SqlParameter("@EditId", model.EditId), new SqlParameter("@IsDeleted", model.IsDeleted), new SqlParameter("@EditDate", model.EditDate) }; object obj = BWJSHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public BWJS.Model.NLLoanConfig GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select Id, RecordCreateTime, KeyType, KeyName, KeyVal, Description, CreatUserID, RecordUpdateUserID, RecordIsDelete, RecordUpdateTime "); strSql.Append(" from dbo.[NLLoanConfig] "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; BWJS.Model.NLLoanConfig model = new BWJS.Model.NLLoanConfig(); DataSet ds = BWJSHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// datarow转成对象实体 /// </summary> public BWJS.Model.NLLoanConfig DataRowToModel(DataRow row) { BWJS.Model.NLLoanConfig model = new BWJS.Model.NLLoanConfig(); if (row != null) { if (row["ID"].ToString() != "") { model.ID = int.Parse(row["ID"].ToString()); } if (row["CreateDate"].ToString() != "") { model.CreateDate = DateTime.Parse(row["CreateDate"].ToString()); } if (row["TypeName"].ToString() != "") { model.TypeName = row["TypeName"].ToString(); } model.KeyName = row["KeyName"].ToString(); model.KeyValue = row["KeyValue"].ToString(); model.KeyDesc = row["KeyDesc"].ToString(); if (row["CreateId"].ToString() != "") { model.CreateId = int.Parse(row["CreateId"].ToString()); } if (row["EditId"].ToString() != "") { model.EditId = int.Parse(row["EditId"].ToString()); } if (row["IsDeleted"].ToString() != "") { if ((row["IsDeleted"].ToString() == "1") || (row["IsDeleted"].ToString().ToLower() == "true")) { model.IsDeleted = 1; } else { model.IsDeleted = 0; } } if (row["EditDate"].ToString() != "") { model.EditDate = DateTime.Parse(row["EditDate"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(BWJS.Model.NLLoanConfig model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update dbo.[NLLoanConfig] set "); strSql.Append(" RecordCreateTime = @RecordCreateTime , "); strSql.Append(" KeyType = @KeyType , "); strSql.Append(" KeyName = @KeyName , "); strSql.Append(" KeyVal = @KeyVal , "); strSql.Append(" Description = @Description , "); strSql.Append(" CreatUserID = @CreatUserID , "); strSql.Append(" RecordUpdateUserID = @RecordUpdateUserID , "); strSql.Append(" RecordIsDelete = @RecordIsDelete , "); strSql.Append(" RecordUpdateTime = @RecordUpdateTime "); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@ID", model.ID), new SqlParameter("@IsDeleted", model.IsDeleted), new SqlParameter("@TypeName", model.TypeName), new SqlParameter("@KeyName", model.KeyName), new SqlParameter("@KeyVal", model.KeyVal), new SqlParameter("@KeyDesc", model.KeyDesc), new SqlParameter("@CreateId", model.CreateId), new SqlParameter("@EditId", model.EditId), new SqlParameter("@IsDeleted", model.IsDeleted), new SqlParameter("@EditDate", model.EditDate) }; int rows = BWJSHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(BWJS.Model.NLLoanConfig model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(BWJS.Model.NLLoanConfig model) { return(dal.Add(model)); }