private void InitCmb()
        {
            //部门
            List<DB_Talk.Model.m_Departments> list = new DB_Talk.BLL.m_Departments().GetModelList("i_Flag=0");
            cmbDept.DataSource = list;
            cmbDept.DisplayMember = "vc_Name";
            cmbDept.ValueMember = "ID";
            cmbDept.SelectedIndex = -1;
            if (_operate == 1)
            {
                if (_mModel.DepartmentID != null)
                {
                    foreach (DB_Talk.Model.m_Departments d in cmbDept.Items)
                    {
                        if (d.ID.ToString() == _mModel.DepartmentID.ToString())
                        {
                            cmbDept.SelectedItem = d;
                            break;
                        }
                    }
                }
            }
            if (list.Count == 0)
            {
                cmbDept.DataSource = null;
                cmbDept.Items.Add(" ");
            }


            //密码模式
            System.Data.DataTable dtPasswordType = new DataTable();
            dtPasswordType.Columns.Add("ID");
            dtPasswordType.Columns.Add("vc_Name");

            Type PasswordType = typeof(PublicEnums.EnumTelPasswordType);  //.EnumNumberType);
            foreach (PublicEnums.EnumTelPasswordType t in Enum.GetValues(PasswordType))
            {
                dtPasswordType.Rows.Add(t.GetHashCode(), t.ToString());
            }
            cmbPassword.DataSource = dtPasswordType;
            cmbPassword.DisplayMember = "vc_Name";
            cmbPassword.ValueMember = "ID";
            cmbPassword.SelectedIndex = -1;
            if (_operate == 1)
            {
                if (_mModel.i_NuPasswordType != null)
                {
                    foreach (DataRowView d in cmbPassword.Items)
                    {
                        if (d["ID"].ToString() == _mModel.i_NuPasswordType.ToString())
                        {
                            cmbPassword.SelectedItem = d;
                            break;
                        }
                    }
                    if (cmbPassword.SelectedIndex == 1) txtPassword.Enabled = false;
                }
            }
            else if(_operate==0)
            {
                if (dtPasswordType.Rows.Count > 0)
                {
                    cmbPassword.SelectedIndex = 1;  //默认增加,即和号码相同
                    _mModel.i_NuPasswordType = 2;  //密码模式
                    txtPassword.Enabled = false;
                    
                }
            }
           



            //号码类型
            System.Data.DataTable dtNoType = new DataTable();
            dtNoType.Columns.Add("ID");
            dtNoType.Columns.Add("vc_Name");

            Type noType = typeof(PublicEnums.EnumTelType);  //.EnumNumberType);
            foreach (PublicEnums.EnumTelType t in Enum.GetValues(noType))
            {
                if (t == PublicEnums.EnumTelType.调度席话机) continue;
                else if (t == PublicEnums.EnumTelType.G3G手机)
                {
                    if (Global.Params.BoxType == MBoxSDK.ConfigSDK.EnumDeviceType.T_HT8000_3G)  //目前只有800B支持3G
                        dtNoType.Rows.Add(t.GetHashCode(), t.ToString().Substring(1));
                }
                else
                    dtNoType.Rows.Add(t.GetHashCode(), t.ToString());
            }
            cmbNoType.DataSource = dtNoType;
            cmbNoType.DisplayMember = "vc_Name";
            cmbNoType.ValueMember = "ID";
            cmbNoType.SelectedIndex = -1;
            if (_operate == 1)
            {
                if (_mModel.i_TellType != null)
                {
                    foreach (DataRowView d in cmbNoType.Items)
                    {
                        if (d["ID"].ToString() == _mModel.i_TellType.ToString())
                        {
                            cmbNoType.SelectedItem = d;
                            break;
                        }
                    }
                }
                // cmbNoType.Enabled = false;
            }
            else if (_operate == 0)
            {
                if (dtNoType.Rows.Count > 0)
                {
                    cmbNoType.SelectedIndex = 0;  //默认wifi手机
                    _mModel.NumberTypeID = 4;  //用户类型
                    _mModel.i_TellType = 1;    //电话类型
                }
            }
            

            //号码级别,默认为空即最低级别
            System.Data.DataTable dtNoLevel = new DataTable();
            dtNoLevel.Columns.Add("ID");
            dtNoLevel.Columns.Add("vc_Name");

            Type Level = typeof(PublicEnums.EnumLevel);
            foreach (PublicEnums.EnumLevel l in Enum.GetValues(Level))
            {
                if (l == PublicEnums.EnumLevel.none) continue;
                dtNoLevel.Rows.Add(l.GetHashCode(), l.ToString());
            }

            cmbNumberLevel.DataSource = dtNoLevel;
            cmbNumberLevel.DisplayMember = "vc_Name";
            cmbNumberLevel.ValueMember = "ID";
            cmbNumberLevel.SelectedIndex = -1;
            if (_operate == 1)
            {
                if (_mModel.LevelID != null)
                {
                    foreach (DataRowView d in cmbNumberLevel.Items)
                    {
                        if (d["ID"].ToString() == _mModel.LevelID.ToString())
                        {
                            cmbNumberLevel.SelectedItem = d;
                            break;
                        }
                    }
                }
            }


            //用户权限
            System.Data.DataTable dtNoAuthority = new DataTable();
            dtNoAuthority.Columns.Add("ID");
            dtNoAuthority.Columns.Add("vc_Name");

            Type Au = typeof(PublicEnums.EnumAuthority);
            foreach (PublicEnums.EnumAuthority a in Enum.GetValues(Au))
            {
                if (a == PublicEnums.EnumAuthority.none) continue;
                dtNoAuthority.Rows.Add(a.GetHashCode(), a.ToString());
            }

            cmbAuthority.DataSource = dtNoAuthority;
            cmbAuthority.DisplayMember = "vc_Name";
            cmbAuthority.ValueMember = "ID";
            cmbAuthority.SelectedIndex = -1;  //默认内部分机
            if (_operate == 1)
            {
                if (_mModel.i_Authority != null)
                {
                    foreach (DataRowView d in cmbAuthority.Items)
                    {
                        if (d["ID"].ToString() == _mModel.i_Authority.ToString())
                        {
                            cmbAuthority.SelectedItem = d;
                            break;
                        }
                    }
                }
            }
            else if(_operate==0)
            {
                cmbAuthority.SelectedIndex = 3;  //默认内部分机
                _mModel.i_Authority = 3;  //内部分机
            }

        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DB_Talk.Model.m_Member DataRowToModel(DataRow row)
        {
            DB_Talk.Model.m_Member model = new DB_Talk.Model.m_Member();
            if (row != null)
            {
                try
                {
                    model.BoxID = Global.Params.BoxID;
                    //model.NumberTypeID = 4;// CommControl.PublicEnums.EnumNumberType.SIP.GetHashCode();
                    //姓名
                    string strName = row["用户姓名"].ToString().Replace(" ", "");
                    bool CheckLen = strName.Length <=  Global.Params.ConfigModel.SystemConfig.MaxNameTextLengh;
                    if (Global.Params.ConfigModel.SystemConfig.MaxNameTextLengh == 0)
                        CheckLen = true;

                    if (row["用户姓名"] != null && strName != "" &&
                        CheckLen && 
                        checkFormat(false, ref strName, false))
                    {
                        model.vc_Name = strName;
                    }
                    else
                    {
                        return model=null;
                    }

                    //电话
                    string strTel = row["电话号码"].ToString().Replace(" ","");
                    if (row["电话号码"] != null && strTel != "" &&
                        strTel.Length == Global.Params.NumberLen &&
                        checkFormat(true, ref strTel, false))
                    {
                        string str = strTel.Trim().Substring(0, 1);
                        if (Global.Params.strNumHead.IndexOf(str) < 0)
                        {
                            return model = null;
                        }
                        model.i_Number = int.Parse(strTel);

                    }
                    else
                    {
                        return model = null;
                    }
                    if (model.i_Number > Math.Pow(10, Global.Params.NumberLen) - 1) return model = null;

                    //部门
                    string strDept = row["部门"].ToString().Replace(" ", "");
                    if (row["部门"] != null && strDept != "" && strDept.Length <= 10)
                    {
                       
                        DB_Talk.Model.m_Departments modelDept = new DB_Talk.BLL.m_Departments().GetModel("i_Flag=0 and vc_Name='" + strDept + "'");
                        if (modelDept != null)
                            model.DepartmentID = modelDept.ID;
                        else  //无部门时添加部门
                        {
                            modelDept = new DB_Talk.Model.m_Departments();
                            modelDept.vc_Name = strDept;
                            model.DepartmentID = new DB_Talk.BLL.m_Departments().Add(modelDept, true);
                        }
                    }
                    

                    //用户权限
                    if (row["用户权限"] != null && row["用户权限"].ToString() != "")
                    {
                        string strAuthority = row["用户权限"].ToString().Replace(" ", "");
                        switch (strAuthority)
                        {
                            case "国际长途":
                                model.i_Authority = 0;
                                break;
                            case "国内长途":
                                model.i_Authority = 1;
                                break;
                            case "市话":
                                model.i_Authority = 2;
                                break;
                            case "内部分机":
                                model.i_Authority = 3;
                                break;
                            case "禁止主叫":
                                model.i_Authority = 4;
                                break;

                            default:
                                return model = null;
                        }
                    }
                    else
                    {
                        return model = null;
                    }

                    //号码类型
                    if (row["电话类型"] != null && row["电话类型"].ToString() != "")
                    {
                        string strTellType = row["电话类型"].ToString().Replace(" ", "").ToUpper();
                        switch (strTellType)
                        {
                            case "WIFI手机":
                                model.i_TellType = PublicEnums.EnumTelType.WiFi手机.GetHashCode();
                                model.NumberTypeID = PublicEnums.EnumNumberType.手机Wifi.GetHashCode();
                                model.i_NuPasswordType = PublicEnums.EnumTelPasswordType.增加.GetHashCode();
                                model.i_NuPassword = (uint)model.i_Number;
                                break;
                            case "3G手机":
                                if (Global.Params.BoxType == MBoxSDK.ConfigSDK.EnumDeviceType.T_HT8000_3G)  //目前只有800B支持3G)
                                {
                                    model.i_TellType = PublicEnums.EnumTelType.G3G手机.GetHashCode();
                                    model.NumberTypeID = PublicEnums.EnumNumberType.手机3G.GetHashCode();
                                    if (row["标示码"] != null && row["标示码"].ToString() != "")
                                    {
                                        string strUmtsImsi = row["标示码"].ToString().Replace(" ", "");
                                        if (strUmtsImsi.Length == Global.Params.UmtsImsiLen)
                                            model.vc_UmtsImsi = strUmtsImsi;
                                        else
                                            return model = null;
                                    }
                                }
                                else
                                {
                                    return model = null;
                                }
                              
                                break;
                            case "固话":  //wifi和固话 默认密码为增加模式 与号码相同
                                 model.i_TellType = PublicEnums.EnumTelType.固话.GetHashCode();
                                 model.NumberTypeID = PublicEnums.EnumNumberType.固话.GetHashCode();
                                 model.i_NuPasswordType = PublicEnums.EnumTelPasswordType.增加.GetHashCode();
                                 model.i_NuPassword = (uint)model.i_Number;
                                break;
                            case "广播":  //wifi和固话 默认密码为增加模式 与号码相同
                                model.i_TellType = PublicEnums.EnumTelType.广播.GetHashCode();
                                model.NumberTypeID = PublicEnums.EnumNumberType.固话.GetHashCode();  //固话、wifi手机、广播=4
                                model.i_NuPasswordType = PublicEnums.EnumTelPasswordType.增加.GetHashCode();
                                model.i_NuPassword = (uint)model.i_Number;
                                if (row["广播IP"] != null && row["广播IP"].ToString() != "")
                                {
                                    string strIP = row["广播IP"].ToString().Replace(" ", "");
                                    if (Global.Methods.checkIP(strIP))
                                    {
                                        model.vc_IP = strIP;
                                    }
                                    else
                                        return model = null;
                                }
                                break;
                            default:
                                return model = null;
                        }
                    }
                    else
                    {
                        return model = null;
                    }
                    //if (model.i_Number < Math.Pow(10, Global.Params.NumberLen-1) - 1) return model = null;
                }
                catch
                {
                    model = null;
                }
            }
            return model;
        }
        public int LoadData()
        {
            dgvList.Rows.Clear();

            List<DB_Talk.Model.m_Departments> lst = new List<DB_Talk.Model.m_Departments>();
            lst = new DB_Talk.BLL.m_Departments().GetModelList("i_Flag=0");

            int i = 0;
            foreach (DB_Talk.Model.m_Departments item in lst)
            {
                i++;
                dgvList.Rows[dgvList.Rows.Add(i,
                    item.vc_Name,
                    item.vc_Memo
                    )].Tag = item;
            }
            kryptonHeaderGroup1.ValuesSecondary.Heading="  共" + dgvList.Rows.Count.ToString() + "个部门";
            kryptonHeaderGroup1.Refresh();
            //Tools.AcrReportManage.Current.RefushDataset();
            LoadReport();
            return lst.Count;
        }