Example #1
0
        protected void btn_AddRoom_Click(object sender, EventArgs e)
        {
            int hostid = 0;

            if (Session["DormitoryHostid"] != null)
            {
                hostid = Convert.ToInt32(Session["DormitoryHostid"].ToString());

                int hostRoomid = 0;
                if (Session["HostRoomId"] != null)
                {
                    hostRoomid = Convert.ToInt32(Session["HostRoomId"].ToString());
                }

                var cDormitory_HostRoom = new CDormitoryHostRoom();
                if (hostRoomid == 0) //new room
                {
                    var HRoom = new DormitoryHostRoom();
                    hostid              = Convert.ToInt32(Session["DormitoryHostid"].ToString());
                    HRoom.HostId        = hostid;
                    HRoom.HostRoomName  = txtRoomName.Text;
                    HRoom.HostRoomFloor = 1;     //Convert.ToInt32(ddlRoomLocation.SelectedValue);
                    HRoom.HostRoomType  = false; //Convert.ToBoolean(Convert.ToInt32(ddlRoomType.SelectedValue));
                    HRoom.CreatedId     = CurrentUserId;
                    HRoom.CreatedDate   = DateTime.Now;
                    int HRoom_Save = cDormitory_HostRoom.Add(HRoom);
                    if (HRoom_Save == -1)
                    {
                        ShowMessage("Failed to add Dormitory Host Room, please try it again.");
                    }
                    else
                    {
                        ShowMessage("Dormitory Host Room is added successfully.");
                    }
                }
                else //update room
                {
                    var host_room = cDormitory_HostRoom.Get(hostRoomid);
                    host_room.HostRoomId    = hostRoomid;
                    host_room.HostRoomName  = txtRoomName.Text;
                    host_room.HostRoomFloor = 1; // Convert.ToInt32(ddlRoomLocation.SelectedValue);
                    host_room.HostRoomType  = false; Convert.ToBoolean(Convert.ToInt32(ddlRoomType.SelectedValue));
                    host_room.UpdatedId     = CurrentUserId;
                    host_room.UpdatedDate   = DateTime.Now;
                    Boolean HRoom_Update = cDormitory_HostRoom.Update(host_room);
                    if (HRoom_Update)
                    {
                        ShowMessage("Host Room is updated successfully.");
                    }
                    else
                    {
                        ShowMessage("Failed to update Host Room, please try it again.");
                    }
                }


                ClearHostRoomForm(); //Clear up Host Room Form
            }
        }
Example #2
0
        protected void Grid_HostRoom_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (Grid_HostRoom.SelectedValue != null)
            {
                int HostRoomId = Convert.ToInt32(Grid_HostRoom.SelectedValue.ToString());
                Session["HostRoomId"] = HostRoomId;

                var cDormitory_HostRoom     = new CDormitoryHostRoom();
                DormitoryHostRoom Host_Room = cDormitory_HostRoom.Get(HostRoomId);

                txtRoomName.Text = Host_Room.HostRoomName;

                ddlRoomLocation.SelectedValue = Convert.ToInt32(Host_Room.HostRoomFloor).ToString();

                ddlRoomType.SelectedValue = Convert.ToUInt32(Convert.ToBoolean(Host_Room.HostRoomType)).ToString();
            }
        }