public JsonResult UpdatePropertyValue(long id, string properties_value_edit) { try { CatalogPropertiesValueBusiness catalogPropertiesValueBusiness = new CatalogPropertiesValueBusiness(); CatalogPropertiesValue catalogPropertiesValue = new CatalogPropertiesValue(); catalogPropertiesValue = catalogPropertiesValueBusiness.GetById(id); catalogPropertiesValue.Value = properties_value_edit; catalogPropertiesValueBusiness.Edit(catalogPropertiesValue); return(Json(1)); } catch { return(Json(0)); } }
public JsonResult AddPropertyUpdate(long id, string propertyvalue) { try { CatalogPropertiesBusiness catalogPropertiesBusiness = new CatalogPropertiesBusiness(); CatalogProperty catalogProperty = new CatalogProperty(); catalogProperty = catalogPropertiesBusiness.GetById(id); CatalogPropertiesValue objCatalogPropertiesValue = new CatalogPropertiesValue(); objCatalogPropertiesValue.Value = propertyvalue; objCatalogPropertiesValue.CatalogPropertieId = id; catalogProperty.CatalogPropertiesValues.Add(objCatalogPropertiesValue); catalogPropertiesBusiness.Edit(catalogProperty); return(Json(1));//Cập nhật thành công } catch (Exception) { return(Json(0)); //write log throw; } }
public JsonResult AddProperty(string nameproperty, int typevalue, int typedesgin, long cate, string allvalue) { try { CatalogProperty objCatalogProperty = new CatalogProperty(); objCatalogProperty.CatalogId = cate; objCatalogProperty.Type = typevalue; objCatalogProperty.TypeDesign = typedesgin; objCatalogProperty.Name = nameproperty; objCatalogProperty.Key = Function.ConvertFileName(nameproperty); var vl = allvalue.TrimEnd('|'); var arrValue = vl.Split('|'); List <CatalogPropertiesValue> catalogPropertiesValues = new List <CatalogPropertiesValue>(); foreach (var s in arrValue) { CatalogPropertiesValue objCatalogPropertiesValue = new CatalogPropertiesValue(); objCatalogPropertiesValue.Value = s; catalogPropertiesValues.Add(objCatalogPropertiesValue); } objCatalogProperty.CatalogPropertiesValues = catalogPropertiesValues; _catalogPropertiesBusiness.AddNew(objCatalogProperty); string htm = ""; htm += "<div class=\"panel panel-default tht_panel panlel_" + objCatalogProperty.Id + "\">" + "<div class=\"panel-heading\">" + "<h3 class=\"panel-title\">" + " <input id=\"cataproname" + objCatalogProperty.Id + "\" type=\"text\" value=\"" + objCatalogProperty.Name + "\" />" + " <input id=\"cataprokey" + objCatalogProperty.Id + "\" type=\"text\" value=\"" + objCatalogProperty.Key + "\" />"; if (objCatalogProperty.TypeDesign == 1) { if (objCatalogProperty.Type == 1) { htm += "<label ><input type=\"checkbox\" style=\"display:none;\" checked id =\"typeproperty\" value=\"" + objCatalogProperty.Type + "\">Cho phép chọn nhiều? </label><input type=\"checkbox\" id =\"typedesignproperty\" checked value=\"" + objCatalogProperty.TypeDesign + "\">Hiển thị 1 dòng </label><a class=\"del_1\" onclick=\"UpdateProperties(" + objCatalogProperty.Id + ")\">Sửa</a><a class=\"del_1\" onclick=\"DeleteProperties(" + objCatalogProperty.Id + ")\">Xóa</a></div>" + "<div class=\"panel-body\">"; } else { htm += "<label ><input type=\"checkbox\" style=\"display:none;\" id =\"typeproperty\" value=\"" + objCatalogProperty.Type + "\">Cho phép chọn nhiều? </label><input type=\"checkbox\" id =\"typedesignproperty\" checked value=\"" + objCatalogProperty.TypeDesign + "\">Hiển thị 1 dòng </label><a class=\"del_1\" onclick=\"UpdateProperties(" + objCatalogProperty.Id + ")\">Sửa</a><a class=\"del_1\" onclick=\"DeleteProperties(" + objCatalogProperty.Id + ")\">Xóa</a></div>" + "<div class=\"panel-body\">"; } } else { if (objCatalogProperty.Type == 1) { htm += "<label><input type=\"checkbox\" style=\"display:none;\" id =\"typeproperty\" checked value=\"" + objCatalogProperty.Type + "\">Cho phép chọn nhiều? </label><input type=\"checkbox\" id =\"typedesignproperty\" value=\"" + objCatalogProperty.TypeDesign + "\">Hiển thị 1 dòng </label><a class=\"del_1\" onclick=\"UpdateProperties(" + objCatalogProperty.Id + ")\">Sửa</a><a class=\"del_1\" onclick=\"DeleteProperties(" + objCatalogProperty.Id + ")\">Xóa</a></div>" + "<div class=\"panel-body\">"; } else { htm += "<label><input type=\"checkbox\" style=\"display:none;\" id =\"typeproperty\" value=\"" + objCatalogProperty.Type + "\">Cho phép chọn nhiều? </label><input type=\"checkbox\" id =\"typedesignproperty\" value=\"" + objCatalogProperty.TypeDesign + "\">Hiển thị 1 dòng </label><a class=\"del_1\" onclick=\"UpdateProperties(" + objCatalogProperty.Id + ")\">Sửa</a><a class=\"del_1\" onclick=\"DeleteProperties(" + objCatalogProperty.Id + ")\">Xóa</a></div>" + "<div class=\"panel-body\">"; } } foreach (var item2 in objCatalogProperty.CatalogPropertiesValues) { htm += "<p id=\"properties_value_" + item2.Id + "\">+ <input id=\"properties_value_edit_" + item2.Id + "\" type=\"text\" value=\"" + item2.Value + "\" /><a class=\"update_2\" onclick=\"UpdatePropertiesValue(" + item2.Id + ")\">Sửa</a><a class=\"del_2\" onclick=\"DeletePropertiesValue(" + item2.Id + ")\">Xóa</a></p>"; } htm += " </div></div>"; return(Json(htm));//add susess } catch (Exception) { return(Json(0)); //write log throw; } }