public static void Load() { if (File.Exists(@"C:\Temp\spisok.json") == true) { string s = File.ReadAllText(@"C:\Temp\spisok.json"); dbContext = System.Text.Json.JsonSerializer.Deserialize <database>(s); } else { dbContext = new database(); } }
private void confirmB_Click(object sender, EventArgs e) { /*add the information to the row*/ data = new database(); /*search for the userID*/ Guid guid; data.myCommand.CommandText = "SELECT UserID from Users where Users.username =@user"; data.myCommand.Parameters.AddWithValue("user", customerFName.Text); try { guid = (Guid)data.myCommand.ExecuteScalar(); data.myCommand.Parameters.Clear(); } catch { MessageBox.Show("User does not exist"); } Guid guidLocation; data.myCommand.CommandText = "SELECT BranchID from Branch where Branch.Location =@location"; data.myCommand.Parameters.AddWithValue("location", locationB.SelectedItem); guidLocation = (Guid)data.myCommand.ExecuteScalar(); data.myCommand.Parameters.Clear(); try { guidLocation = (Guid)data.myCommand.ExecuteScalar(); data.myCommand.Parameters.Clear(); Decimal price = calPrice(CarID, startTimePicker, endTimePicker);//calculate price /*insert the row*/ Guid guidRev = Guid.NewGuid(); data.myCommand.CommandText = "INSERT INTO [dbo].[Reservation] VALUES (@ReservationID, @startDate, @endDate, @price, @BranchID, @VehicleID, @UserID)"; data.myCommand.Parameters.AddWithValue("ReservationID", guidRev); data.myCommand.Parameters.AddWithValue("startDate", startTimePicker.Value); data.myCommand.Parameters.AddWithValue("endDate", endTimePicker.Value); data.myCommand.Parameters.AddWithValue("price", price); data.myCommand.Parameters.AddWithValue("BranchID", guidLocation); data.myCommand.Parameters.AddWithValue("VehicleID", CarID); data.myCommand.Parameters.AddWithValue("UserID", customerID); data.myCommand.ExecuteNonQuery(); data.myCommand.Parameters.Clear(); //MessageBox.Show("Reservation added"); } catch { MessageBox.Show("Please choose a city"); } this.Close(); }
private void pictureBox2_Click(object sender, EventArgs e) { database obj = new database(); obj.Show(); }
public Reservation() { InitializeComponent(); data = new database(); }
public Form1() { InitializeComponent(); db = new database(); flag = true; }