/// <summary> /// 获取指定运行里程下所有的票价信息 /// </summary> /// <param name="Yxlc">运行里程</param> /// <returns></returns> public bool GetPriceInfo(int Yxlc, int trainType) { bool result = false; JTable tab = new JTable("TicketPrice"); List <SearchField> condition = new List <SearchField>(); condition.Add(new SearchField("StartMile", Yxlc.ToString(), SearchOperator.SmallerAndEqual, SearchFieldType.NumericType)); condition.Add(new SearchField("EndMile", Yxlc.ToString(), SearchOperator.BiggerAndEqual, SearchFieldType.NumericType)); condition.Add(new SearchField("TrainType", trainType.ToString(), SearchOperator.Equal, SearchFieldType.NumericType)); DataRow dr = tab.GetFirstDataRow(condition, new string[] { "*" }); string sql = tab.CommandText; if (dr != null) { if (!Convert.IsDBNull(dr["YZPrice"]) && dr["YZPrice"] != null) { this.YZPrice = Convert.ToDouble(dr["YZPrice"]); } if (!Convert.IsDBNull(dr["RZPrice"]) && dr["RZPrice"] != null) { this.RZPrice = Convert.ToDouble(dr["RZPrice"]); } if (!Convert.IsDBNull(dr["PTJKPrice"]) && dr["PTJKPrice"] != null) { this.PTJKPrice = Convert.ToDouble(dr["PTJKPrice"]); } if (!Convert.IsDBNull(dr["KSJKPrice"]) && dr["KSJKPrice"] != null) { this.KSJKPrice = Convert.ToDouble(dr["KSJKPrice"]); } if (!Convert.IsDBNull(dr["YWSPrice"]) && dr["YWSPrice"] != null) { this.YWSPrice = Convert.ToDouble(dr["YWSPrice"]); } if (!Convert.IsDBNull(dr["YWZPrice"]) && dr["YWZPrice"] != null) { this.YWZPrice = Convert.ToDouble(dr["YWZPrice"]); } if (!Convert.IsDBNull(dr["YWXPrice"]) && dr["YWXPrice"] != null) { this.YWXPrice = Convert.ToDouble(dr["YWXPrice"]); } if (!Convert.IsDBNull(dr["RWSPrice"]) && dr["RWSPrice"] != null) { this.RWSPrice = Convert.ToDouble(dr["RWSPrice"]); } if (!Convert.IsDBNull(dr["RWZPrice"]) && dr["RWZPrice"] != null) { this.RWZPrice = Convert.ToDouble(dr["RWZPrice"]); } if (!Convert.IsDBNull(dr["RWXPrice"]) && dr["RWXPrice"] != null) { this.RWXPrice = Convert.ToDouble(dr["RWXPrice"]); } if (!Convert.IsDBNull(dr["KDPrice"]) && dr["KDPrice"] != null) { this.KDPrice = Convert.ToDouble(dr["KDPrice"]); } result = true; } else { result = false;//没有找到对应里程的数据 } tab.Dispose(); tab.Close(); return(result); }