protected void Calendar_SelectionChanged(object sender, EventArgs e) { SqlConnection con = new SqlConnection(constr); con.Open(); LabelDay.Text = Calendar.SelectedDate.ToString("dd MMMM yyyy"); DishListDayClient.Visible = true; AddDishDayClient.Visible = true; dayDiet.Visible = true; SqlCommand cmd = new SqlCommand("SELECT dm.id AS dania_menuID, d.Id, d.nazwa, d.kategoria, d.przepis FROM Danie d JOIN Dania_Menu dm ON d.Id = dm.Id_dania JOIN Menu m ON dm.Id_menu = m.id WHERE CONVERT(date, m.data, 103)=CONVERT(date, '" + Calendar.SelectedDate + "', 103) AND m.id_klienta=" + KlientID, new SqlConnection(constr)); //SqlCommand cmd = new SqlCommand("SELECT dm.id AS dania_menuID, d.Id, d.nazwa, d.kategoria, d.przepis FROM Danie d JOIN Dania_Menu dm ON d.Id = dm.Id_dania JOIN Menu m ON dm.Id_menu = m.id WHERE CONVERT(date, m.data, 103)=CONVERT(date, '" + Calendar.SelectedDate.ToShortDateString() + "', 23) AND m.id_klienta=" + KlientID, new SqlConnection(constr)); SqlDataAdapter sda = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); sda.Fill(dt); DishListDayClientRepeater.DataSource = dt; DishListDayClientRepeater.DataBind(); //ZLICZANIE odswiezZliczanie(); //cmd = new SqlCommand( //"SELECT SUM(ps.kalorie*s.ilosc/100) Kalorie, SUM(ps.weglowodany*s.ilosc/100) Weglowodany, SUM(ps.bialka*s.ilosc/100) Bialka, SUM(ps.blonnik*s.ilosc/100) Blonnik, SUM(ps.sol*s.ilosc/100) Sol, SUM(ps.tluszcze*s.ilosc/100) Tluszcze " + //"FROM Produkt_spozywczy ps JOIN Skladnik s ON ps.Id = s.Id_produktu JOIN Danie d ON d.Id = s.Id_dania JOIN Dania_Menu dm ON d.Id = dm.Id_dania JOIN Menu m ON dm.Id_menu = m.id " + //"WHERE CONVERT(date, m.data, 103) = CONVERT(date, '" + Calendar.SelectedDate.ToShortDateString() + "', 23) AND m.id_klienta=" + KlientID, con); con.Close(); }
protected void odswiezMenu() { SqlCommand cmd = new SqlCommand("SELECT dm.id AS dania_menuID, d.Id, d.nazwa, d.kategoria, d.przepis FROM Danie d JOIN Dania_Menu dm ON d.Id = dm.Id_dania JOIN Menu m ON dm.Id_menu = m.id WHERE CONVERT(date, m.data, 103)=CONVERT(date, '" + Calendar.SelectedDate + "', 103) AND m.id_klienta=" + KlientID, new SqlConnection(constr)); SqlDataAdapter sda = new SqlDataAdapter(cmd); DataTable dt = new DataTable(); sda.Fill(dt); DishListDayClientRepeater.DataSource = dt; DishListDayClientRepeater.DataBind(); }