private void btnAddnewPurchase_Click(object sender, EventArgs e) { try { DataTable dt = new DataTable(); dt.Columns.Add("REF"); dt.Columns.Add("QUT_CD"); foreach (DataGridViewRow dr in dgvFacture.Rows) { dt.Rows.Add(dr.Cells[0].Value, dr.Cells[3].Value); } CLASS_FACTURE.PS_INSERTFACTURE(dateTimePicker1.Value, Convert.ToDecimal(txttotal.Text), Convert.ToDecimal(txtrest.Text), txtCodeclient.Text, dt); MessageBox.Show("Ajoute reussit."); PrintPurchase.Enabled = true; } catch (SqlException ex) { MessageBox.Show(ex.Message + ex.Number.ToString()); } }