Пример #1
0
        /// <summary>
        /// Add a new entry to the TicketRefund table
        /// </summary>
        public static TicketRefund Add(YearId ticketPrimaryKey, int employeeId,
                                       int registerDrawerId, double amount, TicketRefundType refundType)
        {
            TicketRefund result     = null;
            DateTime     refundTime = DateTime.Now;

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

            using (SqlCommand sqlCmd = new SqlCommand(cmd, cn))
            {
                sqlCmd.CommandType = CommandType.StoredProcedure;
                BuildSqlParameter(sqlCmd, "@TicketRefundYear", SqlDbType.SmallInt, ticketPrimaryKey.Year);
                BuildSqlParameter(sqlCmd, "@TicketRefundEmployeeId", SqlDbType.Int, employeeId);
                BuildSqlParameter(sqlCmd, "@TicketRefundTicketId", SqlDbType.Int, ticketPrimaryKey.Id);
                BuildSqlParameter(sqlCmd, "@TicketRefundRegisterDrawerId", SqlDbType.Int, registerDrawerId);
                BuildSqlParameter(sqlCmd, "@TicketRefundDate", SqlDbType.DateTime, refundTime);
                BuildSqlParameter(sqlCmd, "@TicketRefundAmount", SqlDbType.Float, amount);
                BuildSqlParameter(sqlCmd, "@TicketRefundStatus", SqlDbType.TinyInt, refundType);
                BuildSqlParameter(sqlCmd, "@TicketRefundId", SqlDbType.Int, ParameterDirection.ReturnValue);
                if (sqlCmd.ExecuteNonQuery() > 0)
                {
                    result = new TicketRefund(
                        new YearId(ticketPrimaryKey.Year,
                                   Convert.ToInt32(sqlCmd.Parameters["@TicketRefundId"].Value)),
                        employeeId, ticketPrimaryKey.Id, registerDrawerId, refundTime, amount, refundType);
                }
            }
            FinishedWithConnection(cn);

            return(result);
        }
Пример #2
0
        /// <summary>
        /// Get an entry from the TicketRefund table
        /// </summary>
        public static TicketRefund Get(YearId primaryKey)
        {
            TicketRefund result = null;

            SqlConnection cn = GetConnection();

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

            return(result);
        }
Пример #3
0
        private static TicketRefund Get(SqlConnection cn, YearId primaryKey)
        {
            TicketRefund result = null;

            using (SqlCommand cmd = new SqlCommand("SELECT * FROM TicketRefund WHERE (TicketRefundId=" + primaryKey.Id + " AND TicketRefundYear=" + primaryKey.Year + ")", cn))
            {
                using (SqlDataReader rdr = cmd.ExecuteReader())
                {
                    if (rdr.Read())
                    {
                        result = BuildTicketRefund(rdr);
                    }
                }
            }
            return(result);
        }