Esempio n. 1
0
        private void load_info()
        {
            try
            {
                rpsDataContext dbcon = new rpsDataContext();

                RENTER r;

                ///flat f = new flat();

                r = dbcon.RENTERs.SingleOrDefault(x => x.rented_flat == flat.flatselected);

                if (r != null)
                {
                    textBox1.Text     = r.r_name;
                    textBox2.Text     = r.rf_name;
                    textBox3.Text     = r.rm_name;
                    textBox4.Text     = r.pt_address;
                    textBox5.Text     = r.r_contact;
                    textBox6.Text     = r.r_occupation;
                    textBox7.Text     = r.r_off_add;
                    textBox8.Text     = r.r_off_contact;
                    textBox9.Text     = r.rented_flat;
                    textBox10.Text    = r.renter_family_mamber;
                    textBox11.Text    = r.renter_email;
                    textBox12.Text    = r.rent_date.ToString();
                    renterImage.Image = load_image(r);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 2
0
        private void load_data()
        {
            rpsDataContext dbcon = new rpsDataContext();

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

            bills = bills.OrderByDescending(x => x.Bill_Date);
            dataGridView1.DataSource = bills;

            RENTER r = dbcon.RENTERs.SingleOrDefault(x => x.rented_flat == comboBox1.SelectedValue.ToString());

            if (r != null)
            {
                label5.Text = r.r_name;
                label6.Text = r.rent_date.ToString();;
            }
        }
Esempio n. 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                rpsDataContext dbcon = new rpsDataContext();
                login          l     = new login();

                l = dbcon.logins.SingleOrDefault(x => x.user_id == textBox1.Text && x.password == textBox2.Text);

                user = textBox1.Text;
                if (user == "owner" && textBox1.Text == l.user_id && textBox2.Text == l.password)
                {
                    this.Hide();
                    new floors().Show();
                }


                else if (textBox1.Text == l.user_id && textBox2.Text == l.password)
                {
                    this.Hide();
                    new My_Information().Show();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Invalid Username or Password");
            }
        }
        public Sign_Up()
        {
            InitializeComponent();
            rpsDataContext dbcon = new rpsDataContext();

            giveRent();
        }
        public My_Information()
        {
            InitializeComponent();

            textBox9.Text = login.user;

            rpsDataContext dbcon = new rpsDataContext();
            RENTER         r     = dbcon.RENTERs.SingleOrDefault(x => x.rented_flat == login.user);

            if (r != null)
            {
                textBox1.Text = r.r_name;

                textBox2.Text  = r.rf_name;
                textBox3.Text  = r.rm_name;
                textBox5.Text  = r.r_contact;
                textBox10.Text = r.renter_email;
                textBox4.Text  = r.pt_address;
                textBox7.Text  = r.r_off_add;
                textBox6.Text  = r.r_occupation;
                textBox12.Text = Convert.ToString(r.rent_date);
                textBox11.Text = r.renter_family_mamber;
                textBox8.Text  = r.r_off_contact;
                textBox9.Text  = r.rented_flat;
            }
        }
        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 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;
            }
        }
        public flat()
        {
            InitializeComponent();
            //richTextBox1.Text = "sadi khondoker\n01696969";

            label1.Text = floors.floor_no;
            label2.Text = floors.flat1;
            label3.Text = floors.flat2;


            rpsDataContext dbcon = new rpsDataContext();

            RENTER r = dbcon.RENTERs.SingleOrDefault(x => x.rented_flat == label2.Text);

            if (r != null)
            {
                label4.Visible      = true;
                pictureBox3.Visible = true;
                label6.Visible      = true;
                flat1_status();

                richTextBox1.Text = r.r_name + "\n" + r.r_contact;
            }
            r = dbcon.RENTERs.SingleOrDefault(x => x.rented_flat == label3.Text);
            if (r != null)
            {
                label5.Visible      = true;
                pictureBox4.Visible = true;
                label7.Visible      = true;
                flat2_status();

                richTextBox2.Text = r.r_name + "\n" + r.r_contact;
            }
        }
        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();
            }
        }
Esempio n. 10
0
        public Previous_Bills()
        {
            InitializeComponent();

            rpsDataContext dbcon = new rpsDataContext();

            comboBox1.DataSource  = dbcon.RENTERs;
            comboBox1.ValueMember = "rented_flat";

            load_data();

            //string s = comboBox1.SelectedText;

            if (login.user != "owner")
            {
                button1.Visible = false;
                button2.Visible = false;
                //comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
                comboBox1.SelectedIndex = comboBox1.FindStringExact(login.user);
                comboBox1.Enabled       = false;
                //comboBox1.IsAccessible = false  ;
                //remove_flats_combo();
            }
            else
            {
                comboBox1.SelectedIndex = comboBox1.FindStringExact(flat.flatselected);
            }
        }
 private void comboBox1_SelectionChangeCommitted(object sender, EventArgs e)
 {
     if (this.Text == "New_Bill")
     {
         rpsDataContext dbcon = new rpsDataContext();
         RENTER         r     = dbcon.RENTERs.SingleOrDefault(x => x.rented_flat == comboBox1.SelectedItem.ToString());
         if (r == null)
         {
             dateTimePicker1.Enabled = false;
             richTextBox1.Enabled    = false;
             richTextBox2.Enabled    = false;
             richTextBox3.Enabled    = false;
             richTextBox4.Enabled    = false;
             richTextBox5.Enabled    = false;
             button1.Enabled         = false;
             MessageBox.Show("Currently no renter in this flat");
         }
         else
         {
             dateTimePicker1.Enabled = true;
             richTextBox1.Enabled    = true;
             richTextBox2.Enabled    = true;
             richTextBox3.Enabled    = true;
             richTextBox4.Enabled    = true;
             richTextBox5.Enabled    = true;
             button1.Enabled         = true;
             //MessageBox.Show("Currently no renter in this flat");
         }
     }
 }
        private void load_contact()
        {
            rpsDataContext dbcon = new rpsDataContext();
            building       b     = dbcon.buildings.SingleOrDefault(x => x.b_id == "1");

            if (b != null)
            {
                label8.Text = b.contact;
            }
        }
        private bool flat_has_renter()
        {
            rpsDataContext dbcon = new rpsDataContext();
            RENTER         r     = dbcon.RENTERs.SingleOrDefault(x => x.rented_flat == flatselected);

            if (r != null)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            Previous_Bills.billType = "new";
            rpsDataContext dbcon = new rpsDataContext();
            RENTER         r     = dbcon.RENTERs.SingleOrDefault(x => x.rented_flat == flat.flatselected.ToString());

            if (r == null)
            {
                MessageBox.Show("Currently no renter in this flat");
            }
            else
            {
                new New_Bill().ShowDialog();
            }
        }
Esempio n. 15
0
        private void button2_Click(object sender, EventArgs e)
        {
            rpsDataContext dbcon = new rpsDataContext();


            building b = dbcon.buildings.SingleOrDefault(x => x.contact == search);

            if (b != null)
            {
                b.contact = textBox2.Text;
                dbcon.SubmitChanges();
                MessageBox.Show("Successfully upadated");

                textBox2.Text     = b.contact;
                textBox2.ReadOnly = true;
            }
        }
