当前位置: 首页>>代码示例>>C#>>正文


C# IDataContext.BeginTransaction方法代码示例

本文整理汇总了C#中IDataContext.BeginTransaction方法的典型用法代码示例。如果您正苦于以下问题:C# IDataContext.BeginTransaction方法的具体用法?C# IDataContext.BeginTransaction怎么用?C# IDataContext.BeginTransaction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IDataContext的用法示例。


在下文中一共展示了IDataContext.BeginTransaction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: insert

        public void insert()
        {
            try
            {
                DataAccessProviderFactory factory = new DataAccessProviderFactory();
                dataContext = factory.GetDataContext();
                dataContext.BeginTransaction();

                insertKategorijeGimnasticara();
                insertKluboviIMesta();
                insertDrzave();
                insertGimnasticari();
                insertRegistrovaniGimnasticari();
                insertSudije();

                dataContext.Commit();
            }
            catch (Exception ex)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                throw new InfrastructureException(
                    Strings.getFullDatabaseAccessExceptionMessage(ex), ex);
            }
            finally
            {
                if (dataContext != null)
                    dataContext.Dispose();
                dataContext = null;
            }
        }
开发者ID:stankela,项目名称:bilten,代码行数:31,代码来源:RegistarInitializer.cs

示例2: btnOK_Click

        // TODO: Dodaj provere i validaciju.
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                DataAccessProviderFactory factory = new DataAccessProviderFactory();
                dataContext = factory.GetDataContext();
                dataContext.BeginTransaction();

                takmicenje.ZrebZaFinalePoSpravama = textBox1.Text.Trim();
                dataContext.Save(takmicenje);
                dataContext.Commit();
            }
            catch (Exception ex)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                MessageDialogs.showError(
                    Strings.getFullDatabaseAccessExceptionMessage(ex), this.Text);
                this.DialogResult = DialogResult.Cancel;
            }
            finally
            {
                if (dataContext != null)
                    dataContext.Dispose();
                dataContext = null;
            }
        }
开发者ID:stankela,项目名称:bilten,代码行数:28,代码来源:ZrebForm.cs

示例3: OtvoriTakmicenjeForm

        public OtvoriTakmicenjeForm(Nullable<int> currTakmicenjeId, bool selectMode, int broj, bool gornjaGranica)
        {
            InitializeComponent();
            this.currTakmicenjeId = currTakmicenjeId;
            this.selectMode = selectMode;
            this.broj = broj;
            this.gornjaGranica = gornjaGranica;

            try
            {
                DataAccessProviderFactory factory = new DataAccessProviderFactory();
                dataContext = factory.GetDataContext();
                dataContext.BeginTransaction();

                initUI();
                takmicenja = loadTakmicenja();
                setTakmicenja(takmicenja);

                //          dataContext.Commit();
            }
            catch (Exception ex)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                throw new InfrastructureException(
                    Strings.getFullDatabaseAccessExceptionMessage(ex), ex);
            }
            finally
            {
                if (dataContext != null)
                    dataContext.Dispose();
                dataContext = null;
            }
        }
开发者ID:stankela,项目名称:bilten,代码行数:34,代码来源:OtvoriTakmicenjeForm.cs

示例4: SelectGimnasticariPrethTakmForm

        public SelectGimnasticariPrethTakmForm(Gimnastika gim, bool izborTakmicenja)
        {
            InitializeComponent();
            this.gim = gim;
            this.izborTakmicenja = izborTakmicenja;
            try
            {
                DataAccessProviderFactory factory = new DataAccessProviderFactory();
                dataContext = factory.GetDataContext();
                dataContext.BeginTransaction();

                initUI();
                gimMap = new Dictionary<int, List<GimnasticarUcesnik>>();
                takmicenja = loadTakmicenja(gim);
                setTakmicenja(takmicenja);
            }
            catch (Exception ex)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                throw new InfrastructureException(
                    Strings.getFullDatabaseAccessExceptionMessage(ex), ex);
            }
            finally
            {
                if (dataContext != null)
                    dataContext.Dispose();
                dataContext = null;
            }
        }
开发者ID:stankela,项目名称:bilten,代码行数:30,代码来源:SelectGimnasticariPrethTakmForm.cs

