Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.Xml;
- using System.Windows;
- using System.Xml.Linq;
- namespace Portal_of_Asura
- {
- public partial class ShopForm : Form
- {
- public string ShopName;
- public string ShopKeeperName;
- public string ShopSpecies;
- public List<XmlNode> Items = new List<XmlNode>() { };
- public ShopForm(String ShopName)
- {
- InitializeComponent();
- }
- public DataSet ds = new DataSet();
- private void ShopForm_FormClosed(object sender, FormClosedEventArgs e)
- {
- ds.WriteXml("./ReferenceXMLS/ShopList.xml");
- }
- private void ShopForm_Load_1(object sender, EventArgs e)
- {
- //XElement xelement = XElement.Load("./ReferenceXMLS/ShopList.xml");
- //
- //IEnumerable<XElement> books = xelement.Elements();
- //List<XElement> books2 = new List<XElement> { };
- //foreach(var element in books)
- //{
- // books2.Add(element);
- //
- //}
- //foreach (var element2 in books2)
- //{
- // if(element2.Attribute("name").Value == "Tiarga")
- // {
- //
- // }
- //}
- var xml = XDocument.Load(@"./ReferenceXMLS/ShopList.xml");
- var ds = xml.Root.Descendants("Shop")
- .Single(x => x.Attribute("name").Value == "Tiarga")
- .Descendants("Item")
- .Select(x => new {
- Name = x.Attribute("name").Value,
- Price = x.Descendants("Price").FirstOrDefault()?.Value,
- Stats = x.Descendants("Stats").FirstOrDefault()?.Value,
- Quantity = x.Descendants("Quantity").FirstOrDefault()?.Value,
- })
- .ToList();
- dataGridView1.DataSource = ds;
- //Console.WriteLine(ds.Tables["Item"].ToString());
- //dataGridView1.DataSource = ds.Tables["Item"];
- }
- private void button1_Click(object sender, EventArgs e)
- {
- var targetRow = dataGridView1.CurrentCell.RowIndex;
- var cellValue = dataGridView1.Rows[targetRow].Cells[3].Value.ToString();
- Console.WriteLine(dataGridView1.Rows[targetRow].Cells[3].Value);
- dataGridView1.Rows[targetRow].Cells[3].Value = int.Parse(cellValue) - 1;
- ds.AcceptChanges();
- }
- }
- }
Add Comment
Please, Sign In to add comment