Exemple #1
0
        private void SearchCustomerOnCoName(object sender, KeyEventArgs e)
        {
            string filter = tstxtb_Customer_CoName.Text;

            if (e.KeyCode == Keys.Return)
            {
                dbh.OpenConnection();
                customerPanel.Controls.Clear();
                DataTable dt     = dbh.FilterCustomers(filter, "company_name");
                int       amount = dt.Rows.Count;
                if (!showAllCustomers && amount > 5)
                {
                    amount = 5;
                }

                CustomerPanel[] customerInfoPanel = new CustomerPanel[amount];

                for (int i = 0; i < customerInfoPanel.Length; i++)
                {
                    customerInfoPanel[i]             = new CustomerPanel(i, dt);
                    customerInfoPanel[i].BorderStyle = BorderStyle.FixedSingle;
                    customerInfoPanel[i].Dock        = DockStyle.Top;
                    customerPanel.Controls.Add(customerInfoPanel[i]);
                    customerInfoPanel[i].btn_editCustomer.AccessibleName = dt.Rows[i]["customer_id"].ToString();
                    customerInfoPanel[i].btn_editCustomer.Click         += new System.EventHandler(this.EditFinancialDetails);
                }
                dbh.CloseConnection();
            }
        }
Exemple #2
0
        private void ShowCustomers()
        {
            dbh.OpenConnection();
            DataTable dt = dbh.GetCustomers();

            customerPanel.Controls.Clear();
            int amount = dt.Rows.Count;

            if (!showAllCustomers && amount > 5)
            {
                amount = 5;

                Button showAllCustomersButton = new Button();
                showAllCustomersButton.Text   = "Show all customers";
                showAllCustomersButton.Dock   = DockStyle.Bottom;
                showAllCustomersButton.Click += new System.EventHandler(this.ShowAllCustomers);
                customerPanel.Controls.Add(showAllCustomersButton);
            }

            CustomerPanel[] customerInfoPanel = new CustomerPanel[amount];

            for (int i = 0; i < customerInfoPanel.Length; i++)
            {
                customerInfoPanel[i]             = new CustomerPanel(i, dt);
                customerInfoPanel[i].BorderStyle = BorderStyle.FixedSingle;
                customerInfoPanel[i].Dock        = DockStyle.Top;
                customerPanel.Controls.Add(customerInfoPanel[i]);
                customerInfoPanel[i].btn_editCustomer.AccessibleName = dt.Rows[i]["customer_id"].ToString();
                customerInfoPanel[i].btn_editCustomer.Click         += new EventHandler(this.EditCustomer);
            }
            dbh.CloseConnection();
        }