Beispiel #1
0
        public void QueryCloseOrder(SqlConnection conn, SessionQh session, FineQh fine)
        {
            string sql;

            if (fine != null)
            {
                sql = "update Session set End_datetime = @dateclosed where Session_ID = @sessionid;" +
                      "insert into Car_Return(Session_ID, Fine_ID) Values (@sessionid, @fineid);" +
                      "insert into Payments(Session_ID, Date_time) Values (@sessionid, @dateclosed);";
            }
            else
            {
                sql = "update Session set End_datetime = @dateclosed where Session_ID = @sessionid;" +
                      "insert into Car_Return(Session_ID) Values (@sessionid);" +
                      "insert into Payments(Session_ID, Date_time) Values (@sessionid, @dateclosed);";
            }

            var cmd = new SqlCommand()
            {
                Connection  = conn,
                CommandText = sql
            };

            if (fine != null)
            {
                cmd.Parameters.Add("@fineid", SqlDbType.Int).Value = fine.Fine_ID;
            }
            cmd.Parameters.Add("@dateclosed", SqlDbType.DateTime).Value = DateTime.Now;
            cmd.Parameters.Add("@sessionid", SqlDbType.Int).Value       = session.Session_ID;
            cmd.ExecuteNonQuery();
        }
Beispiel #2
0
        public List <FineQh> QueryFines(SqlConnection conn)
        {
            var fines = new List <FineQh>();
            var sql   = "select * from Fine";
            var cmd   = new SqlCommand
            {
                Connection  = conn,
                CommandText = sql
            };

            using (DbDataReader reader = cmd.ExecuteReader())
            {
                if (reader.HasRows)
                {
                    while (reader.Read())
                    {
                        var fId   = reader.GetInt32(0);
                        var fDesc = reader.GetString(1);
                        var fCost = reader.GetInt32(2);


                        var tempFine = new FineQh()
                        {
                            Fine_ID          = fId,
                            Fine_description = fDesc,
                            Fine_cost        = fCost
                        };

                        fines.Add(tempFine);
                    }
                }
            }

            return(fines);
        }