Ejemplo n.º 1
0
        private void button19_Click(object sender, EventArgs e)
        {
            button20_Click(sender, e);

            if (comboBox3.Text == "")
            {
                errorProvider1.SetError(comboBox3, "Select A Month");
            }
            else
            {
                errorProvider1.Dispose();
            }

            if (comboBox4.Text == "")
            {
                errorProvider1.SetError(comboBox4, "Select A Year");
            }
            else
            {
                errorProvider1.Dispose();

            }
            if (textBox3.Text == "")
            {
                errorProvider1.SetError(textBox3, "Enter a valide number");
            }
            else if (Convert.ToInt32(textBox3.Text) < 0)
            {
                errorProvider1.SetError(textBox3, "Enter a valide number");
            }
            else
            {
                errorProvider1.Dispose();
                double result = calculate(textBox3.Text, label28.Text);
                label26.Text = "Rs. " + Convert.ToString(result);
                int units = Convert.ToInt32(textBox3.Text);
                double amount = result;
                bill = new bill(comboBox3.Text, comboBox4.Text, units, amount, textBox5.Text);
                dbEntry = new Water_Board_Management.Database("a" + textBox2.Text, "month");

                if (dbEntry.hasEntry(bill.getMonth()) == true)
                {
                    if (MessageBox.Show("Do you want to update the data?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        dbEntry.updateMany(new String[] { "units", "amount", "remarks" }, bill.getMonth(), new String[] { Convert.ToString(bill.getUnits()), Convert.ToString(bill.getAmount()), bill.getRemarks() });
                        MessageBox.Show("Successfully Updated Data");
                        textBox3.Text = "";
                        label26.Text = "";
                        textBox5.Text = "";
                    }

                }
                else
                {
                    dbEntry.insert(new Water_Board_Management.BillingRow(bill.getMonth(), bill.getUnits(), bill.getAmount(), bill.getRemarks()));
                    MessageBox.Show("Successfully Entered Data");
                    textBox3.Text = "";
                    label26.Text = "";
                    textBox5.Text = "";
                }

                if (dbBUlk.hasEntry(bill.getMonth()) == true)
                {
                    int usage;
                    usage = Convert.ToInt32(dbBUlk.get("usag", bill.getMonth()));
                    usage += bill.getUnits();
                    dbBUlk.update("usag", bill.getMonth(), Convert.ToString(usage));
                }
                else
                {
                    dbBUlk.insert(new Water_Board_Management.MeterRow(bill.getMonth(), 0, bill.getUnits()));
                }

            }
        }
Ejemplo n.º 2
0
        private void button19_Click(object sender, EventArgs e)
        {
            button20_Click(sender, e);

            if (comboBox3.Text == "")
            {
                errorProvider1.SetError(comboBox3, "Select A Month");
            }
            else
            {
                errorProvider1.Dispose();
            }

            if (comboBox4.Text == "")
            {
                errorProvider1.SetError(comboBox4, "Select A Year");
            }
            else
            {
                errorProvider1.Dispose();
            }
            if (textBox3.Text == "")
            {
                errorProvider1.SetError(textBox3, "Enter a valide number");
            }
            else if (Convert.ToInt32(textBox3.Text) < 0)
            {
                errorProvider1.SetError(textBox3, "Enter a valide number");
            }
            else
            {
                errorProvider1.Dispose();
                double result = calculate(textBox3.Text, label28.Text);
                label26.Text = "Rs. " + Convert.ToString(result);
                int    units  = Convert.ToInt32(textBox3.Text);
                double amount = result;
                bill    = new bill(comboBox3.Text, comboBox4.Text, units, amount, textBox5.Text);
                dbEntry = new Water_Board_Management.Database("a" + textBox2.Text, "month");

                if (dbEntry.hasEntry(bill.getMonth()) == true)
                {
                    if (MessageBox.Show("Do you want to update the data?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        dbEntry.updateMany(new String[] { "units", "amount", "remarks" }, bill.getMonth(), new String[] { Convert.ToString(bill.getUnits()), Convert.ToString(bill.getAmount()), bill.getRemarks() });
                        MessageBox.Show("Successfully Updated Data");
                        textBox3.Text = "";
                        label26.Text  = "";
                        textBox5.Text = "";
                    }
                }
                else
                {
                    dbEntry.insert(new Water_Board_Management.BillingRow(bill.getMonth(), bill.getUnits(), bill.getAmount(), bill.getRemarks()));
                    MessageBox.Show("Successfully Entered Data");
                    textBox3.Text = "";
                    label26.Text  = "";
                    textBox5.Text = "";
                }

                if (dbBUlk.hasEntry(bill.getMonth()) == true)
                {
                    int usage;
                    usage  = Convert.ToInt32(dbBUlk.get("usag", bill.getMonth()));
                    usage += bill.getUnits();
                    dbBUlk.update("usag", bill.getMonth(), Convert.ToString(usage));
                }
                else
                {
                    dbBUlk.insert(new Water_Board_Management.MeterRow(bill.getMonth(), 0, bill.getUnits()));
                }
            }
        }