Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void Deletbtn_Click(object sender, EventArgs e)
- {
- XmlNode node = doc.SelectSingleNode("//entry[@entryno='" + Dgv.CurrentRow.Cells[0].Value + "']");
- try
- {
- if (node != null && Dgv.CurrentRow.Selected == true)
- {
- doc.DocumentElement.RemoveChild(node);
- // Trying to refresh the sequence each time an node is deleted.
- int Attrno = int.Parse(doc.SelectSingleNode("//entry[@entryno]").Value);
- do
- {
- Attrno = 0;
- Attrno++;
- } while (Attrno < doc.ChildNodes.Count);
- doc.SelectSingleNode("//entry[@entryno]").InnerText = Attrno.ToString();
- doc.Save(Application.StartupPath + @"SleepRecords.xml");
- }
- else
- MessageBox.Show("Click the left side of the grid to select a row to delete.", "Select row", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- catch (Exception ex)
- {
- MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- }
- ReloadData();
- Resetbtn_Click(Deletbtn, e);
- makePdf();
- }
- XmlNodeList nodes = doc.SelectNodes("//entry");
- int max = 0;
- foreach (XmlNode node in nodes)
- {
- int nodeAttr = int.Parse(node.Attributes["entryno"].Value);
- max = nodeAttr;
- }
- max++;
Add Comment
Please, Sign In to add comment