/// <summary> /// Adds an entry for the TicketItem table /// </summary> public static TicketItem Add(YearId ticketPrimaryKey, int itemId, int quantity, double price, DateTime?orderTime, DateTime?preparedTime, int?parentTicketItemId = null) { TicketItem result; SqlConnection cn = GetConnection(); using (SqlCommand sqlCmd = new SqlCommand("AddTicketItem", cn)) { sqlCmd.CommandType = CommandType.StoredProcedure; BuildSqlParameter(sqlCmd, "@TicketItemYear", SqlDbType.SmallInt, ticketPrimaryKey.Year); BuildSqlParameter(sqlCmd, "@TicketItemTicketId", SqlDbType.Int, ticketPrimaryKey.Id); BuildSqlParameter(sqlCmd, "@TicketItemItemId", SqlDbType.Int, itemId); BuildSqlParameter(sqlCmd, "@TicketItemQuantity", SqlDbType.SmallInt, quantity); BuildSqlParameter(sqlCmd, "@TicketItemPrice", SqlDbType.Float, price); BuildSqlParameter(sqlCmd, "@TicketItemOrderTime", SqlDbType.DateTime, orderTime); BuildSqlParameter(sqlCmd, "@TicketItemPreparedTime", SqlDbType.DateTime, preparedTime); BuildSqlParameter(sqlCmd, "@TicketItemParentTicketItemId", SqlDbType.Int, parentTicketItemId); BuildSqlParameter(sqlCmd, "@TicketItemId", SqlDbType.Int, ParameterDirection.Output); sqlCmd.ExecuteNonQuery(); result = CreateOrUpdate(YearId.Create(ticketPrimaryKey.Year, Convert.ToInt32(sqlCmd.Parameters["@TicketItemId"].Value)), ticketPrimaryKey.Id, itemId, quantity, null, price, orderTime, preparedTime, null, null, null, null, false, parentTicketItemId, null); if (result.PrimaryKey.Id == 0) { throw new Exception("No id returned"); } } FinishedWithConnection(cn); // Reduce the inventory of for the ticketitem AdjustInventory(result, false); return(result); }
/// <summary> /// Adds a new entry to the Ticket table /// </summary> public static Ticket Add(TicketType type, int partyId, int seatingId, int employeeId, int customerId) { Ticket result = null; DateTime now = DateTime.Now; short year = DayOfOperation.CurrentYear; SqlConnection cn = GetConnection(); using (SqlCommand sqlCmd = new SqlCommand("AddTicket", cn)) { sqlCmd.CommandType = CommandType.StoredProcedure; BuildSqlParameter(sqlCmd, "@TicketYear", SqlDbType.SmallInt, year); BuildSqlParameter(sqlCmd, "@TicketType", SqlDbType.SmallInt, type); BuildSqlParameter(sqlCmd, "@TicketPartyId", SqlDbType.Int, partyId); BuildSqlParameter(sqlCmd, "@TicketSeatingId", SqlDbType.Int, seatingId); BuildSqlParameter(sqlCmd, "@TicketEmployeeId", SqlDbType.Int, employeeId); BuildSqlParameter(sqlCmd, "@TicketCustomerId", SqlDbType.Int, customerId); BuildSqlParameter(sqlCmd, "@TicketCreateTime", SqlDbType.DateTime, now); BuildSqlParameter(sqlCmd, "@TicketId", SqlDbType.Int, ParameterDirection.ReturnValue); if (sqlCmd.ExecuteNonQuery() > 0) { result = new Ticket(YearId.Create(year, Convert.ToInt32(sqlCmd.Parameters["@TicketId"].Value)), null, type, partyId, seatingId, employeeId, customerId, now, null) { IsBeingModified = true }; } } FinishedWithConnection(cn); return(result); }
/// <summary> /// Used for returns /// </summary> public double GetTax(double itemCost) { Item item = Item.Get(ItemId); Tax tax = Tax.Get(item.TaxId); Ticket ticket = Ticket.Get(YearId.Create(PrimaryKey.Year, TicketId)); if (item.IsTaxExemptable && (ticket.TaxExemptId != null)) { return(0); } return(itemCost * tax.Percentage); }
private static Ticket BuildTicket(SqlDataReader rdr) { short year = GetYear(rdr); int id = GetId(rdr); return(new Ticket(YearId.Create(year, id), GetOrderId(rdr), GetTicketType(rdr), GetPartyId(rdr), GetSeatingId(rdr), GetEmployeeId(rdr), GetCustomerId(rdr), GetCreatedTime(rdr), GetStartTime(rdr), GetPrepareTime(rdr), GetReadyTime(rdr), GetClosedTime(rdr), GetManagerNote(rdr), GetIsCanceled(rdr), GetTaxExemptId(rdr))); }
private static YearId GetPrimaryKey(SqlDataReader rdr) { return(YearId.Create( rdr.GetInt16(0), rdr.GetInt32(1))); }