protected void Button1_Click(object sender, EventArgs e)
        {
            //int cust_id = 0;
            int defaultID = 0;
            lucia_dataEntities allData = new lucia_dataEntities();
            //Create customer address first;
            Cust_Postal_Address cust_address = Cust_Postal_Address.CreateCust_Postal_Address(defaultID, DropDownList2.Text, txSuburb.Text, txStreet.Text, Convert.ToInt32(txStreetNumber.Text), Convert.ToInt32(txPostCode.Text));
            //assign optional unit number to customer
            if (!String.IsNullOrEmpty(txUnitNumber.Text))
                cust_address.unit_number = Convert.ToInt32(txUnitNumber.Text);
            //add customer address to database set
            allData.AddToCust_Postal_Address(cust_address);

            defaultID++;
            //now create customer, reference cust_address
            Customer customer = Customer.CreateCustomer(defaultID, txBusinessName.Text, txTradingName.Text, Convert.ToInt32(txBusinessYear.Text), txABN.Text, txNatureOperation.Text, cust_address.id, txFirstName.Text, txLastName.Text, txPosition.Text, txPhoneNumber.Text, txMobileNumber.Text, txEmail.Text, Convert.ToDecimal(txCreditLimit.Text), DropDownList1.Text);
            customer.Cust_Postal_Address = cust_address;
            //assign optional middle name for customer
            if (!String.IsNullOrEmpty(txMiddleName.Text))
                customer.contact_middle_name = txMiddleName.Text;
            //assign optional fax
            if (!String.IsNullOrEmpty(txFaxNumber.Text))
                customer.fax_no = txFaxNumber.Text;
            //add customer to database set
            allData.AddToCustomers(customer);

            defaultID++;

            allData.SaveChanges();

            allData.Dispose();

            lucia_dataEntities alldata = new lucia_dataEntities();
            int customer_ida = customer.id;
            Account account = Account.CreateAccount(defaultID, "active", Convert.ToDecimal(txCreditLimit.Text), "0000", Convert.ToDecimal(txCreditLimit.Text), customer_ida);
            alldata.AddToAccounts(account);
            //create log
            int empid = Convert.ToInt32(Request.Cookies["empid"].Value);
            alldata.SaveChanges();
            operationLog log = operationLog.CreateoperationLog(empid, account.cust_id, "create new customer", 1, DateTime.Now);
            alldata.AddTooperationLogs(log);
            alldata.SaveChanges();
            Label22.Text = "Your detail has been successfully saved." + account.id;
            alldata.Dispose();
        }