Skip to content

Instantly share code, notes, and snippets.

@archer884
Last active August 29, 2015 14:21
Show Gist options
  • Save archer884/b2a47269f297404145d9 to your computer and use it in GitHub Desktop.
Save archer884/b2a47269f297404145d9 to your computer and use it in GitHub Desktop.
/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