protected void btnDetail_Click(object sender, EventArgs e) { List <KeyValuePair <string, string> > lst = new List <KeyValuePair <string, string> >(); int id = ddlCriteria.SelectedIndex; if (id == 0) { lst.Add(new KeyValuePair <string, string> ("id", txtId.Text)); lst.Add(new KeyValuePair <string, string> ("name", HttpUtility.HtmlDecode(txtName.Text))); lst.Add(new KeyValuePair <string, string> ("parent", txtParent.Text)); lst.Add(new KeyValuePair <string, string> ("idnumber", txtIdnumber.Text)); } else if (id == 1) { lst.Add(new KeyValuePair <string, string> ("id", txtId.Text)); } else if (id == 2) { lst.Add(new KeyValuePair <string, string> ("name", HttpUtility.HtmlDecode(txtName.Text))); } else if (id == 3) { lst.Add(new KeyValuePair <string, string> ("parent", txtParent.Text)); } else { lst.Add(new KeyValuePair <string, string> ("idnumber", txtIdnumber.Text)); } XmlDocument doc = new XmlDocument(); doc.LoadXml(MoodleCategory.GetCategories(lst, chkSubCategory.Checked, (string)Session["token"])); doc.Save("D:\\" + txtId.Text + ".xml"); XmlNode xmlnode = doc.ChildNodes[1]; treeCategoryDetail.Nodes.Clear(); treeCategoryDetail.Nodes.Add(new TreeNode(doc.DocumentElement.Name)); TreeNode tNode; tNode = treeCategoryDetail.Nodes[0]; MoodleUtilites.AddNode(xmlnode, tNode); treeCategoryDetail.ExpandAll(); }
protected void btnGetDetail_Click(object sender, EventArgs e) { if (txtId.Text == "" || Convert.ToInt32(txtId.Text) < 1) { lblUpdateMessage.Text = "Vui lòng nhập một ID khoa> 0"; txtId.Focus(); return; } List <KeyValuePair <string, string> > list = new List <KeyValuePair <string, string> >(); int id = ddlCriteria.SelectedIndex; if (id == 0) { list.Add(new KeyValuePair <string, string> ("id", txtId.Text)); } else if (id == 1) { list.Add(new KeyValuePair <string, string> ("idnumber", txtIdnumber.Text)); } else { list.Add(new KeyValuePair <string, string> ("name", HttpUtility.HtmlDecode(txtName.Text))); } XmlDocument doc = new XmlDocument(); doc.LoadXml(MoodleCategory.GetCategories(list, chkSubCategory.Checked, (string)Session["token"])); doc.Save("D:\\faculty_" + txtId.Text + ".xml"); XmlNode xmlnode = doc.ChildNodes[1]; treeDetail.Nodes.Clear(); treeDetail.Nodes.Add(new TreeNode(doc.DocumentElement.Name)); TreeNode tNode; tNode = treeDetail.Nodes[0]; MoodleUtilites.AddNode(xmlnode, tNode); treeDetail.ExpandAll(); treeDetail.Focus(); }