private void prev_record()
        {
            rpsDataContext dbcon = new rpsDataContext();



            Bill_Table bill  = new Bill_Table();
            var        bills = from q in dbcon.Bill_Tables
                               where q.flat == login.user
                               select new
            {
                //q.Bill_Date,
                q.House_Rent,
                q.Electricity_Bill,
                q.Water_Bill,
                q.Gas_Bill,
                q.Service_Charge
            };

            if (bills.Sum(x => x.House_Rent) == 0 &&
                bills.Sum(x => x.Electricity_Bill) == 0 &&
                bills.Sum(x => x.Water_Bill) == 0 &&
                bills.Sum(x => x.Gas_Bill) == 0 &&
                bills.Sum(x => x.Service_Charge) == 0)
            {
                pictureBox3.Image = Properties.Resources.check;
            }
            else
            {
                pictureBox3.Image = Properties.Resources.caution;
            }
        }
        private void load_bill()
        {
            rpsDataContext dbcon = new rpsDataContext();


            string flat_search;

            if (login.user != "owner")
            {
                flat_search = login.user;
            }
            else
            {
                flat_search = flat.flatselected;
            }


            Bill_Table bill  = new Bill_Table();
            var        query = from q in dbcon.Bill_Tables
                               where q.flat == flat_search
                               select q;

            var curr_bill = query.OrderByDescending(x => x.Bill_Date).First();


            if (curr_bill != null)
            {
                richTextBox1.Text = curr_bill.House_Rent.ToString();
                richTextBox2.Text = curr_bill.Electricity_Bill.ToString();
                richTextBox3.Text = curr_bill.Water_Bill.ToString();
                richTextBox4.Text = curr_bill.Gas_Bill.ToString();
                richTextBox5.Text = curr_bill.Service_Charge.ToString();
            }
        }
        private void flat2_status()
        {
            rpsDataContext dbcon = new rpsDataContext();

            Bill_Table bill  = new Bill_Table();
            var        query = from q in dbcon.Bill_Tables
                               where q.flat == label3.Text
                               select new
            {
                //q.Bill_Date,
                q.House_Rent,
                q.Electricity_Bill,
                q.Water_Bill,
                q.Gas_Bill,
                q.Service_Charge
            };



            if (query.Sum(x => x.House_Rent) == 0 &&
                query.Sum(x => x.Electricity_Bill) == 0 &&
                query.Sum(x => x.Water_Bill) == 0 &&
                query.Sum(x => x.Gas_Bill) == 0 &&
                query.Sum(x => x.Service_Charge) == 0)
            {
                pictureBox4.Image = Properties.Resources.check;
                label5.Text       = "paid";
            }
            else
            {
                label5.Text       = "due";
                pictureBox4.Image = Properties.Resources.caution;
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            rpsDataContext dbcon = new rpsDataContext();
            //int id = Int32.Parse(comboBox1.SelectedValue.ToString());
            Bill_Table bill = dbcon.Bill_Tables.SingleOrDefault(x => x.flat == comboBox1.SelectedItem.ToString() && x.Bill_Date == dateTimePicker1.Value);

            if (bill != null)
            {
                richTextBox1.Text = Convert.ToString(bill.House_Rent);
                richTextBox2.Text = Convert.ToString(bill.Electricity_Bill);
                richTextBox3.Text = Convert.ToString(bill.Water_Bill);
                richTextBox4.Text = Convert.ToString(bill.Gas_Bill);
                richTextBox5.Text = Convert.ToString(bill.Service_Charge);
            }
            else
            {
                MessageBox.Show("Bill not found");
            }
        }
        private void ConfirmButton_Click(object sender, EventArgs e)
        {
            try
            {
                rpsDataContext dbcon = new rpsDataContext();

                if (FirstNameTextBox.Text == null || FatherFirstNameTextBox.Text == null ||
                    MotherFirstNameTextBox == null || ContactNoTextbox.Text == null ||
                    EmailTextbox.Text == null || PAddressTextBox.Text == null ||
                    OffAddressTextBox == null || comboBox1.Text == null ||
                    OfficeContNoTextBox == null || RentedFlatComboBox.Text == null ||
                    renterImage.Image == null)
                {
                    MessageBox.Show("Please fill up all the feilds!!!");
                }

                else if (textBox1.Text.Length < 6)
                {
                    MessageBox.Show("Select a password with at least 6 characters !!");
                }

                else
                {
                    //renter
                    RENTER r = new RENTER();
                    r.r_name               = FirstNameTextBox.Text + " " + LastNameTextBox.Text;
                    r.rf_name              = FatherFirstNameTextBox.Text + " " + FatherLastNameTextBox.Text;
                    r.rm_name              = MotherFirstNameTextBox.Text + " " + MotherLastNameTextBox.Text;
                    r.r_contact            = ContactNoTextbox.Text;
                    r.renter_email         = EmailTextbox.Text;
                    r.pt_address           = PAddressTextBox.Text;
                    r.r_off_add            = OffAddressTextBox.Text;
                    r.r_occupation         = textBox2.Text;
                    r.rent_date            = dateTimePicker1.Value;
                    r.renter_family_mamber = comboBox1.Text;
                    r.r_off_contact        = OfficeContNoTextBox.Text;
                    r.rented_flat          = RentedFlatComboBox.Text;

                    byte[]       img = null;
                    FileStream   fs  = new FileStream(imgLoc, FileMode.Open, FileAccess.Read);
                    BinaryReader br  = new BinaryReader(fs);
                    img = br.ReadBytes((int)fs.Length);

                    r.renter_image = img;

                    //login_table
                    login l = new login();
                    l.user_id  = RentedFlatComboBox.Text;
                    l.password = textBox1.Text;

                    //deafult bill
                    Bill_Table bill = new Bill_Table();
                    bill.flat             = RentedFlatComboBox.Text;
                    bill.House_Rent       = 0;
                    bill.Electricity_Bill = 0;
                    bill.Water_Bill       = 0;
                    bill.Gas_Bill         = 0;
                    bill.Service_Charge   = 0;

                    dbcon.logins.InsertOnSubmit(l);
                    dbcon.RENTERs.InsertOnSubmit(r);
                    dbcon.Bill_Tables.InsertOnSubmit(bill);

                    dbcon.SubmitChanges();

                    MessageBox.Show("Congratulations!! You may login now");
                    this.Hide();
                    new login().Show();
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 6
0
 partial void DeleteBill_Table(Bill_Table instance);
Esempio n. 7
0
 partial void UpdateBill_Table(Bill_Table instance);
Esempio n. 8
0
 partial void InsertBill_Table(Bill_Table instance);
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                rpsDataContext dbcon = new rpsDataContext();

                if (this.Text == "Update_bill")
                {
                    //rpsDataContext dbcon = new rpsDataContext();
                    //int id = Int32.Parse(comboBox1.SelectedValue.ToString());
                    Bill_Table bill = dbcon.Bill_Tables.SingleOrDefault(x => x.flat == comboBox1.SelectedItem.ToString() && x.Bill_Date == dateTimePicker1.Value);
                    if (bill != null)
                    {
                        bill.House_Rent       = Convert.ToDouble(richTextBox1.Text);
                        bill.Electricity_Bill = Convert.ToDouble(richTextBox2.Text);
                        bill.Water_Bill       = Convert.ToDouble(richTextBox3.Text);
                        bill.Gas_Bill         = Convert.ToDouble(richTextBox4.Text);
                        bill.Service_Charge   = Convert.ToDouble(richTextBox5.Text);
                        dbcon.SubmitChanges();
                        MessageBox.Show("Bill Updated successfully");
                        this.Dispose();
                    }
                }

                else
                {
                    // Bill_Table bill = dbcon.Bill_Tables.SingleOrDefault(x => x.Bill_Date == dateTimePicker1.Value);


                    if (comboBox1.Text == null || dateTimePicker1.Text == null || richTextBox1.Text == null ||
                        richTextBox2.Text == null || richTextBox3.Text == null ||
                        richTextBox4.Text == null || richTextBox5.Text == null)
                    {
                        MessageBox.Show("Please fill up all feilds with valid data");
                    }

                    else if (dbcon.Bill_Tables.Any(x => x.flat == comboBox1.SelectedItem.ToString() && x.Bill_Date == dateTimePicker1.Value) == true)
                    {
                        MessageBox.Show("A bill aready exists for this date in this flat");
                    }
                    else
                    {
                        Bill_Table bill = new Bill_Table();

                        bill.flat             = comboBox1.SelectedItem.ToString();
                        bill.Bill_Date        = dateTimePicker1.Value;
                        bill.House_Rent       = Convert.ToDouble(richTextBox1.Text);
                        bill.Electricity_Bill = Convert.ToDouble(richTextBox2.Text);
                        bill.Water_Bill       = Convert.ToDouble(richTextBox3.Text);
                        bill.Gas_Bill         = Convert.ToDouble(richTextBox4.Text);
                        bill.Service_Charge   = Convert.ToDouble(richTextBox5.Text);

                        dbcon.Bill_Tables.InsertOnSubmit(bill);
                        dbcon.SubmitChanges();
                        MessageBox.Show("new bill created for " + comboBox1.SelectedItem.ToString());
                        this.Dispose();
                    }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }