public List <Racun> ZavrsiSmenu(string r) { List <Racun> smena = new List <Racun>(); List <Racun> s = new List <Racun>(); DateTime vreme = DateTime.Now.AddHours(-8); try { connection.Open(); OleDbCommand comm = new OleDbCommand(); comm.Connection = connection; comm.CommandText = "select * from Racun where Radnik='" + r + "';"; OleDbDataReader reader = comm.ExecuteReader(); while (reader.Read()) { Racun racun = new Racun(); racun.VremeDolaska = (DateTime)reader["Dolazak"]; racun.VremeOdlaska = (DateTime)reader["Odlazak"]; racun.Naplata = Decimal.Parse(reader["Naplata"].ToString()); s.Add(racun); } connection.Close(); } catch (Exception ex) { if (ex is SystemException || ex is OleDbException || ex is NotSupportedException || ex is UnauthorizedAccessException || ex is FormatException || ex is IndexOutOfRangeException || ex is InsufficientMemoryException || ex is EntryPointNotFoundException || ex is EntryPointNotFoundException || ex is InvalidCastException || ex is InvalidProgramException) { MessageBox.Show(ex.Message, "Greska"); } else { MessageBox.Show(ex.Message, "Greska"); } if (connection != null) { connection.Close(); } } foreach (Racun x in s) { if (x.VremeOdlaska > vreme) { smena.Add(x); } } return(smena); }
private void ucitaj_graf() { Racun rac = new Racun(); List <Racun> ls = new List <Racun>(); ls = rac.DnevniIzvestaj(); int Jan = 0; int Feb = 0; int Mar = 0; int Apr = 0; int Jun = 0; int May = 0; int Avg = 0; int Jul = 0; int Sept = 0; int Okt = 0; int Nov = 0; int Dec = 0; Korisnik koris = new Korisnik(); List <Korisnik> kor = new List <Korisnik>(); kor = koris.izlistaj_korisnike(); foreach (Racun r in ls) { if (r.VremeDolaska.Month == 1) { Jan++; } if (r.VremeDolaska.Month == 2) { Feb++; } if (r.VremeDolaska.Month == 3) { Mar++; } if (r.VremeDolaska.Month == 4) { Apr++; } if (r.VremeDolaska.Month == 5) { May++; } if (r.VremeDolaska.Month == 6) { Jun++; } if (r.VremeDolaska.Month == 7) { Jul++; } if (r.VremeDolaska.Month == 8) { Avg++; } if (r.VremeDolaska.Month == 9) { Sept++; } if (r.VremeDolaska.Month == 10) { Okt++; } if (r.VremeDolaska.Month == 11) { Nov++; } if (r.VremeDolaska.Month == 12) { Dec++; } } cartesianChart1.Series = new SeriesCollection { new LineSeries { Title = "Broj racuna", Values = new ChartValues <int> { Jan, Feb, Mar, Apr, May, Jun, Jul, Avg, Sept, Okt, Nov, Dec }, PointGeometry = DefaultGeometries.Square, PointGeometrySize = 15 } }; cartesianChart1.AxisX.Add(new Axis { Title = "Mesec", Labels = new[] { "Jan", "Feb", "Mar", "Apr", "Maj", "Jun", "Jul", "Avgust", "Septembar", "Oktobar", "Novembar", "Decembar" } }); cartesianChart1.AxisY.Add(new Axis { Title = "Prodaja", LabelFormatter = value => value.ToString() }); cartesianChart1.LegendLocation = LegendLocation.Bottom; }