private void InitializeCarnet() { List <MarkModel> note = SqlDataAcces.GetAllMarks(SqlDataAcces.ConnectionString, UserLoged); dataGridView1.Columns.Clear(); DataTable newTable = new DataTable(); newTable.Columns.Add("Nota", typeof(int)); newTable.Columns.Add("Data", typeof(DateTime)); foreach (MarkModel item in note) { DataRow newRow = newTable.NewRow(); newRow["Nota"] = item.Nota; newRow["Data"] = item.Data; newTable.Rows.Add(newRow); } dataGridView1.DataSource = newTable; }
private void InitializeChart() { List <MarkModel> note = SqlDataAcces.GetAllMarks(SqlDataAcces.ConnectionString, this.UserLoged); note = note.OrderBy(x => x.Data).ToList(); Series serie = new Series(); serie.ChartType = SeriesChartType.Line; foreach (MarkModel nota in note) { serie.Points.AddXY(nota.Data, nota.Nota); } chart1.Series.Clear(); chart1.Series.Add(serie); chart1.Series[0].XValueType = ChartValueType.DateTime; chart1.Series[0].Name = "Nota"; chart1.ChartAreas[0].AxisX.LabelStyle.Format = "dd.MM.yyyy"; //chart1.ChartAreas[0].AxisX.Interval = 1; chart1.ChartAreas[0].AxisX.IntervalType = DateTimeIntervalType.Days; DateTime maxDate = note.Max(x => x.Data); DateTime minDate = note.Min(x => x.Data); chart1.ChartAreas[0].AxisX.Maximum = maxDate.ToOADate(); chart1.ChartAreas[0].AxisX.Minimum = minDate.ToOADate(); Series notaMedie = new Series(); notaMedie.ChartType = SeriesChartType.Line; notaMedie.Points.AddXY(minDate, MarkModel.NotaMedie); notaMedie.Points.AddXY(maxDate, MarkModel.NotaMedie); chart1.Series.Add(notaMedie); chart1.Series[1].Name = "Media clasei"; }