Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.Cookies["user_server"] != null)
            {
                HttpCookie local = Request.Cookies["user_server"];


                Users_DAL user = new Users_DAL();

                foreach (var item in user.select_All())
                {
                    if (item.Email == local.Values["user_email"])
                    {
                        Label1.Text = item.First_Name;
                    }
                }



                Apartments_DAL  apartment = new Apartments_DAL();
                Apartments_DATA a         = apartment.select_Item(Convert.ToInt16(Request.QueryString["ID"]));
                Area.Text       = a.Area.ToString();
                Disription.Text = a.Descriptions;
                //price_per_meter.Text = a.Price_Per_meter.ToString();
                Design_img.ImageUrl  = "../images/" + a.Design_Image;
                Image1.ImageUrl      = "../images/" + a.Image_1;
                Image2.ImageUrl      = "../images/" + a.Image_2;
                Image3.ImageUrl      = "../images/" + a.Image_3;
                Design_img1.ImageUrl = "../images/" + a.Design_Image;
                Image4.ImageUrl      = "../images/" + a.Image_1;
                Image5.ImageUrl      = "../images/" + a.Image_2;
                Image6.ImageUrl      = "../images/" + a.Image_3;

                Total_Price.Text = (a.Price_Per_meter * a.Area).ToString();
                // price_per_meter.Text = a.Price_Per_meter.ToString();
                Building_DAL  b = new Building_DAL();
                Building_DATA d = new Building_DATA();
                d = b.select_All().SingleOrDefault(x => x.ID == a.FK_Building);
                Location_OF_Building_DAL  location = new Location_OF_Building_DAL();
                Location_OF_Building_DATA l        = new Location_OF_Building_DATA();
                l            = location.select_All().SingleOrDefault(x => x.ID == d.FK_Location_OF_Building);
                Country.Text = l.Country;
                City.Text    = l.City;
                Govern.Text  = l.Governorate;

                List <Room_DATA> room     = new List <Room_DATA>();
                Room_DAL         room_Dal = new Room_DAL();
                room = room_Dal.select_All().Where(x => x.FK_Apartment == a.ID).ToList();

                Who_See_Announce_DAL  who_see_announce_Insert = new Who_See_Announce_DAL();
                Who_See_Announce_DATA who_see_announce        = new Who_See_Announce_DATA();
                who_see_announce.Owner_ID     = a.FK_Users;
                who_see_announce.Visitor_ID   = Convert.ToInt16(local.Values["user_ID"]);
                who_see_announce.ID_Apartment = a.ID;
                who_see_announce.Owner_visitor_apartment_ID = (who_see_announce.Visitor_ID.ToString() + who_see_announce.ID_Apartment.ToString() +
                                                               who_see_announce.ID_Apartment.ToString());
                if (who_see_announce.Visitor_ID != who_see_announce.Owner_ID)
                {
                    who_see_announce_Insert.insert(who_see_announce);
                }
            }

            else
            {
                Response.Redirect("/User_Pages/User_Main_Page.aspx");
            }
        }
        protected void apply_Click1(object sender, EventArgs e)
        {
            HttpCookie                local     = Request.Cookies["user_server"];
            Apartments_DATA           apartment = new Apartments_DATA();
            Building_DATA             building  = new Building_DATA();
            Roles_DATA                roles     = new Roles_DATA();
            Users_DATA                user      = new Users_DATA();
            Location_OF_Building_DATA location  = new Location_OF_Building_DATA();
            Purpose_Apartment_DATA    purpose   = new Purpose_Apartment_DATA();
            Room_DATA room = new Room_DATA();

            Apartments_DAL           apartment_inset = new Apartments_DAL();
            Building_DAL             building_inset  = new Building_DAL();
            Roles_DAL                roles_inset     = new Roles_DAL();
            Users_DAL                user_inset      = new Users_DAL();
            Location_OF_Building_DAL location_inset  = new Location_OF_Building_DAL();
            Purpose_Apartment_DAL    purpose_inset   = new Purpose_Apartment_DAL();
            Room_DAL room_insert = new Room_DAL();

            location.City              = city.Text;
            location.Country           = country.Text;
            location.Governorate       = government.Text;
            location.Numer_of_Building = Convert.ToInt16(building_number.Text);
            location.Street_NAME       = street_name.Text;
            location_inset.insert(location);

            building.Area                    = Convert.ToInt16(building_area.Text);
            building.Descriptions            = building_description.Text;
            building.Floor_Number            = Convert.ToInt16(floor.Text);
            building.Year_Of_Building        = building_year.SelectedDate;
            building.Image_1                 = ViewState["building_img1"].ToString();
            building.Desgin_Image            = ViewState["building_deign"].ToString();
            building.FK_Location_OF_Building = location_inset.select_All().Last().ID;
            building_inset.insert(building);
            building = building_inset.select_All().Last();

            apartment.Area                 = Convert.ToInt16(apartment_area.Text);
            apartment.Avalable             = 1;
            apartment.Descriptions         = apartment_Description.Text;
            apartment.Image_1              = ViewState["imge1"].ToString();
            apartment.Image_2              = ViewState["imge2"].ToString();
            apartment.Image_3              = ViewState["imge3"].ToString();
            apartment.Design_Image         = ViewState["apartment_design"].ToString();
            apartment.Price_Per_meter      = Convert.ToInt16(price.Text);
            apartment.Apartments_Type      = apartment_type.Text;
            apartment.FK_Building          = building.ID;
            apartment.FK_Purpoes_Apartment = Convert.ToInt16(apartment_purpose.SelectedValue);
            apartment.FK_Users             = Convert.ToInt16(local.Values["user_ID"]);
            apartment_inset.insert(apartment);
            apartment = apartment_inset.select_All().Last();
            count     = Convert.ToInt16(ViewState["count"]);
            for (int i = 0; i < count; i++)
            {
                Panel        mylable      = new Panel();
                TextBox      area         = new TextBox();
                FileUpload   imge1        = new FileUpload();
                Image        image        = new Image();
                TextBox      Room_Name    = new TextBox();
                DropDownList FK_Room_Type = new DropDownList();


                mylable      = (Panel)View4.FindControl("panal" + i);
                area         = (TextBox)mylable.FindControl("area" + mylable.ID);
                imge1        = (FileUpload)mylable.FindControl("imge1" + mylable.ID);
                Room_Name    = (TextBox)mylable.FindControl("Room_Name" + mylable.ID);
                FK_Room_Type = (DropDownList)mylable.FindControl("FK_Room_Type" + mylable.ID);
                image        = (Image)mylable.FindControl("image" + mylable.ID);

                room.Area         = Convert.ToInt16(area.Text);
                room.Image_1      = image.ImageUrl;
                room.Room_Name    = Room_Name.Text;
                room.FK_Room_Type = Convert.ToInt16(FK_Room_Type.SelectedValue);
                room.FK_Apartment = apartment.ID;
                room_insert.insert(room);
            }
            Response.Redirect("/User_Pages/announc.aspx");
        }