Exemplo n.º 1
0
        public static Banka GetBanka(string racun)
        {
            using (SqlConnection connection = new SqlConnection(SQLConnection.ConnectionString))
            {
                connection.Open();
                string query = "SELECT * FROM BANKA LEFT OUTER JOIN RACUN ON BANKA.ID_BANKA = RACUN.ID_BANKA WHERE RACUN.RACUN = '" + racun + "'";

                using (SqlCommand command = new SqlCommand(query, connection))
                {
                    SqlDataReader reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        Common.Model.Banka banka = new Common.Model.Banka(
                            int.Parse(reader["ID_BANKA"].ToString()),
                            reader["NAZIV"].ToString(),
                            reader["SWIFT"].ToString(),
                            reader["RACUN"].ToString());

                        return(banka);
                    }
                }

                connection.Close();
            }

            return(null);
        }
Exemplo n.º 2
0
        private void PrenosUnutarBanke(NalogPrenos prenos, Common.Model.Banka banka)
        {
            Racun racunDuznika  = DAO.GetRacunBrojRacuna(prenos.RacunDuznika);
            Racun racunPrimaoca = DAO.GetRacunBrojRacuna(prenos.RacunPrimalac);

            if (racunDuznika.Stanje < prenos.Iznos)
            {
                return;
            }

            DAO.UpdateStanjeRacuna(racunDuznika.BrojRacun, racunDuznika.Stanje - prenos.Iznos);
            DAO.UpdateStanjeRacuna(racunPrimaoca.BrojRacun, racunPrimaoca.Stanje + prenos.Iznos);
        }
Exemplo n.º 3
0
        private void Clearing(NalogPrenos prenos, Common.Model.Banka bankaDuznik, Common.Model.Banka bankaPrimaoca)
        {
            Firma duznik   = DAO.GetFirmaBrojRacuna(prenos.RacunDuznika);
            Firma primalac = DAO.GetFirmaBrojRacuna(prenos.RacunPrimalac);

            Racun racunDuznika = DAO.GetRacunBrojRacuna(prenos.RacunDuznika);

            DAO.UpdateStanjeRacuna(racunDuznika.BrojRacun, racunDuznika.Stanje - prenos.Iznos);

            MT102 mt102 = null;

            clearing.TryGetValue(bankaPrimaoca.Naziv, out mt102);

            if (mt102 == null)
            {
                mt102 = new MT102(
                    "id",
                    bankaDuznik.Swift,
                    bankaDuznik.Racun,
                    bankaPrimaoca.Swift,
                    bankaPrimaoca.Racun,
                    prenos.Iznos,
                    "RSD",
                    prenos.DatumNaloga,
                    prenos.DatumValute);

                clearing.Add(bankaPrimaoca.Naziv, mt102);
            }

            MT102Stavka stavka = new MT102Stavka(
                prenos.IdNalog.ToString(),
                duznik.Naziv,
                prenos.SvrhaPlacanja,
                primalac.Naziv,
                prenos.DatumNaloga,
                racunDuznika.BrojRacun,
                prenos.ModelZaduzenja,
                prenos.PozivNaBrZaduzenja,
                prenos.RacunPrimalac,
                prenos.ModelOdobrenja,
                prenos.PozivNaBrOdobrenja.ToString(),
                prenos.Iznos,
                "RSD"
                );

            mt102.Stavke.Add(stavka);
        }
Exemplo n.º 4
0
        private void RTGS(NalogPrenos prenos, Common.Model.Banka bankaDuznik, Common.Model.Banka bankaPrimaoca)
        {
            Firma duznik   = DAO.GetFirmaBrojRacuna(prenos.RacunDuznika);
            Firma primalac = DAO.GetFirmaBrojRacuna(prenos.RacunPrimalac);

            Racun racunDuznika = DAO.GetRacunBrojRacuna(prenos.RacunDuznika);

            DAO.UpdateStanjeRacuna(racunDuznika.BrojRacun, racunDuznika.Stanje - prenos.Iznos);

            MT103 mt103 = new MT103(
                "id",
                bankaDuznik.Swift,
                bankaDuznik.Racun,
                bankaPrimaoca.Swift,
                bankaPrimaoca.Racun,
                duznik.Naziv,
                prenos.SvrhaPlacanja,
                primalac.Naziv,
                prenos.DatumNaloga,
                prenos.DatumValute,
                prenos.RacunDuznika,
                prenos.ModelZaduzenja,
                prenos.PozivNaBrZaduzenja,
                prenos.RacunPrimalac,
                prenos.ModelOdobrenja,
                prenos.PozivNaBrOdobrenja.ToString(),
                prenos.Iznos,
                "RSD"
                );


            ChannelFactory <ICentralnaBanka> factory = new ChannelFactory <ICentralnaBanka>(new NetTcpBinding(), new EndpointAddress("net.tcp://localhost:9000/CB"));
            ICentralnaBanka proxy = factory.CreateChannel();

            MT900 mt900 = null;

            try
            {
                mt900 = proxy.RTGS(mt103);
            }
            catch (Exception)
            { }
        }
Exemplo n.º 5
0
        public void SendNalogPrenos(NalogPrenos prenos)
        {
            Common.Model.Banka bankaDuznika  = DAO.GetBanka(prenos.RacunDuznika);
            Common.Model.Banka bankaPrimaoca = DAO.GetBanka(prenos.RacunPrimalac);

            if (bankaDuznika.IdBanka == bankaPrimaoca.IdBanka)
            {
                PrenosUnutarBanke(prenos, bankaDuznika);
            }
            else
            {
                if (prenos.Hitno || prenos.Iznos >= 250000)
                {
                    RTGS(prenos, bankaDuznika, bankaPrimaoca);
                }
                else
                {
                    Clearing(prenos, bankaDuznika, bankaPrimaoca);
                }
            }
        }