private Rooms GetRoomExecQuery(string query)
        {
            Rooms room = new Rooms();

            using (connection = DBHelper.OpenConnection()) {
                MySqlCommand cmd = new MySqlCommand(query, connection);
                using (reader = cmd.ExecuteReader()) {
                    if (reader.Read())
                    {
                        room = Room_DAL.GetRoom(reader);
                    }
                }
            }
            return(room);
        }
示例#2
0
        public void Fill()
        {
            //להביא מה-DAL טבלה מלאה בכל הלקוחות

            DataTable dataTable = Room_DAL.GetDataTable();

            //להעביר את הערכים מהטבלה לתוך אוסף הלקוחות
            //להעביר כל שורה בטבלה ללקוח

            DataRow dataRow;
            Room    room;

            for (int i = 0; i < dataTable.Rows.Count; i++)
            {
                dataRow = dataTable.Rows[i];
                room    = new Room(dataRow);
                this.Add(room);
            }
        }
示例#3
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");
            }
        }
示例#4
0
        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");
        }