public Result AddSysParams(string key, string value, string remark) { Result result = new Result(); result.StateCodeID = 0; result.IsOK = false; try { PCBEntities pCBEntities = new PCBEntities(); //PCB_ConfigTB configSys = ParameterAPI.GetConfig(key); PCB_ConfigTB configSys = pCBEntities.PCB_ConfigTB.FirstOrDefault(p => p.ConfigCode == key); if (configSys == null) { //增加 PCB_ConfigTB confignew = new PCB_ConfigTB(); confignew.ConfigID = System.Guid.NewGuid(); confignew.ConfigCode = key; confignew.ConfigValue = value; confignew.Remark = remark; pCBEntities.AddToPCB_ConfigTB(confignew); result.IsOK = Convert.ToBoolean(pCBEntities.SaveChanges()); if (result.IsOK) { result.Description = "增加" + key + "成功"; } } else { ////更新 //configSys.ConfigValue = value; //configSys.Remark = remark; //pCBEntities.Refresh(System.Data.Objects.RefreshMode.ClientWins, configSys); //result.IsOK = Convert.ToBoolean(pCBEntities.SaveChanges()); ////result = Common.Common.UpdateConfigTB(key, value, remark); //if (result.IsOK) // result.Description = "更新" + key + "成功"; result.IsOK = false; result.StateCodeID = 1; result.Description = "该项已存在"; return(result); } } catch (Exception ex) { LogHelper.WriteLog(GetType()).Info(ex.StackTrace); result.IsOK = false; result.Description = ex.Message; } return(result); }