protected void btnUpdate_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; } MoodleCategory category; XmlDocument doc = new XmlDocument(); category = new MoodleCategory { Id = Convert.ToInt32(txtId.Text), Name = HttpUtility.HtmlDecode(txtName.Text), Parent = 0, IdNumber = HttpUtility.HtmlDecode(txtIdnumber.Text), Description = HttpUtility.HtmlDecode(txtName.Text), DescriptionFormat = 1, Theme = null }; List <MoodleCategory> lst = new List <MoodleCategory>(); lst.Add(category); doc.LoadXml(MoodleCategory.UpdateCategories(lst, (string)Session["token"])); doc.Save("D:\\faculty_" + txtId.Text + ".xml"); }
protected void btnUpdate_Click(object sender, EventArgs e) { if (txtId.Text == "" || Convert.ToInt32(txtId.Text) < 1) { lblUpdateMessage.Text = "Vui lòng nhập một ID bộ môn > 0"; txtId.Focus(); return; } DCVimaruDataContext dc = new DCVimaruDataContext(); Khoa khoa = dc.Khoas.Single(t => t.MaKhoa == cboFilter.SelectedValue); int parent = Convert.ToInt32(khoa.Id); MoodleCategory category; XmlDocument doc = new XmlDocument(); category = new MoodleCategory { Id = Convert.ToInt32(txtId.Text), Name = HttpUtility.HtmlDecode(txtName.Text), Parent = parent, IdNumber = HttpUtility.HtmlDecode(txtIdnumber.Text), Description = HttpUtility.HtmlDecode(txtName.Text), DescriptionFormat = 1, Theme = null }; List <MoodleCategory> lst = new List <MoodleCategory>(); lst.Add(category); doc.LoadXml(MoodleCategory.UpdateCategories(lst, (string)Session["token"])); doc.Save("D:\\department_" + txtId.Text + ".xml"); }
protected void btnUpdate_Click(object sender, EventArgs e) { if (txtId.Text == "") { lblCategoryMessage.Text = "Vui lòng nhập id mục cần cập nhật!"; txtId.Focus(); return; } MoodleCategory category = new MoodleCategory(); category.Id = Convert.ToInt32(txtId.Text); if (txtName.Text != "") { category.Name = txtName.Text; } if (txtParent.Text == "") { category.Parent = 0; } else { category.Parent = Convert.ToInt32(txtParent.Text); } if (txtIdnumber.Text == "") { category.IdNumber = null; } else { category.IdNumber = txtIdnumber.Text; } if (txtDecscription.Text == "") { category.Description = null; } else { category.Description = txtDecscription.Text; } if (txtDescriptionFormat.Text == "") { category.DescriptionFormat = 1; } else { category.DescriptionFormat = Convert.ToInt32(txtDescriptionFormat.Text); } if (txtTheme.Text == "") { category.Theme = null; } else { category.Theme = txtTheme.Text; } XmlDocument doc = new XmlDocument(); List <MoodleCategory> lst = new List <MoodleCategory>(); lst.Add(category); doc.LoadXml(MoodleCategory.UpdateCategories(lst, (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(); }