/// <summary> /// 增加一条数据 /// </summary> public void Add(Entity.BASE_BUS_OVERRUN model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into BASE_BUS_OVERRUN("); strSql.Append("ID,AXISNUM,OVERLOADRATE,TOTALWEIGHT,TOTALTOLL,DISTANCE,IMPORTDATE,VEHICLELICENSE,ENTRYSTATION,ENTRYSTATIONNAME,ENTRYTIME,EXITSTATION,EXITSTATIONNAME,EXITTIME,PAYTYPE"); strSql.Append(") values ("); strSql.Append(":ID,:AXISNUM,:OVERLOADRATE,:TOTALWEIGHT,:TOTALTOLL,:DISTANCE,:IMPORTDATE,:VEHICLELICENSE,:ENTRYSTATION,:ENTRYSTATIONNAME,:ENTRYTIME,:EXITSTATION,:EXITSTATIONNAME,:EXITTIME,:PAYTYPE"); strSql.Append(") "); OracleParameter[] parameters = { new OracleParameter(":ID", OracleType.Number, 4), new OracleParameter(":AXISNUM", OracleType.Number, 4), new OracleParameter(":OVERLOADRATE", OracleType.Number, 4), new OracleParameter(":TOTALWEIGHT", OracleType.Number, 4), new OracleParameter(":TOTALTOLL", OracleType.Number, 4), new OracleParameter(":DISTANCE", OracleType.Number, 4), new OracleParameter(":IMPORTDATE", OracleType.DateTime), new OracleParameter(":VEHICLELICENSE", OracleType.VarChar, 200), new OracleParameter(":ENTRYSTATION", OracleType.Number, 4), new OracleParameter(":ENTRYSTATIONNAME", OracleType.VarChar, 200), new OracleParameter(":ENTRYTIME", OracleType.DateTime), new OracleParameter(":EXITSTATION", OracleType.Number, 4), new OracleParameter(":EXITSTATIONNAME", OracleType.VarChar, 200), new OracleParameter(":EXITTIME", OracleType.DateTime), new OracleParameter(":PAYTYPE", OracleType.VarChar, 200) }; parameters[0].Value = model.ID; parameters[1].Value = model.AXISNUM; parameters[2].Value = model.OVERLOADRATE; parameters[3].Value = model.TOTALWEIGHT; parameters[4].Value = model.TOTALTOLL; parameters[5].Value = model.DISTANCE; parameters[6].Value = model.IMPORTDATE; parameters[7].Value = model.VEHICLELICENSE; parameters[8].Value = model.ENTRYSTATION; parameters[9].Value = model.ENTRYSTATIONNAME; parameters[10].Value = model.ENTRYTIME; parameters[11].Value = model.EXITSTATION; parameters[12].Value = model.EXITSTATIONNAME; parameters[13].Value = model.EXITTIME; parameters[14].Value = model.PAYTYPE; OracleHelper.ExecuteNonQuery(strSql.ToString(), parameters); }
/// <summary> /// 得到一个对象实体 /// </summary> public Entity.BASE_BUS_OVERRUN GetEntity(decimal ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select ID, AXISNUM, OVERLOADRATE, TOTALWEIGHT, TOTALTOLL, DISTANCE, IMPORTDATE, VEHICLELICENSE, ENTRYSTATION, ENTRYSTATIONNAME, ENTRYTIME, EXITSTATION, EXITSTATIONNAME, EXITTIME, PAYTYPE "); strSql.Append(" from BASE_BUS_OVERRUN "); strSql.Append(" where ID=:ID "); OracleParameter[] parameters = { new OracleParameter(":ID", OracleType.Number, 4) }; parameters[0].Value = ID; Entity.BASE_BUS_OVERRUN entity = new Entity.BASE_BUS_OVERRUN(); DataTable dt = OracleHelper.Query(CommandType.Text, strSql.ToString(), parameters); if (dt.Rows.Count > 0) { if (dt.Rows[0]["ID"].ToString() != "") { entity.ID = decimal.Parse(dt.Rows[0]["ID"].ToString()); } if (dt.Rows[0]["AXISNUM"].ToString() != "") { entity.AXISNUM = decimal.Parse(dt.Rows[0]["AXISNUM"].ToString()); } if (dt.Rows[0]["OVERLOADRATE"].ToString() != "") { entity.OVERLOADRATE = decimal.Parse(dt.Rows[0]["OVERLOADRATE"].ToString()); } if (dt.Rows[0]["TOTALWEIGHT"].ToString() != "") { entity.TOTALWEIGHT = decimal.Parse(dt.Rows[0]["TOTALWEIGHT"].ToString()); } if (dt.Rows[0]["TOTALTOLL"].ToString() != "") { entity.TOTALTOLL = decimal.Parse(dt.Rows[0]["TOTALTOLL"].ToString()); } if (dt.Rows[0]["DISTANCE"].ToString() != "") { entity.DISTANCE = decimal.Parse(dt.Rows[0]["DISTANCE"].ToString()); } if (dt.Rows[0]["IMPORTDATE"].ToString() != "") { entity.IMPORTDATE = DateTime.Parse(dt.Rows[0]["IMPORTDATE"].ToString()); } entity.VEHICLELICENSE = dt.Rows[0]["VEHICLELICENSE"].ToString(); if (dt.Rows[0]["ENTRYSTATION"].ToString() != "") { entity.ENTRYSTATION = decimal.Parse(dt.Rows[0]["ENTRYSTATION"].ToString()); } entity.ENTRYSTATIONNAME = dt.Rows[0]["ENTRYSTATIONNAME"].ToString(); if (dt.Rows[0]["ENTRYTIME"].ToString() != "") { entity.ENTRYTIME = DateTime.Parse(dt.Rows[0]["ENTRYTIME"].ToString()); } if (dt.Rows[0]["EXITSTATION"].ToString() != "") { entity.EXITSTATION = decimal.Parse(dt.Rows[0]["EXITSTATION"].ToString()); } entity.EXITSTATIONNAME = dt.Rows[0]["EXITSTATIONNAME"].ToString(); if (dt.Rows[0]["EXITTIME"].ToString() != "") { entity.EXITTIME = DateTime.Parse(dt.Rows[0]["EXITTIME"].ToString()); } entity.PAYTYPE = dt.Rows[0]["PAYTYPE"].ToString(); return(entity); } else { return(null); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Entity.BASE_BUS_OVERRUN model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update BASE_BUS_OVERRUN set "); strSql.Append(" ID = :ID , "); strSql.Append(" AXISNUM = :AXISNUM , "); strSql.Append(" OVERLOADRATE = :OVERLOADRATE , "); strSql.Append(" TOTALWEIGHT = :TOTALWEIGHT , "); strSql.Append(" TOTALTOLL = :TOTALTOLL , "); strSql.Append(" DISTANCE = :DISTANCE , "); strSql.Append(" IMPORTDATE = :IMPORTDATE , "); strSql.Append(" VEHICLELICENSE = :VEHICLELICENSE , "); strSql.Append(" ENTRYSTATION = :ENTRYSTATION , "); strSql.Append(" ENTRYSTATIONNAME = :ENTRYSTATIONNAME , "); strSql.Append(" ENTRYTIME = :ENTRYTIME , "); strSql.Append(" EXITSTATION = :EXITSTATION , "); strSql.Append(" EXITSTATIONNAME = :EXITSTATIONNAME , "); strSql.Append(" EXITTIME = :EXITTIME , "); strSql.Append(" PAYTYPE = :PAYTYPE "); strSql.Append(" where ID=:ID "); OracleParameter[] parameters = { new OracleParameter(":ID", OracleType.Number, 4), new OracleParameter(":AXISNUM", OracleType.Number, 4), new OracleParameter(":OVERLOADRATE", OracleType.Number, 4), new OracleParameter(":TOTALWEIGHT", OracleType.Number, 4), new OracleParameter(":TOTALTOLL", OracleType.Number, 4), new OracleParameter(":DISTANCE", OracleType.Number, 4), new OracleParameter(":IMPORTDATE", OracleType.DateTime), new OracleParameter(":VEHICLELICENSE", OracleType.VarChar, 200), new OracleParameter(":ENTRYSTATION", OracleType.Number, 4), new OracleParameter(":ENTRYSTATIONNAME", OracleType.VarChar, 200), new OracleParameter(":ENTRYTIME", OracleType.DateTime), new OracleParameter(":EXITSTATION", OracleType.Number, 4), new OracleParameter(":EXITSTATIONNAME", OracleType.VarChar, 200), new OracleParameter(":EXITTIME", OracleType.DateTime), new OracleParameter(":PAYTYPE", OracleType.VarChar, 200) }; parameters[15].Value = model.ID; parameters[16].Value = model.AXISNUM; parameters[17].Value = model.OVERLOADRATE; parameters[18].Value = model.TOTALWEIGHT; parameters[19].Value = model.TOTALTOLL; parameters[20].Value = model.DISTANCE; parameters[21].Value = model.IMPORTDATE; parameters[22].Value = model.VEHICLELICENSE; parameters[23].Value = model.ENTRYSTATION; parameters[24].Value = model.ENTRYSTATIONNAME; parameters[25].Value = model.ENTRYTIME; parameters[26].Value = model.EXITSTATION; parameters[27].Value = model.EXITSTATIONNAME; parameters[28].Value = model.EXITTIME; parameters[29].Value = model.PAYTYPE; int rows = OracleHelper.ExecuteNonQuery(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }