public void OrderSave(OrderClass aOrderClass) { connect.Open(); string insertQuery = string.Format("INSERT INTO OrderInfo VALUES({0},{1},{2},{3},{4},'{5}')", aOrderClass.Cust_ID, aOrderClass.Item_ID, aOrderClass.Quantity, aOrderClass.Unit_Price, aOrderClass.Bill, aOrderClass.Date); SqlCommand comm = new SqlCommand(insertQuery, connect); comm.ExecuteNonQuery(); connect.Close(); }
private void saveButton_Click(object sender, EventArgs e) { if (qtyTextBox.Text == "" || unitPriceTextBox.Text == "" || billTextBox.Text == "") { MessageBox.Show("Field value is missing", "Input Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } OrderClass aOrderClass = new OrderClass(); OrderGatewayClass aOrderGatewayClass = new OrderGatewayClass(); aOrderClass.Cust_ID = Convert.ToInt32(customer_comboBox.SelectedValue); aOrderClass.Item_ID = Convert.ToInt32(item_ComboBox.SelectedValue); aOrderClass.Quantity = Convert.ToInt32(qtyTextBox.Text); aOrderClass.Unit_Price = Convert.ToInt32(unitPriceTextBox.Text); aOrderClass.Bill = Convert.ToInt32(billTextBox.Text); aOrderClass.Date = Convert.ToDateTime(txt_Date.Text); aOrderGatewayClass.OrderSave(aOrderClass); //reset(); MessageBox.Show("Data Saved", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); }