/// <summary> /// 更新一条数据 /// </summary> public bool Update(ICPOS.EntityFramwork.Model.Role model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Role set "); strSql.Append("Role_Name=@Role_Name,"); strSql.Append("Role_Description=@Role_Description,"); strSql.Append("Role_Priv_Level=@Role_Priv_Level"); strSql.Append(" where Role_ID=@Role_ID"); SqlParameter[] parameters = { new SqlParameter("@Role_Name", SqlDbType.NVarChar, 20), new SqlParameter("@Role_Description", SqlDbType.NVarChar, 50), new SqlParameter("@Role_Priv_Level", SqlDbType.Int, 4), new SqlParameter("@Role_ID", SqlDbType.Int, 4) }; parameters[0].Value = model.Role_Name; parameters[1].Value = model.Role_Description; parameters[2].Value = model.Role_Priv_Level; parameters[3].Value = model.Role_ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(ICPOS.EntityFramwork.Model.Role model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Role("); strSql.Append("Role_Name,Role_Description,Role_Priv_Level)"); strSql.Append(" values ("); strSql.Append("@Role_Name,@Role_Description,@Role_Priv_Level)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Role_Name", SqlDbType.NVarChar, 20), new SqlParameter("@Role_Description", SqlDbType.NVarChar, 50), new SqlParameter("@Role_Priv_Level", SqlDbType.Int, 4) }; parameters[0].Value = model.Role_Name; parameters[1].Value = model.Role_Description; parameters[2].Value = model.Role_Priv_Level; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 得到一个对象实体 /// </summary> public ICPOS.EntityFramwork.Model.Role DataRowToModel(DataRow row) { ICPOS.EntityFramwork.Model.Role model = new ICPOS.EntityFramwork.Model.Role(); if (row != null) { if (row["Role_ID"] != null && row["Role_ID"].ToString() != "") { model.Role_ID = int.Parse(row["Role_ID"].ToString()); } if (row["Role_Name"] != null) { model.Role_Name = row["Role_Name"].ToString(); } if (row["Role_Description"] != null) { model.Role_Description = row["Role_Description"].ToString(); } if (row["Role_Priv_Level"] != null && row["Role_Priv_Level"].ToString() != "") { model.Role_Priv_Level = int.Parse(row["Role_Priv_Level"].ToString()); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public ICPOS.EntityFramwork.Model.Role GetModel(int Role_ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Role_ID,Role_Name,Role_Description,Role_Priv_Level from Role "); strSql.Append(" where Role_ID=@Role_ID"); SqlParameter[] parameters = { new SqlParameter("@Role_ID", SqlDbType.Int, 4) }; parameters[0].Value = Role_ID; ICPOS.EntityFramwork.Model.Role model = new ICPOS.EntityFramwork.Model.Role(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }