private void txt_search_TextChanged(object sender, EventArgs e) { string search = txt_search.Text.Trim(); DateTime date = date_search.Value; if (search.Length > 0) { dgv_liste.Rows.Clear(); string query = "select c.* from mouvements_stock c inner join articles a on c.article = a.id where a.reference like '" + search + "%' or a.designation like '" + search + "%'"; if (!date.Equals(Convert.ToDateTime("01/01/1970 00:00:00"))) { query = "select c.* from mouvements_stock c inner join articles a on c.article = a.id where a.reference like '" + search + "%' or a.designation like '" + search + "%' and c.date_save between '" + date.ToShortDateString() + "' and '" + date.AddDays(1).ToShortDateString() + "'"; } List <MouvementStock> l = MouvementStockBLL.List(query); foreach (MouvementStock f in l) { AddRow(f); } } else { LoadGrille(); } }
private void LoadGrille() { dgv_liste.Rows.Clear(); string query = "select * from mouvements_stock order by date_save"; List <MouvementStock> l = MouvementStockBLL.List(query); foreach (MouvementStock m in l) { AddRow(m); } }