public void SaveData(ModSysDirc t) { BllSysDirc bll = new BllSysDirc(); ModJsonResult json = new ModJsonResult(); if (!string.IsNullOrEmpty(Request["modify"])) //修改 { var model = bll.LoadData(t.Id); model.Name = t.Name; model.OrderNum = t.OrderNum; //判断名称是否存在 int count = 0; bool flag = bll.Exists("Sys_Group", " and CompanyId='" + t.CompanyId + "' and Name='" + t.Name + "' and Type=" + t.Type + " and Id<>'" + t.Id + "' and Status!=" + (int)StatusEnum.除, out count); if (flag) { json.success = false; json.msg = " 保存失败,该名称已经存在!"; } else { int result = bll.Update(model); if (result <= 0) { json.success = false; json.msg = "修改失败,请稍后再操作!"; } } } else { //判断名称是否存在 int count = 0; bool flag = bll.Exists("Sys_Dirc", " and Name='" + t.Name + "' and Type=" + t.Type + " and Status!=" + (int)StatusEnum.除, out count); if (flag) { json.success = false; json.msg = " 保存失败,该名称已经存在!"; } else { t.Id = Guid.NewGuid().ToString(); t.Status = (int)StatusEnum.正常; t.CreaterId = CurrentMaster.Id; t.CreateTime = DateTime.Now; t.CompanyId = CurrentMaster.Cid; t.ParentId = "0"; t.Type = int.Parse(Request["Type"]); int result = bll.Insert(t); if (result <= 0) { json.success = false; json.msg = " 保存失败,请稍后再操作!"; } } } WriteJsonToPage(json.ToString()); }
/// <summary> /// 删除 /// </summary> public void DeleteData(string id) { var msg = new ModJsonResult(); try { var SysDir = new BllSysDirc(); //判断字典类型是否被引用 var model = SysDir.LoadData(id); int count = 0; var flag = false; if (model != null) { switch (model.Type) { case 0: //仓库类别 flag = new BllContractInOut().Exists("H_OrderIn", " and StoreId='" + id + "' and Status!=" + (int)StatusEnum.除, out count); if (flag == false) { flag = new BllContractInOut().Exists("H_Purchase", " and StoreId='" + id + "' and Status!=" + (int)StatusEnum.除, out count); } break; case 1: //供应商类别 flag = new BllContractInOut().Exists("Sys_Company", " and Type='" + id + "' and Status!=" + (int)StatusEnum.除, out count); break; } } if (count > 0) { msg.success = false; msg.msg = "该字典项已被引用,不能直接进行删除。"; } else { int result = new BllSysDirc().DeleteStatus(id); if (result > 0) { msg.success = true; } else { msg.success = false; msg.msg = "删除失败."; } LogInsert(OperationTypeEnum.访问, "字典类型删除操作", "删除操作成功."); } } catch (Exception ex) { LogInsert(OperationTypeEnum.异常, "字典类型删除操作", "删除操作异常消息:" + ex.Message.ToString()); } WriteJsonToPage(msg.ToString()); }