/// <summary> /// 增加一条数据 /// </summary> public bool Add(FunctionsME model) { StringBuilder strSql=new StringBuilder(); strSql.Append("insert into Functions("); strSql.Append("functionid,functionName,moduleNo)"); strSql.Append(" values ("); strSql.Append("@functionid,@functionName,@moduleNo)"); SqlParameter[] parameters = { new SqlParameter("@functionid", SqlDbType.Int,4), new SqlParameter("@functionName", SqlDbType.NVarChar,50), new SqlParameter("@moduleNo", SqlDbType.Int,4)}; parameters[0].Value = model.functionid; parameters[1].Value = model.functionName; parameters[2].Value = model.moduleNo; int rows = DbHelperSQL.ExecuteSql(PubConstant.ConnectionStringAccountDB,strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(FunctionsME model) { StringBuilder strSql=new StringBuilder(); strSql.Append("update Functions set "); strSql.Append("functionName=@functionName,"); strSql.Append("moduleNo=@moduleNo"); strSql.Append(" where functionid=@functionid "); SqlParameter[] parameters = { new SqlParameter("@functionName", SqlDbType.NVarChar,50), new SqlParameter("@moduleNo", SqlDbType.Int,4), new SqlParameter("@functionid", SqlDbType.Int,4)}; parameters[0].Value = model.functionName; parameters[1].Value = model.moduleNo; parameters[2].Value = model.functionid; int rows = DbHelperSQL.ExecuteSql(PubConstant.ConnectionStringAccountDB,strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } }
/// <summary> /// 得到一个对象实体 /// </summary> public FunctionsME GetModel(int functionid) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 functionid,functionName,moduleNo from Functions "); strSql.Append(" where functionid=@functionid "); SqlParameter[] parameters = { new SqlParameter("@functionid", SqlDbType.Int,4) }; parameters[0].Value = functionid; FunctionsME model=new FunctionsME(); DataSet ds = DbHelperSQL.Query(PubConstant.ConnectionStringAccountDB,strSql.ToString(), parameters); if(ds.Tables[0].Rows.Count>0) { if(ds.Tables[0].Rows[0]["functionid"]!=null && ds.Tables[0].Rows[0]["functionid"].ToString()!="") { model.functionid=int.Parse(ds.Tables[0].Rows[0]["functionid"].ToString()); } if(ds.Tables[0].Rows[0]["functionName"]!=null && ds.Tables[0].Rows[0]["functionName"].ToString()!="") { model.functionName=ds.Tables[0].Rows[0]["functionName"].ToString(); } if(ds.Tables[0].Rows[0]["moduleNo"]!=null && ds.Tables[0].Rows[0]["moduleNo"].ToString()!="") { model.moduleNo=int.Parse(ds.Tables[0].Rows[0]["moduleNo"].ToString()); } return model; } else { return null; } }