public void Metodazabuseve(string path) { Dtime dt2 = new Dtime(); try { if (DateTime.Today.DayOfWeek != DayOfWeek.Saturday || DateTime.Today.DayOfWeek != DayOfWeek.Sunday || (DateTime.Now.TimeOfDay > new TimeSpan(06, 00, 00) && DateTime.Now.TimeOfDay < new TimeSpan(21, 00, 00))) { using (StreamReader str = new StreamReader(path)) { while (!str.EndOfStream) { string z = str.ReadLine(); if (!z.Contains("-")) { array = z.Split(';'); timespan = new TimeSpan[array.Length]; for (int i = 0; i < array.Length; i++) { timespan[i] = new TimeSpan(dt2.GetHours(array[i]), dt2.GetMinutes(array[i]), 0); } } } } timespan = lista.ToArray(); for (int i = 0; i < timespan.Length; i++) { if (timespan[i] > DateTime.Now.TimeOfDay) { TimeSpan t1 = timespan[i].Subtract(DateTime.Now.TimeOfDay); if (i == timespan.Length - 1) { t2 = new TimeSpan(0, 0, 0); } else { t2 = timespan[i + 1].Subtract(DateTime.Now.TimeOfDay); } total_seconds1 = t1.TotalSeconds; total_seconds2 = t2.TotalSeconds; Label16.Text = t1.ToString(@"mm\:ss"); Label17.Text = t2.ToString(@"mm\:ss"); break; } } } else { Response.Write("NO BUS AVAILABLE AT THIS MOMEMNT !!!!"); } } catch (Exception ef) { Response.Write(ef.ToString()); } }
private bool Nazocnost_profesora() { TimeSpan tr = new TimeSpan(11, 11, 11); TimeSpan tr2 = new TimeSpan(12, 12, 12); if (tr > tr2) { } SqlConnection con = con = new SqlConnection("workstation id=Fakultet.mssql.somee.com;packet size=4096;user id=marko78087808_SQLLogin_1;pwd=cejbhg7ats;data source=Fakultet.mssql.somee.com;persist security info=False;initial catalog=Fakultet "); con.Open(); Dtime dt = new Dtime(); SqlCommand cmd = new SqlCommand (@" SELECT tjedan_nastavnik.Pocetak_konz, tjedan_nastavnik.Kraj_konz,Tjedan.ID,Gender.naziv_spola FROM tjedan_nastavnik,Nastavnik,Tjedan,Gender WHERE Nastavnik.ID=tjedan_nastavnik.Nastavnik_ID AND tjedan_nastavnik.TjedanID=Tjedan.ID AND Nastavnik.GenderID=Gender.Spol_ID AND Nastavnik.ime=@fname AND Nastavnik.prezime=@lname", con); cmd.Parameters.Add(new SqlParameter("fname", Getfirstname(ListBox2.SelectedItem.ToString()))); cmd.Parameters.Add(new SqlParameter("lname", Getsurname(ListBox2.SelectedItem.ToString()))); SqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { ViewState["c"] = dr[0].ToString(); ViewState["d"] = dr[1].ToString(); ViewState["dan_broj"] = dr.GetInt32(2); ViewState["Spol"] = dr.GetString(3); if ((int)ViewState["dan_broj"] == (int)DateTime.Now.DayOfWeek) // da izbjegnem polje i strukturiziranje nepotrebno { break; } } string spol = ViewState["Spol"].ToString().Trim(); if (spol == "Male") { Value = Gender.Male; } if (spol == "Female") { Value = Gender.Female; } con.Close(); TimeSpan ts1 = new TimeSpan(dt.GetHours(ViewState["c"].ToString()), dt.GetMinutes(ViewState["c"].ToString()), 00); TimeSpan ts2 = new TimeSpan(dt.GetHours(ViewState["d"].ToString()), dt.GetMinutes(ViewState["d"].ToString()), 00); string g = DateTime.Now.ToShortTimeString(); //? kakve su ovo brie // pitaj profa jel bi brze radio program ako bi stavi ogranicenje na h tipa od 08 00 do 20 00 ili ne bi imalo bas neku ulogu... if (DateTime.Now.TimeOfDay.CompareTo(ts1) == 1 && ts2.CompareTo(DateTime.Now.TimeOfDay) == 1 && (int)ViewState["dan_broj"] == (int)DateTime.Now.DayOfWeek) // ovo tu ne radi jel ovaj populira u petlji samo zadnji red!!!! { return(true); } else { return(false); } }