Advertisement
Guest User

Untitled

a guest
Mar 31st, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. bool fl = false;
  2. sr = new StreamReader("produkt.txt");
  3. while (!sr.EndOfStream)
  4. {
  5. string line = sr.ReadLine();
  6. linePro = line.Split(';');
  7.  
  8. // MessageBox.Show("vtri 1: " + linePro[3]);
  9. string name=linePro[1];
  10. // MessageBox.Show("name: " + linePro[1]);
  11. int n=listBox2.Items.Count;
  12.  
  13. for (int i = 0; i < n;i++ )
  14. {
  15. // MessageBox.Show("hej");
  16. if (listBox2.Items[i].ToString().Equals(name))
  17. {
  18. // MessageBox.Show("hej inne");
  19. int antal = Int32.Parse(linePro[3]);
  20. updateAntal = antal - 1;
  21. MessageBox.Show("vtri 1: " + updateAntal);
  22. fl = true;
  23.  
  24. }
  25. }
  26. }
  27. sr.Close();
  28. if(fl==true)
  29. {
  30. sw = new StreamWriter("produkt.txt", true);
  31. int n2 = listBox1.Items.Count;
  32. for (int i = 0; i < n2; i++)
  33. {
  34.  
  35. sw.WriteLine(linePro[0] + ";" + linePro[1] + ";" + linePro[2] + ";" + updateAntal);
  36.  
  37. }
  38. sw.Close();
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement