01
private
void
loadMenu(
string
_language)
02
{
03
connectionString =
"Data Source =..."
;
04
05
sql =
"SELECT MAIN_MNU,MAIN_MNU_GRP,CHILD_MNU,CHILD_MNU_GRP FROM MENU_TABLE WHERE LANG='"
+ _language +
"'"
06
SqlConnection connection =
new
SqlConnection(connectionString);
07
SqlDataAdapter dataadapter =
SqlDataAdapter(sql, connection);
08
DataSet ds =
DataSet();
09
connection.Open();
10
dataadapter.Fill(ds,
"Menu Table"
);
11
connection.Close();
12
13
MenuItem[] mnuItem =
MenuItem[ds.Tables[0].Rows.Count];
14
if
(ds.Tables[0].Rows.Count > 0)
15
16
//ds.Tables[0].Rows.Count
17
for
(
int
j = 0; j < ds.Tables[0].Rows.Count; j++)
18
19
s = ds.Tables[0].Rows[j].ItemArray[0].ToString();
20
mnuItem[j] =
MenuItem(s,
System.EventHandler(mnuClick));
21
22
(ds.Tables[0].Rows[j].ItemArray[1].ToString() ==
"0"
)
23
24
this
.mnuMainMenu.MenuItems.Add(ds.Tables[0].Rows[j].ItemArray[0].ToString());
25
}
26
(ds.Tables[0].Rows[j].ItemArray[3].ToString() ==
"1"
27
28
father = Convert.ToInt32(ds.Tables[0].Rows[j].ItemArray[1].ToString());
29
//this.mnuMainMenu.MenuItems[father].MenuItems.Add(mnuItem[j]);
30
.mnuMainMenu.MenuItems[father].MenuItems.Add(ds.Tables[0].Rows[j].ItemArray[2].ToString());
31
32
33
34
35
36
.Menu = mnuMainMenu;
37
38
39
40
mnuClick(
object
sender, System.EventArgs e)
41
42
MenuItem item = (MenuItem)sender;
43
mess = item.Text.ToString();
44
MessageBox.Show(
"You clicked menu "
+ mess);
45
46