Guest User

Untitled

a guest
Jan 21st, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. using System.Windows.Forms;
  11. using System.Xml;
  12. using System.Windows;
  13. using System.Xml.Linq;
  14.  
  15. namespace Portal_of_Asura
  16. {
  17. public partial class ShopForm : Form
  18. {
  19. public string ShopName;
  20. public string ShopKeeperName;
  21. public string ShopSpecies;
  22. public List<XmlNode> Items = new List<XmlNode>() { };
  23. public ShopForm(String ShopName)
  24. {
  25. InitializeComponent();
  26.  
  27. }
  28. public DataSet ds = new DataSet();
  29.  
  30. private void ShopForm_FormClosed(object sender, FormClosedEventArgs e)
  31. {
  32. ds.WriteXml("./ReferenceXMLS/ShopList.xml");
  33.  
  34.  
  35. }
  36.  
  37. private void ShopForm_Load_1(object sender, EventArgs e)
  38. {
  39.  
  40.  
  41.  
  42. //XElement xelement = XElement.Load("./ReferenceXMLS/ShopList.xml");
  43. //
  44. //IEnumerable<XElement> books = xelement.Elements();
  45. //List<XElement> books2 = new List<XElement> { };
  46. //foreach(var element in books)
  47. //{
  48. // books2.Add(element);
  49. //
  50. //}
  51. //foreach (var element2 in books2)
  52. //{
  53. // if(element2.Attribute("name").Value == "Tiarga")
  54. // {
  55. //
  56. // }
  57. //}
  58.  
  59. var xml = XDocument.Load(@"./ReferenceXMLS/ShopList.xml");
  60. var ds = xml.Root.Descendants("Shop")
  61. .Single(x => x.Attribute("name").Value == "Tiarga")
  62. .Descendants("Item")
  63. .Select(x => new {
  64. Name = x.Attribute("name").Value,
  65. Price = x.Descendants("Price").FirstOrDefault()?.Value,
  66. Stats = x.Descendants("Stats").FirstOrDefault()?.Value,
  67. Quantity = x.Descendants("Quantity").FirstOrDefault()?.Value,
  68. })
  69. .ToList();
  70. dataGridView1.DataSource = ds;
  71.  
  72.  
  73. //Console.WriteLine(ds.Tables["Item"].ToString());
  74.  
  75.  
  76. //dataGridView1.DataSource = ds.Tables["Item"];
  77. }
  78.  
  79. private void button1_Click(object sender, EventArgs e)
  80. {
  81. var targetRow = dataGridView1.CurrentCell.RowIndex;
  82. var cellValue = dataGridView1.Rows[targetRow].Cells[3].Value.ToString();
  83. Console.WriteLine(dataGridView1.Rows[targetRow].Cells[3].Value);
  84. dataGridView1.Rows[targetRow].Cells[3].Value = int.Parse(cellValue) - 1;
  85. ds.AcceptChanges();
  86. }
  87.  
  88. }
  89. }
Add Comment
Please, Sign In to add comment