Exemplo n.º 1
0
    public void btnSavePageAccessRole_Clicked(object sender, EventArgs e)
    {
        MonkData db = new MonkData();
        Guid roleId = new Guid(hidRoleId.Value);
        var pagesUnderRole = db.aspnet_PageUnderRoles.Where(p=>p.RoleId == roleId && p.FilePath == dlPages.SelectedValue);
        if(pagesUnderRole.Count() > 0)
        {
            // Role was already found that was defined for this page.
            return;
        }

        Monks.aspnet_PageUnderRole pageUnderRole = new Monks.aspnet_PageUnderRole();
        pageUnderRole.FilePath = dlPages.SelectedValue.Trim();
        pageUnderRole.PageId = Guid.NewGuid();
        pageUnderRole.RoleId = roleId;

        db.aspnet_PageUnderRoles.InsertOnSubmit(pageUnderRole);
        db.SubmitChanges();

        var pagePermissions = db.aspnet_PageUnderRoles.Where(p=>p.RoleId == roleId);
        rpPagePermissions.DataSource = pagePermissions;
        rpPagePermissions.DataBind();

        var tablePermissions = db.aspnet_TableUnderRoles.Where(p=>p.RoleId == roleId);
        rpTablePermissions.DataSource = tablePermissions;
        rpTablePermissions.DataBind();
    }
Exemplo n.º 2
0
    public void btnAddMediaRole_Clicked(object sender, EventArgs e)
    {
        if(dlRolesToAssign.Items.Count == 0)
            throw new Exception("Roles must be created first before trying to assign roles.");
        MonkData db = new MonkData();
        Monks.jkp_MediaRole mediaRole = new Monks.jkp_MediaRole();
        if(MediaType == Monks.Enums.MediaTypes.Audio)
            mediaRole.AudioId = ItemId;
        else if(MediaType == Monks.Enums.MediaTypes.Book)
            mediaRole.BookId = ItemId;
        else if(MediaType == Monks.Enums.MediaTypes.Image)
            mediaRole.ImageId = ItemId;
        else if(MediaType == Monks.Enums.MediaTypes.Video)
            mediaRole.VideoId = ItemId;
        mediaRole.RoleId = new Guid(dlRolesToAssign.SelectedValue);
        mediaRole.MediaRoleId = Guid.NewGuid();

        var existingSameRole = from d in db.jkp_MediaRoles
                               where object.Equals( d.AudioId, mediaRole.AudioId) && object.Equals( d.BookId, mediaRole.BookId) && object.Equals( d.ImageId, mediaRole.ImageId) && object.Equals(d.VideoId , mediaRole.VideoId)
                               && d.RoleId == mediaRole.RoleId
                               select d;
        if(existingSameRole.Count() > 0)
        {
            modalAddRole.Hide();
            return;
        }

        db.jkp_MediaRoles.InsertOnSubmit(mediaRole);
        db.SubmitChanges();
        LoadPageData();
        modalAddRole.Hide();
    }
Exemplo n.º 3
0
 public void lbtnRemoveMediaRole_Clicked(object sender, EventArgs e)
 {
     LinkButton lbtnRemoveMediaRole = (LinkButton)sender;
     Guid mediaRoleId = new Guid(lbtnRemoveMediaRole.Attributes["mediaroleid"]);
     MonkData db = new MonkData();
     Monks.jkp_MediaRole mediaRole = db.jkp_MediaRoles.First(p => p.MediaRoleId == mediaRoleId);
     db.jkp_MediaRoles.DeleteOnSubmit(mediaRole);
     db.SubmitChanges();
     LoadPageData();
 }
