/// <summary> /// 得到一个对象实体 /// </summary> public BWJS.Model.Function GetModel(int FunctionId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select FunctionId, Status, OrderId, CreateId, CreateDate, EditId, EditDate, IsDeleted, Remark, FunctionName, FunctionCode, FunctionIcon, FunctionClass, ClassId, ParentId, ExternalLinkAddress, FunctionDir "); strSql.Append(" from [Function] "); strSql.Append(" where FunctionId=@FunctionId"); SqlParameter[] parameters = { new SqlParameter("@FunctionId", SqlDbType.Int, 4) }; parameters[0].Value = FunctionId; BWJS.Model.Function model = new BWJS.Model.Function(); 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> /// 更新一条数据 /// </summary> public bool Update(BWJS.Model.Function model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update [Function] set "); strSql.Append(" Status = @Status , "); strSql.Append(" OrderId = @OrderId , "); strSql.Append(" EditId = @EditId , "); strSql.Append(" EditDate = @EditDate , "); strSql.Append(" IsDeleted = @IsDeleted , "); strSql.Append(" Remark = @Remark , "); strSql.Append(" FunctionName = @FunctionName , "); strSql.Append(" FunctionCode = @FunctionCode , "); strSql.Append(" FunctionIcon = @FunctionIcon , "); strSql.Append(" FunctionClass = @FunctionClass , "); strSql.Append(" ClassId = @ClassId , "); strSql.Append(" ParentId = @ParentId , "); strSql.Append(" ExternalLinkAddress = @ExternalLinkAddress , "); strSql.Append(" FunctionDir = @FunctionDir "); strSql.Append(" where FunctionId=@FunctionId "); SqlParameter[] parameters = { new SqlParameter("@FunctionId", model.FunctionId), new SqlParameter("@Status", model.Status), new SqlParameter("@OrderId", model.OrderId), new SqlParameter("@EditId", model.EditId), new SqlParameter("@EditDate", model.EditDate), new SqlParameter("@IsDeleted", model.IsDeleted), new SqlParameter("@Remark", model.Remark), new SqlParameter("@FunctionName", model.FunctionName), new SqlParameter("@FunctionCode", model.FunctionCode), new SqlParameter("@FunctionIcon", model.FunctionIcon), new SqlParameter("@FunctionClass", model.FunctionClass), new SqlParameter("@ClassId", model.ClassId), new SqlParameter("@ParentId", model.ParentId), new SqlParameter("@ExternalLinkAddress", model.ExternalLinkAddress), new SqlParameter("@FunctionDir", model.FunctionDir) }; int rows = BWJSHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(BWJS.Model.Function model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into [Function]("); strSql.Append("Status,OrderId,CreateId,CreateDate,EditId,EditDate,IsDeleted,Remark,FunctionName,FunctionCode,FunctionIcon,FunctionClass,ClassId,ParentId,ExternalLinkAddress,FunctionDir"); strSql.Append(") values ("); strSql.Append("@Status,@OrderId,@CreateId,@CreateDate,@EditId,@EditDate,@IsDeleted,@Remark,@FunctionName,@FunctionCode,@FunctionIcon,@FunctionClass,@ClassId,@ParentId,@ExternalLinkAddress,@FunctionDir"); strSql.Append(") "); strSql.Append(";select SCOPE_IDENTITY()"); SqlParameter[] parameters = { new SqlParameter("@Status", model.Status), new SqlParameter("@OrderId", model.OrderId), new SqlParameter("@CreateId", model.CreateId), new SqlParameter("@CreateDate", model.CreateDate), new SqlParameter("@EditId", model.EditId), new SqlParameter("@EditDate", model.EditDate), new SqlParameter("@IsDeleted", model.IsDeleted), new SqlParameter("@Remark", model.Remark), new SqlParameter("@FunctionName", model.FunctionName), new SqlParameter("@FunctionCode", model.FunctionCode), new SqlParameter("@FunctionIcon", model.FunctionIcon), new SqlParameter("@FunctionClass", model.FunctionClass), new SqlParameter("@ClassId", model.ClassId), new SqlParameter("@ParentId", model.ParentId), new SqlParameter("@ExternalLinkAddress", model.ExternalLinkAddress), new SqlParameter("@FunctionDir", model.FunctionDir) }; object obj = BWJSHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// datarow转成对象实体 /// </summary> public BWJS.Model.Function DataRowToModel(DataRow row) { BWJS.Model.Function model = new BWJS.Model.Function(); if (row != null) { if (row["FunctionId"].ToString() != "") { model.FunctionId = int.Parse(row["FunctionId"].ToString()); } if (row["Status"].ToString() != "") { model.Status = int.Parse(row["Status"].ToString()); } if (row["OrderId"].ToString() != "") { model.OrderId = int.Parse(row["OrderId"].ToString()); } if (row["CreateId"].ToString() != "") { model.CreateId = int.Parse(row["CreateId"].ToString()); } if (row["CreateDate"].ToString() != "") { model.CreateDate = DateTime.Parse(row["CreateDate"].ToString()); } if (row["EditId"].ToString() != "") { model.EditId = int.Parse(row["EditId"].ToString()); } if (row["EditDate"].ToString() != "") { model.EditDate = DateTime.Parse(row["EditDate"].ToString()); } if (row["IsDeleted"].ToString() != "") { model.IsDeleted = int.Parse(row["IsDeleted"].ToString()); } model.Remark = row["Remark"].ToString(); model.FunctionName = row["FunctionName"].ToString(); model.FunctionCode = row["FunctionCode"].ToString(); model.FunctionIcon = row["FunctionIcon"].ToString(); model.FunctionClass = row["FunctionClass"].ToString(); if (row["ClassId"].ToString() != "") { model.ClassId = int.Parse(row["ClassId"].ToString()); } if (row["ParentId"].ToString() != "") { model.ParentId = int.Parse(row["ParentId"].ToString()); } model.ExternalLinkAddress = row["ExternalLinkAddress"].ToString(); model.FunctionDir = row["FunctionDir"].ToString(); return(model); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(BWJS.Model.Function model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(BWJS.Model.Function model) { return(dal.Add(model)); }