private void Save()
        {
            try
            {
                List <UDT.Players> addplayers = new List <UDT.Players>();
                foreach (DataGridViewRow drv in dgSearch.SelectedRows)
                {
                    int sid = int.Parse(drv.Tag.ToString());

                    UDT.Players p = new UDT.Players();
                    p.RefStudentId = sid;
                    p.ClassName    = drv.Cells[colClassName.Index].Value.ToString();
                    p.SeatNo       = int.Parse(drv.Cells[colSeatNo.Index].Value.ToString());
                    p.Name         = drv.Cells[colName.Index].Value.ToString();
                    p.CreatedBy    = drv.Cells[colAccount.Index].Value.ToString();
                    p.RefTeamId    = _team_id;
                    p.RefEventId   = _refEventID;
                    // 如果沒有隊,自己是隊長
                    if (_team_id.HasValue == false)
                    {
                        p.IsTeamLeader = true;
                    }

                    addplayers.Add(p);
                }
                addplayers.SaveAll();
            }
            catch (Exception ex)
            {
                _sbError.Append("參賽人員儲存錯誤," + ex.Message);
            }
        }
        private string parsePlayerToJSonString(UDT.Players p)
        {
            char   cc    = '"';
            string c1    = "'";
            string value = "{'ref_student_id':" + p.RefStudentId + ",'name':'" + p.Name + "','class_name':'" + p.ClassName + "','seat_no':" + p.SeatNo + ",'is_team_leader':" + p.IsTeamLeader.ToString().ToLower() + "}";

            value = value.Replace(Char.Parse(c1), cc);
            return(value);
        }
        private void _bgLoadData_DoWork(object sender, DoWorkEventArgs e)
        {
            AccessHelper ah = new AccessHelper();

            _temp   = ah.Select <UDT.Players>(" uid = " + _uid);
            _player = null;
            if (_temp != null && _temp.Count > 0)
            {
                _player = _temp[0];
            }

            if (_isTeam)
            {
                if (_player.RefTeamId.HasValue)
                {
                    _teamP = ah.Select <UDT.Players>("ref_team_id = " + _player.RefTeamId.Value);
                }
            }
        }