Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8541785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T11:54:35+00:00 2026-06-11T11:54:35+00:00

I have a problem with class which should: issue couple invoices, shows/update progress bar

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T11:54:36+00:00Added an answer on June 11, 2026 at 11:54 am

    Dear Craig Ringer,

    Thank U for Your quick reaction. I have not got any error message and I have version 9,1 of postgresql.

    I have found solution:)

    Function “WyemitujFakture” is in thread so it hasnot got access to SessionScope object which is created in main thread. I added to function WyemitujFakture 4 lines:

    SessionScope session2 = new SessionScope(FlushAction.Never);
                        fs.Save();
                        session2.Flush();
    if (session2 != null) session2.Dispose();
    

    Above 4 lines have resolved problem.
    Below I attached whole function which works properly:

    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);
        SessionScope session2 = new SessionScope(FlushAction.Never);
                        fs.Save();
                        session2.Flush();
       session2.Flush();
    
    
       if (session2 != null) session2.Dispose();
       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();
    }
    }
    

    Thank You for Your engagement!!!!

    Best regards!!!!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a problem to test my non activity-class which need the context of
I have the following tricky problem: I have implemented a (rather complicated) class which
Here is my problem, I have a class which have a object who throw
I have the following problem. I have a class named A in which I
I'm having an issue dealing with two entities which should have a relationship of
Hi I have some issue regarding constructor and destructor. I have list class, which
Good day, I have the following problem: class B extends class A and methods
I have a design problem: Question class: have a question and answer (String) TextQuestion
I have a problem with ViewHolder class. I use ViewHolder to improve my List
I have problem organizing my unittest based class test for family of tests. For

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.