Advertisement
Guest User

form

a guest
Apr 25th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using Oracle.ManagedDataAccess.Client;
  11. using PaymentClasses;
  12. using Databases;
  13.  
  14. namespace Lab_6
  15. {
  16. public partial class frmCustomer : Form
  17. {
  18. frmPayment payForm;
  19. public static Payment payment;
  20.  
  21. CustomerTable table;
  22.  
  23. public frmCustomer()
  24. {
  25. InitializeComponent();
  26. payForm = new frmPayment();
  27. payment = new Payment();
  28. txtFName.Enabled = false;
  29. txtAdd.Enabled = false;
  30.  
  31. table = new CustomerTable();
  32. //cmbManufacturer.DataSource = manufacturers;
  33. }
  34.  
  35. private void btnPayment_Click(object sender, EventArgs e)
  36. {
  37. payment.Customer = new Customer(txtFName.Text, txtLName.Text, txtAdd.Text);
  38.  
  39.  
  40. try
  41. {
  42. Customer custt = table.GetCustomer(Convert.ToString(txtLName.Text));
  43. txtFName.Text = custt.FirstName;
  44. txtAdd.Text = custt.Address;
  45. }
  46. catch (OracleException objException)
  47. {
  48. MessageBox.Show("A problem occurred with the database: " + objException.Message + " Please contact the programmer");
  49. Close();
  50. }
  51. catch (Exception objException)
  52. {
  53. if (objException.Message == "Sorry, that record id doesn't exist on the database")
  54. {
  55. MessageBox.Show(objException.Message);
  56. }
  57. else
  58. {
  59. MessageBox.Show(objException.Message, objException.GetType().ToString());
  60. }
  61. }
  62.  
  63. }
  64.  
  65. private void btnClear_Click(object sender, EventArgs e)
  66. {
  67. DialogResult dialogResult = MessageBox.Show("Do you want to start a new customer and payment?", "New?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
  68. switch (dialogResult)
  69. {
  70. case System.Windows.Forms.DialogResult.Yes:
  71. //payForm = new frmPayment();
  72. txtAdd.Text = string.Empty;
  73. txtFName.Text = string.Empty;
  74. txtLName.Text = string.Empty;
  75. break;
  76. }
  77. }
  78.  
  79. private void btnExit_Click(object sender, EventArgs e)
  80. {
  81. Close();
  82. }
  83. }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement