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"); }