Exemplo n.º 4
0
 public void btnDelete_Clicked(object sender, EventArgs e)
 {
     LinkButton lbtnDelete = (LinkButton)sender;
     Guid itemIdToDelete = new Guid(lbtnDelete.Attributes["itemid"]);
     MonkData db = new MonkData();
     string tableName = ((System.Data.Linq.Mapping.TableAttribute)DataType.GetCustomAttributes(typeof(System.Data.Linq.Mapping.TableAttribute), false).First()).Name;
     primaryKeyProp = GetPrimaryKeyProperty(DataType);
     db.ExecuteCommand("DELETE FROM " + tableName + " WHERE " + primaryKeyProp.Name + " = '" + itemIdToDelete.ToString() + "'");
     db.SubmitChanges();
 }
Exemplo n.º 5
0
    public void lbtnRemoveRole_Clicked(object sender, EventArgs e)
    {
        MonkData db = new MonkData();
        LinkButton lbtnRemoveRole = (LinkButton)sender;
        Guid roleId = new Guid( lbtnRemoveRole.Attributes["roleid"]);
        Monks.aspnet_UsersInRole userInRole = db.aspnet_UsersInRoles.First(p=>p.RoleId == roleId && p.UserId == PageUserId);
        db.aspnet_UsersInRoles.DeleteOnSubmit(userInRole);
        db.SubmitChanges();

        LoadPageData();
    }
Exemplo n.º 6
0
    public void detailsAddress_OnItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
    {
        DropDownList dlSanghas = (DropDownList)detailsAddress.FindControl("dlSanghas");
        string idStringOfSangha = dlSanghas.SelectedValue;
        MonkData db = new MonkData();

        Monks.jkp_Person jPerson = db.aspnet_Memberships.First(p => p.UserId == UserId).jkp_Person;
        jPerson.jkp_Address.Add_San_ID = new Guid(idStringOfSangha);
        db.SubmitChanges();

        detailsAddress.DataBind();
    }
Exemplo n.º 7
0
    public void DetailsView2_OnItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
    {
        DropDownList dlGender = (DropDownList)DetailsView2.FindControl("genderSelection");
        string valueOfGender = dlGender.SelectedItem.Text;

        MonkData db = new MonkData();

        Monks.jkp_Person jPerson = db.aspnet_Memberships.First(p => p.UserId == UserId).jkp_Person;
        jPerson.Per_Gender = valueOfGender[0];
        db.SubmitChanges();

        DetailsView2.DataBind();
    }
Exemplo n.º 8
0
    public void btnMarkAsPaidSave_Clicked(object sender, EventArgs e)
    {
        Guid contribId = new Guid(btnMarkAsPaidSave.Attributes["contid"]);
        MonkData db = new MonkData();
        Monks.jkp_Contribution contrib = db.jkp_Contributions.First(p => p.Cont_ID == contribId);

        if (!contrib.Cont_AmountPaid.HasValue || contrib.Cont_AmountPaid.Value == 0)
            contrib.Cont_AmountPaid = decimal.Parse(txtAmountPaid.Text);
        else
            contrib.Cont_AmountPaid += decimal.Parse(txtAmountPaid.Text);

        db.SubmitChanges();
        modalMarkAsPaid.Hide();
        LoadContributions();
    }
Exemplo n.º 9
0
    /// <summary>
    /// Event clicked when the user signs up.
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnSignup_Clicked(object sender, EventArgs e)
    {
        if (CheckUsername() || CheckEmail())
            return;

        btnSignup.Enabled = false;
        MonkData db = new MonkData();
        // Get the application from the ASP.NET Membership object. When we create the user, we'll need to know what aspnet_Application object they will use.
        // This is the only spot in the entire site where we'll care about the asp.net application.
        var app = (from u in db.aspnet_Applications
                   where u.ApplicationName == "DeerPark"
                   select u).Single();
        string salt = GenerateSalt();  // Gets the salt that will be used for encoding the password if encoding the password is turned on.

        // Load up all of the LINQ objects for a new user
        bool personExists = false; // use a bool to see if the corresponding person entry exists. if so, do not perform insert to db
        Monks.jkp_Person jPerson = Create_jkp_Person(ref personExists, ref db);
        if (personExists)
        {
            jPerson.Per_Email = txtEmailAddress1.Text;
        }
        Monks.jkp_Address jAddress = Create_jkp_Address();
        Monks.aspnet_Membership curMembership = Create_aspnet_Membership(app, salt);
        Monks.aspnet_User curUser = Create_aspnet_User(curMembership);

        // Attach the Person ID to the aspnet_Membership object
        curMembership.PersonId = jPerson.Per_ID;
        jPerson.Per_Add_ID = jAddress.Add_ID;

        // Setup the inserts.
        db.jkp_Addresses.InsertOnSubmit(jAddress);

        // do not perform insert to the person table if an entry was already found for them
        if (!personExists)
        {
            db.jkp_Persons.InsertOnSubmit(jPerson);
        }

        db.aspnet_Users.InsertOnSubmit(curUser);
        db.aspnet_Memberships.InsertOnSubmit(curMembership);
        // Submit the inserts. This is a transactional insert. If one fails, they all fail.
        db.SubmitChanges();

        // Show the success view.
        mvSignup.ActiveViewIndex = 1;

        FormsAuthentication.SetAuthCookie(txtUsername.Text, false);
    }
Exemplo n.º 10
0
 public void btnCreateBuilding_Clicked(object sender, EventArgs e)
 {
     MonkData db = new MonkData();
     Guid hamletId = new Guid(dlHamlets.SelectedValue);
     Monks.jkp_Building building = new Monks.jkp_Building();
     building.Bld_EnglishName = txtBuildingEnglishName.Text;
     building.Bld_LocalName = txtBuildingLocalName.Text;
     building.Bld_VietnameseName = txtBuildingVietnameseName.Text;
     building.Bld_Ham_ID = hamletId;
     building.Bld_ID = Guid.NewGuid();
     db.jkp_Buildings.InsertOnSubmit(building);
     db.SubmitChanges();
     RedrawBuildingsList(db);
     txtBuildingEnglishName.Text = "";
     txtBuildingLocalName.Text = "";
     txtBuildingVietnameseName.Text = "";
 }
Exemplo n.º 11
0
    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 = "";
    }
Exemplo n.º 12
0
    public void btnSaveTablePermission_Clicked(object sender, EventArgs e)
    {
        MonkData db = new MonkData();
        Guid roleId = new Guid(hidRoleId.Value);
        var tablesWithSameName = from t in db.aspnet_TableUnderRoles
                                 where t.TableName == dlTables.SelectedValue && t.RoleId == roleId
                                 select t;
        if(tablesWithSameName.Count() > 0)
            return; // Found a table role assignment that was alredy created.
        Monks.aspnet_TableUnderRole tableUnderRole = new Monks.aspnet_TableUnderRole();
        tableUnderRole.RoleId = roleId;
        tableUnderRole.TableName = dlTables.SelectedValue;
        tableUnderRole.TableUnderRoleId = Guid.NewGuid();
        db.aspnet_TableUnderRoles.InsertOnSubmit(tableUnderRole);
        db.SubmitChanges();

        LoadRoles(db);
    }
Exemplo n.º 13
0
    public void btnAddRole_Clicked(object sender, EventArgs e)
    {
        modalAddRole.Hide();
        MonkData db = new MonkData();
        Monks.aspnet_UsersInRole userInRole = new Monks.aspnet_UsersInRole();
        userInRole.RoleId = new Guid(dlRolesToAssign.SelectedValue);
        userInRole.UserId = PageUserId;

        var usersInRolesSame = from u in db.aspnet_UsersInRoles
                               where u.UserId == PageUserId && u.RoleId == userInRole.RoleId
                               select u;
        if(usersInRolesSame.Count() > 0)
            return;
        db.aspnet_UsersInRoles.InsertOnSubmit(userInRole);
        db.SubmitChanges();

        LoadPageData();
    }
Exemplo n.º 14
0
    public void btnSaveNewRole_Clicked(object sender, EventArgs e)
    {
        MonkData db = new MonkData();
        Monks.aspnet_Role role = new Monks.aspnet_Role();

        var app = (from u in db.aspnet_Applications
                   where u.ApplicationName == "DeerPark"
                   select u).Single();
        role.ApplicationId = app.ApplicationId;
        role.Description = txtDescription.Text;
        role.LoweredRoleName = txtRoleName.Text.ToLower();
        role.RoleName = txtRoleName.Text;
        role.RoleId = Guid.NewGuid();
        db.aspnet_Roles.InsertOnSubmit(role);
        db.SubmitChanges();

        txtRoleName.Text = "";
        txtDescription.Text = "";

        LoadPageData();
    }
Exemplo n.º 15
0
    public void btnSave_Clicked(object sender, EventArgs e)
    {
        MonkData db = new MonkData();
        Monks.jkp_Site site;
        if(SiteId != null)
        {
            site = db.jkp_Sites.First(p=>p.Site_ID == SiteId);
        }
        else
        {
            site = new Monks.jkp_Site();
            site.Site_ID = Guid.NewGuid();
        }

        site.Site_EnglishName = txtEnglishName.Text;
        site.Site_Description = txtDescription.Text;

        if(SiteId == null)
            db.jkp_Sites.InsertOnSubmit(site);
        db.SubmitChanges();
        mvAddEdit.ActiveViewIndex = 1;
    }
Exemplo n.º 16
0
    public void btnSave_Clicked(object sender, EventArgs e)
    {
        MonkData db = new MonkData();
        Monks.jkp_Address address;
        if(AddressId != null)
        {
            address = db.jkp_Addresses.First(p=>p.Add_ID == AddressId);
        }
        else
        {
            address = new Monks.jkp_Address();
            address.Add_ID = Guid.NewGuid();
        }
        address.Add_Street = txtAddress.Text;
        address.Add_State = txtState.Text;
        address.Add_PostalCode = txtZip.Text;
        address.Add_Country = txtCountry.Text;
        address.Add_City = txtCity.Text;

        if(AddressId == null)
            db.jkp_Addresses.InsertOnSubmit(address);
        db.SubmitChanges();
        mvAddEdit.ActiveViewIndex = 1;
    }
Exemplo n.º 17
0
    public void btnSave_Clicked(object sender, EventArgs e)
    {
        MonkData db = new MonkData();
        Monks.jkp_Retreat retreat;
        if(RetreatId != null)
        {
            retreat = db.jkp_Retreats.First(p=>p.Ret_ID == RetreatId);
        }
        else
        {
            retreat = new Monks.jkp_Retreat();
            retreat.Ret_ID = Guid.NewGuid();
        }

        //if(!String.IsNullOrEmpty(txtArrivalTime.Text))
        //    retreat.Ret_ArrivalTime = DateTime.Parse(txtArrivalTime.Text);
        //if(!String.IsNullOrEmpty(txtDepartureTime.Text))
        //    retreat.Ret_DepartureTime = DateTime.Parse(txtDepartureTime.Text);
        if(!String.IsNullOrEmpty(txtEndDate.Text))
            retreat.Ret_EndDate = DateTime.Parse(txtEndDate.Text);
        if(!String.IsNullOrEmpty(txtStartDate.Text))
            retreat.Ret_StartDate = DateTime.Parse(txtStartDate.Text);
        retreat.Ret_Name = txtName.Text.Trim();
        retreat.Ret_Description = txtDescription.Text;
        if(!String.IsNullOrEmpty(dlSite.SelectedValue))
            retreat.Ret_Site_ID = new Guid( dlSite.SelectedValue);

        var selectedLanguage = db.jkp_Languages.SingleOrDefault(p => p.Lang_ID.ToString() == dlLanguage.SelectedValue);
        retreat.Ret_LanguageId = selectedLanguage.Lang_ID;
        Request.QueryString.Add("retreatid", retreat.Ret_ID.ToString());

        if(RetreatId == null)
            db.jkp_Retreats.InsertOnSubmit(retreat);
        db.SubmitChanges();
        mvAddEdit.ActiveViewIndex = 1;
    }
Exemplo n.º 18
0
 public void lbtnRoomDelete_Clicked(object sender, EventArgs e)
 {
     LinkButton lbtnRoomDelete = (LinkButton)sender;
     Guid roomId = new Guid(lbtnRoomDelete.Attributes["roomid"]);
     MonkData db = new MonkData();
     Monks.jkp_Room roomToDelete = db.jkp_Rooms.First(p=>p.Rm_ID == roomId);
     db.jkp_Rooms.DeleteOnSubmit(roomToDelete);
     db.SubmitChanges();
     RedrawRoomsForRetreat(db);
 }
Exemplo n.º 19
0
 public void lbtnDeletePageRole_Clicked(object sender, EventArgs e)
 {
     LinkButton lbtnDeletePageRole = (LinkButton)sender;
     Guid pageRoleId = new Guid(lbtnDeletePageRole.Attributes["pageroleid"]);
     MonkData db = new MonkData();
     Monks.aspnet_PageUnderRole pageUnderRole = db.aspnet_PageUnderRoles.First(p=>p.PageId == pageRoleId);
     db.aspnet_PageUnderRoles.DeleteOnSubmit(pageUnderRole);
     db.SubmitChanges();
     LoadRoles(db);
 }
Exemplo n.º 20
0
    public void btnSave_Clicked(object sender, EventArgs e)
    {
        object itemToCreateOrEdit;
        MonkData db = new MonkData();

        // Find the primary key property
        PropertyInfo primaryKey = GetPrimaryKeyProperty(DataType);

        if (ItemId == null)
        {
            // Dynamically get the datatype
            Type[] emptyConstructorArgs = { };
            itemToCreateOrEdit = DataType.GetConstructor(emptyConstructorArgs).Invoke(null);
        }
        else
        {
            // Load the object from the database.

            Type[] emptyConstructorArgs = { };
            string tableName = ((System.Data.Linq.Mapping.TableAttribute)DataType.GetCustomAttributes(typeof(System.Data.Linq.Mapping.TableAttribute), false).First()).Name;

            IEnumerable itemsFromDB = db.ExecuteQuery(DataType, "select * from " + tableName + " where " + primaryKey.Name + " = '" + ItemId.ToString() + "'", emptyConstructorArgs);
            IEnumerator dbItemsEnumberator = itemsFromDB.GetEnumerator();
            dbItemsEnumberator.MoveNext();
            itemToCreateOrEdit = dbItemsEnumberator.Current;
        }

        // Load all the values from the form into the object
        foreach (Control cntItem in plcForm.Controls)
        {
            var propertiesFound = from p in DataType.GetProperties()
                                  where p.Name == cntItem.ID
                                  select p;
            if (propertiesFound.Count() < 1)
                continue;
            PropertyInfo pInfo = propertiesFound.First();
            object[] attributesOfProperty = pInfo.GetCustomAttributes(false);
            if (attributesOfProperty[0].GetType() == typeof(ColumnAttribute))
            {
                ColumnAttribute columnAttrib = (ColumnAttribute)attributesOfProperty[0];
                if (columnAttrib.DbType.Contains("VarChar") || columnAttrib.DbType.Contains("NChar"))
                {
                    TextBox txtControl = (TextBox)cntItem;
                    pInfo.SetValue(itemToCreateOrEdit, txtControl.Text, null);
                }
                else if (columnAttrib.DbType.Contains("Decimal"))
                {
                    TextBox txtControl = (TextBox)cntItem;
                    pInfo.SetValue(itemToCreateOrEdit, decimal.Parse(txtControl.Text), null);
                }
                else if (columnAttrib.DbType.Contains("DateTime"))
                {
                    TextBox txtControl = (TextBox)cntItem;
                    if (!String.IsNullOrEmpty(txtControl.Text))
                    {
                        DateTime time;

                        // Check if the datetime supplied is actually parseable.
                        if(!DateTime.TryParse(txtControl.Text, out time))
                        {
                            throw new Exception("Failed to parse the datetime in the textbox to the proper datetime format. An example is 12/31/2008 12:59:59 AM. The field was " + GetFieldNameFromString(pInfo.Name));
                        }

                        pInfo.SetValue(itemToCreateOrEdit, time, null);
                    }
                    else if (columnAttrib.CanBeNull)
                        pInfo.SetValue(itemToCreateOrEdit, null, null);
                    else if (!columnAttrib.CanBeNull)
                        throw new Exception("Tried to insert a null datetime into a field tha required a datetime. Field was " + GetFieldNameFromString(pInfo.Name));
                }
                else if (columnAttrib.DbType.Contains("Text"))
                {
                    FreeTextBox txtControl = (FreeTextBox)cntItem;
                    pInfo.SetValue(itemToCreateOrEdit, txtControl.Text, null);
                }
                else if (columnAttrib.DbType.Contains("Bit"))
                {
                    CheckBox chkBox = (CheckBox)cntItem;
                    pInfo.SetValue(itemToCreateOrEdit, chkBox.Checked, null);
                }
                else if (columnAttrib.DbType.Contains("Int"))
                {
                    TextBox txtControl = (TextBox)cntItem;

                    int parsedValue = 0;
                    if(!int.TryParse(txtControl.Text, out parsedValue))
                    {
                        throw new Exception("Failed converting the text in the textbox to an integer. The property name was " + GetFieldNameFromString(pInfo.Name));
                    }

                    pInfo.SetValue(itemToCreateOrEdit, parsedValue, null);
                }
            }
            else if (attributesOfProperty[0].GetType() == typeof(AssociationAttribute))
            {
                AssociationAttribute assocAttrib = (AssociationAttribute)attributesOfProperty[0];

                if (cntItem.GetType() == typeof(DropDownList))
                {
                    DropDownList dList = (DropDownList)cntItem;
                    PropertyInfo propIDOfOtherTableItem = DataType.GetProperties().First(p => p.Name == assocAttrib.ThisKey);
                    if (dList.SelectedValue == "null" || dList.SelectedValue == "")
                    {
                        propIDOfOtherTableItem.SetValue(itemToCreateOrEdit, null, null);
                    }
                    else
                    {
                        Guid selectedGuidOfItem = new Guid(dList.SelectedValue);
                        propIDOfOtherTableItem.SetValue(itemToCreateOrEdit, selectedGuidOfItem, null);
                    }
                }
            }

        }
        // Save the object...

        if (ItemId == null)
        {
            if (primaryKey.PropertyType != typeof(Guid))
                throw new Exception("Primary key of " + DataType.Name + " is not a Guid.");
            primaryKey.SetValue(itemToCreateOrEdit, Guid.NewGuid(), null);

            object[] itemToInsert = { itemToCreateOrEdit };
            //                           Where finds the table we need to examine    // Find the one that's shortest   //Get prop vlaue     // Get the method to insert  // Insert
            var propertyInfosForDatabaseWhereName = db.GetType().GetProperties().Where(p => p.Name.StartsWith(DataType.Name.Substring(0, DataType.Name.Length - 1)));
            var propertyObjectOfTableFromDB = propertyInfosForDatabaseWhereName.OrderBy(p => p.Name.Length).First().GetValue(db, null);
            propertyObjectOfTableFromDB.GetType().GetMethod("InsertOnSubmit").Invoke(propertyObjectOfTableFromDB, itemToInsert);

        }

        db.SubmitChanges();
        mvAddEdit.ActiveViewIndex = 1;

        hlViewItem.NavigateUrl = "AddEdit.aspx?typename=" + DataType.Name + "&itemid=" + primaryKey.GetValue(itemToCreateOrEdit, null).ToString();
        hlReturnToList.NavigateUrl = "GridView.aspx?typename=" + DataType.Name;
    }
Exemplo n.º 21
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();
    }