/// <summary> /// ����һ������ /// </summary> /// <param name="model">model</param> public int AddRecord(ToolRemindTypeData model) { StringBuilder strSql = new StringBuilder(); strSql.Append("set nocount on; "); strSql.Append("insert into ToolRemindType("); strSql.Append("typeNo,typeNm)"); strSql.Append(" values ("); strSql.Append("@typeNo,@typeNm)"); strSql.Append("; select @@identity; set nocount off; "); SqlParameter[] parameters = { new SqlParameter("@typeNo", SqlDbType.NVarChar,2), new SqlParameter("@typeNm", SqlDbType.NVarChar,20) }; parameters[0].Value = model.typeNo; parameters[1].Value = model.typeNm; int id = 0; try { object ret = SqlHelper.ExecuteScalar(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); if (ret != null && ret != DBNull.Value) { id = Convert.ToInt32(ret); } } catch (Exception ex) { throw ex; } return id; }
/// <summary> /// ����һ������ /// </summary> /// <param name="model">model</param> public bool ModifyRecord(ToolRemindTypeData model) { bool ret = false; StringBuilder strSql = new StringBuilder(); strSql.Append("update ToolRemindType set "); strSql.Append("typeNm=@typeNm"); strSql.Append(" where typeNo = @typeNo "); SqlParameter[] parameters = { new SqlParameter("@typeNo", SqlDbType.NVarChar,2), new SqlParameter("@typeNm", SqlDbType.NVarChar,20) }; parameters[0].Value = model.typeNo; parameters[1].Value = model.typeNm; try { SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); ret = true; } catch (Exception ex) { throw ex; } return ret; }
/// <summary> /// ����һ������ /// </summary> /// <param name="model">model</param> public bool ModifyRecord(ToolRemindTypeData model) { return this.ollRemindTypeDB.ModifyRecord(model); }
/// <summary> /// �õ�һ��model /// </summary> /// <param name="typeNo">����ֵ</param> /// <returns>model</returns> public ToolRemindTypeData GetModel(string typeNo) { StringBuilder strSql = new StringBuilder(); strSql.Append("select * from ToolRemindType"); strSql.Append(" where typeNo = @typeNo "); SqlParameter[] parameters = { new SqlParameter("@typeNo", SqlDbType.NVarChar,2) }; parameters[0].Value = typeNo; ToolRemindTypeData model = new ToolRemindTypeData(); DataSet ds = SqlHelper.ExecuteDataset(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { DataRow row = ds.Tables[0].Rows[0]; if (row["typeNo"] != DBNull.Value) { model.typeNo = Convert.ToString(row["typeNo"]); } if (row["typeNm"] != DBNull.Value) { model.typeNm = Convert.ToString(row["typeNm"]); } return model; } else { return null; } }
/// <summary> /// ����һ������ /// </summary> /// <param name="model">model</param> public int AddRecord(ToolRemindTypeData model) { return this.ollRemindTypeDB.AddRecord(model); }