Esempio n. 1
0
        /// <summary>
        /// Get an entry from the ItemPricingChangeLog table
        /// </summary>
        public static ItemPricingChangeLog Get(int id)
        {
            ItemPricingChangeLog result = null;

            SqlConnection cn = GetConnection();

            result = Get(cn, id);
            FinishedWithConnection(cn);

            return(result);
        }
Esempio n. 2
0
        private static ItemPricingChangeLog Get(SqlConnection cn, int id)
        {
            ItemPricingChangeLog result = null;

            using (SqlCommand cmd = new SqlCommand("SELECT * FROM ItemPricingChangeLog WHERE ItemPricingChangeLogId=" + id, cn))
            {
                using (SqlDataReader rdr = cmd.ExecuteReader())
                {
                    if (rdr.Read())
                    {
                        result = BuildItemPricingChangeLog(rdr);
                    }
                }
            }
            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// Add a new entry to the ItemPricingChangeLog table
        /// </summary>
        public static ItemPricingChangeLog Add(int itemId, int employeeId, int?itemPricingId,
                                               double?oldPrice, double?newPrice, Days?oldDayOfTheWeek = null, Days?newDayOfTheWeek = null,
                                               TimeSpan?oldStartTime = null, TimeSpan?newStartTime = null, TimeSpan?oldEndTime = null,
                                               TimeSpan?newEndTime   = null)
        {
            ItemPricingChangeLog result      = null;
            DateTime             changedTime = DateTime.Now;

            SqlConnection cn  = GetConnection();
            string        cmd = "AddItemPricingChangeLog";

            using (SqlCommand sqlCmd = new SqlCommand(cmd, cn))
            {
                sqlCmd.CommandType = CommandType.StoredProcedure;
                BuildSqlParameter(sqlCmd, "@ItemPricingChangeLogItemId", SqlDbType.Int, itemId);
                BuildSqlParameter(sqlCmd, "@ItemPricingChangeLogEmployeeId", SqlDbType.Int, employeeId);
                BuildSqlParameter(sqlCmd, "@ItemPricingChangeLogItemPricingId", SqlDbType.Int, itemPricingId);
                BuildSqlParameter(sqlCmd, "@ItemPricingChangeLogOldPrice", SqlDbType.Float, oldPrice);
                BuildSqlParameter(sqlCmd, "@ItemPricingChangeLogNewPrice", SqlDbType.Float, newPrice);
                BuildSqlParameter(sqlCmd, "@ItemPricingChangeLogOldDayOfWeek", SqlDbType.TinyInt, oldDayOfTheWeek);
                BuildSqlParameter(sqlCmd, "@ItemPricingChangeLogNewDayOfWeek", SqlDbType.TinyInt, newDayOfTheWeek);
                BuildSqlParameter(sqlCmd, "@ItemPricingChangeLogOldStartTime", SqlDbType.Time, oldStartTime);
                BuildSqlParameter(sqlCmd, "@ItemPricingChangeLogNewStartTime", SqlDbType.Time, newStartTime);
                BuildSqlParameter(sqlCmd, "@ItemPricingChangeLogOldEndTime", SqlDbType.Time, oldEndTime);
                BuildSqlParameter(sqlCmd, "@ItemPricingChangeLogNewEndTime", SqlDbType.Time, newEndTime);
                BuildSqlParameter(sqlCmd, "@ItemPricingChangeLogDateTime", SqlDbType.DateTime, changedTime);
                BuildSqlParameter(sqlCmd, "@ItemPricingChangeLogId", SqlDbType.Int, ParameterDirection.ReturnValue);
                if (sqlCmd.ExecuteNonQuery() > 0)
                {
                    result = new ItemPricingChangeLog(Convert.ToInt32(sqlCmd.Parameters["@ItemPricingChangeLogId"].Value),
                                                      itemId, employeeId, itemPricingId, oldPrice, newPrice, oldDayOfTheWeek, newDayOfTheWeek,
                                                      oldStartTime, newStartTime, oldEndTime, newEndTime, changedTime);
                }
            }
            FinishedWithConnection(cn);
            return(result);
        }