public string getCategory() { TypeProductModel model = new TypeProductModel(); List <string[][]> rs = new List <string[][]>(); for (int i = 1; i < 5; i++) { string[][] r = model.GetTypeProductByIdCategory(Convert.ToString(i)); rs.Add(r); } return(JsonConvert.SerializeObject(rs.ToArray())); }
public string SaveTypeProduct(string id, string name, string id_category) { var tpModel = new TypeProductModel(); Dictionary <string, string> res = new Dictionary <string, string>(); if (tpModel.Save(id, id_category, name)) { res.Add("status", "1"); } else { res.Add("status", "0"); } return(JsonConvert.SerializeObject(res)); }
public string ActiveTypeProduct(string id) { var tpModel = new TypeProductModel(); Dictionary <string, string> res = new Dictionary <string, string>(); if (tpModel.ActiveTypeProduct(id)) { res.Add("status", "1"); } else { res.Add("status", "0"); } return(JsonConvert.SerializeObject(res)); }
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)); }
public string InsertTypeProduct(string name, string id_category, string status) { var tpModel = new TypeProductModel(); Dictionary <string, string> res = new Dictionary <string, string>(); if (tpModel.Insert(name, id_category, status)) { res.Add("status", "1"); } else if (tpModel.CheckName(name)) { res.Add("NameError", "Tên kho không được trùng!!"); res.Add("status", "0"); } else { res.Add("msg", "Lỗi không xác định!!"); res.Add("status", "0"); } return(JsonConvert.SerializeObject(res)); }
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)); }