public void MapProperties(System.Data.Common.DbDataReader dr) { ID = dr.GetLong("ID"); Invoice_ID = dr.GetString("Invoice_ID"); Payment_Type = (DepositType)dr.GetByte("Payment_Type"); Detail = dr.GetString("Detail"); Payment = dr.GetDouble("Payment"); Total_Payment = dr.GetDouble("Total_Payment"); Balance = dr.GetDouble("Balance"); Created_By = dr.GetLong("Created_By"); Updated_By = dr.GetLong("Updated_By"); Created_Date = dr.GetDateTime("Created_Date"); Updated_Date = dr.GetDateTime("Updated_Date"); Organization_ID = dr.GetLong("Organization_ID"); IsActive = dr.GetBoolean("IsActive"); IsDeleted = dr.GetBoolean("IsDeleted"); }
/// <summary> /// Gets a double column. Slower then GetOrdinal + GetDouble /// </summary> /// <param name="reader"></param> /// <param name="name"></param> /// <returns></returns> public static double GetDouble(this System.Data.Common.DbDataReader reader, string name) { int ordinal = reader.GetOrdinal(name); return(reader.GetDouble(ordinal)); }
/// <summary> /// Gets a Double column. /// </summary> /// <param name="reader"></param> /// <param name="ordinal">The column number</param> /// <returns></returns> public static double?GetNDouble(this System.Data.Common.DbDataReader reader, int ordinal) { return(reader.IsDBNull(ordinal) ? (double?)null : reader.GetDouble(ordinal)); }
/// <summary> /// Gets a Double column. Slower then GetOrdinal + GetDouble /// </summary> /// <param name="reader"></param> /// <param name="name"></param> /// <returns></returns> public static double?GetNDouble(this System.Data.Common.DbDataReader reader, string name) { int ordinal = reader.GetOrdinal(name); return(reader.IsDBNull(ordinal) ? (double?)null : reader.GetDouble(ordinal)); }
///<summary> ///Return scalesValue from database from <paramref name="fromDate"/> to <paramref name="toDate"/> ///</summary> ///<param name="fromDate">from Date, if null will get all value until toDate</param> ///<param name="toDate">take until Date, if null will get all value after fromDate</param> public List <ScalesValue> getScalesValue(string fromDate, string toDate) { try { string condition = null; if (fromDate != null) { condition = " where Time >= @fromDate"; } if (toDate != null) { if (condition == null) { condition = " where "; } else { condition += " and "; } condition += "Time <= @toDate"; } string query = String.Format("select {0}, {1}, {2} from {3} {4} order by {5}", COL_SCALES_TIME, COL_SCALES_WEIGHT, COL_SCALES_TAG, TABLE_SCALES_VALUE, condition, COL_SCALES_TIME); //SqlCeCommand cmd = new SqlCeCommand(query, mConnection); setQuery(query); if (fromDate != null) { mCmd.Parameters.AddWithValue("@fromDate", DateTime.Parse(fromDate)); } if (toDate != null) { mCmd.Parameters.AddWithValue("@toDate", DateTime.Parse(toDate)); } System.Data.Common.DbDataReader reader = mCmd.ExecuteReader(); List <ScalesValue> list = new List <ScalesValue>(); while (reader.Read()) { ScalesValue value = new ScalesValue(reader.GetDateTime(0), (float)reader.GetDouble(1), reader.GetString(2)); list.Add(value); } reader.Close(); return(list); } catch (Exception e) { UnhandledExceptionEventArgs arg = new UnhandledExceptionEventArgs(e, false); CurrentDomain_UnhandledException(null, arg); return(null); } }