Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                List <Category> categories = CategoryDao.GetCategories();
                foreach (var item in categories)
                {
                    /*HyperLink hl = new HyperLink();
                    *  string id = "cat" + item.CategoryId.ToString();
                    *  hl.Text = item.CategoryName;
                    *  hl.NavigateUrl = Request.Path + "?categoryId=" + id + "#" + id;
                    *  hl.CssClass = "list-group-item";
                    *  hl.ID = id;
                    *  hl.ClientIDMode = System.Web.UI.ClientIDMode.Static;
                    *  pnlCategories.Controls.Add(hl);*/

                    ListItem li = new ListItem(item.CategoryName, item.CategoryId.ToString());
                    li.Attributes.Add("class", "list-group-item");
                    lbCategories.Items.Add(li);

                    ddlCategory.Items.Add(new ListItem()
                    {
                        Text = item.CategoryName, Value = item.CategoryId.ToString()
                    });
                }
                ddlCategory.Items[0].Selected = true;
            }
        }
Beispiel #2
0
        public OrderViewModel()
        {
            Categories = categoryDao.GetCategories();
            Foods      = foodDao.GetFoods();

            if (Categories.Count > 0)
            {
                SelectedCategory = Categories[0];
            }
        }
Beispiel #3
0
        public List <BECategory> GetCategories(int idUser)
        {
            CategoryDao       categoryDao = new CategoryDao();
            List <BECategory> retour      = null;

            try
            {
                retour = categoryDao.GetCategories(idUser);
            }
            catch (Exception ex)
            {
                throw new Exception("Une erreur est survenue lors de la récupération des catégories.", ex);
            }

            return(retour);
        }
Beispiel #4
0
        public List <BETache> trieTache(int id)
        {
            CategoryDao       catDao         = new CategoryDao();
            List <BECategory> listCategories = catDao.GetCategories(id);
            List <BETache>    retour         = new List <BETache>();
            TacheDao          tacheDao       = new TacheDao();

            List <BETache> list = new List <BETache>();

            try
            {
                list = tacheDao.getTaches(id);
                if (list == null)
                {
                    throw new Exception("Erreur lors de la récupération des taches.");
                }

                else
                {
                    bool cond = true;
                    foreach (BECategory cat in listCategories)
                    {
                        foreach (BETache be in list)
                        {
                            foreach (BECategory c in be.Categories)
                            {
                                if (c.Id == cat.Id && cond)
                                {
                                    retour.Add(be);
                                    cond = false;
                                }
                                cond = true;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Une erreur est survenue lors de la récupération des taches", ex);
            }

            return(retour);
        }
Beispiel #5
0
        public List <CategoryModel> GetCategories()
        {
            var ds = dao.GetCategories();
            List <CategoryModel> categories = null;

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                categories = new List <CategoryModel>();
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    var cm = new CategoryModel();
                    cm.Id        = Int32.Parse(dr[0].ToString());
                    cm.EName     = dr[1].ToString();
                    cm.OtherName = dr[2].ToString();

                    categories.Add(cm);
                }
            }

            return(categories);
        }
 public static void GetCategories()
 {
     WPFDbContext.Instance.Categories.Clear();
     CategoryDao.GetCategories().ForEach(x => WPFDbContext.Instance.Categories.Add(x));
 }