// Collection of code snippets by Arne Vajhøj 
// (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) 
import java.math.BigDecimal;

import dk.vajhoej.isam.IsamException;
import dk.vajhoej.isam.IsamSource;
import dk.vajhoej.isam.local.LocalIsamSource;
import dk.vajhoej.record.RecordException;

public class Add {
    public static void main(String[] args) throws IsamException, RecordException {
        IsamSource cisam = new LocalIsamSource("customer.isq", "dk.vajhoej.vms.rms.IndexSequential", false);
        IsamSource oisam = new LocalIsamSource("order.isq", "dk.vajhoej.vms.rms.IndexSequential", false);
        CustomerActual c = new CustomerActual();
        c.setId(7);
        c.setName("G company");
        c.setPhone("7777-7777");
        c.setStatus(Customer.ACTUAL);
        c.setAddress1("G road 7");
        c.setAddress2("G town");
        c.setContact("Mr. G");
        cisam.create(c);
        Order o = new Order();
        o.setId(7);
        o.setCustomer(7);
        o.setStatus("In progress");
        o.setNlines(1);
        OrderLine ol = new OrderLine();
        ol.setItem("X stuff");
        ol.setQuantity(1);
        ol.setPrice(new BigDecimal("72.00"));
        o.getLine()[0] = ol;
        for(int i = 1; i < 10; i++) o.getLine()[i] = new OrderLine();
        oisam.create(o);
        cisam.close();
        oisam.close();
    }
}
