public bool InsertOrUpdate(Material.MStandard parm, SqlTransaction tran) { string strSql = @" if exists (select 1 from ZL_MaterialStandard where mAutoID<>@mAutoID and chrType=@chrType) begin raiserror('已存在相同材料记录',11,1) end else begin if @mAutoID>0 begin update ZL_MaterialStandard set chrType=@chrType ,d10=@d10,d50=@d50,d90=@d90, surfaceArea=@surfaceArea,water=@water,vbDensity=@vbDensity,pdDensity=@pdDensity, plDensity=@plDensity,loi=@loi where mAutoID=@mAutoID end else begin insert into ZL_MaterialStandard(chrType,d10,d50,d90,surfaceArea,water,vbDensity,pdDensity,plDensity,loi) values(@chrType,@d10,@d50,@d90,@surfaceArea,@water,@vbDensity,@pdDensity,@plDensity,@loi) end end "; return(_con.Execute(strSql, parm, tran) > 0 ? true : false); }
public Object Post([FromBody] Material.MStandard newMaterial) { ReturnData Result = new ReturnData(); try { SqlConnection con = new SqlConnection(_ConString); con.Open(); SqlTransaction tran = con.BeginTransaction(); try { BllMaterial Bll = new BllMaterial(con); if (Bll.InsertOrUpdate(newMaterial, tran)) { tran.Commit(); Result.Result = true; Result.Msg = "³É¹¦"; } else { tran.Rollback(); Result.Result = false; Result.Msg = "ʧ°Ü"; } } catch (Exception ex) { tran.Rollback(); Result.Result = false; Result.Msg = ex.Message; } finally { con.Close(); } return(Result); } catch (Exception ex) { Result.Result = false; Result.Msg = ex.Message; return(Result); } }
public bool InsertOrUpdate(Material.MStandard parm, SqlTransaction tran) { return(Dll.InsertOrUpdate(parm, tran)); }