示例5: ZrebForm

        public ZrebForm(int takmicenjeId)
        {
            InitializeComponent();
            try
            {
                DataAccessProviderFactory factory = new DataAccessProviderFactory();
                dataContext = factory.GetDataContext();
                dataContext.BeginTransaction();

                takmicenje = loadTakmicenje(takmicenjeId);

                initUI();

                //dataContext.Commit();
            }
            catch (Exception ex)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                throw new InfrastructureException(
                    Strings.getFullDatabaseAccessExceptionMessage(ex), ex);
            }
            finally
            {
                if (dataContext != null)
                    dataContext.Dispose();
                dataContext = null;
            }
        }
开发者ID:stankela,项目名称:bilten,代码行数:29,代码来源:ZrebForm.cs

示例6: RezultatiEkipeZbirViseKolaForm

        public RezultatiEkipeZbirViseKolaForm(int takmicenjeId)
        {
            InitializeComponent();

            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();
            try
            {
                DataAccessProviderFactory factory = new DataAccessProviderFactory();
                dataContext = factory.GetDataContext();
                dataContext.BeginTransaction();

                takmicenje = loadTakmicenje(takmicenjeId);

                IList<RezultatskoTakmicenje> svaRezTakmicenja = loadRezTakmicenja(takmicenje);
                if (svaRezTakmicenja.Count == 0)
                    throw new BusinessException("Morate najpre da unesete takmicarske kategorije.");

                rezTakmicenja = takmicenje.getRezTakmicenjaEkipe(svaRezTakmicenja, DeoTakmicenjaKod.Takmicenje1, true);
                if (rezTakmicenja.Count == 0)
                    throw new BusinessException("Ne postoji takmicenje IV ni za jednu kategoriju.");

                initUI();
                takmicenjeOpened = new bool[rezTakmicenja.Count];
                cmbTakmicenje.SelectedIndex = 0;

                cmbTakmicenje.SelectedIndexChanged += new EventHandler(cmbTakmicenje_SelectedIndexChanged);

                //onSelectedTakmicenjeChanged();
            }
            catch (BusinessException)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                throw;
            }
            catch (InfrastructureException)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                throw;
            }
            catch (Exception ex)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                throw new InfrastructureException(
                    Strings.getFullDatabaseAccessExceptionMessage(ex), ex);
            }
            finally
            {
                if (dataContext != null)
                    dataContext.Dispose();
                dataContext = null;

                Cursor.Hide();
                Cursor.Current = Cursors.Arrow;
            }
        }
开发者ID:stankela,项目名称:bilten,代码行数:59,代码来源:RezultatiEkipeZbirViseKolaForm.cs

示例7: RezultatiEkipeForm

        public RezultatiEkipeForm(int takmicenjeId, DeoTakmicenjaKod deoTakKod)
        {
            InitializeComponent();
            this.deoTakKod = deoTakKod;

            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();
            try
            {
                DataAccessProviderFactory factory = new DataAccessProviderFactory();
                dataContext = factory.GetDataContext();
                dataContext.BeginTransaction();

                takmicenje = dataContext.GetById<Takmicenje>(takmicenjeId);
                NHibernateUtil.Initialize(takmicenje);

                IList<RezultatskoTakmicenje> svaRezTakmicenja = loadRezTakmicenja(takmicenjeId);
                if (svaRezTakmicenja.Count == 0)
                    throw new BusinessException("Morate najpre da unesete takmicarske kategorije.");

                rezTakmicenja = takmicenje.getRezTakmicenjaEkipe(svaRezTakmicenja, deoTakKod, false);
                if (rezTakmicenja.Count == 0)
                    throw new BusinessException("Ne postoji takmicenje IV ni za jednu kategoriju.");

                ocene = loadOcene(takmicenjeId, deoTakKod);
                sviRezultatiUkupno = takmicenje.createRezultatiUkupnoZaSveEkipe(rezTakmicenja, ocene, deoTakKod);

                initUI();
                takmicenjeOpened = new bool[rezTakmicenja.Count];
            }
            catch (BusinessException)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                throw;
            }
            catch (InfrastructureException)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                throw;
            }
            catch (Exception ex)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                throw new InfrastructureException(
                    Strings.getFullDatabaseAccessExceptionMessage(ex), ex);
            }
            finally
            {
                if (dataContext != null)
                    dataContext.Dispose();
                dataContext = null;

                Cursor.Hide();
                Cursor.Current = Cursors.Arrow;
            }
        }
