Ejemplo n.º 1
0
        private void resetDropDown()
        {
            FoodType ft = new FoodType();

            ddlType.DataSource     = ft.getList();
            ddlType.DataTextField  = "type_name";
            ddlType.DataValueField = "type_id";
            ddlType.DataBind();
        }
Ejemplo n.º 2
0
        public static string searchCode(string key, string page)
        {
            FoodType        f         = new FoodType();
            List <FoodType> foodTypes = f.getList();

            if (key != null && key.Length > 0)
            {
                foodTypes = f.getList(key.Trim());
            }
            int limit   = Convert.ToInt32(new Setting().getObjectAdmin().Value);
            int soTrang = foodTypes.Count / limit + (foodTypes.Count % limit == 0 ? 0 : 1);
            int trang   = Convert.ToInt32(page);
            int from    = (trang - 1) * limit;
            int to      = (trang * limit) - 1;

            for (int i = foodTypes.Count - 1; i >= 0; i--)
            {
                if (i < from || to < i)
                {
                    foodTypes.RemoveAt(i);
                }
            }
            int[] index  = new int[soTrang];
            int[] active = new int[soTrang];

            for (int i = 0; i < soTrang; i++)
            {
                index[i] = i;
                if (i + 1 == trang)
                {
                    active[i] = 1;
                }
                else
                {
                    active[i] = 0;
                }
            }
            Dictionary <string, object> json = new Dictionary <string, object>();

            json.Add("obj", foodTypes);
            json.Add("record", index);
            json.Add("active", active);
            return(new JavaScriptSerializer().Serialize(json));
        }
Ejemplo n.º 3
0
        private void selectDropDown(int value)
        {
            FoodType ft = new FoodType();

            ddlType.DataSource     = ft.getList();
            ddlType.DataTextField  = "type_name";
            ddlType.DataValueField = "type_id";
            ddlType.DataBind();
            ddlType.SelectedValue = value.ToString();
        }
Ejemplo n.º 4
0
        private void resetDropDownType()
        {
            FoodType        ft        = new FoodType();
            List <FoodType> foodTypes = ft.getList();

            if (foodTypes.Count > 0)
            {
                ddListType.DataSource     = foodTypes;
                ddListType.DataTextField  = "type_name";
                ddListType.DataValueField = "type_id";
                ddListType.DataBind();
            }
        }
Ejemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //handle food
            Food        food  = new Food();
            List <Food> foods = new List <Food>();

            if (Request["type_id"] != null)
            {
                foods = food.getList(Convert.ToInt32(Request["type_id"]));
            }
            else
            {
                foods = food.getList();
            }

            //handle foodtype
            FoodType        ft        = new FoodType();
            List <FoodType> foodTypes = ft.getList();

            rptLoaiSP.DataSource = foodTypes;
            rptLoaiSP.DataBind();

            //handle phan trang
            int limit   = Convert.ToInt32(new Setting().getObjectHome().Value);
            int soTrang = foods.Count / limit + (foods.Count % limit == 0 ? 0 : 1);
            int page    = Request["page"] == null ? 1 : Convert.ToInt32(Request["page"]);
            int from    = (page - 1) * limit;
            int to      = (page * limit) - 1;

            for (int i = foods.Count - 1; i >= 0; i--)
            {
                if (i < from || to < i)
                {
                    foods.RemoveAt(i);
                }
            }


            rptSanPham.DataSource = foods;
            rptSanPham.DataBind();

            DataTable dtp = new DataTable();

            dtp.Columns.Add("index");
            dtp.Columns.Add("active");
            for (int i = 1; i <= soTrang; i++)
            {
                DataRow dr = dtp.NewRow();
                dr["index"] = i;
                if ((Request["page"] == null && i == 1) || (Request["page"] != "" && Convert.ToInt32(Request["page"]) == i))
                {
                    dr["active"] = 1;
                }
                else
                {
                    dr["active"] = 0;
                }
                dtp.Rows.Add(dr);
            }
            rptSoTrang.DataSource = dtp;
            rptSoTrang.DataBind();
        }