예제 #1
0
        public DodajUrediClanForm(infosXDatabaseDataSet.ClanRow clanRow, bool isUredi)
        {
            InitializeComponent();
            _isUredi = isUredi;
            ClanRow  = clanRow;

            drustvoTA.Connection.ConnectionString = PomocneFunkcije.connectionString;
            mjestoTA.Connection.ConnectionString  = PomocneFunkcije.connectionString;
        }
예제 #2
0
        private void btnIzbrisi_Click(object sender, EventArgs e)
        {
            IzbrisiUpozorenjeForm izbrisiUpozorenje = new IzbrisiUpozorenjeForm();

            switch (_maticniPodaci)
            {
            case MaticniPodaci.Clan:

                infosXDatabaseDataSet.ClanRow currentClanRow = ((DataRowView)(clanBS.Current)).Row as infosXDatabaseDataSet.ClanRow;
                if (izbrisiUpozorenje.ShowDialog() == DialogResult.OK)
                {
                    currentClanRow.Delete();
                    clanTA.Update(ds.Clan);
                    ds.AcceptChanges();
                }
                else
                {
                    ds.RejectChanges();
                }
                break;

            case MaticniPodaci.Drustva:

                infosXDatabaseDataSet.DrustvoRow currentDrustvoRow = ((DataRowView)(drustvoBS.Current)).Row as infosXDatabaseDataSet.DrustvoRow;
                if (izbrisiUpozorenje.ShowDialog() == DialogResult.OK)
                {
                    currentDrustvoRow.Delete();
                    drustvoTA.Update(ds.Drustvo);
                    ds.AcceptChanges();
                }
                else
                {
                    ds.RejectChanges();
                }
                break;

            case MaticniPodaci.Mjesta:

                infosXDatabaseDataSet.MjestoRow currentMjestoRow = ((DataRowView)(mjestoBS.Current)).Row as infosXDatabaseDataSet.MjestoRow;
                if (izbrisiUpozorenje.ShowDialog() == DialogResult.OK)
                {
                    currentMjestoRow.Delete();
                    mjestoTA.Update(ds.Mjesto);
                    ds.AcceptChanges();
                }
                else
                {
                    ds.RejectChanges();
                }
                break;

            case MaticniPodaci.Drzave:

                infosXDatabaseDataSet.DrzavaRow currentDrzavaRow = ((DataRowView)(drzavaBS.Current)).Row as infosXDatabaseDataSet.DrzavaRow;
                if (izbrisiUpozorenje.ShowDialog() == DialogResult.OK)
                {
                    currentDrzavaRow.Delete();
                    drzavaTA.Update(ds.Drzava);
                    ds.AcceptChanges();
                }
                else
                {
                    ds.RejectChanges();
                }
                break;
            }
        }
예제 #3
0
        private void btnDodaj_Click(object sender, EventArgs e)
        {
            try
            {
                switch (_maticniPodaci)
                {
                case MaticniPodaci.Clan:

                    infosXDatabaseDataSet.ClanRow newClanRow    = ds.Clan.NewClanRow();
                    DodajUrediClanForm            dodajClanForm = new DodajUrediClanForm(newClanRow, false);
                    if (dodajClanForm.ShowDialog() == DialogResult.OK)
                    {
                        ds.Drustvo.Clear();
                        drustvoTA.Fill(ds.Drustvo);

                        ds.Clan.AddClanRow(dodajClanForm.ClanRow);
                        clanTA.Update(ds.Clan);
                        MessageBox.Show("Zapis je uspješno spremljen");
                        ds.AcceptChanges();
                    }
                    else
                    {
                        ds.RejectChanges();
                    }
                    break;

                case MaticniPodaci.Drustva:

                    infosXDatabaseDataSet.DrustvoRow newDrustvoRow    = ds.Drustvo.NewDrustvoRow();
                    DodajUrediDrustvoForm            dodajDrustvoForm = new DodajUrediDrustvoForm(newDrustvoRow, false);
                    if (dodajDrustvoForm.ShowDialog() == DialogResult.OK)
                    {
                        ds.Mjesto.Clear();
                        mjestoTA.Fill(ds.Mjesto);

                        ds.Drustvo.AddDrustvoRow(dodajDrustvoForm.DrustvoRow);
                        drustvoTA.Update(ds.Drustvo);
                        MessageBox.Show("Zapis je uspješno spremljen!");
                        ds.AcceptChanges();
                    }
                    else
                    {
                        ds.Drustvo.RejectChanges();
                    }

                    break;

                case MaticniPodaci.Mjesta:

                    infosXDatabaseDataSet.MjestoRow newMjestoRow    = ds.Mjesto.NewMjestoRow();
                    DodajUrediMjestoForm            dodajMjestoForm = new DodajUrediMjestoForm(newMjestoRow, false);
                    if (dodajMjestoForm.ShowDialog() == DialogResult.OK)
                    {
                        ds.Drzava.Clear();
                        drzavaTA.Fill(ds.Drzava);

                        ds.Mjesto.AddMjestoRow(dodajMjestoForm.MjestoRow);
                        mjestoTA.Update(ds.Mjesto);
                        MessageBox.Show("Zapis je uspješno spremljen!");
                        ds.AcceptChanges();
                    }
                    else
                    {
                        ds.RejectChanges();
                    }
                    break;

                case MaticniPodaci.Drzave:

                    infosXDatabaseDataSet.DrzavaRow newDrzavaRow    = ds.Drzava.NewDrzavaRow();
                    DodajUrediDrzavaForm            dodajDrzavaForm = new DodajUrediDrzavaForm(newDrzavaRow, false);
                    if (dodajDrzavaForm.ShowDialog() == DialogResult.OK)
                    {
                        ds.Drzava.AddDrzavaRow(dodajDrzavaForm.DrzavaRow);
                        drzavaTA.Update(ds.Drzava);
                        MessageBox.Show("Zapis je uspješno spremljen");
                        ds.AcceptChanges();
                    }
                    else
                    {
                        ds.RejectChanges();
                    }
                    break;
                }
            }
            catch (Exception ex)
            {
                if (ex.GetType().IsAssignableFrom(typeof(ConstraintException)))
                {
                    MessageBox.Show("ID već postoji. Unesite jedinstveni ID");
                }
            }
        }
예제 #4
0
        private void btnUredi_Click(object sender, EventArgs e)
        {
            switch (_maticniPodaci)
            {
            case MaticniPodaci.Clan:

                infosXDatabaseDataSet.ClanRow currentClanRow = ((DataRowView)(clanBS.Current)).Row as infosXDatabaseDataSet.ClanRow;
                DodajUrediClanForm            urediClanForm  = new DodajUrediClanForm(currentClanRow, true);
                if (urediClanForm.ShowDialog() == DialogResult.OK)
                {
                    clanTA.Update(ds.Clan);
                    MessageBox.Show("Zapise je uspješno ažuriran");
                    ds.AcceptChanges();
                }
                else
                {
                    ds.RejectChanges();
                }
                break;

            case MaticniPodaci.Drustva:

                infosXDatabaseDataSet.DrustvoRow currentDrustvoRow = ((DataRowView)(drustvoBS.Current)).Row as infosXDatabaseDataSet.DrustvoRow;
                DodajUrediDrustvoForm            urediDrustvoForm  = new DodajUrediDrustvoForm(currentDrustvoRow, true);
                if (urediDrustvoForm.ShowDialog() == DialogResult.OK)
                {
                    drustvoTA.Update(ds.Drustvo);
                    MessageBox.Show("Zapis je uspješno ažuriran");
                    ds.AcceptChanges();
                }
                else
                {
                    ds.RejectChanges();
                }
                break;

            case MaticniPodaci.Mjesta:

                infosXDatabaseDataSet.MjestoRow currentMjestoRow = ((DataRowView)(mjestoBS.Current)).Row as infosXDatabaseDataSet.MjestoRow;
                DodajUrediMjestoForm            urediMjestoForm  = new DodajUrediMjestoForm(currentMjestoRow, true);
                if (urediMjestoForm.ShowDialog() == DialogResult.OK)
                {
                    mjestoTA.Update(ds.Mjesto);
                    MessageBox.Show("Zapis je uspješno ažuriran");
                    ds.AcceptChanges();
                }
                else
                {
                    ds.RejectChanges();
                }
                break;

            case MaticniPodaci.Drzave:

                infosXDatabaseDataSet.DrzavaRow currentDrzavaRow = ((DataRowView)(drzavaBS.Current)).Row as infosXDatabaseDataSet.DrzavaRow;
                DodajUrediDrzavaForm            urediDrzavaRow   = new DodajUrediDrzavaForm(currentDrzavaRow, true);
                if (urediDrzavaRow.ShowDialog() == DialogResult.OK)
                {
                    drzavaTA.Update(ds.Drzava);
                    MessageBox.Show("Zapis je uspješno ažuriran");
                    ds.AcceptChanges();
                }
                else
                {
                    ds.RejectChanges();
                }
                break;
            }
        }
