コード例 #1
0
        private void OkBtn_Click(object sender, EventArgs e)
        {
            PredmetRepository        predmetRepository        = new PredmetRepository(databaseContext);
            PredmetRocisteRepository predmetRocisteRepository = new PredmetRocisteRepository(databaseContext);
            RocisteRepository        rocisteRepository        = new RocisteRepository(databaseContext);
            UplataRepository         uplataRepository         = new UplataRepository(databaseContext);

            switch (funkcija)
            {
            case "nova":
            {
                PredmetModel predmet = predmetRepository.Find(UplataBrPredmetaTxt.Text);
                if (predmet == null)
                {
                    MessageBox.Show("Ne postoji trazeni predmet");
                }
                else
                {
                    uplataRepository.Add(predmet.Id, new UplataModel
                        {
                            Iznos     = Double.Parse(iznosTxt.Text),
                            Uplatilac = PlatilacTxt.Text,
                            Placeno   = placenoCB.Checked
                        });
                }
            }
            break;

            case "postojeca":
            {
                PredmetModel predmet = predmetRepository.Find(PostUplBrPrTxt.Text);
                try {
                    uplataRepository.Update(predmet.Id, UplataDGV.SelectedRows[0].Cells["Id"].Value.ToString(), (bool)UplataDGV.SelectedRows[0].Cells["Placeno"].Value);
                    MessageBox.Show("Uspesna uplata");
                }
                catch (Exception)
                {
                    MessageBox.Show("Morate selektovati ceo red");
                }
            }
            break;

            case "rociste":
            {
                PredmetModel predmet = predmetRepository.Find(BrPredmetaTxt.Text);
                if (predmet == null)
                {
                    MessageBox.Show("Ne postoji trazeni predmet");
                }
                else
                {
                    predmetRocisteRepository.Add(predmet.Id, new PredmetRocisteModel
                        {
                            Datum  = dateTimePicker1.Value.Date.ToString(),
                            Pozvan = true
                        });
                    rocisteRepository.Add(new RocisteModel
                        {
                            Datum     = dateTimePicker1.Value.Date.ToString(),
                            PredmetId = predmet.Id
                        });
                }
            }
            break;

            default:
                break;
            }

            Clear(this.rocisteGB);
            Clear(this.UplataGB);
            Clear(this.NovaUplataGB);
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: dusicajanjevic/MongoDB
        private void PredmetOkBtn(object sender, EventArgs e)
        {
            PredmetRepository        repository               = new PredmetRepository(databaseContext);
            TuzeniRepository         tuzeniRepository         = new TuzeniRepository(databaseContext);
            TuzilacRepository        tuzilacRepository        = new TuzilacRepository(databaseContext);
            PredmetRocisteRepository predmetRocisteRepository = new PredmetRocisteRepository(databaseContext);
            RocisteRepository        rocisteRepository        = new RocisteRepository(databaseContext);
            AdvokatRepository        advokatRepository        = new AdvokatRepository(databaseContext);
            UplataRepository         uplataRepository         = new UplataRepository(databaseContext);

            if (repository.Find(brojPtxt.Text) == null)
            {
                repository.Add(new PredmetModel
                {
                    BrPredmeta = brojPtxt.Text,
                    Mesto      = MestoTxt.Text,
                    Godina     = GodinaTxt.Text,
                    Podaci     = PodaciTxt.Text,
                    NazivSuda  = NazivTxt.Text,
                    Sudija     = SudijaTxt.Text,
                    Vrsta      = vrstaPtxt.Text
                });
                PredmetModel predmet = repository.Find(brojPtxt.Text);
                tuzeniRepository.Add(predmet.Id, new TuzeniModel
                {
                    PunoIme = tuzeniImeTxt.Text,
                    Telefon = TuzeniTelTxt.Text
                });
                tuzilacRepository.Add(predmet.Id, new TuzilacModel
                {
                    PunoIme = TuzilacImeTxt.Text,
                    Telefon = TuzilacTelTxt.Text
                });
                if (pozvanCB.Checked)
                {
                    predmetRocisteRepository.Add(predmet.Id, new PredmetRocisteModel
                    {
                        Datum  = dateTimePicker1.Value.Date.ToString(),
                        Pozvan = pozvanCB.Checked
                    });
                    rocisteRepository.Add(new RocisteModel
                    {
                        Datum     = dateTimePicker1.Value.Date.ToString(),
                        PredmetId = predmet.Id
                    });
                }

                advokatRepository.DodajAdvokataTuzenom(predmet.Id, new AdvokatModel
                {
                    PunoIme = TuzeniAdvImeTxt.Text,
                    Telefon = tuzeniAdvokatTelTxt.Text
                });
                advokatRepository.DodajAdvokataTuziocu(predmet.Id, new AdvokatModel
                {
                    PunoIme = tuzilacImeAdvTxt.Text,
                    Telefon = TuzilacAdvTelTxt.Text
                });

                if (IznosTxt.Text != "")
                {
                    uplataRepository.Add(predmet.Id, new UplataModel
                    {
                        Iznos     = Double.Parse(IznosTxt.Text),
                        Placeno   = PlacenoCB.Checked,
                        Uplatilac = PlatilacTxt.Text
                    });
                }
                Clear(this.DodajPredmetGB);
                GetALlControls(this.DodajPredmetGB);
            }
            else
            {
                MessageBox.Show("Vec postoji predmet sa zadatim brojem");
            }
        }