MaysamSh

Untitled

Jan 31st, 2013
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.59 KB | None | 0 0
  1. public string GenerateNestedMenus(string fTableName, string fID, string fCluase)
  2. {
  3.     string output = "";
  4.     string x = DateAndTime.Now.ToString();
  5.     SetActionResult = "waiting_GenerateNestedMenus";
  6.     string OutputData = "";
  7.     string SQLCommand = null;
  8.     CoreString _string = new CoreString();
  9.  
  10.     SQLCommand = "SELECT * FROM " + fTableName + " WHERE MenuParent=@ID AND Visible=1 AND " + fCluase;
  11.  
  12.     SqlDataReader DR = default(SqlDataReader);
  13.     DeepDB DB = new DeepDB(__ConnectionString, SQLCommand, fTableName);
  14.     DB.ddConnect();
  15.  
  16.     SqlParameter IDParameter = new SqlParameter("@ID", fID);
  17.  
  18.     DB.ddAddParameper(IDParameter);
  19.     string temp = null;
  20.  
  21.     try {
  22.         DR = DB.ddExecuteReader();
  23.  
  24.  
  25.         while (DR.Read) {
  26.             if (Convert.ToInt32(ChildCounter(fTableName, DR("id"))) > 0) {
  27.                 temp = "<li>" + Constants.vbCrLf + "<a href='#'>" + Strings.Trim(DR("MenuName")) + "</a>" + Constants.vbCrLf + Constants.vbTab + "<ul> ";
  28.                 _temp += temp;
  29.                 GenerateNestedMenus("menus", DR("id"), fCluase);
  30.                 _temp += Constants.vbTab + "</ul>" + Constants.vbCrLf + Constants.vbTab + "</li>" + Constants.vbCrLf;
  31.             } else {
  32.                 //For rows they have not child
  33.                 temp = Constants.vbTab + "<li><a href='#'>" + Strings.Trim(DR("MenuName")) + "</a>" + "</li>" + Constants.vbCrLf;
  34.                 _temp += temp;
  35.                 GenerateNestedMenus("menus", DR("id"), fCluase);
  36.  
  37.             }
  38.             SetActionResult = "done_GenerateNestedMenus";
  39.         }
  40.         output = _temp;
  41.     } catch (Exception exp) {
  42.         SetErrorMessage = "GenerateNestedMenus():" + exp.Message;
  43.         SetActionResult = "error_GenerateNestedMenus";
  44.     } finally {
  45.         DB.ddClose();
  46.     }
  47.  
  48.     return output;
  49. }
Advertisement
Add Comment
Please, Sign In to add comment