Exemple #1
0
        public int UpdateBazen(Bazen bazen)
        {
            int bazenID;

            Connection con     = new Connection();
            SqlCommand command = new SqlCommand();

            command.Connection  = con.PoolConnection();
            command.CommandType = CommandType.Text;
            command.CommandText = "Update Bazen set TipBazena = @TipBazena where IDBazen = @IDBazen";

            command.Parameters.Add("@IDBazen", SqlDbType.Int).Value       = bazen.IDBazen;
            command.Parameters.Add("@TipBazena", SqlDbType.VarChar).Value = bazen.TipBazena;

            try
            {
                con.OpenConnection();
                bazenID = Convert.ToInt32(command.ExecuteScalar());
                logger.LogInfo(DateTime.Now, "UpdateBazen method has sucessfully invoked.");
                return(0);
            }
            catch (Exception ex)
            {
                logger.LogError(DateTime.Now, "Error while trying to update bazen." + ex.Message);
                throw new Exception("Error while trying to update bazen." + ex.Message);
            }
            finally
            {
                con.CloseConnection();
            }
        }
Exemple #2
0
        public void GetBazenByIDTest()
        {
            BazenRepository repo  = new BazenRepository();
            Bazen           bazen = repo.GetBazenByID(1);

            Assert.IsNotNull(repo);
        }
Exemple #3
0
        public int AddBazen(Bazen bazen)
        {
            Connection con     = new Connection();
            SqlCommand command = new SqlCommand();

            command.Connection  = con.PoolConnection();
            command.CommandType = CommandType.Text;
            command.CommandText = "Insert into Bazen ( TipBazena) Values ( @TipBazena)";

            command.Parameters.Add("@TipBazena", SqlDbType.VarChar).Value = bazen.TipBazena;

            try
            {
                con.OpenConnection();
                command.ExecuteNonQuery();
                logger.LogInfo(DateTime.Now, "AddBazen method has succesfully invoked.");
                return(0);
            }
            catch (Exception ex)
            {
                logger.LogError(DateTime.Now, "Error while trying to add new Bazen. " + ex.Message);
                throw new Exception("Error while trying to add new Bazen. " + ex.Message);
            }
            finally
            {
                con.CloseConnection();
            }
        }
Exemple #4
0
        public void AddBazenTest()
        {
            Bazen bazen = new Bazen();

            bazen.TipBazena = "test";

            BazenRepository repo = new BazenRepository();
            int             id   = repo.AddBazen(bazen);

            Assert.IsNotNull(id > 0);
        }
Exemple #5
0
        public void UpdateBazenTest()
        {
            Bazen bazen = new Bazen();

            bazen.IDBazen   = 3;
            bazen.TipBazena = "takmicarski";

            BazenRepository repo = new BazenRepository();
            int             id   = repo.UpdateBazen(bazen);

            Assert.IsNotNull(id > 0);
        }
Exemple #6
0
        private Bazen kreirajBazen()
        {
            Bazen r = new Bazen();

            //TimeSpan unixtime =
            //    dateTimePicker1.Value.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            r.brojProstorije = txtBrojSobe.Text.ToString();
            r.tip            = txtTipBazena.Text;
            r.cena           = Int32.Parse(txtCena.Text);


            return(r);
        }
 public PregledEvidencije(ref Bazen bazen)
 {
     this.InitializeComponent();
     b = new Bazen();
     b = bazen;
     foreach (Uposlenik o in b.Uposlenici)
     {
         if (o is Uposlenik)
         {
             list.Items.Add(o.ToString());
         }
     }
 }
Exemple #8
0
        public Bazen GetBazenByID(int bazenID)
        {
            Connection con    = new Connection();
            Bazen      bazeni = new Bazen();

            try
            {
                con.OpenConnection();

                SqlCommand command = new SqlCommand();
                command.Connection  = con.PoolConnection();
                command.CommandType = CommandType.Text;

                command.CommandText = @"Select [IDBazen], [TipBazena] from [PoolApp].dbo.[Bazen] where [IDBazen] = @IDBazen";

                command.Parameters.Add("@IDBazen", SqlDbType.Int).Value = bazenID;

                SqlDataReader dataReader;
                dataReader = command.ExecuteReader();

                while (dataReader.Read())
                {
                    bazeni.IDBazen   = (int)dataReader[0];
                    bazeni.TipBazena = dataReader[1].ToString();
                }
                dataReader.Close();
            }
            catch (Exception ex)
            {
                logger.LogError(DateTime.Now, "Error while trying to get Bazen by id." + ex.Message);
                throw new Exception("Error while trying to get Bazen by id. " + ex.Message);
            }
            finally
            {
                con.CloseConnection();
            }
            logger.LogInfo(DateTime.Now, "GetBazenByID method has sucessfully invoked.");
            return(bazeni);
        }
Exemple #9
0
        public List <Bazen> GetAllBazen()
        {
            List <Bazen> bazenList = new List <Bazen>();

            Connection con     = new Connection();
            SqlCommand command = new SqlCommand();

            command.Connection  = con.PoolConnection();
            command.CommandText = "Select * from Bazen";

            try
            {
                con.OpenConnection();
                SqlDataReader dataReader = command.ExecuteReader();

                while (dataReader.Read())
                {
                    Bazen bazeni = new Bazen();
                    bazeni.IDBazen   = int.Parse(dataReader["IDBazen"].ToString());
                    bazeni.TipBazena = dataReader["TipBazena"].ToString();

                    bazenList.Add(bazeni);
                }
                dataReader.Close();
            }
            catch (Exception ex)
            {
                logger.LogError(DateTime.Now, "Error while trying to get all bazen." + ex.Message);
                throw new Exception("Error while trying to get all bazen. " + ex.Message);
            }
            finally
            {
                con.CloseConnection();
            }
            con.CloseConnection();
            logger.LogInfo(DateTime.Now, "GetAllBazen method has sucessfully invoked.");
            return(bazenList);
        }
 public UposlenikForma(ref Bazen bazen)
 {
     this.InitializeComponent();
     b = new Bazen();
     b = bazen;
 }
 public DodavanjeUposlenika(ref Bazen bazen)
 {
     this.InitializeComponent();
     b = new Bazen();
     b = bazen;
 }
 public UposlenikForma()
 {
     this.InitializeComponent();
     b = new Bazen();
 }
Exemple #13
0
        private void btnDodaj_Click_1(object sender, EventArgs e)
        {
            if (prostorija == 1)
            {
                Soba   soba = this.kreirajSobu();
                string id   = maxId();

                try
                {
                    int mId = Int32.Parse(id);
                    soba.idProstorije = (mId++).ToString();
                }
                catch (Exception exception)
                {
                    soba.idProstorije = "";
                }


                Dictionary <string, object> queryDict = new Dictionary <string, object>();

                queryDict.Add("brojProstorije", soba.brojProstorije);
                queryDict.Add("brojKreveta", soba.brojKreveta);
                queryDict.Add("sprat", soba.sprat);
                queryDict.Add("klima", soba.klima);
                queryDict.Add("tv", soba.tv);
                queryDict.Add("terasa", soba.terasa);
                queryDict.Add("opis", soba.opis);
                queryDict.Add("cena", soba.cena);
                queryDict.Add("idProstorije", soba.idProstorije);


                var query1 = new Neo4jClient.Cypher.CypherQuery("CREATE (n:Prostorija:Soba {brojProstorije:'" + soba.brojProstorije
                                                                + "',brojKreveta:'" + soba.brojKreveta + "',sprat:'" + soba.sprat
                                                                + "', klima:'" + soba.klima + "', tv:'" + soba.tv
                                                                + "', terasa:'" + soba.terasa + "', cena:'" + soba.cena.ToString()
                                                                + "', opis:'" + soba.opis
                                                                + "'}) return n",
                                                                queryDict, CypherResultMode.Set);



                List <Soba> sobe = ((IRawGraphClient)client).ExecuteGetCypherResults <Soba>(query1).ToList();

                //this.DialogResult = DialogResult.OK;
                //this.Close();
            }
            else if (this.prostorija == 2)
            {
                Sala   sala = this.kreirajSalu();
                string id   = maxId();

                try
                {
                    int mId = Int32.Parse(id);
                    sala.idProstorije = (mId++).ToString();
                }
                catch (Exception exception)
                {
                    sala.idProstorije = "";
                }

                Dictionary <string, object> queryDict = new Dictionary <string, object>();

                queryDict.Add("brojProstorije", sala.brojProstorije);
                queryDict.Add("kapacitetSale", sala.kapacitetSale.ToString());
                queryDict.Add("cena", sala.cena.ToString());
                queryDict.Add("idProstorije", sala.idProstorije);


                var query1 = new Neo4jClient.Cypher.CypherQuery("CREATE (n:Prostorija:Sala {brojProstorije:'" + sala.brojProstorije + "',kapacitetSale:'"
                                                                + sala.kapacitetSale.ToString() + "', cena:'" + sala.cena.ToString()
                                                                + "'}) return n",
                                                                queryDict, CypherResultMode.Set);



                List <Sala> sale = ((IRawGraphClient)client).ExecuteGetCypherResults <Sala>(query1).ToList();

                //this.DialogResult = DialogResult.OK;
                //this.Close();
            }
            else if (this.prostorija == 3)
            {
                Restoran restoran = this.kreirajRestoran();
                string   id       = maxId();

                try
                {
                    int mId = Int32.Parse(id);
                    restoran.idProstorije = (mId++).ToString();
                }
                catch (Exception exception)
                {
                    restoran.idProstorije = "";
                }

                Dictionary <string, object> queryDict = new Dictionary <string, object>();

                queryDict.Add("brojProstorije", restoran.brojProstorije);
                queryDict.Add("kapacitetRestorana", restoran.kapacitetRestorana.ToString());
                queryDict.Add("cena", restoran.cena.ToString());
                queryDict.Add("idProstorije", restoran.idProstorije);


                var query1 = new Neo4jClient.Cypher.CypherQuery("CREATE (n:Prostorija:Restoran {brojProstorije:'" + restoran.brojProstorije + "',kapacitetRestorana:'"
                                                                + restoran.kapacitetRestorana.ToString() + "', cena:'" + restoran.cena.ToString()
                                                                + "'}) return n",
                                                                queryDict, CypherResultMode.Set);



                List <Restoran> restorani = ((IRawGraphClient)client).ExecuteGetCypherResults <Restoran>(query1).ToList();

                //this.DialogResult = DialogResult.OK;
                //this.Close();
            }
            else if (this.prostorija == 4)
            {
                Bazen  bazen = this.kreirajBazen();
                string id    = maxId();

                try
                {
                    int mId = Int32.Parse(id);
                    bazen.idProstorije = (mId++).ToString();
                }
                catch (Exception exception)
                {
                    bazen.idProstorije = "";
                }

                Dictionary <string, object> queryDict = new Dictionary <string, object>();

                queryDict.Add("brojProstorije", bazen.brojProstorije);
                queryDict.Add("tip", bazen.tip.ToString());
                queryDict.Add("cena", bazen.cena.ToString());
                queryDict.Add("idProstorije", bazen.idProstorije);


                var query1 = new Neo4jClient.Cypher.CypherQuery("CREATE (n:Prostorija:Bazen {brojProstorije:'" + bazen.brojProstorije + "',tip:'"
                                                                + bazen.tip.ToString() + "', cena:'" + bazen.cena.ToString()
                                                                + "'}) return n",
                                                                queryDict, CypherResultMode.Set);



                List <Bazen> bazeni = ((IRawGraphClient)client).ExecuteGetCypherResults <Bazen>(query1).ToList();

                //this.DialogResult = DialogResult.OK;
                //this.Close();
            }
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
 public DodavanjeUposlenika()
 {
     this.InitializeComponent();
     b = new Bazen();
 }
 public OdabirPaketaForma()
 {
     this.InitializeComponent();
     b = new Bazen();
 }
 public Prijava()
 {
     this.InitializeComponent();
     b = new Bazen();
 }
 public RegistracijaGrupeForma()
 {
     this.InitializeComponent();
     b = new Bazen();
 }
 public OdabirPaketaForma(ref Bazen bazen)
 {
     this.InitializeComponent();
     b = new Bazen();
     b = bazen;
 }
 public Pocetna(ref Bazen bazen)
 {
     this.InitializeComponent();
     b = new Bazen();
     b = bazen;
 }
Exemple #20
0
 public RezervacijaTim(ref Bazen bazen)
 {
     this.InitializeComponent();
     b = new Bazen();
     b = bazen;
 }
 public PregledEvidencije()
 {
     this.InitializeComponent();
     b = new Bazen();
 }
 public IzmeniSobu(Bazen s)
 {
     this.bazen      = s;
     this.prostorija = 4;
     InitializeComponent();
 }
Exemple #23
0
 public RegistracijaPojedincaForma(ref Bazen refBazen)
 {
     this.InitializeComponent();
     b = new Bazen();
     b = refBazen;
 }
 public Pocetna()
 {
     this.InitializeComponent();
     b = new Bazen();
 }
Exemple #25
0
 public RezervacijaTim()
 {
     this.InitializeComponent();
     b = new Bazen();
 }