private void button1_Click(object sender, EventArgs e)
        {
            using (SADIT3Entities pishravi = new SADIT3Entities())
            {

                try
                {
                    var recipient = from a in pishravi.Customers
                        where a.cAlternativePhone == recipientTextBox.Text
                        select a.cAlternativePhone;

                    var initiator = from a in pishravi.Accounts
                        where a.Customer.cAlternativePhone == AccountStatus.LoggedInId
                        select a.AccountID;

                    pishravi.AccTransactions.Add(new AccTransaction
                    {
                        AccountID = initiator.Single(),
                        Status = "Request to " + recipient.Single() + " for " + amountTextbox.Text + " " + serviceCombobox.SelectedItem,
                        tTime = DateTime.Now
                    });
                    pishravi.SaveChanges();
                    MessageBox.Show("Request sent!");
                    this.Close();
                }
                catch
                {
                    MessageBox.Show("No such user!");
                }

            }
            AccountStatus.recipientNumber = "";
        }
        private void removeButton_Click(object sender, EventArgs e)
        {
            var result = MessageBox.Show("Are you sure you want to remove this transaction?", "Remove Transaction", MessageBoxButtons.YesNo);
            if (result == DialogResult.Yes)
            {
                using (SADIT3Entities pishravi = new SADIT3Entities())
                {
                    AccTransaction toDelete =
                        (from a in pishravi.AccTransactions
                         where a.Status == transactionList.SelectedItem.ToString()
                         select a).Single();

                    pishravi.AccTransactions.Remove(toDelete);
                    pishravi.SaveChanges();
                    var selected = transactionList.SelectedItem;
                    transactionList.Items.Remove(selected);
                }
            }
        }
        public Transactions()
        {
            InitializeComponent();

            accountName.Text = AccountStatus.userName;
            accountNumber.Text = AccountStatus.accountNumber;
            using (SADIT3Entities pishravi = new SADIT3Entities())
            {
                var allTrans = from a in pishravi.AccTransactions
                    where a.Account.Customer.cAlternativePhone == AccountStatus.LoggedInId
                    select a.Status;

                foreach (var trans in pishravi.AccTransactions.Where(x=>x.Account.Customer.cAlternativePhone == AccountStatus.LoggedInId))
                {
                    //var singleTrans = trans.Single();
                    transactionList.Items.Add(trans.Status);
                }

            }
        }
        public AccountDetails()
        {
            InitializeComponent();

            using (SADIT3Entities pishravi = new SADIT3Entities())
            {

                var address = from a in pishravi.Customers
                            where a.cAlternativePhone == AccountStatus.LoggedInId
                            select a.cStreetAddress + Environment.NewLine + a.cSuburbAddress + Environment.NewLine + a.cCity;

                var postcode = from a in pishravi.Customers
                            where a.cAlternativePhone == AccountStatus.LoggedInId
                            select a.cPostCode;

                accountNumber.Text = AccountStatus.accountNumber;
                accountName.Text = AccountStatus.userName;
                accountAddress.Text = address.Single();
                accountPostcode.Text = postcode.Single().ToString();

            }
        }
        private void registerButton_Click(object sender, EventArgs e)
        {
            if (nameTextBox.Text != null && emailTextBox.Text != null && addressTextBox.Text != null &&
                cityTextBox.Text != null && passwordTextBox.Text != null && phoneTextBox.Text != null &&
                postcodeTextBox.Text != null && suburbTextBox.Text != null)
            {
                using (SADIT3Entities pishravi = new SADIT3Entities())
                {
                    var user = from a in pishravi.Customers
                        where a.cAlternativePhone == phoneTextBox.Text
                        select a.cAlternativePhone;

                    try
                    {
                        if (user.Single() == phoneTextBox.Text)
                        {
                            MessageBox.Show("Sorry, there is already an account with that phone number");
                            numberDoesntExist = false;
                        }
                        else
                        {
                            numberDoesntExist = true;
                        }
                    }
                    catch
                    {

                    }

                }
                if (!numberDoesntExist) return;
                using (SADIT3Entities pishravi = new SADIT3Entities())
                {
                    if (address2TextBox.Text == "")
                    {
                        address2TextBox.Text = "None";
                    }

                    Customer newCustomer = new Customer
                    {
                        cAlternativePhone = phoneTextBox.Text,
                        cCity = cityTextBox.Text,
                        cEmail = emailTextBox.Text,
                        cFirstName = (nameTextBox.Text.Split(char.Parse(" "))[0].ToString()),
                        cLastName = (nameTextBox.Text.Split(char.Parse(" "))[1].ToString()),
                        cPassword = passwordTextBox.Text,
                        cPostCode = int.Parse(postcodeTextBox.Text),
                        cStreetAddress = addressTextBox.Text,
                        cStreetAddress2 = address2TextBox.Text,
                        cSuburbAddress = suburbTextBox.Text
                    };

                    Account newAccount = new Account {
                        aDateOpened = DateTime.Now,
                        aIsActive = true,
                        aPhoneNumber = phoneTextBox.Text,
                        Customer = newCustomer

                    };
                    pishravi.Accounts.Add(newAccount);
                    pishravi.Customers.Add(newCustomer);
                    pishravi.SaveChanges();
                }
                this.Close();
                new Login().Show();
            }
        }