开发者ID:stankela,项目名称:bilten,代码行数:59,代码来源:RezultatiEkipeForm.cs

示例8: btnIzaberi_Click

        private void btnIzaberi_Click(object sender, EventArgs e)
        {
            DialogResult dlgResult = DialogResult.None;
            SelectGimnasticariPrethTakmForm form = null;
            try
            {
                form = new SelectGimnasticariPrethTakmForm(gimnastika, true);
                dlgResult = form.ShowDialog();
            }
            catch (InfrastructureException ex)
            {
                MessageDialogs.showError(ex.Message, this.Text);
                return;
            }

            if (dlgResult != DialogResult.OK || form.SelTakmicenje == null)
                return;

            try
            {
                DataAccessProviderFactory factory = new DataAccessProviderFactory();
                dataContext = factory.GetDataContext();
                dataContext.BeginTransaction();

                takmicenje = form.SelTakmicenje;
                txtTakmicenje.Text = takmicenje.Naziv;
                dataContext.Attach(takmicenje, false);

                lstTakmicenja.Items.Clear();
                takmicenja.Clear();
                foreach (RezultatskoTakmicenjeDescription d in takmicenje.TakmicenjeDescriptions)
                {
                    lstTakmicenja.Items.Add(d, true);
                    takmicenja.Add(d);
                }
                lstKategorije.Items.Clear();
                kategorije.Clear();
                foreach (TakmicarskaKategorija k in takmicenje.Kategorije)
                {
                    lstKategorije.Items.Add(k, true);
                    kategorije.Add(k);
                }
            }
            catch (Exception ex)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                MessageDialogs.showMessage(
                    Strings.getFullDatabaseAccessExceptionMessage(ex), this.Text);
                return;
            }
            finally
            {
                if (dataContext != null)
                    dataContext.Dispose();
                dataContext = null;
            }
        }
开发者ID:stankela,项目名称:bilten,代码行数:58,代码来源:KopirajTakmicenjeForm.cs

示例9: RezultatiSpravaForm

        public RezultatiSpravaForm(int takmicenjeId, DeoTakmicenjaKod deoTakKod, bool selectMode,
            RezultatskoTakmicenje startTakmicenje, Sprava startSprava)
        {
            InitializeComponent();
            this.deoTakKod = deoTakKod;
            this.selectMode = selectMode;

            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();
            try
            {
                DataAccessProviderFactory factory = new DataAccessProviderFactory();
                dataContext = factory.GetDataContext();
                dataContext.BeginTransaction();

                takmicenje = dataContext.GetById<Takmicenje>(takmicenjeId);
                NHibernateUtil.Initialize(takmicenje);

                IList<RezultatskoTakmicenje> svaRezTakmicenja = loadRezTakmicenja(takmicenjeId);
                if (svaRezTakmicenja.Count == 0)
                    throw new BusinessException("Morate najpre da unesete takmicarske kategorije.");

                rezTakmicenja = takmicenje.getRezTakmicenjaSprava(svaRezTakmicenja, deoTakKod, false);
                if (rezTakmicenja.Count == 0)
                    throw new BusinessException("Ne postoji takmicenje III ni za jednu kategoriju.");

                initUI(startTakmicenje, startSprava);
                rezultatiOpened = new HashSet<int>();
            }
            catch (BusinessException)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                throw;
            }
            catch (InfrastructureException)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                throw;
            }
            catch (Exception ex)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                throw new InfrastructureException(
                    Strings.getFullDatabaseAccessExceptionMessage(ex), ex);
            }
            finally
            {
                if (dataContext != null)
                    dataContext.Dispose();
                dataContext = null;

                Cursor.Hide();
                Cursor.Current = Cursors.Arrow;
            }
        }
开发者ID:stankela,项目名称:bilten,代码行数:58,代码来源:RezultatiSpravaForm.cs

