private void submit_button_Click(object sender, EventArgs e)
        {
            CustomerDB custDB = new CustomerDB();

            string firstName = first_name_textBox.Text;
            string lastName = last_name_textBox.Text;
            string address = address_textBox.Text;
            string city = city_textBox.Text;
            string state = state_comboBox.SelectedItem.ToString();
            int postalCode = Convert.ToInt32(postal_code_textBox.Text);
            string country = country_comboBox.SelectedItem.ToString();
            DateTime dob = dobPicker.Value;
            string ssn = ssn_textBox.Text;
            string phone = cell_phone_textBox.Text;
            string email = email_textBox.Text;
            string username = uname_textBox.Text;
            string password = password_textBox.Text;

            if (custDB.insertData(firstName, lastName, address, city, state, postalCode, country, dob, ssn, phone, email, username, password))
            {
                MessageBox.Show("Data saved successfully");
            }
            else
            {
                MessageBox.Show("Data invalid");
            }
        }
 private void submit_button_Click(object sender, EventArgs e)
 {
     CustomerDB customer = new CustomerDB();
     if (uname_txtBox.Text == "admin" && password_txtBox.Text == "admin123"){
         this.Hide();
         AdminBoard adminBoard = new AdminBoard();
         adminBoard.WindowState = System.Windows.Forms.FormWindowState.Maximized;
         adminBoard.Show();
     }
     else
     {
         int custId = customer.loginCheck(uname_txtBox.Text, password_txtBox.Text);
         if (custId > 0)
         {
             this.Hide();
             DashForm dashboard = new DashForm(custId);
             dashboard.WindowState = System.Windows.Forms.FormWindowState.Maximized;
             dashboard.Show();
         }
         else
         {
             MessageBox.Show("Invalid username and password");
         }
     }
 }
 private void showCustomer()
 {
     CustomerDB custDB = new CustomerDB();
     DataTable dta = new DataTable();
     dta = custDB.showCustomer(customerId);
     foreach (DataRow row in dta.Rows)
     {
         custId_mp_textBox.Text = row["customerId"].ToString();
         fname_mp_textBox.Text = row["firstName"].ToString();
         lname_mp_textBox.Text = row["lastname"].ToString();
         address_mp_textBox.Text = row["address"].ToString();
         city_mp_textBox.Text = row["city"].ToString();
         state_mp_textBox.Text = row["state"].ToString();
         postal_code_mp_textBox.Text = row["postalCode"].ToString();
         country_mp_textBox.Text = row["country"].ToString();
         dobPicker_mp.Value = Convert.ToDateTime(row["dateOfBirth"].ToString());
         ssn_mp_textBox.Text = row["SSN"].ToString();
         cell_phone_mp_textBox.Text = row["phone"].ToString();
         email_mp_textBox.Text = row["email"].ToString();
         uname_mp_textBox.Text = row["username"].ToString();
         password_mp_textBox.Text = row["pword"].ToString();
     }
 }
        private void update_button_Click(object sender, EventArgs e)
        {
            CustomerDB custDB = new CustomerDB();
            if (!string.IsNullOrWhiteSpace(custId_textBox.Text))
            {
                int custId = Convert.ToInt32(custId_textBox.Text);
                if (Convert.ToInt32(custId_textBox.Text) <= 0)
                {
                    if (dataLoaded)
                    {
                        if (custDB.selectCustomer(custId))
                        {
                            string firstName = first_name_textBox.Text;
                            string lastName = last_name_textBox.Text;
                            string address = address_textBox.Text;
                            string city = city_textBox.Text;
                            string state = state_comboBox.SelectedItem.ToString();
                            int postalCode = Convert.ToInt32(postal_code_textBox.Text);
                            string country = country_comboBox.SelectedItem.ToString();
                            DateTime dob = dobPicker.Value;
                            string ssn = ssn_textBox.Text;
                            string phone = cell_phone_textBox.Text;
                            string email = email_textBox.Text;
                            string username = uname_textBox.Text;
                            string password = password_textBox.Text;

                            if (custDB.updateData(Convert.ToInt32(custId_textBox.Text), firstName, lastName, address, city, state, postalCode, country, dob, ssn, phone, email, username, password))
                            {
                                MessageBox.Show("Data updated successfully");
                            }
                        }
                        else
                        {
                            MessageBox.Show("Invalid Customer ID");
                            editCustomer_clearUp();
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Please enter Customer ID");
                editCustomer_clearUp();
            }
        }
 private void load_button_Click(object sender, EventArgs e)
 {
     CustomerDB custDB = new CustomerDB();
     DataTable dta = new DataTable();
     if (!string.IsNullOrWhiteSpace(custId_textBox.Text))
     {
         int custId = Convert.ToInt32(custId_textBox.Text);
         if (custDB.selectCustomer(custId))
         {
             dataLoaded = true;
             dta = custDB.showCustomer(Convert.ToInt32(custId_textBox.Text));
             foreach (DataRow row in dta.Rows)
             {
                 first_name_textBox.Text = row["firstName"].ToString();
                 last_name_textBox.Text = row["lastname"].ToString();
                 address_textBox.Text = row["address"].ToString();
                 city_textBox.Text = row["city"].ToString();
                 state_comboBox.SelectedItem = row["state"].ToString();
                 postal_code_textBox.Text = row["postalCode"].ToString();
                 country_comboBox.SelectedItem = row["country"].ToString();
                 dobPicker.Value = Convert.ToDateTime(row["dateOfBirth"].ToString());
                 ssn_textBox.Text = row["SSN"].ToString();
                 cell_phone_textBox.Text = row["phone"].ToString();
                 email_textBox.Text = row["email"].ToString();
                 uname_textBox.Text = row["username"].ToString();
                 password_textBox.Text = row["pword"].ToString();
             }
         }
         else
         {
             MessageBox.Show("Invalid Customer ID");
             editCustomer_clearUp();
         }
     }
 }
        private void loadBilling_button_Click(object sender, EventArgs e)
        {
            CustomerDB custDB = new CustomerDB();
            BillingDB billDB = new BillingDB();
            DataTable dta = new DataTable();

            if (!string.IsNullOrWhiteSpace(billingId_textBox.Text))
            {
                int billId = Convert.ToInt32(billingId_textBox.Text);
                dataLoaded = true;
                dta = billDB.showBilling(billId);
                string paid = null;
                foreach (DataRow row in dta.Rows)
                {
                    custBilling_textBox.Text = row["customerId"].ToString();
                    monthBilling_comboBox.SelectedItem = row["billingMonth"].ToString();
                    yearBilling_comboBox.SelectedItem = row["billingYear"].ToString();
                    mailDate_picker.Value = Convert.ToDateTime(row["mailDate"].ToString());
                    meterNumber_textBox.Text = row["meterNumber"].ToString();
                    meterReading_textBox.Text = row["meterReading"].ToString();
                    amtToPay_textBox.Text = row["amountToPay"].ToString();
                    paid = row["paid"].ToString();
                    if (paid == "yes")
                    {
                        paidYes_radioButton.Checked = true;
                        paidDate_picker.Value = Convert.ToDateTime(row["paidDate"].ToString());

                    }
                    else
                    {
                        paidNo_radioButton.Checked = true;
                        paidDate_picker.Value = DateTime.Today;
                    }

                }
            }

            else
            {
                MessageBox.Show("Invalid Billing ID");
                editBillingPage_ClearUp();
            }
        }
        private void insertBilling_button_Click(object sender, EventArgs e)
        {
            CustomerDB custDB = new CustomerDB();
            BillingDB billDB = new BillingDB();

            bool insertSuccess = false;

            int custId = Convert.ToInt32(custBilling_textBox.Text);
            string billingMonth = monthBilling_comboBox.SelectedItem.ToString();
            int billingYear = Convert.ToInt32(yearBilling_comboBox.SelectedItem.ToString());
            DateTime mailDate = mailDate_picker.Value;
            int meterNumber = Convert.ToInt32(meterNumber_textBox.Text);
            int meterReading = Convert.ToInt32(meterReading_textBox.Text);
            double amtToPay = Convert.ToDouble(amtToPay_textBox.Text);
            string paid = "no";
            DateTime? paidDate = null;
            if (paidYes_radioButton.Checked)
            {
                paid = "yes";
                paidDate = paidDate_picker.Value;
            }
            else if (paidNo_radioButton.Checked)
            {
                paid = "no";
                paidDate = null;
            }

            if (custDB.selectCustomer(custId))
            {
                if (billDB.insertData(billingId_textBox, custId, billingMonth, billingYear, mailDate, meterNumber, meterReading, amtToPay, paid, paidDate))
                {
                    MessageBox.Show("Data inserted successfully");
                }
            }
            else
            {
                MessageBox.Show("Invalid customer ID");
            }
        }