using WIDESEA_IServices; using WIDESEAWCS_BasicInfoRepository; using WIDESEAWCS_Model.Models; namespace WIDESEAWCS_BasicInfoService { public partial class Dt_SelectionStandardsService : ServiceBase, IDt_SelectionStandardsService { public Dt_SelectionStandardsService(IDt_SelectionStandardsRepository BaseDal) : base(BaseDal) { } public override WebResponseContent AddData(SaveModel saveModel) { WebResponseContent content = new WebResponseContent(); try { string carType = saveModel.MainData["carType"].ToString(); string mttype = saveModel.MainData["mttype"].ToString(); string neworold = saveModel.MainData["neworold"].ToString(); string gkdj = saveModel.MainData["gkdj"].ToString(); decimal lowerValue = Convert.ToDecimal(saveModel.MainData["lowerValue"]); decimal upperValue = Convert.ToDecimal(saveModel.MainData["upperValue"]); int isCantainGK = saveModel.MainData["isCantainGK"].ObjToInt(); decimal lowerValue_gk = Convert.ToDecimal(saveModel.MainData["lowerValue_gk"]); decimal upperValue_gk = Convert.ToDecimal(saveModel.MainData["upperValue_gk"]); if (lowerValue < 0 || upperValue < 0) throw new Exception("过盈量值异常"); if (isCantainGK != 0) { if (lowerValue_gk < 0 || upperValue_gk < 0) throw new Exception("截面过盈量值异常"); } Dt_SelectionStandards selectionStandards = new Dt_SelectionStandards { CarType = carType, CreateDate = DateTime.Now, Creater = App.User.UserName, gkdj = gkdj, isCantainGK = isCantainGK != 0 ? true : false, lowerValue = lowerValue, lowerValue_gk = lowerValue_gk, mttype = mttype, neworold = neworold, upperValue_gk = upperValue_gk, upperValue = upperValue }; if (BaseDal.AddData(selectionStandards) > 0) { return content.OK("添加成功"); } else { return content.Error("添加失败"); } } catch (Exception ex) { return content.Error($"添加失败:{ex.Message}"); } } } }