示例10: KvalifikantiTak2Form

        public KvalifikantiTak2Form(int takmicenjeId)
        {
            InitializeComponent();
            try
            {
                DataAccessProviderFactory factory = new DataAccessProviderFactory();
                dataContext = factory.GetDataContext();
                dataContext.BeginTransaction();

                IList<RezultatskoTakmicenje> svaRezTakmicenja = loadRezTakmicenja(takmicenjeId);
                if (svaRezTakmicenja.Count == 0)
                    throw new BusinessException("Morate najpre da unesete takmicarske kategorije.");

                rezTakmicenja = new List<RezultatskoTakmicenje>();
                foreach (RezultatskoTakmicenje rt in svaRezTakmicenja)
                {
                    if (rt.Propozicije.PostojiTak2 && rt.Propozicije.OdvojenoTak2)
                        rezTakmicenja.Add(rt);
                }
                if (rezTakmicenja.Count == 0)
                    throw new BusinessException("Ne postoji odvojeno takmicenje II ni za jednu kategoriju.");

                takmicenje = dataContext.GetById<Takmicenje>(takmicenjeId);

                initUI();
                takmicenjeOpened = new bool[rezTakmicenja.Count];
                cmbTakmicenje.SelectedIndex = 0;

                cmbTakmicenje.SelectedIndexChanged += new EventHandler(cmbTakmicenje_SelectedIndexChanged);

                //onSelectedTakmicenjeChanged();
            }
            catch (BusinessException)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                throw;
            }
            catch (InfrastructureException)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                throw;
            }
            catch (Exception ex)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                throw new InfrastructureException(
                    Strings.getFullDatabaseAccessExceptionMessage(ex), ex);
            }
            finally
            {
                if (dataContext != null)
                    dataContext.Dispose();
                dataContext = null;
            }
        }
开发者ID:stankela,项目名称:bilten,代码行数:58,代码来源:KvalifikantiTak2Form.cs

示例11: OceneForm

        public OceneForm(int takmicenjeId, DeoTakmicenjaKod deoTakKod)
        {
            InitializeComponent();
            this.deoTakKod = deoTakKod;

            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();
            try
            {
                DataAccessProviderFactory factory = new DataAccessProviderFactory();
                dataContext = factory.GetDataContext();
                dataContext.BeginTransaction();

                kategorije = loadKategorije(takmicenjeId);
                if (kategorije.Count == 0)
                    throw new BusinessException("Morate najpre da unesete takmicarske kategorije.");

                takmicenje = dataContext.GetById<Takmicenje>(takmicenjeId);
                ocene = new Dictionary<int, List<Ocena>>();

                initUI();
                cmbKategorija.SelectedIndex = 0;
                cmbSprava.SelectedIndex = 0;

                cmbKategorija.SelectedIndexChanged += new EventHandler(selectedOceneChanged);
                cmbSprava.SelectedIndexChanged += new EventHandler(selectedOceneChanged);

                onSelectedOceneChanged();

              //          dataContext.Commit();
            }
            catch (BusinessException)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                throw;
            }
            catch (Exception ex)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                throw new InfrastructureException(
                    Strings.getFullDatabaseAccessExceptionMessage(ex), ex);
            }
            finally
            {
                if (dataContext != null)
                    dataContext.Dispose();
                dataContext = null;

                Cursor.Hide();
                Cursor.Current = Cursors.Arrow;
            }
        }
开发者ID:stankela,项目名称:bilten,代码行数:54,代码来源:OceneForm.cs

示例12: TakmicariKategorijeForm

        public TakmicariKategorijeForm(int takmicenjeId)
        {
            InitializeComponent();

            // TODO3: Probaj da nadjes nacin da obavestis korisnika da postoje gimnasticari koji su uneti u kategorije, a
            // nisu uneti u takmicenja (pa nece biti prikazani u rezultatima)

            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();
            try
            {
                DataAccessProviderFactory factory = new DataAccessProviderFactory();
                dataContext = factory.GetDataContext();
                dataContext.BeginTransaction();

                takmicarskeKategorije = loadKategorije(takmicenjeId);
                if (takmicarskeKategorije.Count == 0)
                    throw new BusinessException("Morate najpre da unesete takmicarske kategorije.");

                loadGimnasticari();

                takmicenje = dataContext.GetById<Takmicenje>(takmicenjeId);
                NHibernateUtil.Initialize(takmicenje);

                initUI();
                tabOpened = new bool[takmicarskeKategorije.Count];
                onSelectedIndexChanged();

                //dataContext.Commit();
            }
            catch(BusinessException)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                throw;
            }
            catch (Exception ex)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                throw new InfrastructureException(
                    Strings.getFullDatabaseAccessExceptionMessage(ex), ex);
            }
            finally
            {
                if (dataContext != null)
                    dataContext.Dispose();
                dataContext = null;

                Cursor.Hide();
                Cursor.Current = Cursors.Arrow;
            }
        }
