Exemplo n.º 1
0
        public string GetTypeProductForTagSelect()
        {
            // tp.id 0, tp.name 1, count(p.id_type) quantity 2, c.id id_category 3
            // c.name name_category 4, tp.status 5, tp.date_created 6
            Dictionary <string, string> res = new Dictionary <string, string>();
            var tpModel = new TypeProductModel();

            string[][]    allTP = tpModel.GetAll();
            List <string> data  = new List <string>();

            foreach (string[] row in allTP)
            {
                Dictionary <string, string> r = new Dictionary <string, string>();
                r.Add("id", row[0]);
                r.Add("name", row[1]);
                data.Add(JsonConvert.SerializeObject(r));
            }
            res.Add("status", "1");
            res.Add("data", JsonConvert.SerializeObject(data.ToArray()));
            return(JsonConvert.SerializeObject(res));
        }
Exemplo n.º 2
0
        public string GetAllTypeProduct()
        {
            var tpModel = new TypeProductModel();

            string[][] allTP = tpModel.GetAll();
            Dictionary <string, string[][]> res = new Dictionary <string, string[][]>();
            List <string[]> rs = new List <string[]>();
            int             i  = 1;

            foreach (string[] val in allTP)
            {
                // tp.id 0, tp.name 1, count(p.id_type) quantity 2, c.id id_category 3,
                // c.name name_category 4, tp.status 5, tp.date_created 6
                List <string> r = new List <string>();
                r.Add("<span>" + (i++) + "</span>");
                r.Add("<span class='tp-name' id_tp='" + val[0] + "'>" + val[1] + "</span>");
                r.Add("<span class='tp-quantity' id_tp='" + val[0] + "'>" + val[2] + "</span>");
                r.Add("<span class='tp-category' id_tp='" + val[0] + "' id_category='" + val[3]
                      + "'>" + val[4] + "</span>");
                if (val[5] == "ACTIVE")
                {
                    r.Add("<button class='btn status btn-success' id_tp='" + val[0] + "'>" +
                          val[5] + "</button>");
                    r.Add("<button class='btn modify btn-info' id_tp='" + val[0] + "'" +
                          "data-toggle = 'modal' data-target = '#modify-type-product' > Sửa </button>");
                }
                else
                {
                    r.Add("<button class='btn status btn-danger' id_tp='" + val[0] + "'>" +
                          val[5] + "</button>");
                    r.Add("<button class='btn modify btn-info' id_tp='" + val[0] + "'" +
                          "data-toggle = 'modal' data-target = '#modify-type-product' disabled> Sửa </button>");
                }
                r.Add("<span>" + val[6] + "</span>");
                rs.Add(r.ToArray());
            }
            res.Add("data", rs.ToArray());
            return(JsonConvert.SerializeObject(res));
        }