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 System.Data.SqlClient;
- namespace ProjDatabase
- {
- public partial class Form2 : Form
- {
- public Form2()
- {
- InitializeComponent();
- }
- ////BELOW WILL BE INVOKED IF THE BUTTON "Cancel" is Clicked
- //private void btnCancel_Click(object sender, EventArgs e)
- //{
- //}
- //BELOW WILL BE INVOKED IF THE BUTTON "Saving NOT Using DataSet" is Clicked
- // private void btnSubmit_Click(object sender, EventArgs e)
- // {
- // try
- // {
- // //GET THE DATA IN THE FORM and store them in variables
- // string FigureName, Height, Scale, Price, ProductNumber, Manufacturer, iType, ReleaseDate;
- // FigureName = txtNameofFigurine.Text.ToString();
- // Height = txtHeight.Text.ToString();
- // Scale = txtScale.Text.ToString();
- // Price = txtPrice.Text.ToString();
- // ProductNumber = txtProductNumber.Text.ToString();
- // Manufacturer =txtManufacturer.Text.ToString();
- // iType = txtiType.Text.ToString();
- // ReleaseDate = txtReleaseDate.Text.ToString();
- // //ACCESS THE DATA SOURCE
- // string connString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\marvin\Desktop\FigureSaleDatabase.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
- // SqlConnection connStudent = new SqlConnection(connString);
- // connStudent.Open();
- // string sqlInsertStatement = @"Insert into Name (FigureName, Height, Scale, Price, Product Number)
- // Values ('" + FigureName + "','" +Height + "', '" + Scale + "', '"
- // + Price + "', '" + ProductNumber + "' )";
- // SqlCommand cmdTxt = new SqlCommand(sqlInsertStatement, connStudent);
- // cmdTxt.ExecuteNonQuery();
- // MessageBox.Show("Saving is done!");
- // //CLOSE THE DATA SOURCE
- // connStudent.Close();
- // connStudent.Dispose();
- // this.Close(); //CLOSE THE FORM
- // }
- // catch (Exception exc)
- // {
- // MessageBox.Show(exc.Message);
- // }
- private void btnCancel_Click_1(object sender, EventArgs e)
- {
- this.Close();
- }
- private void btnSubmit_Click_1(object sender, EventArgs e)
- {
- try
- {
- //GET THE DATA IN THE FORM and store them in variables
- string FigureName, Height, Scale, Price, ProductNumber, Manufacturer, iType, ReleaseDate;
- FigureName = txtNameofFigurine.Text.ToString();
- Height = txtHeight.Text.ToString();
- Scale = txtScale.Text.ToString();
- Price = txtPrice.Text.ToString();
- ProductNumber = txtProductNumber.Text.ToString();
- Manufacturer = txtManufacturer.Text.ToString();
- iType = txtiType.Text.ToString();
- ReleaseDate = txtReleaseDate.Text.ToString();
- //ACCESS THE DATA SOURCE
- string connString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\marvin\Desktop\FigureSaleDatabase.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True";
- SqlConnection connStudent = new SqlConnection(connString);
- connStudent.Open();
- string sqlInsertStatement = @"Insert into Name (FigureName, Height, Scale, Price, ProductNumber)
- Values ('" + FigureName + "','" + Height + "', '" + Scale + "', '"
- + Price + "', '" + ProductNumber + "' )";
- string sqlInsertStatement1 = @"Insert into Manufacturer (Manufacturer, iType, ReleaseDate, ProductNumber)
- Values ('" + Manufacturer + "','" +iType + "', '" + ReleaseDate + "', '"
- + ProductNumber + "' )";
- SqlCommand cmdTxt = new SqlCommand(sqlInsertStatement + sqlInsertStatement1, connStudent);
- //cmdTxt.ExecuteNonQuery();
- MessageBox.Show("Saving is done!");
- //CLOSE THE DATA SOURCE
- connStudent.Close();
- connStudent.Dispose();
- this.Close(); //CLOSE THE FORM
- }
- catch (Exception exc)
- {
- MessageBox.Show(exc.Message);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement