public void btnCreateHamlet_Clicked(object sender, EventArgs e) { MonkData db = new MonkData(); Monks.jkp_Retreat retreat = db.jkp_Retreats.First(p => p.Ret_ID == RetreatId); Monks.jkp_Hamlet hamlet = new Monks.jkp_Hamlet(); hamlet.Ham_ID = Guid.NewGuid(); hamlet.Ham_LocalName = txtHamletLocalName.Text; hamlet.Ham_EnglishName = txtHamletEnglishName.Text; hamlet.Ham_VietnameseName = txtHamletVietName.Text; hamlet.Ham_Site_ID = retreat.Ret_Site_ID; db.jkp_Hamlets.InsertOnSubmit(hamlet); db.SubmitChanges(); RedrawHamletList(db); txtHamletEnglishName.Text = ""; txtHamletLocalName.Text = ""; txtHamletVietName.Text = ""; }
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; }
private void detach_jkp_Hamlets(jkp_Hamlet entity) { this.SendPropertyChanging(); entity.jkp_Address = null; }
private void attach_jkp_Hamlets(jkp_Hamlet entity) { this.SendPropertyChanging(); entity.jkp_Site = this; }