예제 #1
0
        private void newAccountForm(int selectedRow, bool p)
        {
            // get the number of columns in data grid view
            int numberOfColumns = dgvDatabaseResults.ColumnCount;

            // create array with objects holds all data from selected row
            Object[] row = new Object[numberOfColumns];

            // check if any row is selected
            if (selectedRow >= 0)
            {
                // this loop will put object to row array from each column from selected row
                for (int i = 0; i < numberOfColumns; i++)
                {
                    row[i] = dgvDatabaseResults[i, selectedRow].Value.ToString();
                }
            }
            else
            {
                row = null;
            }

            // create new form
            frmAccounts accountForm = new frmAccounts(row, true);

            accountForm.ShowDialog();
        }
예제 #2
0
        // form manager (passing the data from selected row, choose which form is going to create and status)
        private void newFormDetails(int selectedRow, string formToCreate, Boolean isReadOnly)
        {
            // get the number of columns in data grid view
            int numberOfColumns = dgvDatabaseResults.ColumnCount;

            // create array with objects holds all data from selected row
            Object[] row = new Object[numberOfColumns];

            // check if any row is selected
            if (selectedRow >= 0)
            {
                // this loop will put object to row array from each column from selected row
                for (int i = 0; i < numberOfColumns; i++)
                {
                    row[i] = dgvDatabaseResults[i, selectedRow].Value.ToString();
                }
            }
            else
            {
                row = null;
            }

            // create new form
            switch (formToCreate)
            {
            case "customerForm":
                frmCustomers customersForm = new frmCustomers(row, isReadOnly);
                customersForm.ShowDialog();
                break;

            case "productForm":
                frmProducts productForm = new frmProducts(row, isReadOnly);
                productForm.ShowDialog();
                break;

            case "transactionForm":
                frmTransactions transactionForm = new frmTransactions(row, isReadOnly);
                transactionForm.ShowDialog();
                break;

            case "accountForm":
                frmAccounts accountForm = new frmAccounts(row, isReadOnly);
                accountForm.ShowDialog();
                break;
            }
        }
예제 #3
0
        // adding nuew customer's account
        private void mnuAccount_Click(object sender, EventArgs e)
        {
            int numberOfAccounts = dgvDatabaseResults.Rows.Count;

            // do only if customer has some accounts
            if (numberOfAccounts > 0)
            {
                // check every account start date account
                for (int i = 0; i < numberOfAccounts; i++)
                {
                    DateTime startAccountDate = DateTime.Parse(dgvDatabaseResults.Rows[i].Cells[6].Value.ToString());
                    if (isDateThisTaxYear(startAccountDate))
                    {
                        MessageBox.Show("Customer created the new account in this tax year. Opening another one is not available.");
                        return;
                    }
                }
            }

            // open an empty form to add new product
            frmAccounts accountForm = new frmAccounts(customerID);

            accountForm.ShowDialog();
        }