/// <summary> ///更新车型信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public int UpdateCarModel(BaseCarModelModel model) { var sql = new StringBuilder("update `base_carmodel` set "); sql.Append(Helper.CreateField(model).Trim().TrimEnd(',')); sql.Append(" where innerid = @innerid"); int result; try { result = Helper.Execute(sql.ToString(), model); } catch (Exception ex) { result = 0; } return result; }
/// <summary> /// 添加车型信息 /// </summary> /// <param name="model"></param> /// <returns></returns> public int AddCarModel(BaseCarModelModel model) { const string sql = @"INSERT INTO `base_carmodel` (`innerid`,`modelname`,`modelprice`,`modelyear`,`minregyear`,`maxregyear`,`liter`,`geartype`,`dischargestandard`,`seriesid`,`isenabled`,`remark`) VALUES (@innerid,@modelname,@modelprice,@modelyear,@minregyear,@maxregyear,@liter,@geartype,@dischargestandard,@seriesid,@isenabled,@remark);"; using (var conn = Helper.GetConnection()) { var tran = conn.BeginTransaction(); try { conn.Execute(sql, model, tran); tran.Commit(); return 1; } catch (Exception ex) { tran.Rollback(); return 0; } } }