开发者ID:stankela,项目名称:bilten,代码行数:53,代码来源:TakmicariKategorijeForm.cs

示例13: delete

        public void delete()
        {
            try
            {
                DataAccessProviderFactory factory = new DataAccessProviderFactory();
                dataContext = factory.GetDataContext();
                dataContext.BeginTransaction();

                IList<Gimnasticar> gimnasticari = dataContext.GetAll<Gimnasticar>();
                foreach (Gimnasticar g in gimnasticari)
                    dataContext.Delete(g);

                IList<KategorijaGimnasticara> kategorije = dataContext.GetAll<KategorijaGimnasticara>();
                foreach (KategorijaGimnasticara k in kategorije)
                    dataContext.Delete(k);

                IList<Klub> klubovi = dataContext.GetAll<Klub>();
                foreach (Klub k in klubovi)
                    dataContext.Delete(k);

                IList<Mesto> mesta = dataContext.GetAll<Mesto>();
                foreach (Mesto m in mesta)
                    dataContext.Delete(m);

                IList<Sudija> sudije = dataContext.GetAll<Sudija>();
                foreach (Sudija s in sudije)
                    dataContext.Delete(s);

                IList<Drzava> drzave = dataContext.GetAll<Drzava>();
                foreach (Drzava d in drzave)
                    dataContext.Delete(d);

                dataContext.Commit();
            }
            catch (Exception ex)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                throw new InfrastructureException(
                    Strings.getFullDatabaseAccessExceptionMessage(ex), ex);
            }
            finally
            {
                if (dataContext != null)
                    dataContext.Dispose();
                dataContext = null;
            }
        }
开发者ID:stankela,项目名称:bilten,代码行数:48,代码来源:RegistarInitializer.cs

示例14: KvalifikantiTak3EditorForm

        public KvalifikantiTak3EditorForm(int takmicenjeId, int rezTakmicenjeId, Sprava sprava)
        {
            InitializeComponent();
            this.sprava = sprava;
            try
            {
                DataAccessProviderFactory factory = new DataAccessProviderFactory();
                dataContext = factory.GetDataContext();
                dataContext.BeginTransaction();

                rezTakmicenje = loadRezTakmicenje(rezTakmicenjeId);
                if (rezTakmicenje == null)
                    throw new BusinessException("Greska u programu.");

                takmicenje = dataContext.GetById<Takmicenje>(takmicenjeId);
                NHibernateUtil.Initialize(takmicenje);

                initUI();
            }
            catch (BusinessException)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                throw;
            }
            catch (InfrastructureException)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                throw;
            }
            catch (Exception ex)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                throw new InfrastructureException(
                    Strings.getFullDatabaseAccessExceptionMessage(ex), ex);
            }
            finally
            {
                if (dataContext != null)
                    dataContext.Dispose();
                dataContext = null;
            }
        }
开发者ID:stankela,项目名称:bilten,代码行数:45,代码来源:KvalifikantiTak3EditorForm.cs

示例15: TakmicariTakmicenjaForm

        public TakmicariTakmicenjaForm(int takmicenjeId)
        {
            InitializeComponent();

            Cursor.Current = Cursors.WaitCursor;
            Cursor.Show();
            try
            {
                DataAccessProviderFactory factory = new DataAccessProviderFactory();
                dataContext = factory.GetDataContext();
                dataContext.BeginTransaction();

                rezTakmicenja = loadRezTakmicenja(takmicenjeId);
                if (rezTakmicenja.Count == 0)
                    throw new BusinessException("Morate najpre da unesete takmicarske kategorije.");

                initUI();
                tabOpened = new bool[rezTakmicenja.Count];
                onSelectedIndexChanged();

                //dataContext.Commit();
            }
            catch (BusinessException)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                throw;
            }
            catch (Exception ex)
            {
                if (dataContext != null && dataContext.IsInTransaction)
                    dataContext.Rollback();
                throw new InfrastructureException(
                    Strings.getFullDatabaseAccessExceptionMessage(ex), ex);
            }
            finally
            {
                if (dataContext != null)
                    dataContext.Dispose();
                dataContext = null;

                Cursor.Hide();
                Cursor.Current = Cursors.Arrow;
            }
        }
开发者ID:stankela,项目名称:bilten,代码行数:45,代码来源:TakmicariTakmicenjaForm.cs


注:本文中的IDataContext.BeginTransaction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。