Exemplo n.º 1
0
        /// <summary>
        /// 添加抽奖人员
        /// </summary>
        /// <param name="m_rank"></param>
        /// <returns></returns>
        public bool AddPerson(Person m_person, out int nPersonId)
        {
            nPersonId = -1;
            if (m_person.PersonPhoto == string.Empty)
            {
                Loger.Debug(" --- add person error : photoName is null --- ");
                return false;
            }

            #region 判断是否已存在
            int nKey = 0;
            if (mapPerson.Count > 0)
            {
                foreach (var data in mapPerson)
                {
                    if (data.Key > nKey)
                    {
                        nKey = data.Key;
                    }
                    if (data.Value.PersonPhoto == m_person.PersonPhoto)
                    {
                        Loger.Debug(" --- add person error : mapPerson has cantains this photo : " + m_person.PersonPhoto + " --- ");
                        return false;
                    }
                }
            }
            nKey++;
            #endregion

            if (!mapPerson.ContainsKey(nKey))
            {
                mapPerson.Add(nKey, m_person);
                nPersonId = nKey;
                Loger.Serialize(Config.PathPerson, mapPerson);
               // Loger.Debug(" --- add person successed. photo : " + m_person.PersonPhoto + " --- ");
                return true;
            }
            else
            {
                Loger.Debug(" --- add person error : mapPerson has cantains this photo : " + m_person.PersonPhoto + " --- . ");
                return false;
            }
        }
Exemplo n.º 2
0
 public void PgChangedMethod(string path)
 {
     int nPersonId = -1;
     Person _person = new Person();
     _person.PersonPhoto = path;
     _person.PersonName = Path.GetFileNameWithoutExtension(path);
     if (!Common.GlobalPrizeSystem.AddPerson(_person, out nPersonId))
     {
         Loger.Debug(" --- import photo error . photo = " + path);
     }
     else
     {
         pgBar.Value++;
         if (pgBar.Value == pgBar.Maximum)
         {
             Initialize();
             MessageBox.Show("导入完成");
         }
     }
     return;
 }
Exemplo n.º 3
0
 /// <summary>
 /// 更新抽奖人员
 /// </summary>
 /// <param name="nRankId"></param>
 /// <param name="m_rank"></param>
 /// <returns></returns>
 public bool UpdatePerson(int nPersonId, Person m_person)
 {
     if (m_person.PersonPhoto == string.Empty)
     {
         Loger.Debug(" --- update person error : person photo is null --- ");
         return false;
     }
     if (!mapPerson.ContainsKey(nPersonId))
     {
         Loger.Debug(" --- update person error : mapPerson not cantains this id : " + nPersonId + " --- ");
         return false;
     }
     mapPerson[nPersonId] = m_person;
     Loger.Serialize(Config.PathPerson, mapPerson);
     return true;
 }
Exemplo n.º 4
0
        /// <summary>
        /// 获取指定的抽奖人员
        /// </summary>
        /// <param name="nRankid"></param>
        /// <param name="bExist"></param>
        /// <returns></returns>
        public Person GetPerson(int nPersonid, out bool bExist)
        {
            Person m_person = new Person();
            bExist = false;

            if (!mapPerson.ContainsKey(nPersonid))
            {
                bExist = false;
                return m_person;
            }
            else
            {
                bExist = true;
                m_person = mapPerson[nPersonid];
                return m_person;
            }
        }