Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Data.OleDb;
- using System.Linq;
- using System.Security.Claims;
- using System.Text;
- using System.Threading.Tasks;
- namespace theater
- {
- internal class Connection
- {
- OleDbConnection connect;
- OleDbCommand command;
- private void connectionTo()
- {
- //connect = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\TCP PROJECT\repairs.accdb");
- connect = new OleDbConnection(@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\ShittyRestaurant\Documents\Theater.accdb");
- command = connect.CreateCommand();
- }
- public Connection()
- {
- connectionTo();
- //('1', '1', '1', 1, 1, 1, '1')";;
- }
- public void insert(Theater theater)
- {
- try
- {
- command.CommandText = "Insert into Theater([Staging], [Director], [Author], [Year], [Actor], [Actor_name], [Title], [Role], [Gender]) Values('" +
- theater.Staging + "','" + theater.Director + "','" + theater.Author + "','" + theater.Year + "','" + theater.Actor + "','" + theater.Actor_name + "','" + theater.Title + "','" + theater.Role + "','" + theater.Gender +
- "')";
- command.CommandType = System.Data.CommandType.Text;
- connect.Open();
- command.ExecuteNonQuery();
- }
- catch (Exception)
- {
- System.Windows.Forms.MessageBox.Show("Incorrect data.");
- }
- finally
- {
- if (connect != null)
- {
- connect.Close();
- }
- }
- }
- public void updateCar(Theater theater)
- {
- try
- {
- command.CommandText = "UPDATE Theater SET Staging = '" + theater.Staging + "', Director = '" + theater.Director + "', Author = '" + theater.Author +
- "', [Year] = '" + theater.Year + "', Actor = '" +theater.Actor + "', Actor_name = '" + theater.Actor_name + "', Title = '" + theater.Title + "', Role = '" + theater.Role + "', Gender = '" + theater.Gender + "' Where Theater_ID=" + theater.Theater_ID;
- // command.CommandText = "UPDATE Car SET Reg_number = '" + car.Reg_number + "' WHERE Car_id = " + car.Car_id;
- command.CommandType = System.Data.CommandType.Text;
- connect.Open();
- command.ExecuteNonQuery();
- }
- catch (Exception)
- {
- System.Windows.Forms.MessageBox.Show("Incorrect data.");
- }
- finally
- {
- if (connect != null)
- {
- connect.Close();
- }
- }
- }
- public void deleteCar(Theater theater)
- {
- try
- {
- command.CommandText = "Delete From Theater WHERE Theater_ID=" + theater.Theater_ID;
- // command.CommandText = "UPDATE Car SET Reg_number = '" + car.Reg_number + "' WHERE Car_id = " + car.Car_id;
- command.CommandType = System.Data.CommandType.Text;
- connect.Open();
- command.ExecuteNonQuery();
- }
- catch (Exception)
- {
- System.Windows.Forms.MessageBox.Show("Incorrect data.");
- }
- finally
- {
- if (connect != null)
- {
- connect.Close();
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement