コード例 #1
0
        // new customer
        private void mnuNew_Click(object sender, EventArgs e)
        {
            // open an empty form to add new customer
            frmCustomers customersForm = new frmCustomers();

            customersForm.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;
            }
        }