Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2014
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.23 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.Windows.Forms;
  9. using Microsoft.Win32;
  10.  
  11. namespace WindowsFormsApplication2
  12. {
  13. public partial class Main : Form
  14. {
  15.  
  16.  
  17. public Main()
  18. {
  19.  
  20. InitializeComponent();
  21. }
  22.  
  23. private void Main_Load(object sender, EventArgs e)
  24. {
  25. // TODO: This line of code loads data into the 'userLoginDataSet.WeaponData' table. You can move, or remove it, as needed.
  26. this.weaponDataTableAdapter.Fill(this.userLoginDataSet.WeaponData);
  27.  
  28. }
  29.  
  30. private void panel1_Paint(object sender, PaintEventArgs e)
  31. {
  32.  
  33. }
  34.  
  35. private void pictureBox1_Click(object sender, EventArgs e)
  36. {
  37.  
  38. }
  39.  
  40. private void button1_Click(object sender, EventArgs e)
  41. {
  42.  
  43.  
  44.  
  45. AddWeapon aw = new AddWeapon();
  46. aw.Show();
  47. }
  48.  
  49. }
  50.  
  51. }
  52.  
  53. using System;
  54. using System.Collections.Generic;
  55. using System.ComponentModel;
  56. using System.Data;
  57. using System.Drawing;
  58. using System.Linq;
  59. using System.Text;
  60. using System.Windows.Forms;
  61. using System.Data.SqlClient;
  62. using System.Data.Sql;
  63. using Microsoft.Win32;
  64. using System.Threading;
  65.  
  66. namespace WindowsFormsApplication2
  67. {
  68. public partial class AddWeapon : Form
  69. {
  70. public AddWeapon()
  71. {
  72. InitializeComponent();
  73. }
  74.  
  75. private void button2_Click(object sender, EventArgs e)
  76. {
  77. this.Close();
  78. }
  79.  
  80. private void button1_Click(object sender, EventArgs e)
  81. {
  82. SqlConnection con = new SqlConnection(@"Data Source=.SQLEXPRESS;AttachDbFilename=C:UsersbrmcbridDocumentsVisual Studio 2010ProjectsWindowsFormsApplication2WindowsFormsApplication2UserLogin.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
  83. SqlCommand cmd = new SqlCommand("INSERT into WeaponData values('" + serialNumber.Text + "','" + brand.Text + "','" + model.Text + "','" + caliber.Text + "','" + type.Text + "' , '" + dateAcquired.Text + "', '" + dateSold.Text + "', '" + purchasePrice.Text + "', '" + sellPrice.Text + "', '" + notes.Text + "')", con);
  84.  
  85.  
  86.  
  87. this.Close();
  88. }
  89.  
  90.  
  91. }
  92. }
  93.  
  94. private void Main_Activated(object sender, EventArgs e)
  95. {
  96. // write your code here
  97. }
  98.  
  99. AddWeapon aw = new AddWeapon(this); // pass this, the main form
  100. aw.Show();
  101.  
  102. public partial class AddWeapon : Form
  103. {
  104. private Main _mainForm;
  105.  
  106. public AddWeapon()
  107. {
  108. InitializeComponent();
  109. }
  110.  
  111. public AddWeapon(Main mainForm) : this()
  112. {
  113. this._mainForm = mainForm;
  114. }
  115.  
  116. // remaining code.
  117.  
  118. private void button1_Click(object sender, EventArgs e)
  119. {
  120. SqlConnection con = new SqlConnection(@"Data Source=.SQLEXPRESS;AttachDbFilename=C:UsersbrmcbridDocumentsVisual Studio 2010ProjectsWindowsFormsApplication2WindowsFormsApplication2UserLogin.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
  121. SqlCommand cmd = new SqlCommand("INSERT into WeaponData values('" + serialNumber.Text + "','" + brand.Text + "','" + model.Text + "','" + caliber.Text + "','" + type.Text + "' , '" + dateAcquired.Text + "', '" + dateSold.Text + "', '" + purchasePrice.Text + "', '" + sellPrice.Text + "', '" + notes.Text + "')", con);
  122.  
  123. // call a public method on the main form that can update the data.
  124. this._mainForm.UpdateData();
  125.  
  126. this.Close();
  127. }
  128. }
  129.  
  130. AddWeapon aw = new AddWeapon();
  131. aw.Main = this;
  132.  
  133. aw.Show();
  134.  
  135. AddWeapon aw = new AddWeapon();
  136. aw.OnDataInserted += this.DataInserted;
  137. aw.Show();
  138.  
  139. public event EventHandler DataInserted;
  140.  
  141. private void button1_Click(object sender, EventArgs e)
  142. {
  143. SqlConnection con = new SqlConnection(@"Data Source=.SQLEXPRESS;AttachDbFilename=C:UsersbrmcbridDocumentsVisual Studio 2010ProjectsWindowsFormsApplication2WindowsFormsApplication2UserLogin.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
  144. SqlCommand cmd = new SqlCommand("INSERT into WeaponData values('" + serialNumber.Text + "','" + brand.Text + "','" + model.Text + "','" + caliber.Text + "','" + type.Text + "' , '" + dateAcquired.Text + "', '" + dateSold.Text + "', '" + purchasePrice.Text + "', '" + sellPrice.Text + "', '" + notes.Text + "')", con);
  145.  
  146. if (this.DataInserted != null)
  147. {
  148. this.DataInserted();
  149. }
  150.  
  151. this.Close();
  152. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement