コード例 #1
0
        private void btnRenterViewHouse_Click(object sender, EventArgs e)
        {
            if (!this._IsHouseIdValid(tbRenterViewHouseId))
            {
                this._CheckRenterViewHouseIdValidation();

                return;
            }

            // Start Database Searching process

            string houseId = tbRenterViewHouseId.Text.Trim();

            House house = RenterController.GetHouse(houseId);

            if (house != null)
            {
                ArrayList houses = new ArrayList();
                houses.Add(house);
                dgvRenterViewHouse.DataSource = houses;
                tbRenterViewHouseId.Text      = "";
            }
            else
            {
                // Displays the MessageBox.
                MessageBox.Show(
                    "House not found",
                    "Error | House not found",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information
                    );

                this._LoadRenterViewHouseInformation();
            }
        }
コード例 #2
0
        private void btnRenterDeleteHouse_Click(object sender, EventArgs e)
        {
            if (!this._IsHouseIdValid(tbRenterDeleteHouseId))
            {
                this._CheckRenterDeleteHouseIdValidation();

                return;
            }

            // Start Database Searching process

            DialogResult confirm = MessageBox.Show(
                this,
                "Are you sure you want to Delete the House data?",
                "Confirmation",
                MessageBoxButtons.YesNo,
                MessageBoxIcon.Question
                );

            if (confirm == DialogResult.Yes)
            {
                string houseId = tbRenterDeleteHouseId.Text.Trim();

                bool isHouseDelete = RenterController.DeleteHouse(houseId);

                if (isHouseDelete)
                {
                    // Displays the MessageBox.
                    MessageBox.Show(
                        "User Deleted Successfully",
                        "Success | User Deleted",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Information
                        );

                    tbRenterDeleteHouseId.Text = "";
                    this._LoadRenterViewHouseInformation();
                }
                else
                {
                    // Displays the MessageBox.
                    MessageBox.Show(
                        "User not found",
                        "Error | User not found",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Information
                        );
                }
            }
        }
コード例 #3
0
        private void btnRenterAddHouse_Click(object sender, EventArgs e)
        {
            if (!this._IsRenterAddHouseNameValid() || !this._IsRenterAddHouseNumberValid() || !this._IsRenterAddHouseSectorValid() || !this._IsRenterAddHousePrizeValid())
            {
                this._CheckRenterAddHouseNameValidation();
                this._CheckRenterAddHouseNumberValidation();
                this._CheckRenterAddHouseSectorValidation();
                this._CheckRenterAddHousePrizeValidation();

                return;
            }

            // Start Database Addding process

            string houseName   = tbRenterAddHouseName.Text.Trim();
            string houseNumber = tbRenterAddHouseNumber.Text.Trim();
            string houseSector = tbRenterAddHouseSector.Text.Trim();
            string housePrice  = tbRenterAddHousePrize.Text.Trim();

            House house = new House();

            house.Name   = houseName;
            house.Number = Int32.Parse(houseNumber);
            house.Sector = Int32.Parse(houseSector);
            house.Price  = housePrice;

            bool isCreated = RenterController.AddHouse(house, "" + this.renter.Id);

            this._ResetRenterAddHouseInputs();

            if (isCreated)
            {
                this._LoadRenterViewHouseInformation();
                // Displays the MessageBox.
                MessageBox.Show(
                    "Added Successfull!",
                    "Add House",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information
                    );
            }
        }
コード例 #4
0
 private void _LoadRenterViewHouseInformation()
 {
     dgvRenterViewHouse.DataSource = RenterController.GetAllHouse();
 }
コード例 #5
0
        private void btnRenterEditProfile_Click(object sender, EventArgs e)
        {
            if (!this._IsRenterEditNameValid() || !this._IsEmailValid(tbRenterEditEmail) || !this._IsRenterEditPhoneValid())
            {
                this._CheckRenterEditNameValidation();
                this._CheckRenterEditEmailValidation();
                this._CheckRenterEditPhoneValidation();

                return;
            }

            // Start Database Editing process

            string name     = tbRenterEditName.Text.Trim();
            string oldEmail = this.renter.Email.Trim();
            string newEmail = tbRenterEditEmail.Text.Trim();
            string phone    = tbRenterEditPhone.Text.Trim();

            // new tenant
            Renter newRenter = new Renter();

            newRenter.Name     = name;
            newRenter.Email    = newEmail;
            newRenter.Phone    = phone;
            newRenter.Password = renter.Password.Trim();

            // update the tenant
            Renter updateRenter = RenterController.EditProfile(newRenter, oldEmail);

            if (updateRenter != null)
            {
                // update the auth
                this.renter.Name  = updateRenter.Name.Trim();
                this.renter.Email = updateRenter.Email.Trim();
                this.renter.Phone = updateRenter.Phone.Trim();

                // Displays the MessageBox.
                MessageBox.Show(
                    "Successfully Updated your profile",
                    "Susscess | Update Profile",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information
                    );

                //update the form
                tbRenterEditName.Text  = updateRenter.Name.Trim();
                tbRenterEditEmail.Text = updateRenter.Email.Trim();
                tbRenterEditPhone.Text = updateRenter.Phone.Trim();

                // disable the submit (Edit) button
                btnRenterEditProfile.Enabled = false;
            }
            else
            {
                this._LoadRenterEditInfromation();
                // Displays the MessageBox.
                MessageBox.Show(
                    "Updating profile Unsuccessfull",
                    "Unsuccessfull | Profile not update",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Information
                    );
            }
        }