Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using Microsoft.Win32;
- namespace WindowsFormsApplication2
- {
- public partial class Main : Form
- {
- public Main()
- {
- InitializeComponent();
- }
- private void Main_Load(object sender, EventArgs e)
- {
- // TODO: This line of code loads data into the 'userLoginDataSet.WeaponData' table. You can move, or remove it, as needed.
- this.weaponDataTableAdapter.Fill(this.userLoginDataSet.WeaponData);
- }
- private void panel1_Paint(object sender, PaintEventArgs e)
- {
- }
- private void pictureBox1_Click(object sender, EventArgs e)
- {
- }
- private void button1_Click(object sender, EventArgs e)
- {
- AddWeapon aw = new AddWeapon();
- aw.Show();
- }
- }
- }
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Data.SqlClient;
- using System.Data.Sql;
- using Microsoft.Win32;
- using System.Threading;
- namespace WindowsFormsApplication2
- {
- public partial class AddWeapon : Form
- {
- public AddWeapon()
- {
- InitializeComponent();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- SqlConnection con = new SqlConnection(@"Data Source=.SQLEXPRESS;AttachDbFilename=C:UsersbrmcbridDocumentsVisual Studio 2010ProjectsWindowsFormsApplication2WindowsFormsApplication2UserLogin.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
- 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);
- this.Close();
- }
- }
- }
- private void Main_Activated(object sender, EventArgs e)
- {
- // write your code here
- }
- AddWeapon aw = new AddWeapon(this); // pass this, the main form
- aw.Show();
- public partial class AddWeapon : Form
- {
- private Main _mainForm;
- public AddWeapon()
- {
- InitializeComponent();
- }
- public AddWeapon(Main mainForm) : this()
- {
- this._mainForm = mainForm;
- }
- // remaining code.
- private void button1_Click(object sender, EventArgs e)
- {
- SqlConnection con = new SqlConnection(@"Data Source=.SQLEXPRESS;AttachDbFilename=C:UsersbrmcbridDocumentsVisual Studio 2010ProjectsWindowsFormsApplication2WindowsFormsApplication2UserLogin.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
- 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);
- // call a public method on the main form that can update the data.
- this._mainForm.UpdateData();
- this.Close();
- }
- }
- AddWeapon aw = new AddWeapon();
- aw.Main = this;
- aw.Show();
- AddWeapon aw = new AddWeapon();
- aw.OnDataInserted += this.DataInserted;
- aw.Show();
- public event EventHandler DataInserted;
- private void button1_Click(object sender, EventArgs e)
- {
- SqlConnection con = new SqlConnection(@"Data Source=.SQLEXPRESS;AttachDbFilename=C:UsersbrmcbridDocumentsVisual Studio 2010ProjectsWindowsFormsApplication2WindowsFormsApplication2UserLogin.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
- 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);
- if (this.DataInserted != null)
- {
- this.DataInserted();
- }
- this.Close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement