예제 #1
0
 public Generator(int brElementP, int brElementC)
 {
     elementPs = new ElementP[brElementP];
     for (int i = 0; i < brElementP; i++)
     {
         elementPs[i] = new ElementP(brElementC, i + 1);
         elementPs[i].Stampaj();
     }
     Console.WriteLine("---------------------------------------------------");
 }
예제 #2
0
        public ElementP IDSearch(string ID)
        {
            ElementP el = new ElementP();

            foreach (var v in elementPs)
            {
                if (v.IdentifikacioniKod == ID)
                {
                    el = v;
                }
            }
            if (el.IdentifikacioniKod != "")
            {
                el.Stampaj();
                return(el);
            }
            else
            {
                Console.WriteLine("Nema elemenata za taj ID!");
                return(null);
            }
        }
예제 #3
0
        public void ProbaZaCitanje(string s)
        {
            List <ElementP> elementPs = new List <ElementP>();
            SqlConnection   con       = new SqlConnection(@"Data Source=VLADICA-PC\SQLEXPRESS;Initial Catalog=NewDatbase;Integrated Security=True;");

            try
            {
                con.Open();
                DateTime dateTime = DateTime.Parse(s);
                dateTime = new DateTime(2000, 1, 1, dateTime.Hour, dateTime.Minute, dateTime.Second);

                string sqlP = "SELECT IdentifikacioniKod,RedniBroj,DatumPretrage FROM ElementP";

                SqlCommand cmdP = new SqlCommand(sqlP, con);

                using (SqlDataReader oReader = cmdP.ExecuteReader())
                {
                    while (oReader.Read())
                    {
                        if (dateTime < DateTime.Parse(oReader["DatumPretrage"].ToString()))
                        {
                            ElementP ELP = new ElementP();
                            ELP.IdentifikacioniKod = oReader["IdentifikacioniKod"].ToString();
                            ELP.RedniBroj          = Int32.Parse(oReader["RedniBroj"].ToString());
                            elementPs.Add(ELP);
                            Console.WriteLine("Citanje Podataka P");
                        }
                    }
                }

                foreach (var item in elementPs)
                {
                    List <ElementC> elementCs = new List <ElementC>();
                    string          IDenKod   = item.IdentifikacioniKod;
                    string          sqlC      = "SELECT Grupa,Vrednost FROM ElementC WHERE IDKOD=@IDenKod";
                    SqlCommand      cmdC      = new SqlCommand(sqlC, con);
                    cmdC.Parameters.AddWithValue("@IDenKod", IDenKod);
                    using (SqlDataReader oReader = cmdC.ExecuteReader())
                    {
                        while (oReader.Read())
                        {
                            ElementC ELC = new ElementC(oReader["Grupa"].ToString().ToCharArray()[0], Int32.Parse(oReader["Vrednost"].ToString()));

                            elementCs.Add(ELC);
                            Console.WriteLine("Citanje Podataka C");
                        }
                    }
                    item.AddCs(elementCs);
                }
                foreach (var item in elementPs)
                {
                    item.Stampaj();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
            finally
            {
                con.Close();
            }
        }