Esempio n. 16
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                rpsDataContext dbcon = new rpsDataContext();

                if (dbcon.logins.Any(x => x.user_id == login.user &&
                                     x.password == textBox1.Text) == true)
                {
                    if (textBox2.Text.Length < 6)
                    {
                        MessageBox.Show("Select a password with at least 6 characters !!");
                    }
                    else if (textBox2.Text != textBox3.Text)
                    {
                        MessageBox.Show("Password doesn't match");
                    }

                    else
                    {
                        login l = new login();
                        l = dbcon.logins.SingleOrDefault(x => x.user_id == login.user);

                        if (l != null)
                        {
                            l.user_id  = label5.Text;
                            l.password = textBox2.Text;
                            dbcon.SubmitChanges();
                            MessageBox.Show("Password successfully changed! Please re-login");
                            this.Dispose();
                            new login().Show();
                        }
                    }
                }

                else
                {
                    MessageBox.Show("Your password is incorrect!");
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 17
0
        private void load_house_info()
        {
            rpsDataContext dbcon = new rpsDataContext();
            building       b     = dbcon.buildings.SingleOrDefault(x => x.b_id == "1");

            if (b != null)
            {
                HouseAddressTextbox.Text = b.address;
                textBox1.Text            = b.owner_name;
                textBox2.Text            = b.contact;
            }

            else
            {
                MessageBox.Show("Data not found");
            }
        }
        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 button4_Click(object sender, EventArgs e)
        {
            rpsDataContext dbcon = new rpsDataContext();
            RENTER         r     = dbcon.RENTERs.SingleOrDefault(x => x.rented_flat == login.user);

            if (r != null)
            {
                r.r_contact            = textBox5.Text;
                r.renter_email         = textBox10.Text;
                r.r_off_add            = textBox7.Text;
                r.r_occupation         = textBox6.Text;
                r.renter_family_mamber = textBox11.Text;
                r.r_off_contact        = textBox8.Text;

                dbcon.SubmitChanges();
                MessageBox.Show("Successfully upadated");



                textBox1.Text = r.r_name;

                textBox2.Text  = r.rf_name;
                textBox3.Text  = r.rm_name;
                textBox5.Text  = r.r_contact;
                textBox10.Text = r.renter_email;
                textBox4.Text  = r.pt_address;
                textBox7.Text  = r.r_off_add;
                textBox6.Text  = r.r_occupation;
                textBox12.Text = Convert.ToString(r.rent_date);
                textBox11.Text = r.renter_family_mamber;
                textBox8.Text  = r.r_off_contact;
                textBox9.Text  = r.rented_flat;

                textBox5.ReadOnly  = true;
                textBox10.ReadOnly = true;
                textBox7.ReadOnly  = true;
                textBox6.ReadOnly  = true;
                textBox11.ReadOnly = true;
                textBox8.ReadOnly  = true;
            }
        }
Esempio n. 20
0
        private void button1_Click(object sender, EventArgs e)
        {
            DialogResult dlg = MessageBox.Show(" Are you sure want to remove this renter from your building?",
                                               "Clear", MessageBoxButtons.YesNo);

            if (dlg == DialogResult.Yes)
            {
                rpsDataContext dbcon = new rpsDataContext();

                var bills = from b in dbcon.Bill_Tables
                            where b.flat == flat.flatselected
                            select b;
                dbcon.Bill_Tables.DeleteAllOnSubmit(bills);

                var renter = from r in dbcon.RENTERs
                             where r.rented_flat == flat.flatselected
                             select r;

                dbcon.RENTERs.DeleteAllOnSubmit(renter);

                var log = from l in dbcon.logins
                          where l.user_id == flat.flatselected
                          select l;
                dbcon.logins.DeleteAllOnSubmit(log);



                dbcon.SubmitChanges();

                MessageBox.Show("Cleared Scuccessfully");
                this.Hide();
                new floors().Show();
            }
            else if (dlg == DialogResult.No)
            {
                this.Show();
            }
        }
        public void giveRent()
        {
            rpsDataContext dbcon = new rpsDataContext();
            RENTER         r     = dbcon.RENTERs.SingleOrDefault(x => x.rented_flat == "A-1");

            if (r != null)
            {
                RentedFlatComboBox.Items.Remove("A-1");
            }

            r = dbcon.RENTERs.SingleOrDefault(x => x.rented_flat == "A-2");
            if (r != null)
            {
                RentedFlatComboBox.Items.Remove("A-2");
            }

            r = dbcon.RENTERs.SingleOrDefault(x => x.rented_flat == "A-3");
            if (r != null)
            {
                RentedFlatComboBox.Items.Remove("A-3");
            }

            r = dbcon.RENTERs.SingleOrDefault(x => x.rented_flat == "A-4");
            if (r != null)
            {
                RentedFlatComboBox.Items.Remove("A-4");
            }

            r = dbcon.RENTERs.SingleOrDefault(x => x.rented_flat == "A-5");
            if (r != null)
            {
                RentedFlatComboBox.Items.Remove("A-5");
            }

            r = dbcon.RENTERs.SingleOrDefault(x => x.rented_flat == "A-6");
            if (r != null)
            {
                RentedFlatComboBox.Items.Remove("A-6");
            }

            r = dbcon.RENTERs.SingleOrDefault(x => x.rented_flat == "B-1");
            if (r != null)
            {
                RentedFlatComboBox.Items.Remove("B-1");
            }
            r = dbcon.RENTERs.SingleOrDefault(x => x.rented_flat == "B-2");
            if (r != null)
            {
                RentedFlatComboBox.Items.Remove("B-2");
            }

            r = dbcon.RENTERs.SingleOrDefault(x => x.rented_flat == "B-3");
            if (r != null)
            {
                RentedFlatComboBox.Items.Remove("B-3");
            }

            r = dbcon.RENTERs.SingleOrDefault(x => x.rented_flat == "B-4");
            if (r != null)
            {
                RentedFlatComboBox.Items.Remove("B-4");
            }

            r = dbcon.RENTERs.SingleOrDefault(x => x.rented_flat == "B-5");
            if (r != null)
            {
                RentedFlatComboBox.Items.Remove("B-5");
            }
            r = dbcon.RENTERs.SingleOrDefault(x => x.rented_flat == "B-6");
            if (r != null)
            {
                RentedFlatComboBox.Items.Remove("B-6");
            }
        }
        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);
            }
        }
        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);
            }
        }