Guest User

Untitled

a guest
Jan 18th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. public partial class Form2 : Form
  2. {
  3. public int InventoryId = 0;
  4. private DataRow CurrentRow;
  5.  
  6. public Form2()
  7. {
  8. InitializeComponent();
  9. }
  10.  
  11. private void SaveItem_Click()
  12. {
  13. this.Validate();
  14. this.inventoryBindingSource.EndEdit();
  15. this.tableAdapterManager.UpdateAll(this.garysInventoryDataSet);
  16. }
  17.  
  18. private void Form2_Load(object sender, EventArgs e)
  19. {
  20. this.inventoryTableAdapter.Fill(this.garysInventoryDataSet.Inventory);
  21.  
  22. CurrentRow = (from x in garysInventoryDataSet.Inventory
  23. where x.InventoryId == InventoryId
  24. select x).FirstOrDefault();
  25.  
  26. if (CurrentRow == null)
  27. {
  28. MessageBox.Show("Inventory Item Not Found.");
  29. }
  30.  
  31. yearToDateQuantityTextBox.Text = CurrentRow["YearToDateQuantity"].ToString();
  32. }
  33.  
  34. private void button3_Click(object sender, EventArgs e)
  35. {
  36. CurrentRow["YearToDateQuantity"] = Convert.ToInt32(CurrentRow["YearToDateQuantity"]) + 1;
  37. yearToDateQuantityTextBox.Text = CurrentRow["YearToDateQuantity"].ToString();
  38. }
  39.  
  40. private void button2_Click(object sender, EventArgs e)
  41. {
  42. CurrentRow["YearToDateQuantity"] = Convert.ToInt32(CurrentRow["YearToDateQuantity"]) - 1;
  43. yearToDateQuantityTextBox.Text = CurrentRow["YearToDateQuantity"].ToString();
  44. }
  45.  
  46. private void Form2_FormClosing(object sender, FormClosingEventArgs e)
  47. {
  48. SaveItem_Click();
  49. }
  50. }
Add Comment
Please, Sign In to add comment