private void updBilling_button_Click(object sender, EventArgs e)
        {
            BillingDB billDB = new BillingDB();

            if (!string.IsNullOrWhiteSpace(billingId_textBox.Text))
            {
                int billId = Convert.ToInt32(billingId_textBox.Text);
                if (dataLoaded)
                {
                    if (billDB.selectBill(billId))
                    {
                        int      customerId   = 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 (billDB.updateBilling_Data(billId, customerId, billingMonth, billingYear, mailDate, meterNumber, meterReading, amtToPay, paid, paidDate))
                        {
                            MessageBox.Show("Data updated successfully");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Invalid Billing ID");
                        editCustomer_clearUp();
                    }
                }
                else
                {
                    MessageBox.Show("Please load the data first");
                    editCustomer_clearUp();
                }
            }
            else
            {
                MessageBox.Show("Please enter Billing ID");
                editCustomer_clearUp();
            }
        }
        private void compare_cmp_button_Click(object sender, EventArgs e)
        {
            BillingDB billDB = new BillingDB();
            DataTable dta    = new DataTable();
            string    month1 = month1_cmp_comboBox.SelectedItem.ToString();
            int       year1  = Convert.ToInt32(year1_cmp_comboBox.SelectedItem.ToString());

            string month2 = month2_cmp_comboBox.SelectedItem.ToString();
            int    year2  = Convert.ToInt32(year2_cmp_comboBox.SelectedItem.ToString());

            dta = billDB.compareBilling(customerId, month1, year1, month2, year2);
            CompareView.DataSource = dta;
        }
 private void reportGen_rpg_button_Click(object sender, EventArgs e)
 {
     if (month_rpg_comboBox.SelectedIndex < 13 && year_rpg_comboBox.SelectedIndex <= 16)
     {
         BillingDB billDB = new BillingDB();
         string    month  = month_rpg_comboBox.SelectedItem.ToString();
         int       year   = Convert.ToInt32(year_rpg_comboBox.SelectedItem.ToString());
         if (!(billDB.generateReport(customerId, month, year, billingID_rpg_textBox, mailDate_rpg_textBox, meterNumber_rpg_textBox, meterReading_rpg_textBox, amtToPay_rpg_textBox, paid_rpg_textBox, paidDate_rpg_textBox)))
         {
             reportGenTab_ClearUp();
             MessageBox.Show("No item to be displayed");
         }
     }
 }
        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");
            }
        }