/// <summary>加载会议分组用户</summary>
        private void LoadMeetingGroupMember()
        {
            #region 临时会议操作Tab页
            AddMeetingGroup(MeetingGroupModel.EnumMeetingState.Off, MeetingGroupModel.EnumMeetingType.Lemc, 0, 0, "临时会议", new List<DB_Talk.Model.m_Member>(), 0, true);
            #endregion
            

            #region 加载紧急选选人用的Tab页
            
            
            List<DB_Talk.Model.m_Member> lstLemcMember = new List<DB_Talk.Model.m_Member>();
            foreach (SingleUserControl item in Pub._memberManage._lstGroup[0].lstControl)
            {
                lstLemcMember.Add(new DB_Talk.Model.m_Member()
                {
                    i_Number = item.Number,
                    vc_Name = item.MemberName,
                    i_TellType = item.TellType.GetHashCode(),
                    ID=item.ID
                });
            }
            AddMeetingGroup(MeetingGroupModel.EnumMeetingState.Off, MeetingGroupModel.EnumMeetingType.Lemc, 0, 0, "临时会议选人用", lstLemcMember, 0,false );

            #endregion

            #region 固定分组
            
            
            List<DB_Talk.Model.m_Group> lstGroup = new DB_Talk.BLL.m_Group().GetModelList(string.Format("i_Flag=0 and groupTypeID={0} and BoxID={1}", PublicEnums.EnumGroupType.Meeting.GetHashCode(),Pub.manageModel.BoxID.Value));
            foreach (DB_Talk.Model.m_Group item in lstGroup)
            {
                List<DB_Talk.Model.v_GroupMembers> lstGroupMember = new DB_Talk.BLL.v_GroupMembers().GetModelList("groupid=" + item.ID);

                List<DB_Talk.Model.m_Member> lstMember = new List<DB_Talk.Model.m_Member>();
                foreach (DB_Talk.Model.v_GroupMembers gitem in lstGroupMember)
                {
                    if (gitem.i_Number != Pub.manageModel.LeftDispatchNumber && gitem.i_Number != Pub.manageModel.RightDispatchNumber)
                    {
                        lstMember.Add(new DB_Talk.Model.m_Member()
                        {
                            i_Number = gitem.i_Number,
                            vc_Name = gitem.vc_Name,
                            i_TellType = gitem.i_TellType,
                            ID=gitem.ID
                        });
                    }
                }
                AddMeetingGroup(MeetingGroupModel.EnumMeetingState.Off, MeetingGroupModel.EnumMeetingType.Formal, item.ID, 0, item.vc_Name, lstMember,0,true);
            }
            #endregion

           
        }
 private bool LoadReport()
 {
     try
     {
         AcrManage.AddVariable(this.dgvLeft);
         AcrManage.AddVariable(this.dgvRight);
         AcrManage.FillDataTableToAcFromGridView(this.dgvLeft, "m_Group");
         string strW = ("i_Flag=0 and BoxID='" + Global.Params.BoxID + "' and GroupTypeID='" + GroupType.GetHashCode() + "'");
         string sql = "select GroupID, vc_Name as 名称,i_Number as 电话,vc_Memo as 备注" +
                  " from v_GroupMembers where " + strW;
         DataSet ds = new DB_Talk.BLL.v_GroupMembers().GetListSql(sql);
         ds.Tables[0].TableName = "v_GroupMembers";
         AcrManage.CopyDataTableToAC(ds.Tables[0]);
         return true;
     }
     catch
     {
         return false;
     }
    
    
 }
        public int LoadDataRight()
        {
            if (dgvLeft.Rows.Count == 0) dgvRight.Rows.Clear();
            if (_selectLeftListIndex < 0) return 0;
            sbMemberID.Clear();
            dgvRight.Rows.Clear();
            try
            {
                string GroupID = dgvLeft.Rows[_selectLeftListIndex].Cells["colID"].Value.ToString();

                List<DB_Talk.Model.v_GroupMembers> lst = new List<DB_Talk.Model.v_GroupMembers>();
                lst = new DB_Talk.BLL.v_GroupMembers().GetModelList(" GroupID='" + GroupID + "' and BoxID='" + Global.Params.BoxID + "'");
                int i = 0;
                foreach (DB_Talk.Model.v_GroupMembers item in lst)
                {
                    i++;
                    dgvRight.Rows[dgvRight.Rows.Add(i,
                        item.vc_Name,
                        item.i_Number,
                        item.vc_Memo,
                        item.ID
                        )].Tag = item;
                    sbMemberID.Append("," + item.MemberID);
                }
                if (sbMemberID.Length > 0) sbMemberID.Remove(0, 1);
                kryptonHeaderGroup2.ValuesSecondary.Heading = "  共" + dgvRight.Rows.Count.ToString() + "条记录";
                dgvLeft.Rows[_selectLeftListIndex].Cells["colMemberCount"].Value = dgvRight.Rows.Count;
            }
            catch { }
           
            return dgvLeft.Rows.Count;
        }
 public int LoadDataLeft()
 {
     dgvLeft.Rows.Clear();
     List<DB_Talk.Model.m_Group> lst = new List<DB_Talk.Model.m_Group>();
     lst = new DB_Talk.BLL.m_Group().GetModelList("i_Flag=0 and GroupTypeID='" + 
                                                GroupType.GetHashCode() + "' and BoxID='"+Global.Params.BoxID+"'" );
    
     int i = 0;
     foreach (DB_Talk.Model.m_Group item in lst)
     {
         i++;
         List<DB_Talk.Model.v_GroupMembers> lstMember = new DB_Talk.BLL.v_GroupMembers().GetModelList(" GroupID='" + item.ID+ 
                                                        "' and BoxID='" + Global.Params.BoxID + "'");
         dgvLeft.Rows[dgvLeft.Rows.Add(i,
             item.vc_Name,
             item.vc_Memo,
             lstMember.Count,
             item.ID
             )].Tag = item;
     }
     kryptonHeaderGroup1.ValuesSecondary.Heading = "  共" + dgvLeft.Rows.Count.ToString() + "条记录";
     if (lst.Count == 0) _selectLeftListIndex = -1;
     // Tools.AcrReportManage.Current.RefushDataset(true);
     //loadReport();
     return lst.Count;
 }
        /// <summary>加载分组用户</summary>
        private void LoadGroupMember()
        {
            List<DB_Talk.Model.m_Group> lstGroup = new DB_Talk.BLL.m_Group().GetModelList(string.Format("i_Flag=0 and groupTypeID={0} and BoxID={1}", PublicEnums.EnumGroupType.Normal.GetHashCode(),Pub.manageModel.BoxID.Value));
            int index = 1;//因为前面已加过两个了
            foreach (DB_Talk.Model.m_Group item in lstGroup)
            {
                index++;
                 NormalGroupModel gModel = new NormalGroupModel();
                 _lstGroup.Add(gModel);
                SuperTabItem a = new SuperTabItem();
                a.Text = item.vc_Name;
                a.SelectedTabFont = new System.Drawing.Font("宋体", 16F, System.Drawing.FontStyle.Bold);
                superTabLinearGradientColorTable1.Colors = new System.Drawing.Color[] {
        System.Drawing.Color.FromArgb(((int)(((byte)(36)))), ((int)(((byte)(41)))), ((int)(((byte)(48))))),
        System.Drawing.Color.FromArgb(((int)(((byte)(95)))), ((int)(((byte)(113)))), ((int)(((byte)(130)))))};
                superTabItemStateColorTable1.Background = superTabLinearGradientColorTable1;
                superTabColorStates1.Selected = superTabItemStateColorTable1;
                superTabItemColorTable1.Bottom = superTabColorStates1;
                a.TabColor = superTabItemColorTable1;
                a.Tag = index;
                a.Click += new EventHandler(_mainForm.MemberTabItem_Click);

                Pub.SetSupperTabColor(a);

                _mainForm.superTabControlDispatch.Tabs.Add(a);


                SuperTabControlPanel sp = new SuperTabControlPanel();
                _mainForm.superTabControlDispatch.Controls.Add(sp);
                a.AttachedControl = sp;
                

                PageControl fp = new PageControl();
                sp.Controls.Add(fp);
                fp.Dock = DockStyle.Fill;

                gModel.PageControl = fp;
                List<DB_Talk.Model.v_GroupMembers> lstGroupMember = new DB_Talk.BLL.v_GroupMembers().GetModelList("groupid=" + item.ID);
                foreach (DB_Talk.Model.v_GroupMembers gItem in lstGroupMember)
                {
                    if (gItem.i_Number.Value != Pub.manageModel.LeftDispatchNumber.Value && gItem.i_Number.Value != Pub.manageModel.RightDispatchNumber.Value )
                    {
                        SingleUserControl sc = new SingleUserControl();
                        sc.MemberName = gItem.vc_Name;
                        sc.Number = gItem.i_Number.Value;
                        sc.ID = gItem.MemberID.Value;
                        if (gItem.DepartmentID!=null)
                        {
                            sc.DepartmentID = gItem.DepartmentID.Value;    
                        }

                        if (gItem.i_TellType != null)
                        {
                            sc.TellType = (CommControl.PublicEnums.EnumTelType)gItem.i_TellType.Value;
                        }

                        gModel.lstControl.Add(sc);
                        sc.Click += new EventHandler(_mainForm.single_Click);
                    }
                }
                fp.Init(gModel.lstControl);
            }
        }
        /// <summary>
        /// 删除正式会议成员
        /// </summary>
        /// <param name="model"></param>
        /// <param name="meetingID"></param>
        /// <param name="number"></param>
        private void DeleteFormlMeetingMember(SuperTabItem sti,MeetingGroupModel model, long number)
        {
            List<DB_Talk.Model.v_GroupMembers> lstGroupMember = new DB_Talk.BLL.v_GroupMembers().GetModelList("groupid=" + model.GroupID);

            DB_Talk.Model.v_GroupMembers member = lstGroupMember.Find(m => m.i_Number == number);

            if (member == null)//说明是邀请过来的
            {
                model.lstControl.Remove(model.lstControl.Find(p => p.Number == number));
            }
            //int tempCount = model.lstControl.Count;
            //for (int j = tempCount - 1; j >= 0; j--)
            //{
            //    bool isFind = false;
            //    foreach (DB_Talk.Model.v_GroupMembers mem in lstGroupMember)
            //    {
            //        if (model.lstControl[j].Number == mem.i_Number.Value)
            //        {
            //            isFind = true;
            //            break;
            //        }
            //    }
            //    if (isFind == false)
            //    {
            //        model.lstControl.Remove(model.lstControl[j]);
            //    }
            //}
            Pub.CanDestroyControl = false;
            model.pageControl.Init(model.lstControl);
            Pub.CanDestroyControl = true;

            List<SingleUserControl> lstControl = model.lstControl.FindAll(p =>
                    p.UserLineStatus == TalkControl.EnumUserLineStatus.Busy
                    || p.UserLineStatus == TalkControl.EnumUserLineStatus.Forbid
                    || p.UserLineStatus == TalkControl.EnumUserLineStatus.Isolate
                    || p.UserLineStatus == TalkControl.EnumUserLineStatus.Ring
                    || p.UserLineStatus == TalkControl.EnumUserLineStatus.Record
                    );

            if (lstControl != null && lstControl.Count > 0)
            {

            }
            else
            {
                model.MeetingState = MeetingGroupModel.EnumMeetingState.Off;
                sti.RaiseClick();
            }

            //bool allIdel = true;//所有都空闲改变会议状态为结束
            ////
            //foreach (SingleUserControl item in model.lstControl)
            //{
            //    if (item.UserLineStatus == TalkControl.EnumUserLineStatus.Busy)
            //    {
            //        allIdel = false;
            //        break;
            //    }
            //}
            //if (allIdel)
            //{
            //    model.MeetingState = MeetingGroupModel.EnumMeetingState.Off;
             //_mainForm.superTabControlMeeting.Tabs[i].RaiseClick();
            //}
        }
        /// <summary>删除会议分组</summary>
        /// <param name="meetingDBID"></param>
        /// <param name="meetingID"></param>
        public void DeleteMeeting(int meetingID)
        {
            for (int i = 0; i < _mainForm.superTabControlMeeting.Tabs.Count; i++)
            {
                MeetingGroupModel model = (MeetingGroupModel)_mainForm.superTabControlMeeting.Tabs[i].Tag;
                if (model.MeetingState == MeetingGroupModel.EnumMeetingState.Running
                   && model.MeetingID == meetingID
                   && model.MeetingType == MeetingGroupModel.EnumMeetingType.Lemc)
                {
                    model.MeetingState = MeetingGroupModel.EnumMeetingState.Off;
                }

                if (model.MeetingState == MeetingGroupModel.EnumMeetingState.Running
                    && model.MeetingID == meetingID
                    && model.MeetingType == MeetingGroupModel.EnumMeetingType.Temp)
                {
                    if (i < _mainForm.superTabControlMeeting.Tabs.Count)
                    {
                        if (_mainForm.InvokeRequired)
                        {
                            System.Console.WriteLine("开始:_mainForm.InvokeRequired");
                            _mainForm.Invoke(new EventHandler(delegate(object o, EventArgs e)
                            {
                                try
                                {
                                    _mainForm.superTabControlMeeting.Tabs.Remove(_mainForm.superTabControlMeeting.Tabs[i]);
                                    _lstGroup.Remove(model);
                                    if (_mainForm.superTabControlMeeting.SelectedTab != null)
                                    {
                                        _mainForm.superTabControlMeeting.SelectedTab.RaiseClick();
                                    }
                                }
                                catch (Exception)
                                {


                                }
                            }));
                            System.Console.WriteLine("结束:_mainForm.InvokeRequired");
                        }
                        else
                        {
                            try
                            {
                                _mainForm.superTabControlMeeting.Tabs.Remove(_mainForm.superTabControlMeeting.Tabs[i]);
                                _lstGroup.Remove(model);
                                if (_mainForm.superTabControlMeeting.SelectedTab != null)
                                {
                                    _mainForm.superTabControlMeeting.SelectedTab.RaiseClick();
                                }
                            }
                            catch (Exception)
                            {


                            }
                        }
                    }
                }

                ///删除会议内成员
                if (model.MeetingID==meetingID && model.MeetingState== MeetingGroupModel.EnumMeetingState.Running && model.MeetingType == MeetingGroupModel.EnumMeetingType.Formal)
                {
                    model.MeetingState = MeetingGroupModel.EnumMeetingState.Off;
                    _mainForm.superTabControlMeeting.Tabs[i].RaiseClick();

                    List<DB_Talk.Model.v_GroupMembers> lstGroupMember = new DB_Talk.BLL.v_GroupMembers().GetModelList("groupid=" + model.GroupID);

                    int tempCount = model.lstControl.Count;
                    for (int j = tempCount-1; j >=0; j--)
                    {
                        bool isFind = false;
                        foreach (DB_Talk.Model.v_GroupMembers mem in lstGroupMember)
                        {
                            if (model.lstControl[j].Number == mem.i_Number.Value)
                            {
                                isFind = true;
                                break;
                            }
                        }
                        if (isFind == false)
                        {
                            model.lstControl.Remove(model.lstControl[j]);
                        }
                       // model.lstControl[j].PeerNumber = "0";
                    }
                    Pub.CanDestroyControl = false;
                    model.pageControl.Init(model.lstControl);
                    Pub.CanDestroyControl = true;
                }
            }
        }