protected void apply_Click1(object sender, EventArgs e) { try { 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(); 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(); location.ID = Convert.ToInt16(Label2.Text); 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.update(location); building.ID = Convert.ToInt16(Label3.Text); 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.ID; building_inset.update(building); apartment.ID = Convert.ToInt16(Label4.Text); 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.update(apartment); Room_DATA room = new Room_DATA(); Room_DAL room_update = new Room_DAL(); List <Room_DATA> room_list = new List <Room_DATA>(); room_list = room_update.select_All().Where(x => x.FK_Apartment == apartment.ID).ToList(); for (int i = 0; i < update_panel; i++) { try { Panel mylable = new Panel(); TextBox area = new TextBox(); FileUpload imge1 = new FileUpload(); Image image = new Image(); TextBox Room_Name = new TextBox(); TextBox ID = new TextBox(); DropDownList FK_Room_Type = new DropDownList(); Button button = new Button(); Button cancel = new Button(); TextBox lable_ID = new TextBox(); Room_Type_DAL room_type = new Room_Type_DAL(); room_type.select_All(); foreach (var item in room_type.select_All()) { ListItem listitem = new ListItem(); listitem.Text = item.Room_Type_Name; listitem.Value = item.ID.ToString(); FK_Room_Type.Items.Add(listitem); } mylable = (Panel)View4.FindControl("panal" + i); image = (Image)mylable.FindControl("image" + mylable.ID); room.Image_1 = image.ImageUrl; ID.ID = "ID" + mylable.ID; area = (TextBox)mylable.FindControl("Area" + mylable.ID); room.Area = Convert.ToInt16(area.Text); Room_Name = (TextBox)mylable.FindControl("Room_Name" + mylable.ID); room.Room_Name = Room_Name.Text; FK_Room_Type = (DropDownList)mylable.FindControl("FK_Room_Type" + mylable.ID); room.FK_Room_Type = Convert.ToInt16(FK_Room_Type.SelectedValue); room.FK_Apartment = apartment.ID; ID = (TextBox)mylable.FindControl("ID" + mylable.ID); room.ID = Convert.ToInt16(ID.Text); //lable_ID= (TextBox)mylable.FindControl("ID" + mylable.ID); //room.ID =Convert.ToInt16( lable_ID.Text); //lable_ID.Visible = false; //room =room_list[i]; room_update.update(room); room_list = room_list.Where(x => x.ID != room.ID).ToList(); } catch { } } foreach (var item in room_list) { room_update.delete(item); } for (int i = update_panel; 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(); Button button = new Button(); Button cancel = new Button(); mylable.ID = "IDpanal" + i; button.ID = "button_ADD" + "panal" + i; button.Text = "add"; button.Click += Button_Click; cancel.ID = "button_cancel" + "panal" + i; cancel.Text = "cancel"; cancel.Click += Cancel_Click; image.ID = "image" + mylable.ID; area.ID = "area" + mylable.ID; imge1.ID = "imge1" + mylable.ID; Room_Name.ID = "Room_Name" + mylable.ID; FK_Room_Type.ID = "FK_Room_Type" + mylable.ID; Room_Type_DAL room_type = new Room_Type_DAL(); room_type.select_All(); foreach (var item in room_type.select_All()) { ListItem listitem = new ListItem(); listitem.Text = item.Room_Type_Name; listitem.Value = item.ID.ToString(); FK_Room_Type.Items.Add(listitem); } //mylable.Controls.Add(area); //mylable.Controls.Add(Room_Name); //mylable.Controls.Add(FK_Room_Type); //mylable.Controls.Add(imge1); //mylable.Controls.Add(button); //mylable.Controls.Add(cancel); //mylable.Controls.Add(image); //View4.Controls.Add(mylable); //room.Image_1 = image.ImageUrl; //room.Area = Convert.ToInt16(area.Text); //room.Room_Name = Room_Name.Text; //room.FK_Room_Type = Convert.ToInt16(FK_Room_Type.SelectedValue); //room.FK_Apartment = apartment.ID; 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 = room_list[i]; room_update.insert(room); } } catch { }; }
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"); }