private void record_txt_Click(object sender, EventArgs e) { string reference = "INV" + Random(); string payRef = "awaiting"; SqlConnection cnn = new SqlConnection(connectionString); SqlCommand comm = new SqlCommand(); comm.CommandType = CommandType.Text; comm.Connection = cnn; comm.CommandText = "INSERT INTO invoice (c_id, date_added, customer, status, items, description, quantity, unit_value, total, notes, notes_internal, ref, payment_ref) VALUES (@c_id, @date_added, @customer, @status, @items, @description, @quantity, @unit_value, @total, @notes, @notes_internal, @ref, @payment_ref)"; comm.Parameters.AddWithValue("@c_id", Int32.Parse(customer_dd.SelectedValue.ToString())); comm.Parameters.AddWithValue("@date_added", DateTime.Today.ToShortDateString()); comm.Parameters.AddWithValue("@customer", customer_dd.Text); comm.Parameters.AddWithValue("@status", Int32.Parse(status)); comm.Parameters.AddWithValue("@items", "Item"); // from gridview comm.Parameters.AddWithValue("@description", "Descrioption"); // from gridview comm.Parameters.AddWithValue("@quantity", Int32.Parse(("Qty").ToString())); // from gridview comm.Parameters.AddWithValue("@unit_value", Int32.Parse("Unit_Value")); // from gridview comm.Parameters.AddWithValue("@total", Int32.Parse("Line_Total")); // from gridview comm.Parameters.AddWithValue("@notes", notes_txt.Text); comm.Parameters.AddWithValue("@notes_internal", internal_txt.Text); comm.Parameters.AddWithValue("@ref", reference); comm.Parameters.AddWithValue("@payment_ref", payRef); cnn.Open(); comm.ExecuteNonQuery(); cnn.Close();