I have a problem with class which should: issue couple invoices, shows/update progress bar and save to nhibernate classes some values. Below code shows function which calls WyemitujFakture and display progress bar windows.
private void BtOK_Click(object sender, EventArgs e)
{
lista.Add(2);
lista.Add(8);
liczbaWygenerowach = 0;
ilosc_zrobionych = 0;
fpb = new FrmProgressBar("Emisja faktur potwierdzonych, proszę czekać...");
fpb.Show();
Application.DoEvents();
WyemitujFakture(lista);
fpb.Close();
}
Windows form shows progress bar and invoices are generate but can not save values from nHibernate classes. It looks like lines: fs.Save(); and Session.Flush(); do not work. Have You got any idea how to resolve this problem?
private void WyemitujFakture(List<int> lista)
{
foreach (int knh_id in lista)
{
try
{
if (luk.Count > 0)
{
FakturySprzedazy fs = new FakturySprzedazy();
fs.FKS_AKCYZA = false;
fs.FKS_CZY_KLON = false;
fs.FKS_DATA_DOW_KS = Convert.ToDateTime(MTBDataZapisuDoFK.Text);
fs.FKS_DATA_FAKTURY = Convert.ToDateTime(MTBDataFaktury.Text);
fs.FKS_DATA_SPRZEDAZY = Convert.ToDateTime(MTBDataSprzedazy.Text);
fs.Save();
Session.Flush();
liczbaWygenerowach++;
}
}
catch (Exception ex)
{
MessageBox.Show("Nie mozna wyemitowac faktury dla kontrahenta o id = " + knh_id.ToString() + " " + ex.Message);
}
ilosc_zrobionych++;
fpb.PBStan.Value = (int)((100 * ilosc_zrobionych) / liczbaKontrahentow);
Application.DoEvents();
}
}
Many thanks for help in advance