예제 #5
0
        private void UvozForm_Load(object sender, EventArgs e)
        {
            btnPohrani.Visible  = true;
            btnOdustani.Visible = true;

            try
            {
                OpenFileDialog openXml = new OpenFileDialog();

                if (openXml.ShowDialog() == DialogResult.OK)
                {
                    XDocument xmlDoc = XDocument.Load(openXml.FileName);

                    switch (_maticniPodaci)
                    {
                    case MaticniPodaci.Clan:

                        foreach (var i in xmlDoc.Descendants("Clan"))
                        {
                            infosXDatabaseDataSet.ClanRow clanRow = ds.Clan.NewClanRow();

                            clanRow.OIB          = i.Element("OIB").Value;
                            clanRow.Ime          = i.Element("Ime").Value;
                            clanRow.Prezime      = i.Element("Prezime").Value;
                            clanRow.DatumRodenja = Convert.ToDateTime(i.Element("DatumRodenja").Value);
                            clanRow.Zanimanje    = (i.Element("Zanimanje").Value != "") ? i.Element("Zanimanje").Value : "";
                            clanRow.Drustvo_ID   = i.Element("Drustvo_ID").Value;
                            clanRow.Mjesto_ID    = (i.Element("Mjesto_ID").Value != "") ? i.Element("Mjesto_ID").Value : null;
                            clanRow.Email        = (i.Element("Email").Value != "") ? i.Element("Email").Value : "";
                            clanRow.Adresa       = (i.Element("Adresa").Value != "") ? i.Element("Adresa").Value : "";
                            clanRow.Telefon      = (i.Element("Telefon").Value != "") ? i.Element("Telefon").Value : "";

                            ds.Clan.AddClanRow(clanRow);
                        }

                        dgvUvoz.DataSource = ds.Clan;
                        PomocneFunkcije.AutoSizeDgvColumns(dgvUvoz.Columns);
                        break;

                    case MaticniPodaci.Drustva:

                        int j = 1;
                        foreach (var i in xmlDoc.Descendants("Drustvo"))
                        {
                            infosXDatabaseDataSet.DrustvoRow drustvoRow = ds.Drustvo.NewDrustvoRow();

                            drustvoRow.ID         = "drustvo" + j;
                            drustvoRow.Naziv      = i.Element("Naziv").Value;
                            drustvoRow.Adresa     = (i.Element("Adresa").Value != "") ? i.Element("Adresa").Value : "";         //null
                            drustvoRow.Email      = (i.Element("Email").Value != "") ? i.Element("Email").Value : "";           //null
                            drustvoRow.Mjesto_ID  = i.Element("Mjesto_ID").Value;
                            drustvoRow.BrojRacuna = (i.Element("BrojRacuna").Value != "") ? i.Element("BrojRacuna").Value : ""; //null
                            drustvoRow.Telefon    = (i.Element("Telefon").Value != "") ? i.Element("Telefon").Value : "";       //null

                            ds.Drustvo.AddDrustvoRow(drustvoRow);
                            j++;
                        }

                        dgvUvoz.DataSource = ds.Drustvo;
                        PomocneFunkcije.AutoSizeDgvColumns(dgvUvoz.Columns);
                        break;

                    case MaticniPodaci.Mjesta:

                        int k = 1;
                        foreach (var i in xmlDoc.Descendants("Mjesto"))
                        {
                            infosXDatabaseDataSet.MjestoRow mjestoRow = ds.Mjesto.NewMjestoRow();

                            mjestoRow.ID        = "mjesto" + k;
                            mjestoRow.Ime       = i.Element("Ime").Value;
                            mjestoRow.Drzava_ID = i.Element("Drzava_ID").Value;

                            ds.Mjesto.AddMjestoRow(mjestoRow);
                            k++;
                        }

                        dgvUvoz.DataSource = ds.Mjesto;
                        PomocneFunkcije.AutoSizeDgvColumns(dgvUvoz.Columns);
                        break;

                    case MaticniPodaci.Drzave:

                        int p = 1;
                        foreach (var i in xmlDoc.Descendants("Drzava"))
                        {
                            infosXDatabaseDataSet.DrzavaRow drzavaRow = ds.Drzava.NewDrzavaRow();

                            drzavaRow.ID          = "drzava" + p;
                            drzavaRow.Ime         = i.Element("Ime").Value;
                            drzavaRow.Jezik       = i.Element("Jezik").Value;
                            drzavaRow.PozivniBroj = i.Element("PozivniBroj").Value;
                            drzavaRow.Valuta      = i.Element("Valuta").Value;

                            ds.Drzava.AddDrzavaRow(drzavaRow);

                            p++;
                        }

                        dgvUvoz.DataSource = ds.Drzava;
                        PomocneFunkcije.AutoSizeDgvColumns(dgvUvoz.Columns);
                        break;
                    }
                }
                else
                {
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Greška s uvozom vanjske XML datoteke: " + ex.Message);
                this.Close();
            }
        }