Пример #1
0
        /*
            private void MediaPlayer_ErrorEvent(object sender, System.EventArgs e)
            {

               // AxMicrosoft.MediaPlayer.Interop.AxWindowsMediaPlayer Player = (AxMicrosoft.MediaPlayer.Interop.AxWindowsMediaPlayer) sender;
                AxWMPLib.AxWindowsMediaPlayer Player = (AxWMPLib.AxWindowsMediaPlayer) sender;

                string sError = Player.Error.ToString();

                if((sError == "An unknown error has occurred.")||(sError == "Failed to set the property on this stream."))
                {

                }
                else if(sError == "Cannot play back the file.  The format is not supported.")
                {
                    MessageBox.Show("Cannot play back file. Either file is missing or Video Server is down.","Adminstrative Software Video Playback Error");
                }
                else
                    MessageBox.Show(sError,"Video Player Message");

                try
                {
                    btnPause.ForeColor = System.Drawing.Color.Black;
                    btnReverse.ForeColor = Color.Black;
                    btnForward.ForeColor = Color.Black;

                    btnPlay.Enabled = true;
                    btnPause.Enabled = false;
                    btnStop.Enabled = false;
                    btnForward.Enabled = false;
                    btnReverse.Enabled = false;
                    btnGoTo.Enabled = false;
                    tbHR.Enabled = false;
                    tbMin.Enabled = false;
                    tbSec.Enabled = false;
                }
                catch(Exception Err)
                {
                    string peekerror = Err.Message;
                }
            }

            private void MediaPlayer_MediaError(object sender, AxWMPLib._WMPOCXEvents_MediaErrorEvent e)
            {
                AxWMPLib.AxWindowsMediaPlayer Player = (AxWMPLib.AxWindowsMediaPlayer) sender;
                //AxMicrosoft.MediaPlayer.Interop.AxWindowsMediaPlayer Player = (AxMicrosoft.MediaPlayer.Interop.AxWindowsMediaPlayer) sender;

                string sError = Player.Error.ToString();

                if((sError == "An unknown error has occurred.")||(sError == "Failed to set the property on this stream."))
                {

                }
                else if(sError == "Cannot play back the file.  The format is not supported.")
                {
                    MessageBox.Show("Cannot play back file. Either file is missing or Video Server is down.","Adminstrative Software Video Playback Error");
                }
                else
                    MessageBox.Show(sError,"Video Player Message");

                try
                {
                    btnPause.ForeColor = System.Drawing.Color.Black;
                    btnReverse.ForeColor = Color.Black;
                    btnForward.ForeColor = Color.Black;

                    btnPlay.Enabled = true;
                    btnPause.Enabled = false;
                    btnStop.Enabled = false;
                    btnForward.Enabled = false;
                    btnReverse.Enabled = false;
                    btnGoTo.Enabled = false;
                    tbHR.Enabled = false;
                    tbMin.Enabled = false;
                    tbSec.Enabled = false;
                }
                catch(Exception Err)
                {
                    string peekerror = Err.Message;
                }
            }

            private void MediaPlayer_EndOfStream(object sender, AxWMPLib._WMPOCXEvents_EndOfStreamEvent e)
            {
                try
                {

                    btnPause.ForeColor = System.Drawing.Color.Black;
                    btnReverse.ForeColor = Color.Black;
                    btnForward.ForeColor = Color.Black;

                    btnPlay.Enabled = true;
                    btnPause.Enabled = false;
                    btnStop.Enabled = false;
                    btnForward.Enabled = false;
                    btnReverse.Enabled = false;
                    btnGoTo.Enabled = false;
                    tbHR.Enabled = false;
                    tbMin.Enabled = false;
                    tbSec.Enabled = false;

                }
                catch(Exception Err)
                {
                    string peekerror = Err.Message;
                }
            }

            private void MediaPlayer_PlayStateChange(object sender, AxWMPLib._WMPOCXEvents_PlayStateChangeEvent e)
            {
                HeadSpeedCount = 0;
                ReverseTimer.Enabled = false;
                ForwardTimer.Enabled = false;
                //if(e.newState == e.oldState) return;

                switch(e.newState)
                {
                    case 0:

                        btnPause.ForeColor = System.Drawing.Color.Black;
                        btnReverse.ForeColor = Color.Black;
                        btnForward.ForeColor = Color.Black;
                        MediaPlayer.Ctlcontrols.currentPosition = 0;
                        btnPlay.Enabled = true;
                        btnPause.Enabled = false;
                        btnStop.Enabled = false;
                        btnForward.Enabled = false;
                        btnReverse.Enabled = false;

                        break;
                    case 1:

                        btnPause.ForeColor = System.Drawing.Color.Red;
                        btnPlay.Enabled = false;
                        btnPause.Enabled = true;
                        btnStop.Enabled = true;
                        btnForward.Enabled = true;
                        btnReverse.Enabled = true;
                        break;
                    case 2:

                        btnPause.ForeColor = System.Drawing.Color.Black;
                        btnPlay.Enabled = true;
                        btnPause.Enabled = false;
                        btnStop.Enabled = true;
                        btnForward.Enabled = true;
                        btnReverse.Enabled = true;
                        break;
                    case 3:
                        break;
                    case 4:
                        break;
                    case 5:
                        break;
                    case 6:
                        break;
                    case 7:
                        break;
                    case 8:
                        MediaPlayer.Ctlcontrols.currentPosition = 0;
                        btnPlay.Enabled = false;
                        btnPause.Enabled = false;
                        btnStop.Enabled = false;
                        btnForward.Enabled = false;
                        btnReverse.Enabled = false;
                        break;
                }
            }

            */
        private void tbActionBar_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
        {
            if(e.Button == tbActionBar.Buttons[0])
            {
                switch(e.Button.Text)
                {
                    case "Add User(s)":
                        if(treeView1.SelectedNode != null)
                        {
                            TreeNode XNode = treeView1.SelectedNode;
                            if(XNode.Tag is OysterClassLibrary.Section)
                            {
                                g_objSection = (OysterClassLibrary.Section)XNode.Tag;
                                PassOysterData POD = new PassOysterData();
                                POD.CurrentSection = g_objSection;
                                POD.CurrentUser = LoginUser;
                                POD.OSystem = OSystem;

                                AddUsersDialog1 AUD = new AddUsersDialog1();
                                AUD.Tag = POD;
                                DialogResult DR = AUD.ShowDialog(this);
                                POD = (PassOysterData)AUD.Tag;
                                AUD.Dispose();
                                if(DR == DialogResult.Abort)
                                {
                                    MessageBox.Show("An error has occurred attempting to open AddUsersDialog!");
                                    return;
                                }
                                else if(DR == DialogResult.OK)
                                {

                                    if(POD.NumMessages != 0)
                                    {
                                        string Display_Errors = "";
                                        foreach(string err_msg in POD.sMessage)
                                        {
                                            if(err_msg != "")
                                                Display_Errors += "\n" + "System Error! Failed to Add User: "******"One or more Users failed to be Added to Group! These Users may have been deleted by another party...");
                                    }
                                    if(POD.IsSuccess == true)
                                    {
                                        LoginUser = OSystem.Refresh();
                                        BuildUserHierarchy();
                                    }
                                }
                            }
                        }
                        break;

                    case "Edit User":
                        if(treeView1.SelectedNode != null)
                        {
                            TreeNode XNode = treeView1.SelectedNode;
                            if(XNode.Tag is OysterClassLibrary.User)
                            {
                                UserWizard UW = new UserWizard();
                                UW.Tag = XNode.Tag;
                                DialogResult DR = UW.ShowDialog(this);
                                UW.Dispose();
                                if(DR == DialogResult.OK)
                                {
                                    LoginUser = OSystem.Refresh();
                                    BuildUserHierarchy();
                                }
                                else
                                {
                                    return;
                                }
                            }

                        }
                        break;
                    case "Create New User":
                        if(treeView1.SelectedNode != null)
                        {
                            TreeNode XNode = treeView1.SelectedNode;
                            if(XNode.Tag is string)
                            {
                                UserWizard UW = new UserWizard();

                                DialogResult DR = UW.ShowDialog(this);
                                UW.Dispose();
                                if(DR == DialogResult.OK)
                                {
                                    LoginUser = OSystem.Refresh();
                                    BuildUserHierarchy();
                                }
                                else
                                {
                                    return;
                                }
                            }
                        }
                        break;
                    case "View Recording":
                        if(treeView1.SelectedNode != null)
                        {
                            TreeNode XNode = treeView1.SelectedNode;
                            if(XNode.Tag is OysterClassLibrary.Recording)
                            {
                                g_objRecording = (OysterClassLibrary.Recording)XNode.Tag;
                                ShowDisplay(ShowRecordingInfo);
                                CurrentPlayingRecording = g_objRecording;
                                btnPlay.Enabled = false;

                                //						MediaPlayer.Height = 512;
                                //						MediaPlayer.Width = 696;
                                //						MediaPlayer.Location  = new System.Drawing.Point(pnlRecordingInfo.Location.X + 28, pnlRecordingInfo.Location.Y + 53);

                                OysterClassLibrary.VideoStorageServer VSS =  OSystem.GetVideoStorageServerById(g_objRecording.VideoStorageServerID);
                                string sRecording = "";
                                if(VSS.ControlAddress != "Not Assigned")
                                {
                                    OysterClassLibrary.VideoStorageServerType VST = VSS.CurrentVideoStorageServerType;

                                    bool UsePort = Convert.ToBoolean(VST["UsePort"]);
                                    string StreamHeader = (string)VST["StreamHeader"];
                                    string VSS_Directory = VSS.StorageDirectory;//(string)VST["OysterSourceDirectory"];
                                    if(VSS_Directory != "")
                                        sRecording = StreamHeader + VSS.ControlAddress + "/" + VSS_Directory + "/" + g_objRecording.Description;
                                    else if(UsePort == true)
                                        sRecording = StreamHeader + VSS.ControlAddress + ":" + VSS.ControlPort + "/" + VSS_Directory + "/" + g_objRecording.Description;
                                    else
                                        sRecording = StreamHeader + VSS.ControlAddress + "/" + g_objRecording.Description;
                                }
                                else
                                    sRecording = "d://" + g_objRecording.Description;
                                try
                                {
                                    WWWW.Open(sRecording);
                                    // MediaPlayer.URL = sRecording;
                                    //frmPlayer fP = new frmPlayer();
                                    //fP.sURL = sRecording;
                                    //fP.Show();
                                    gLastRecording = sRecording;
                                    //MediaPlayer.Ctlcontrols.play();
                                    //btnPlay_Click(btnPlay,new EventArgs());

                                }
                                catch(Exception Err)
                                {
                                    MessageBox.Show(Err.Message + ":" + Err.InnerException);
                                }

                                // btnPlay.Enabled = true;
                            }
                        }
                        break;
                    case "View Camera":
                        if(tvCameras.SelectedNode != null)
                        {
                            TreeNode XNode = tvCameras.SelectedNode;
                            if(XNode.Tag is OysterClassLibrary.StreamingEncoder)
                            {
                                OysterClassLibrary.StreamingEncoder SE = (OysterClassLibrary.StreamingEncoder)XNode.Tag;
                                string sURL = "";
                                switch(SE.StreamingHeader.ToLower())
                                {
                                    case "vbricksys://":
                                        sURL = SE.StreamingHeader + "ip=" + SE.StreamingAddress + "&port=" + SE.StreamingPort.ToString();

                                        break;
                                    case "vbrick://":
                                        sURL = SE.StreamingHeader + "ip=" + SE.StreamingAddress + "&port=" + SE.StreamingPort.ToString();
                                        break;
                                    default:
                                        MessageBox.Show("System not able to read header: '" + SE.StreamingHeader + "' at this time");
                                        return;
                                        break;
                                }
                                //								CameraPlayer.URL = sURL;
                                //								CameraPlayer.Ctlcontrols.play();
                            }
                        }
                        break;
                    default:
                        break;
                }
            }
            else if(e.Button == tbActionBar.Buttons[2])
            {
                switch(e.Button.Text)
                {
                    case "Record Scene":
                        TreeNode RSNode = tvCameras.SelectedNode;

                        if(RSNode.Tag is OysterClassLibrary.Room)
                        {
                            OysterClassLibrary.Room RM = (OysterClassLibrary.Room)RSNode.Tag;

                            frmRecordScene RC = new frmRecordScene();
                            RC.ThisRoom = RM;

                            DialogResult DR = RC.ShowDialog(this);
                            if(DR == DialogResult.Abort)
                            {
                                //MessageBox.Show("Detected Abort");
                            }
                            else if(DR == DialogResult.OK)
                            {
                                //MessageBox.Show("Detected OK");
                            }
                        }
                        break;
                    case "Control Camera":
                        TreeNode XNode = tvCameras.SelectedNode;
                        if(XNode.Tag is OysterClassLibrary.StreamingEncoder)
                        {
                            OysterClassLibrary.StreamingEncoder SE = (OysterClassLibrary.StreamingEncoder)XNode.Tag;

                            frmCameraControl CC = new frmCameraControl();
                            CC.CodecAddress = SE.ControlAddress;
                            CC.CodecPort = SE.ControlPort;

                            CC.ShowDialog(this);
                        }

                        break;
                    case "Delete User(s)":
                        DialogResult DR2 = new DialogResult();

                        DR2 = MessageBox.Show(this,"You have the authority to permanently delete any User in the System! For each User that you delete all of that User's Recordings will also be permanently deleted!","Show Delete User(s) Screen?",MessageBoxButtons.YesNo);
                        if(DR2 == DialogResult.No)
                            return;
                        Status(g_objUser.Description + " is preparing to delete users....");
                        Form RU = new RemoveUsers();

                        g_OAU.AllUsers = OSystem.CurrentSystemUsers;
                        g_OAU.CurrentUser = LoginUser;
                        g_OAU.CurrentBody = null;
                        g_OAU.ThisCurrentSectionType = LoginUser.HighestAuthorityLevel;
                        g_OAU.TrueDelete = true;

                        RU.Tag = g_OAU;
                        RU.ShowDialog(this);

                        if(RU.DialogResult == DialogResult.OK)
                        {
                            AdministrativeSoftware.RemoveUsers.User_List UL = (AdministrativeSoftware.RemoveUsers.User_List) RU.Tag;
                            foreach(string sUser in UL.DeletedUsers)
                                Status("Permanently deleted User: "******" has aborted Delete User operation.");
                            RU.Dispose();
                        }
                        break;
                    case "Remove User(s)":
                        if(treeView1.SelectedNode != null)
                        {
                            TreeNode XNode2 = treeView1.SelectedNode;
                            if(XNode2.Tag is OysterClassLibrary.Section)
                            {
                                g_objSection = (OysterClassLibrary.Section)XNode2.Tag;
                                DialogResult DR3 = new DialogResult();

                                OysterClassLibrary.SectionType UT = OSystem.GetSectionTypeById(g_objSection.CreatedBySectionType.NextSectionTypeID);

                                DR3 = MessageBox.Show(this,"You have the authority to remove any " + UT.Description  + " in this " + g_objSection.CreatedBySectionType.CreatesSectionTypeDescription + ". For each " + UT.Description  + " that you delete all of that " + UT.Description  + "'s recordings will also be permanently deleted!","Show Delete " + UT.Description  + "(s) Screen?",MessageBoxButtons.YesNo);
                                if(DR3 == DialogResult.No)
                                    return;

                                Form RU2 = new RemoveUsers();

                                g_OAU.AllUsers = null;
                                g_OAU.CurrentUser = null;
                                g_OAU.CurrentBody = g_objSection;
                                g_OAU.ThisCurrentSectionType = g_objSection.CreatedBySectionType;
                                g_OAU.TrueDelete = false;
                                g_OAU.iLocalMBSAddress = LocalIpAddress;

                                RU2.Tag = g_OAU;

                                RU2.ShowDialog(this);

                                if(RU2.DialogResult == DialogResult.OK)
                                {
                                    AdministrativeSoftware.RemoveUsers.User_List UL = (AdministrativeSoftware.RemoveUsers.User_List) RU2.Tag;
                                    foreach(string sUser in UL.DeletedUsers)
                                        Status("Removed User: "******" has aborted Remove User operation.");
                                    RU2.Dispose();
                                }
                            }
                        }
                        break;
                    case "Reassign Recording":
                        AdministrativeSoftware.PassRecordingInfo PRI= new AdministrativeSoftware.PassRecordingInfo();

                        ListView lvMember = new ListView();

                        OysterClassLibrary.Section B = OSystem.GetSectionById(g_objRecording.CurrentSectionID);

                        PRI.objSectionType = CurrentSectionType;
                        OysterClassLibrary.Functions F = new OysterClassLibrary.Functions();

                        OysterClassLibrary.Sections MembersOf = LoginUser.AllMemberSections;//F.GetMemberSections(LoginUser.ID,false);
                        if(PRI.objSectionType == null)
                            PRI.objSectionType = HighestSectionType;
                        F.Dispose();
                        //Check to See if B is in LoginUsers Hierarchy
                        if(!B.IsMember)
                        {
                            ListView lvCheckEm = new ListView();
                            if(B.IsDefault)
                            {
                                foreach(OysterClassLibrary.Section TSection in LoginUser.AllOwnedSections)
                                {
                                    if(!TSection.IsDefault)
                                    {
                                        bool AddToMe = true;
                                        foreach(ListViewItem LVIK in lvMember.Items)
                                        {
                                            OysterClassLibrary.Section lvMSection = (OysterClassLibrary.Section)LVIK.Tag;

                                            if(lvMSection.ID == TSection.ID)
                                            {
                                                AddToMe = false;
                                                break;
                                            }
                                        }
                                        if(AddToMe)
                                        {
                                            ListViewItem LVAM = lvMember.Items.Add(TSection.Description);
                                            LVAM.Tag = TSection;
                                        }
                                    }
                                }
                            }

                            foreach(OysterClassLibrary.Section MySection in LoginUser.AllOwnedSections)
                            {
                                if((!MySection.IsDefault)&&(MySection.CreatedBySectionType.ID != OSystem.SectionTypeSysAdmin.ID))

                                {
                                    bool AddToMe = true;
                                    foreach(ListViewItem LVJK in lvMember.Items)
                                    {
                                        OysterClassLibrary.Section lvMSection = (OysterClassLibrary.Section)LVJK.Tag;

                                        if(lvMSection.ID == MySection.ID)
                                        {
                                            AddToMe = false;
                                            break;
                                        }
                                    }
                                    if(AddToMe)
                                    {
                                        ListViewItem LVI = lvCheckEm.Items.Add(MySection.Description);
                                        LVI.Tag = MySection;
                                    }
                                }
                            }

                            if(lvCheckEm.Items.Count != 0)
                            {
                                foreach(ListViewItem TLVI in lvCheckEm.Items)
                                {
                                    OysterClassLibrary.Section S = (OysterClassLibrary.Section)TLVI.Tag;
                                    ListViewItem LII = lvMember.Items.Add(S.Description);
                                    LII.Tag = S;

                                    foreach(OysterClassLibrary.User U in S.AllUsersInHierarchy)
                                    {
                                        foreach(OysterClassLibrary.Section USection in U.AllOwnedSections)
                                        {
                                            if(S.IsSectionInMyHierarchy(USection.ID))
                                            {
                                                bool AddToMe = true;
                                                foreach(ListViewItem LVIK in lvMember.Items)
                                                {
                                                    OysterClassLibrary.Section lvMSection = (OysterClassLibrary.Section)LVIK.Tag;

                                                    if(lvMSection.ID == USection.ID)
                                                    {
                                                        AddToMe = false;
                                                        break;
                                                    }
                                                }
                                                if(AddToMe)
                                                {
                                                    ListViewItem LVAM = lvMember.Items.Add(USection.Description);
                                                    LVAM.Tag = USection;
                                                }
                                            }
                                        }
                                    }
                                }
                            }

                        }

                        if(PRI.objSectionType.ID == OSystem.SectionTypeSysAdmin.ID)
                        {
                            foreach(OysterClassLibrary.Section SystemBody in LoginUser.AllOwnedSections)
                            {
                                if(SystemBody.IsDefault == false)
                                {
                                    if(SystemBody.CreatedBySectionTypeID != OSystem.SectionTypeSysAdmin.ID)
                                    {
                                        bool AddIt = true;
                                        foreach(ListViewItem ALVI in lvMember.Items)
                                        {
                                            OysterClassLibrary.Section OS = (OysterClassLibrary.Section)ALVI.Tag;

                                            if(OS.ID == SystemBody.ID)
                                            {
                                                AddIt = false;
                                                break;
                                            }
                                        }
                                        if(AddIt)
                                        {
                                            ListViewItem LI = new ListViewItem();
                                            LI = lvMember.Items.Add(SystemBody.Description);
                                            LI.Tag = SystemBody;
                                        }
                                    }
                                    GatherAllBodys(lvMember,SystemBody.CurrentUsers);
                                }
                            }
                        }
                        else
                        {
                            if(!B.IsDefault)
                            {
                                if(B.CreatedBySectionTypeID != OSystem.SectionTypeSysAdmin.ID)
                                {
                                    bool AddIt = true;
                                    foreach(ListViewItem BLVI in lvMember.Items)
                                    {
                                        OysterClassLibrary.Section OS = (OysterClassLibrary.Section)BLVI.Tag;

                                        if(OS.ID == B.ID)
                                        {
                                            AddIt = false;
                                            break;
                                        }
                                    }
                                    if(AddIt)
                                    {
                                        ListViewItem LI = new ListViewItem();
                                        LI = lvMember.Items.Add(B.Description);
                                        LI.Tag = B;
                                    }
                                }
                                GatherAllBodys(lvMember,B.CurrentUsers);
                            }
                            foreach(OysterClassLibrary.Section M in MembersOf)
                            {
                                bool AddIt = true;
                                foreach(ListViewItem ALVI in lvMember.Items)
                                {
                                    OysterClassLibrary.Section OS = (OysterClassLibrary.Section)ALVI.Tag;

                                    if(OS.ID == M.ID)
                                    {
                                        AddIt = false;
                                        break;
                                    }
                                }
                                if(AddIt)
                                {
                                    ListViewItem LA = lvMember.Items.Add(M.Description);
                                    LA.Tag = M;
                                }
                            }
                        }
                        if(lvMember.Items.Count == 0)
                        {
                            MessageBox.Show("No Member Sections or Owned Sections detected for " + LoginUser.FirstName + " " + LoginUser.LastName +
                                " at this time.","No legal location to send recording...abort action.");
                            return;
                        }

                        PRI.CurrentUser = LoginUser;
                        PRI.Rec = g_objRecording;
                        PRI.LV = lvMember;
                        PRI.OSystem = OSystem;
                        //PRI.objSectionType = CurrentSectionType;

                        Form RA = new frmMoveRecording();

                        RA.Tag = PRI;

                        RA.ShowDialog(this);

                        if(RA.DialogResult == DialogResult.OK)
                        {
                            LoginUser = OSystem.Refresh();
                            BuildUserHierarchy();
                        }
                        else
                            RA.Dispose();
                        break;
                    default:
                        break;
                }
            }
            else if(e.Button == tbActionBar.Buttons[4])
            {
                string sEditButton = "Edit " + g_objSection.CreatedBySectionType.CreatesSectionTypeDescription;

                if(e.Button.Text == sEditButton) //Edit Section
                {
                    if(treeView1.SelectedNode != null)
                    {
                        TreeNode XNode = treeView1.SelectedNode;
                        if(XNode.Tag is OysterClassLibrary.Section)
                        {
                            SectionWizard SW = new SectionWizard();
                            PassSectionInfo PSI = new PassSectionInfo();
                            PSI.CurrentSection = (OysterClassLibrary.Section)XNode.Tag;
                            PSI.PreviousSection = PSI.CurrentSection.PreviousSection;
                            PSI.OSystem = OSystem;
                            PSI.CurrentUser = LoginUser;
                            PSI.IsEdit = true;
                            SW.Tag = PSI;
                            DialogResult DR = SW.ShowDialog(this);
                            SW.Dispose();
                            if(DR == DialogResult.Abort)
                            {
                                MessageBox.Show("Edit " + PSI.CurrentSection.Description + " failed");
                            }
                            else if(DR == DialogResult.OK)
                            {
                                LoginUser = OSystem.Refresh();
                                BuildUserHierarchy();
                            }
                        }
                    }
                }
                else if(e.Button.Text == "Remove User")
                {
                    //User doesn't exist
                    System.Windows.Forms.DialogResult DR = new System.Windows.Forms.DialogResult();
                    bool bSuccess = false;
                    TreeNode X = null;
                    //int ErrorNumber = 0;
                    if(g_objUser == null)
                    {
                        X = treeView1.SelectedNode;
                        if(X == null)return;
                        g_objUser = (OysterClassLibrary.User)X.Tag;
                    }

                    if(g_objUser == null)return;

                    string UserName = g_objUser.FirstName + " " + g_objUser.MiddleName + ". " + g_objUser.LastName;
                    DR = System.Windows.Forms.MessageBox.Show("Removing " + UserName + " will delete any of " +
                        UserName + " recordings that are assigned to " + g_objUser.CurrentSection.Description + ".", "Do you wish to proceed with Remove User?", System.Windows.Forms.MessageBoxButtons.YesNo);
                    if(DR == DialogResult.Yes)
                    {
                        OysterClassLibrary.Functions F = new OysterClassLibrary.Functions();

                        try
                        {
                            //OysterClassLibrary.Functions F = new OysterClassLibrary.Functions();
                            try
                            {
                                F.RemoveUser(g_objUser.ID,g_objUser.CurrentSectionID);
                                F.Dispose();

                                g_objSection = g_objUser.CurrentSection;
                                bSuccess = true;
                            }
                            catch(Exception Err)
                            {
                                string peekError = Err.Message;
                                bSuccess = false;
                            }
                            //       bSuccess = objBody.DestroyUser(g_objUser,false,ref ErrorNumber);
                            if(bSuccess ==true)
                            {

                                Status("Successfully Removed " + g_objUser.Description + " from " + g_objSection.Description);

                                LoginUser = OSystem.Refresh();
                                BuildUserHierarchy();
                                ShowDisplay(ShowGroupInfo);
                            }
                        }
                        catch(Exception Err)
                        {
                            MessageBox.Show(Err.Message);
                            return;
                        }
                    }
                }
                else if(e.Button.Text == "Rename Recording")
                {
                    UpdateRecording RR = new UpdateRecording();

                    RR.Tag = g_objRecording;
                    RR.ShowDialog(this);

                    if(RR.DialogResult == DialogResult.OK)
                    {
                        BuildUserHierarchy();
                        //ShowDisplay(ShowRecordingInfo);
                        Status("Rename Recording completed.");
                        RR.Dispose();
                    }
                    else
                        Status("Aborted Rename Recording operation.");
                    RR.Dispose();
                }
                else
                {
                    switch(e.Button.Text)
                    {
                        default:
                            break;
                    }
                }
            }
            else if(e.Button == tbActionBar.Buttons[6])
            {
                string sNewSection = "";
                string sDeleteSection = "";
                string sSType = "";
                //TreeNode YNode = treeView1.SelectedNode;
                if(treeView1.SelectedNode.Tag is OysterClassLibrary.User)
                {
                    sSType = g_objUser.CurrentSection.CreatedBySectionType.NextSectionType.CreatesSectionTypeDescription;
                    sNewSection = "New " + sSType;
                }
                else if(treeView1.SelectedNode.Tag is OysterClassLibrary.Section)
                {
                    if(g_objSection.ID == MainSystemSection.ID)
                    {
                        sSType = g_objSection.CreatedBySectionType.NextSectionType.CreatesSectionTypeDescription;

                    }
                    else
                    {
                        sSType = g_objSection.CreatedBySectionType.CreatesSectionTypeDescription;
                    }
                    sDeleteSection = "Delete " + sSType;
                    sNewSection = "New " + sSType;

                }
                if(e.Button.Text == sNewSection)
                {
                    if(treeView1.SelectedNode != null)
                    {
                        TreeNode XNode = treeView1.SelectedNode;
                        if(XNode.Tag is OysterClassLibrary.Section)
                        {
                            SectionWizard SW = new SectionWizard();
                            PassSectionInfo PSI = new PassSectionInfo();
                            PSI.PreviousSection = (OysterClassLibrary.Section)XNode.Tag;
                            PSI.OSystem = OSystem;
                            PSI.CurrentUser = LoginUser;
                            PSI.IsEdit = false;
                            SW.Tag = PSI;
                            DialogResult DR = SW.ShowDialog(this);
                            SW.Dispose();
                            if(DR == DialogResult.Abort)
                            {
                                MessageBox.Show("Create New " + PSI.CurrentSection.CreatedBySectionType.NextSectionType.CreatesSectionTypeDescription + " failed");
                            }
                            else if(DR == DialogResult.OK)
                            {
                                LoginUser = OSystem.Refresh();
                                BuildUserHierarchy();
                            }

                        }
                        else if(XNode.Tag is OysterClassLibrary.User)
                        {
                            OysterClassLibrary.User UU = (OysterClassLibrary.User)XNode.Tag;
                            SectionWizard SW = new SectionWizard();
                            PassSectionInfo PSI = new PassSectionInfo();
                            PSI.PreviousSection = UU.CurrentSection;
                            PSI.CurrentUser = UU;
                            PSI.OSystem = OSystem;
                            PSI.IsEdit = false;
                            SW.Tag = PSI;
                            DialogResult DR = SW.ShowDialog(this);
                            SW.Dispose();
                            if(DR == DialogResult.Abort)
                            {
                                MessageBox.Show("Create New " + PSI.PreviousSection.CreatedBySectionType.NextSectionType.CreatesSectionTypeDescription + " failed");
                            }
                            else if(DR == DialogResult.OK)
                            {
                                LoginUser = OSystem.Refresh();
                                BuildUserHierarchy();
                            }
                        }
                    }
                }
                else if(e.Button.Text == sDeleteSection)
                {
                    if(treeView1.SelectedNode != null)
                    {
                        TreeNode XNode = treeView1.SelectedNode;
                        if(XNode.Tag is OysterClassLibrary.Section)
                        {
                            System.Windows.Forms.DialogResult DR = new System.Windows.Forms.DialogResult();
                            bool bSuccess = false;

                            DR = System.Windows.Forms.MessageBox.Show("Destroying " + g_objSection.Description + " will permanently destroy ALL Recordings that have been assigned to this " + sSType,"Do you wish to proceed with Delete " + sSType + "?",System.Windows.Forms.MessageBoxButtons.YesNo);

                            if(DR == DialogResult.Yes)
                            {
                                Status(LoginUser.Description + " gave order to proceed with deletion...");
                                OysterClassLibrary.Functions F = new OysterClassLibrary.Functions();
                                OysterClassLibrary.User objUser = F.GetUser(g_objSection.OwnerID);
                                if(objUser == null)
                                    return;
                                try
                                {
                                    F.RemoveSection(g_objSection.ID);
                                    F.Dispose();
                                    bSuccess = true;
                                }
                                catch(Exception Err)
                                {
                                    string peekerror = Err.Message;
                                    F.Dispose();
                                    bSuccess = false;
                                }

                                if(bSuccess ==true)
                                {
                                    Status("Successfully deleted: " + g_objSection.Description);
                                    //cbSectionType.Items.Clear();
                                    //cbSectionType.Text = "";
                                    LoginUser = OSystem.Refresh();
                                    BuildUserHierarchy();
                                    ShowDisplay(ShowGroupInfo);
                                }
                            }
                        }
                    }
                }
                else if(e.Button.Text == "Delete Recording")
                {
                    DialogResult DR = new DialogResult();
                    if((btnPlay.Enabled == true)||(btnPause.Enabled == true)||(btnStop.Enabled == true))
                    {
                        try
                        {
                            //                            MediaPlayer.Ctlcontrols.stop();
                            if(gLastRecording != "")
                            {
                                try
                                {
                                    // MediaPlayer.URL = "";
                                }
                                catch(Exception Err)
                                {
                                    string peekerror = Err.Message;
                                }
                            }
                            btnPlay.Enabled = false;

                        }
                        catch(Exception Err)
                        {
                            MessageBox.Show(Err.Message);
                        }

                    }

                    DR = MessageBox.Show(this,"Do you wish to permanently delete tne recording: '" + g_objRecording.DisplayName + "'","Deleting Recording",MessageBoxButtons.YesNo);

                    if(DR == DialogResult.No)
                        return;
                    OysterClassLibrary.Functions F = new OysterClassLibrary.Functions();

                    TreeNode X = treeView1.SelectedNode;
                    string test = X.Text;
                    X = X.Parent;
                    test = X.Text;
                    OysterClassLibrary.Section B = F.GetSection(g_objRecording.CurrentSectionID);

                    if(g_objRecording.CurrentUserID == g_objRecording.OwnerID)
                    {
                        int CurrentUser = 0;
                        if(g_objUser == null)
                        {
                            if(g_objRecording.CurrentUserID == 0)
                                CurrentUser = LoginUser.ID;
                            else
                                CurrentUser = g_objRecording.CurrentUserID;
                        }
                        else
                            CurrentUser = g_objUser.ID;
                        try
                        {
                            F.RemoveRecording(g_objRecording.ID,CurrentUser,B.ID);
                            LoginUser = OSystem.Refresh();
                        }
                        catch(Exception Err)
                        {
                            MessageBox.Show(Err.Message,"Error occurred during Delete Recording operation");
                        }
                        BuildUserHierarchy();
                        return;
                    }
                    else  // test == "Recordings" which means all we have to do is go up till we find the body it is attached to
                    {
                        try
                        {
                            F.RemoveRecording(g_objRecording.ID,g_objRecording.CurrentUserID,g_objRecording.CurrentSectionID);
                            LoginUser = OSystem.Refresh();
                            BuildUserHierarchy();
                            return;
                        }
                        catch(Exception Err)
                        {
                            MessageBox.Show(Err.Message);
                            return;
                        }
                    }
                }
                else
                {
                    switch(e.Button.Text)
                    {
                        default:
                            break;
                    }
                }
            }
            else if(e.Button == tbActionBar.Buttons[8])
            {
                if(e.Button.Text == "View Notes")
                {
                    if(FN != null)
                    {
                        if(FN.IsDisposed != true)
                        {
                            FN.Dispose();
                        }
                    }
                    FN = new frmNotes();
                    FN.Owner = this;
                    LastSelectedRecording = g_objRecording;
                    FN.Show();
                }
            }
        }