public ActionResult Delete(int id) { AjaxResult result = new AjaxResult(); try { GreenFactoryClass entity = m_FTISService.GetGreenFactoryClassById(id); //檢查底下的GreenFactory數量 IDictionary <string, string> conditions = new Dictionary <string, string>(); conditions.Add("GreenFactoryClassId", id.ToString()); int subsCount = m_FTISService.GetGreenFactoryCount(conditions); if (subsCount > 0) { return(this.Json(new AjaxResult(AjaxResultStatus.Fail, string.Format("{0}底下尚有綠色工廠,不可刪除。", entity.Name)))); } m_FTISService.DeleteGreenFactoryClass(entity); result.ErrorCode = AjaxResultStatus.Success; result.Message = string.Format("{0}刪除成功", entity.Name); } catch (Exception ex) { result.ErrorCode = AjaxResultStatus.Exception; result.Message = ex.Message; } return(this.Json(result)); }
protected void LoadEntity(GreenFactoryClass entity) { if (entity != null) { EntityId = entity.GreenFactoryClassId; Name = entity.Name; SortId = entity.SortId; Status = entity.Status; } }
private void Save(GreenFactoryClass entity) { entity.Name = Name; entity.SortId = SortId; entity.Status = Status; if (entity.GreenFactoryClassId == 0) { m_FTISService.CreateGreenFactoryClass(entity); } else { m_FTISService.UpdateGreenFactoryClass(entity); } LoadEntity(entity.GreenFactoryClassId); }
public ActionResult SetSort(string entityId, string sortValue) { AjaxResult result = new AjaxResult(AjaxResultStatus.Success, string.Empty); StringBuilder sbMsg = new StringBuilder(); try { GreenFactoryClass entity = m_FTISService.GetGreenFactoryClassById(Convert.ToInt32(entityId)); entity.SortId = int.Parse(sortValue); m_FTISService.UpdateGreenFactoryClass(entity); } catch (Exception ex) { result.ErrorCode = AjaxResultStatus.Fail; sbMsg.AppendFormat(ex.Message + "<br/>"); } result.Message = sbMsg.ToString(); return(this.Json(result)); }
public ActionResult MultiDelete(string allId) { AjaxResult result = new AjaxResult(AjaxResultStatus.Success, string.Empty); StringBuilder sbMsg = new StringBuilder(); string[] ids = allId.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string id in ids) { try { GreenFactoryClass entity = m_FTISService.GetGreenFactoryClassById(Convert.ToInt32(id)); //檢查底下的GreenFactory數量 IDictionary <string, string> conditions = new Dictionary <string, string>(); conditions.Add("GreenFactoryClassId", id.ToString()); int subsCount = m_FTISService.GetGreenFactoryCount(conditions); if (subsCount == 0) { m_FTISService.DeleteGreenFactoryClass(entity); } else { result.ErrorCode = AjaxResultStatus.Fail; sbMsg.AppendFormat("{0},底下尚有綠色工廠,不可刪除。<br/>", entity.Name); } } catch (Exception ex) { result.ErrorCode = AjaxResultStatus.Fail; sbMsg.AppendFormat(ex.Message + "<br/>"); } } result.Message = sbMsg.ToString(); return(this.Json(result)); }
public void Update() { GreenFactoryClass entity = m_FTISService.GetGreenFactoryClassById(EntityId); Save(entity); }
public void Insert() { GreenFactoryClass entity = new GreenFactoryClass(); Save(entity); }
protected void LoadEntity(int id) { GreenFactoryClass entity = m_FTISService.GetGreenFactoryClassById(id); LoadEntity(entity); }