private void button1_Click(object sender, EventArgs e) { if (textBox1.Text == "") { return; } XmlDocument doc = new XmlDocument(); doc.Load("stocks.dbs"); if (doc.SelectSingleNode("//company[@name='" + textBox1.Text + "']") != null) { MessageBox.Show("Already"); return; } XmlElement rootElement = doc.DocumentElement; XmlElement newcomapny = doc.CreateElement("company"); newcomapny.SetAttribute("name", textBox1.Text); rootElement.AppendChild(newcomapny); doc.Save("stocks.dbs"); stocks.relode(); stocks.comboBox1.SelectedItem = textBox1.Text; stocks.RefreshList(); reload(); textBox1.Text = ""; }
private void button1_Click(object sender, EventArgs e) { if (ValPer.Text == "") { ValPer.Value = 0; } XmlDocument stockdoc = new XmlDocument(); stockdoc.Load("stocks.dbs"); string qtybefore = stockdoc.SelectSingleNode("//company[@name='" + stocks.comboBox1.Text + "']" + "//item[@name='" + itemLabel.Text + "']").InnerText; string qtyafter = (Convert.ToInt32(qtybefore) + ValPer.Value).ToString(); stockdoc.SelectSingleNode("//company[@name='" + stocks.comboBox1.Text + "']" + "//item[@name='" + itemLabel.Text + "']").InnerText = qtyafter; stockdoc.Save("stocks.dbs"); stocks.RefreshList(); this.Close(); }
private void button1_Click(object sender, EventArgs e) { //try //{ // XmlConvert.VerifyName(textBox1.Text.Replace(" ", "_")); //} //catch (Exception) //{ // MessageBox.Show("This item name is not valid, Use Alphabates only."); // return; //} if (textBox1.Text == "") { return; } XmlDocument doc = new XmlDocument(); doc.Load("stocks.dbs"); if (doc.SelectSingleNode("//company[@name='" + stocks.comboBox1.Text + "']" + "//item[@name='" + textBox1.Text + "']") != null) { MessageBox.Show("Already"); return; } if (ValPer.Text == "") { ValPer.Value = 0; } var rootElement = doc.SelectSingleNode("//company[@name='" + stocks.comboBox1.Text + "']"); XmlElement newItem = doc.CreateElement("item"); newItem.SetAttribute("name", textBox1.Text); newItem.InnerText = ValPer.Value.ToString(); rootElement.AppendChild(newItem); doc.Save("stocks.dbs"); stocks.RefreshList(); textBox1.Text = ""; ValPer.Text = ""; }