Example #1
0
 private void LoadGrid()
 {
     DataSet ds;
     ds = new HouseDAO().SelectAllDataset();
     ds.Tables[0].PrimaryKey = new DataColumn[] { ds.Tables[0].Columns["HouseId"] };
     gvPropertyList.SettingsText.ConfirmDelete = Messages.Delete_Confirm;
     gvPropertyList.DataSource = ds.Tables[0];
     gvPropertyList.DataBind();
 }
Example #2
0
        public bool Save()
        {
            bool result = false;

            Database     db         = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING);
            DbConnection connection = db.CreateConnection();

            connection.Open();
            DbTransaction transaction = connection.BeginTransaction();

            try
            {
                HouseDAO houseDAO = new HouseDAO();

                //If landlord user is a partial user, this logic might need to change
                if (!new LandlordDAO().IsLandlordExist(new Landlord()
                {
                    LandlordId = this.LandlordId
                }))
                {
                    new Landlord()
                    {
                        LandlordId = this.LandlordId, LandlordTypeId = (int)Enums.LandlordType.SimpleLandlord, CreatedBy = this.CreatedBy
                    }.Save();
                }

                if (houseDAO.IsHouseExist(this))
                {
                    result = houseDAO.Update(this, db, transaction);
                }
                else
                {
                    result = houseDAO.Insert(this, db, transaction);
                }

                if (result)
                {
                    transaction.Commit();
                }
                else
                {
                    transaction.Rollback();
                }
            }
            catch (System.Exception ex)
            {
                transaction.Rollback();
                result = false;
                throw ex;
            }
            finally
            {
                connection.Close();
            }
            return(result);
        }
Example #3
0
        public bool Save(House house)
        {
            bool result = false;

            Database     db         = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING);
            DbConnection connection = db.CreateConnection();

            connection.Open();
            DbTransaction transaction = connection.BeginTransaction();

            try
            {
                HouseDAO houseDAO = new HouseDAO();
                // House house = new House();

                if (houseDAO.IsHouseExist(house))
                {
                    result = new HouseOptionDAO().Delete(new HouseOption()
                    {
                        HouseId = house.HouseId.Value
                    }, db, transaction);
                    if (house.HouseOptionList != null)
                    {
                        foreach (HouseOption item in house.HouseOptionList)
                        {
                            new HouseOptionDAO().Insert(item, db, transaction);
                        }
                    }
                }

                if (result)
                {
                    transaction.Commit();
                }
                else
                {
                    transaction.Rollback();
                }
            }
            catch (System.Exception ex)
            {
                transaction.Rollback();
                result = false;
                throw ex;
            }
            finally
            {
                connection.Close();
            }
            return(result);
        }
Example #4
0
        public bool Save(House house)
        {
            bool result = false;

            Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING);
            DbConnection connection = db.CreateConnection();
            connection.Open();
            DbTransaction transaction = connection.BeginTransaction();

            try
            {
                HouseDAO houseDAO = new HouseDAO();
               // House house = new House();

                if (houseDAO.IsHouseExist(house))
                {
                    result = new HouseOptionDAO().Delete(new HouseOption() { HouseId = house.HouseId.Value }, db, transaction);
                    if (house.HouseOptionList != null)
                    {
                        foreach (HouseOption item in house.HouseOptionList)
                        {
                            new HouseOptionDAO().Insert(item, db, transaction);
                        }
                    }
                }

                if (result)
                {
                    transaction.Commit();
                }
                else
                {
                    transaction.Rollback();
                }

            }
            catch (System.Exception ex)
            {
                transaction.Rollback();
                result = false;
                throw ex;
            }
            finally
            {
                connection.Close();
            }
            return result;
        }
Example #5
0
        protected void FindHome_Click(object sender, EventArgs e)
        {
            StudentSearchresults.Visible = false;
            HouseSearch house = new HouseSearch();
            HouseDAO houseDAO = new HouseDAO();

            house.Zip = string.IsNullOrEmpty(Zipcode.Text.Trim()) ? null : Zipcode.Text.Trim();

            if (DrpBedRooms.SelectedItem.Value != "-1")
            {
                house.BedRooms = int.Parse(DrpBedRooms.SelectedItem.Value);
            }
            else
            {
                house.BedRooms = null;
            }

            if (DrpBathRooms.SelectedItem.Value != "-1")
            {
                house.BathRooms = int.Parse(DrpBathRooms.SelectedItem.Value);
            }
            else
            {
                house.BathRooms = null;
            }

            DataSet ds;
            ds = houseDAO.Search(house);

            if (ds != null)
            {
                DataListHouseSearchresults.DataSource = ds.Tables[0];
                DataListHouseSearchresults.DataBind();

                HouseSearchresults.Visible = true;
            }
            else
            {
                Searchresults.Visible = true;
            }
        }
        public void loadHouseDatadata(User user_)
        {
            if (user_.HouseId != null && user_.HouseId != Guid.Empty)
            {
                UserDAO userDAO = new UserDAO();
                DataSet LandlordData = userDAO.SelectLandlordByHouseId(user_.HouseId.Value);

                if (LandlordData != null && LandlordData.Tables[0].Rows.Count > 0)
                {
                    hdLandloadId.Value = string.IsNullOrEmpty(LandlordData.Tables[0].Rows[0]["LandlordId"].ToString().Trim()) ? string.Empty : LandlordData.Tables[0].Rows[0]["LandlordId"].ToString().Trim();

                }

                DataSet ds = new DataSet();
                ds = new HouseDAO().SelectAllDataset(Guid.Parse(hdLandloadId.Value));
                ds.Tables[0].PrimaryKey = new DataColumn[] { ds.Tables[0].Columns["HouseId"] };

                if (DrpHouse.Items.Count < 1)
                {
                    DrpHouse.DataSource = ds;
                    DrpHouse.DataTextField = "StreetAddress";
                    DrpHouse.DataValueField = "HouseId";
                    DrpHouse.DataBind();
                    DrpHouse.Items.Insert(0, new ListItem(Constants.DROPDOWN_EMPTY_ITEM_TEXT, Constants.DROPDOWN_EMPTY_ITEM_VALUE));
                }

                HouseEdit.Visible = true;
                // set selected house
                if (user_.HouseId.HasValue)
                {
                    for (int i = 0; i < DrpHouse.Items.Count; i++)
                    {
                        if (DrpHouse.Items[i].Value.ToString().ToLower() == user_.HouseId.ToString().ToLower())
                        {
                            DrpHouse.ClearSelection();
                            DrpHouse.Items[i].Selected = true;
                        }
                    }
                }

                House houseData = House.Select(user_.HouseId.Value);

                if (houseData != null)
                {
                    if (houseData.IsPartialHouse == true)
                    {
                       // HouseSearch.Visible = true;
                        chknotavailable.Visible = true;
                        DrpHouse.Enabled = true;

                        EnableEdit();

                        if (houseData.StateId.HasValue)
                        {

                            for (int i = 0; i < Drpstate.Items.Count; i++)
                            {
                                if (Drpstate.Items[i].Value.ToString().ToLower() == houseData.StateId.ToString().ToLower())
                                {
                                    Drpstate.ClearSelection();
                                    Drpstate.Items[i].Selected = true;
                                }
                            }

                            State state;
                            state = Generic.Get<State>(houseData.StateId.Value);
                            if (state != null)
                            {
                                State.Text = state.StateName;
                            }
                        }

                        Address.Text = houseData.StreetAddress;
                        City.Text = houseData.City;
                        Zip.Text = houseData.Zip;

                        RentalAddress.Text = houseData.StreetAddress;
                        RentalCity.Text = houseData.City;
                        RentalZip.Text = houseData.Zip;
                    }
                    else
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.CurrentHouseNotPartialHouse + "'); window.location = '/Student/Student_Profile_Current_House_Details.aspx';}", true);

                    }
                }
            }
            else
            {

                Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.CurrentHouseNoRecords + "'); window.location = '/Student/Student_Profile_Current_House.aspx';}", true);

            }
        }
Example #7
0
        public static House SelectByRoomId(Guid baseHouseRoomId)
        {
            House house = new HouseDAO().SelectByRoomId(baseHouseRoomId);

            return(house);
        }
Example #8
0
        public DataSet SelectAllDataset(Guid LandlordId)
        {
            HouseDAO house = new HouseDAO();

            return(house.SelectAllDataset(LandlordId));
        }
        public void loadHouseDatadata()
        {
            House_Search.Visible = false;
            DrpHouse.Visible = false;
            DrpHouse.Items.Clear();

                DataSet ds = new DataSet();
                ds = new HouseDAO().SelectAllDataset(Guid.Parse(hdLandloadId.Value));
                ds.Tables[0].PrimaryKey = new DataColumn[] { ds.Tables[0].Columns["HouseId"] };

                if (ds.Tables[0].Rows.Count > 0)
                {
                    LabelRentalAddressMessage.Text = "";
                    House_Search.Visible = true;
                    DrpHouse.Visible = true;
                    showHouseDetails();
                    if (DrpHouse.Items.Count < 1)
                    {
                        DrpHouse.DataSource = ds;
                        DrpHouse.DataTextField = "StreetAddress";
                        DrpHouse.DataValueField = "HouseId";
                        DrpHouse.DataBind();
                        DrpHouse.Items.Insert(0, new ListItem(Constants.DROPDOWN_EMPTY_ITEM_TEXT, Constants.DROPDOWN_EMPTY_ITEM_VALUE));
                    }
                    else
                    {

                    }
                }
                else
                {
                    LabelRentalAddressMessage.Text = "No House Registerd for Landlord, Please Contact Landlord to Add a New House.";
                    LabelRentalAddressMessage.Visible = true;
                    ButtonLandload.Visible = false;
                    ClearHouse();

                }
        }
Example #10
0
        public void CreateHouse()
        {
            if (Page.IsValid == true)
            {
                try
                {

                    house.LandlordId = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());
                    house.StreetAddress = Address.Text.Trim();
                    house.City = City.Text.Trim();
                    house.StateId = Int32.Parse(Drpstate.SelectedValue.Trim());
                    house.Zip = Zip.Text.Trim();
                    house.YearHomeBuild = int.Parse(DRPYear.SelectedValue.Trim());
                    house.BedRooms = int.Parse(DrpBedRooms.SelectedValue.Trim());
                    house.BathRooms = int.Parse(DrpBathRooms.SelectedValue.Trim());
                    house.LotSquareFootage = LotSQFootage.Text.Trim() == string.Empty ? 0 : Int32.Parse(LotSQFootage.Text.Trim());
                    house.TotalSquareFootage = TotalSQFootage.Text.Trim() == string.Empty ? 0 : Int32.Parse(TotalSQFootage.Text.Trim());
                    house.UtilitiesIncludedInRent = Utilities.Text.Trim();
                    house.Price = Convert.ToDecimal(Price.Text.ToString().Trim());
                    house.UpdatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());// user.UserId.Value;
                    house.CreatedBy = Guid.Parse(Membership.GetUser().ProviderUserKey.ToString());// user.UserId.Value;

                    if (house.Save())
                    {
                        DataSet ds;
                        ds = new HouseDAO().SelectAllDataset(house.LandlordId);
                        ds.Tables[0].PrimaryKey = new DataColumn[] { ds.Tables[0].Columns["HouseId"] };
                        Session[Constants.SESSION_HOUSELIST] = ds;

                        string houseid = house.HouseId.ToString();
                        //This can be used everywhere to call java script and parameters.
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Save_Success + "'); window.location = '/Land_load/Land_Load_House_Option_Add.aspx?HouseId=" + house.HouseId.ToString() + "'; }", true);

                    }
                    else
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Save_Unsuccess + "'); }", true);

                        //Save error
                    }

                }
                catch (Exception ex)
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Redirect", "window.onload = function(){ alert('" + Messages.Save_Unsuccess + "'); }", true);
                }
            }
        }
Example #11
0
        public DataSet SelectAllDataset(Guid LandlordId)
        {
            HouseDAO house = new HouseDAO();

            return house.SelectAllDataset(LandlordId);
        }
Example #12
0
        public bool Save()
        {
            bool result = false;

            Database db = DatabaseFactory.CreateDatabase(Constants.CONNECTIONSTRING);
            DbConnection connection = db.CreateConnection();
            connection.Open();
            DbTransaction transaction = connection.BeginTransaction();

            try
            {
                HouseDAO houseDAO = new HouseDAO();

                //If landlord user is a partial user, this logic might need to change
                if (!new LandlordDAO().IsLandlordExist(new Landlord() { LandlordId = this.LandlordId }))
                {
                    new Landlord() { LandlordId = this.LandlordId, LandlordTypeId = (int)Enums.LandlordType.SimpleLandlord, CreatedBy = this.CreatedBy }.Save();
                }

                if (houseDAO.IsHouseExist(this))
                {
                    result = houseDAO.Update(this, db, transaction);
                }
                else
                {
                    result = houseDAO.Insert(this, db, transaction);
                }

                if (result)
                {
                    transaction.Commit();
                }
                else
                {
                    transaction.Rollback();
                }

            }
            catch (System.Exception ex)
            {
                transaction.Rollback();
                result = false;
                throw ex;
            }
            finally
            {
                connection.Close();
            }
            return result;
        }
Example #13
0
 public static House SelectByRoomId(Guid baseHouseRoomId)
 {
     House house = new HouseDAO().SelectByRoomId(baseHouseRoomId);
     return house;
 }