/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.BaseMenu DataRowToModel(DataRow row) { Maticsoft.Model.BaseMenu model = new Maticsoft.Model.BaseMenu(); if (row != null) { if (row["MenuID"] != null && row["MenuID"].ToString() != "") { model.MenuID = int.Parse(row["MenuID"].ToString()); } if (row["ParentMenuID"] != null && row["ParentMenuID"].ToString() != "") { model.ParentMenuID = int.Parse(row["ParentMenuID"].ToString()); } if (row["PageID"] != null && row["PageID"].ToString() != "") { model.PageID = int.Parse(row["PageID"].ToString()); } if (row["MenuName"] != null) { model.MenuName = row["MenuName"].ToString(); } if (row["LinkUrl"] != null) { model.LinkUrl = row["LinkUrl"].ToString(); } if (row["Target"] != null) { model.Target = row["Target"].ToString(); } if (row["Value1"] != null) { model.Value1 = row["Value1"].ToString(); } if (row["Value2"] != null) { model.Value2 = row["Value2"].ToString(); } if (row["Value3"] != null) { model.Value3 = row["Value3"].ToString(); } if (row["IDX"] != null && row["IDX"].ToString() != "") { model.IDX = int.Parse(row["IDX"].ToString()); } if (row["IsMenu"] != null && row["IsMenu"].ToString() != "") { if ((row["IsMenu"].ToString() == "1") || (row["IsMenu"].ToString().ToLower() == "true")) { model.IsMenu = true; } else { model.IsMenu = false; } } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.BaseMenu model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update BaseMenu set "); strSql.Append("ParentMenuID=@ParentMenuID,"); strSql.Append("PageID=@PageID,"); strSql.Append("MenuName=@MenuName,"); strSql.Append("LinkUrl=@LinkUrl,"); strSql.Append("Target=@Target,"); strSql.Append("Value1=@Value1,"); strSql.Append("Value2=@Value2,"); strSql.Append("Value3=@Value3,"); strSql.Append("IDX=@IDX,"); strSql.Append("IsMenu=@IsMenu"); strSql.Append(" where MenuID=@MenuID "); SqlParameter[] parameters = { new SqlParameter("@ParentMenuID", SqlDbType.Int, 4), new SqlParameter("@PageID", SqlDbType.Int, 4), new SqlParameter("@MenuName", SqlDbType.NVarChar, 50), new SqlParameter("@LinkUrl", SqlDbType.NVarChar, 100), new SqlParameter("@Target", SqlDbType.NVarChar, 50), new SqlParameter("@Value1", SqlDbType.NVarChar, 200), new SqlParameter("@Value2", SqlDbType.NVarChar, 50), new SqlParameter("@Value3", SqlDbType.NVarChar, 200), new SqlParameter("@IDX", SqlDbType.Int, 4), new SqlParameter("@IsMenu", SqlDbType.Bit, 1), new SqlParameter("@MenuID", SqlDbType.Int, 4) }; parameters[0].Value = model.ParentMenuID; parameters[1].Value = model.PageID; parameters[2].Value = model.MenuName; parameters[3].Value = model.LinkUrl; parameters[4].Value = model.Target; parameters[5].Value = model.Value1; parameters[6].Value = model.Value2; parameters[7].Value = model.Value3; parameters[8].Value = model.IDX; parameters[9].Value = model.IsMenu; parameters[10].Value = model.MenuID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Maticsoft.Model.BaseMenu model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into BaseMenu("); strSql.Append("MenuID,ParentMenuID,PageID,MenuName,LinkUrl,Target,Value1,Value2,Value3,IDX,IsMenu)"); strSql.Append(" values ("); strSql.Append("@MenuID,@ParentMenuID,@PageID,@MenuName,@LinkUrl,@Target,@Value1,@Value2,@Value3,@IDX,@IsMenu)"); SqlParameter[] parameters = { new SqlParameter("@MenuID", SqlDbType.Int, 4), new SqlParameter("@ParentMenuID", SqlDbType.Int, 4), new SqlParameter("@PageID", SqlDbType.Int, 4), new SqlParameter("@MenuName", SqlDbType.NVarChar, 50), new SqlParameter("@LinkUrl", SqlDbType.NVarChar, 100), new SqlParameter("@Target", SqlDbType.NVarChar, 50), new SqlParameter("@Value1", SqlDbType.NVarChar, 200), new SqlParameter("@Value2", SqlDbType.NVarChar, 50), new SqlParameter("@Value3", SqlDbType.NVarChar, 200), new SqlParameter("@IDX", SqlDbType.Int, 4), new SqlParameter("@IsMenu", SqlDbType.Bit, 1) }; parameters[0].Value = model.MenuID; parameters[1].Value = model.ParentMenuID; parameters[2].Value = model.PageID; parameters[3].Value = model.MenuName; parameters[4].Value = model.LinkUrl; parameters[5].Value = model.Target; parameters[6].Value = model.Value1; parameters[7].Value = model.Value2; parameters[8].Value = model.Value3; parameters[9].Value = model.IDX; parameters[10].Value = model.IsMenu; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.BaseMenu GetModel(int MenuID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 MenuID,ParentMenuID,PageID,MenuName,LinkUrl,Target,Value1,Value2,Value3,IDX,IsMenu from BaseMenu "); strSql.Append(" where MenuID=@MenuID "); SqlParameter[] parameters = { new SqlParameter("@MenuID", SqlDbType.Int, 4) }; parameters[0].Value = MenuID; Maticsoft.Model.BaseMenu model = new Maticsoft.Model.BaseMenu(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }