Advertisement
Guest User

Untitled

a guest
Nov 26th, 2015
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. public frmEnterCheck()
  2. {
  3. InitializeComponent();
  4. }
  5. private string tableName;
  6. private string user;
  7.  
  8. public frmEnterCheck(string table, string user)
  9. {
  10. InitializeComponent();
  11. this.tableName = table;
  12. this.user = user;
  13. lblTableName.Text = table;
  14. }
  15.  
  16. public void checkValues()
  17. {
  18. if (tbDrop.Text == "" || tbHeadcount.Text == "" || tbTo.Text == "" || tbFrom.Text == "" || tbResult.Text == "" || monthCalendar1.SelectionRange.Start.ToShortDateString() == null)
  19. {
  20. MessageBox.Show("Please enter all values and pick a date", "Invalid entry");
  21. return;
  22. }
  23. }
  24.  
  25. private void btnFinish_Click(object sender, EventArgs e)
  26. {
  27. checkValues();
  28.  
  29. //all good, insert
  30.  
  31. int year = monthCalendar1.SelectionStart.Year;
  32. int month = monthCalendar1.SelectionStart.Month;
  33. int day = monthCalendar1.SelectionStart.Day;
  34.  
  35. Data newData = new Data(user, tableName, year, month, day, int.Parse(tbFrom.Text), int.Parse(tbTo.Text),
  36. double.Parse(tbDrop.Text), double.Parse(tbResult.Text), int.Parse(tbHeadcount.Text));
  37.  
  38. DbConnect conn = new DbConnect();
  39. conn.openConnection();
  40. conn.addNewData(newData);
  41. conn.closeConnection();
  42.  
  43. MessageBox.Show("Successfully added!");
  44. this.Close();
  45.  
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement