Last active
August 29, 2015 14:21
-
-
Save archer884/b2a47269f297404145d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/Closes the window and commits the order to the database | |
private void btnComplete_Click(object sender, EventArgs e) | |
{ | |
using(var conn = new OleDbConnection(Utilities.CONNECTION_STRING)) | |
{ | |
OleDbCommand cmd = new OleDbCommand | |
("INSERT INTO tblOrders ([OrdersProducts],[OrdersSoldTo],[OrdersTotalPrice])Values(@Products,@Clients,@TotalCost)"); | |
cmd.Connection = conn; | |
conn.Open(); | |
if (conn.State == ConnectionState.Open) | |
{ | |
cmd.Parameters.Add("@Products",OleDbType.VarChar).Value = txtTotal.Text; | |
cmd.Parameters.Add("@Clients",OleDbType.VarChar).Value = cbClients.Text; | |
cmd.Parameters.Add("@TotalCost",OleDbType.Numeric).Value = txtTotalCost.Text; | |
try | |
{ | |
cmd.ExecuteNonQuery(); | |
conn.Close(); | |
} | |
catch(Exception ex) | |
{ | |
MessageBox.Show(ex.Message); | |
} | |
} | |
else | |
{ | |
MessageBox.Show("Somethings fucky"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment