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();
|
Sam HobbsPosted Aug 20, 2010, 3:39 AM
Sarah NelPosted Aug 20, 2010, 3:08 AM
I'm creating a Windows Application in Visual Studio 2005, coding in c#. I've tried using DataGrid and DataGridView from the toolbox.
Sam HobbsPosted Aug 19, 2010, 2:01 PM
You might benefit from my article Database Table Update in a DataGridView without Writing Code.
Sarah NelPosted Aug 19, 2010, 4:31 AM
Sam HobbsPosted Aug 19, 2010, 3:39 AM
Sarah NelPosted Aug 19, 2010, 3:28 AM
Sam HobbsPosted Aug 18, 2010, 11:38 AM