Exemple #1
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);
            }
        }
Exemple #2
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;
            }
        }
        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;
            }
        }
Exemple #4
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();
            }
        }
        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);
            }
        }