Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            int index = cbBillAmount.SelectedIndex;

            switch (index)
            {
            case 0:
                sda = ConsumerDB.getBAGT(Convert.ToDouble(txtBA.Text));
                break;

            case 1:
                sda = ConsumerDB.getBALT(Convert.ToDouble(txtBA.Text));
                break;

            case 2:
                sda = ConsumerDB.getBAGTE(Convert.ToDouble(txtBA.Text));
                break;

            case 3:
                sda = ConsumerDB.getBALTE(Convert.ToDouble(txtBA.Text));
                break;

            case 4:
                sda = ConsumerDB.getBAE(Convert.ToDouble(txtBA.Text));
                break;
            }
            dataTable = new DataTable();
            sda.Fill(dataTable);
            dataGridBillAmount.DataSource = dataTable;
            DBUtil.closeSqlConnection();
        }
Esempio n. 2
0
        private void tbCityName_TextChanged(object sender, EventArgs e)
        {
            if (tbCityName.Text != "")
            {
                if (cbNameCity.SelectedIndex == 0)
                {
                    sda = ConsumerDB.getConsumerFirstNameLike(tbCityName.Text);
                }
                else if (cbNameCity.SelectedIndex == 1)
                {
                    sda = ConsumerDB.getConsumerLastNameLike(tbCityName.Text);
                }
                else if (cbNameCity.SelectedIndex == 2)
                {
                    sda = ConsumerDB.getConsumerCityLike(tbCityName.Text);
                }

                dataTable = new DataTable();
                sda.Fill(dataTable);
                dataGridCityName.DataSource = dataTable;
                DBUtil.closeSqlConnection();
            }
            else
            {
                dataGridCityName.DataSource = null;
            }
        }
Esempio n. 3
0
 private void btnDisplayAll_Click(object sender, EventArgs e)
 {
     sda       = ConsumerDB.getAll();
     dataTable = new DataTable();
     sda.Fill(dataTable);
     dataGridViewAll.DataSource = dataTable;
     DBUtil.closeSqlConnection();
 }
Esempio n. 4
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     if (tbCID.Text.Length == 11)
     {
         ConsumerDB.deleteID(tbCID.Text);
         DBUtil.closeSqlConnection();
         btnDisplayAll_Click(null, null);
     }
 }
Esempio n. 5
0
 private void duedate_change(object sender, EventArgs e)
 {
     if (rbDefaulter.Checked)
     {
         sda = ConsumerDB.getDefaulter(DateTime.Now.Date);
     }
     else if (rbRegular.Checked)
     {
         sda = ConsumerDB.getRegular(DateTime.Now.Date);
     }
     dataTable = new DataTable();
     sda.Fill(dataTable);
     dataGridDueDate.DataSource = dataTable;
     DBUtil.closeSqlConnection();
 }
Esempio n. 6
0
 private void btnSearchID_Click(object sender, EventArgs e)
 {
     if (tbID.Text != "")
     {
         sda       = ConsumerDB.getConsumerID(tbID.Text);
         dataTable = new DataTable();
         sda.Fill(dataTable);
         dataGridConsumerID.DataSource = dataTable;
         DBUtil.closeSqlConnection();
     }
     else
     {
         dataGridConsumerID.DataSource = null;
     }
 }
Esempio n. 7
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     if (tbConsumerID.Text != "" && tbFirstName.Text != "" &&
         tbLastName.Text != "" && tbCity.Text != "" && tbBillAmount.Text != "")
     {
         Consumer consumer = new Consumer();
         try
         {
             consumer.setConsumerID(Convert.ToInt64(tbConsumerID.Text));
             consumer.FirstName  = tbFirstName.Text.ToUpper();
             consumer.LastName   = tbLastName.Text.ToUpper();
             consumer.City       = tbCity.Text.ToUpper();
             consumer.BillAmount = Convert.ToDouble(tbBillAmount.Text);
             DateTime date = dateTimePicker1.Value.Date;
             consumer.DueDate = date;
             ConsumerDB.add(consumer);
             DialogResult result = MessageBox.Show("Record added to database", "Add", MessageBoxButtons.OK, MessageBoxIcon.Information);
             if (result == System.Windows.Forms.DialogResult.OK)
             {
                 clearConsumerForm();
             }
         }
         catch (ConsumerIDException)
         {
             MessageBox.Show("consumer ID should be 11 digits");
         }
         catch (System.FormatException)
         {
             MessageBox.Show("Consumer ID field cannot be empty");
         }
         catch (System.Data.SqlClient.SqlException)
         {
             MessageBox.Show("Consumer ID must be unique");
         }
         DBUtil.closeSqlConnection();
     }
     else
     {
         MessageBox.Show("No field should be empty", "Empty Field", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }