I am trying to insert data from frm1
and frm2
into SQL Server at the same time. frm1
contains product information (barcode, qty , price, vat, total etc) and frm2
(contains payments information like cash and change). The idea is that when the user clicks the btnfrm2
the data from frm1
should be passed into frm2
(but not displayed), and in frm2
the user gives the payment info (cash and change) and after clicking btnsave
the data from frm1
and frm2
should be inserted into the database.
I created a class, and a method to pass data to frm2
.
internal void mbushe(string[] args)
{
for (int i = 0; i < dataTable.Rows.Count; i++)
{
arka_data ad = new arka_data();
ad.NR = int.Parse(txtnrfatures.Text);
ad.VLERATVSHTOTAL = float.Parse(textBox1.Text);
ad.BARKODI = int.Parse(dataTable.Rows[i][0].ToString());
ad.EMERTIMI = dataTable.Rows[i][1].ToString();
ad.SASIA = int.Parse(dataTable.Rows[i][2].ToString());
ad.CMIMI = int.Parse(dataTable.Rows[i][3].ToString());
ad.TVSH = int.Parse(dataTable.Rows[i][4].ToString());
ad.NENTOTALI = float.Parse(txttotali.Text);
ad.ZBRITJA = float.Parse(txtzbritja.Text);
ad.TOTALI = float.Parse(totali.Text);
ad.KOHA = DateTime.Now;
ad.KASIERI = lbluser.Text;
ad.KLIENTI = cmbklienti.Text;
ad.VLERAETVSH = float.Parse(dataTable.Rows[i][7].ToString());
ad.VLERAPATVSH = float.Parse(dataTable.Rows[i][6].ToString());
ad.NRATIKUJVE = int.Parse(lblnumri.Text);
ad.TOTALIPCS = float.Parse(dataTable.Rows[i][5].ToString());
}
}
public class arka_data
{
public int NR { get; set; }
public int BARKODI { get; set; }
public string EMERTIMI { get; set; }
public int SASIA { get; set; }
public float CMIMI { get; set; }
public float TVSH { get; set; }
public float TOTAL { get; set; }
public float NENTOTALI { get; set; }
public float ZBRITJA { get; set; }
public float TOTALI { get; set; }
public DateTime KOHA { get; set; }
public string KASIERI { get; set; }
public string KLIENTI { get; set; }
public float VLERAETVSH { get; set; }
public float VLERAPATVSH { get; set; }
public int NRATIKUJVE { get; set; }
public float TOTALIPCS { get; set; }
public float VLERATVSHTOTAL { get; set; }
}
and in the second form I will use the elements of method( from first form)
cmd.Parameters.Add(new SqlParameter("@nrfatures", mbushe.NR);
cmd.Parameters.Add(new SqlParameter("@klienti", mbushe.Barkodi)); etc
while mbushe is the method from first form