Exemplo n.º 1
0
    public void lbtnCopyRooms_Clicked(object sender, EventArgs e)
    {
        LinkButton lbtnCopyRooms = (LinkButton)sender;
        Guid retreatId = new Guid(lbtnCopyRooms.Attributes["retreatid"]);
        Monks.jkp_Retreat retreat = db.jkp_Retreats.First(p => p.Ret_ID == retreatId);

        List<Monks.jkp_Hamlet> newHamlets = new List<Monks.jkp_Hamlet>();
        List<Monks.jkp_Building> newBuildings = new List<Monks.jkp_Building>();
        List<Monks.jkp_Room> newRooms = new List<Monks.jkp_Room>();
        List<Monks.jkp_RoomRate> newRoomRates = new List<Monks.jkp_RoomRate>();
        foreach (Monks.jkp_Hamlet hamletInRetreat in retreat.jkp_Site.jkp_Hamlets)
        {
            Monks.jkp_Hamlet newHamlet = new Monks.jkp_Hamlet();
            newHamlet.Ham_Add_ID = hamletInRetreat.Ham_Add_ID;
            newHamlet.Ham_Comment = hamletInRetreat.Ham_Comment;
            newHamlet.Ham_Description = hamletInRetreat.Ham_Description;
            newHamlet.Ham_ID = Guid.NewGuid();
            newHamlet.Ham_LocalName = hamletInRetreat.Ham_LocalName;

            newHamlet.Ham_Site_ID = retreat.Ret_Site_ID;
            newHamlet.Ham_VietnameseName = hamletInRetreat.Ham_VietnameseName;
            newHamlet.Ham_EnglishName = hamletInRetreat.Ham_EnglishName;
            newHamlets.Add(newHamlet);

            foreach (Monks.jkp_Building building in hamletInRetreat.jkp_Buildings)
            {
                Monks.jkp_Building newBuilding = new Monks.jkp_Building();
                newBuilding.Bld_Comment = building.Bld_Comment;
                newBuilding.Bld_Description = building.Bld_Description;
                newBuilding.Bld_Directions = building.Bld_Directions;
                newBuilding.Bld_EnglishName = building.Bld_EnglishName;
                newBuilding.Bld_Ham_ID = newHamlet.Ham_ID;
                newBuilding.Bld_ID = Guid.NewGuid();
                newBuilding.Bld_LocalName = building.Bld_LocalName;
                newBuilding.Bld_VietnameseName = building.Bld_VietnameseName;
                newBuildings.Add(newBuilding);

                foreach (Monks.jkp_Room room in building.jkp_Rooms)
                {
                    Monks.jkp_Room newRoom = new Monks.jkp_Room();
                    newRoom.Rm_Bld_ID = newBuilding.Bld_ID;
                    newRoom.Rm_Comment = room.Rm_Comment;
                    newRoom.Rm_ID = Guid.NewGuid();
                    newRoom.Rm_Level = room.Rm_Level;
                    newRoom.Rm_Name = room.Rm_Name;
                    newRoom.Rm_RmType_ID = room.Rm_RmType_ID;
                    newRoom.Rm_TotalCapacity = room.Rm_TotalCapacity;
                    newRooms.Add(newRoom);

                    foreach (Monks.jkp_RoomRate roomRate in room.jkp_RoomRates)
                    {
                        Monks.jkp_RoomRate newRoomRate = new Monks.jkp_RoomRate();
                        newRoomRate.RR_EndDate = roomRate.RR_EndDate;
                        newRoomRate.RR_StartDate = roomRate.RR_StartDate;
                        newRoomRate.RR_Rm_ID = newRoom.Rm_ID;
                        newRoomRate.RR_Rt_ID = roomRate.RR_Rt_ID;
                        newRoomRates.Add(newRoomRate);
                    }

                }
            }
        }

        db.jkp_Hamlets.InsertAllOnSubmit(newHamlets);
        db.jkp_Buildings.InsertAllOnSubmit(newBuildings);
        db.jkp_Rooms.InsertAllOnSubmit(newRooms);
        db.jkp_RoomRates.InsertAllOnSubmit(newRoomRates);
        db.SubmitChanges();
        db.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues);
        LoadRetreatsFromSelectedSite();

        mvCopy.ActiveViewIndex = 1;
    }
Exemplo n.º 2
0
		private void detach_jkp_Rooms(jkp_Room entity)
		{
			this.SendPropertyChanging();
			entity.jkp_RoomType = null;
		}
Exemplo n.º 3
0
    public void btnCreateRoom_Clicked(object sender, EventArgs e)
    {
        MonkData db = new MonkData();
        Guid buildingId = new Guid(dlBuildings.SelectedValue);

        // Check to see if there are any rooms with this same name already on the building.
        var roomsWithSameNameInBuilding = from r in db.jkp_Rooms
                                          where r.Rm_Bld_ID == buildingId && r.Rm_Name == txtCreateRoomsName.Text.Trim().ToUpper()
                                          select r;
        if(roomsWithSameNameInBuilding.Count() > 0)
            return; // Duplicate room found.

        Monks.jkp_Room room = new Monks.jkp_Room();
        room.Rm_Bld_ID = buildingId;
        room.Rm_ID = Guid.NewGuid();
        if (!String.IsNullOrEmpty(txtCreateRoomLevelNumber.Text))
            room.Rm_Level = int.Parse(txtCreateRoomLevelNumber.Text);
        room.Rm_Name = txtCreateRoomsName.Text.Trim().ToUpper();
        room.Rm_RmType_ID = new Guid( dlRoomType.SelectedValue);
        room.Rm_TotalCapacity = int.Parse(txtCreateRoomCapacity.Text);
        room.Rm_ContructedDate = DateTime.Parse(txtCreateRoomConstructionDate.Text);
        if(!String.IsNullOrEmpty(txtCreateRoomDestructionDate.Text))
            room.Rm_DestroyedDate = DateTime.Parse(txtCreateRoomDestructionDate.Text);

        db.jkp_Rooms.InsertOnSubmit(room);

        db.SubmitChanges();
        RedrawRoomsForRetreat(db);
        txtCreateRoomsName.Text = "";
        modalRoom.Hide();
    }
Exemplo n.º 4
0
		private void attach_jkp_Rooms(jkp_Room entity)
		{
			this.SendPropertyChanging();
			entity.jkp_RoomType = this;
		}