예제 #1
0
    public string profile_get_loadcontestants(string _eventID)
    {
        DataTable _contestantsDT = new DataTable();
        DataTable _scoresDT      = new DataTable();
        DataTable _judgesDT      = new DataTable();

        resultaccount = new DataTable();
        resultaccount.Columns.Add("PersonID", typeof(string));
        resultaccount.Columns.Add("Name", typeof(string));
        resultaccount.Columns.Add("FScore", typeof(string));

        databaseCon.ExecuteStoredProc("MCspViewContestantsEvent", "@EventID", _eventID);
        if (databaseCon.Data.Rows.Count > 0)
        {
            _contestantsDT = databaseCon.Data;
        }

        foreach (DataRow cont in _contestantsDT.Rows)
        {
            string fullname = cont.Field <string>(1);
            double final    = 0;
            double total    = 0;
            int    judgectr = 0;

            databaseCon.ExecuteCommand("SELECT EventJudgesID FROM EventJudges WHERE EventID = " + _eventID);
            int CID = cont.Field <int>(0);
            if (databaseCon.Data.Rows.Count > 0)
            {
                _judgesDT = databaseCon.Data;
            }
            foreach (DataRow judge in _judgesDT.Rows)
            {
                judgectr++;
                databaseCon.ExecuteStoredProc("MCspViewScoreWeight", "@ContestantID", CID.ToString(), "@EventJudgesID", judge.Field <int>(0));
                if (databaseCon.Data.Rows.Count > 0)
                {
                    _scoresDT = databaseCon.Data;
                }
                foreach (DataRow sco in _scoresDT.Rows)
                {
                    double score  = sco.Field <double>(0) / 10;
                    double weight = sco.Field <double>(1);
                    total += score * weight;
                }
            }
            final += total / judgectr;
            databaseCon.ExecuteCommand("UPDATE Contestant SET TotalScore = " + final.ToString() + "WHERE ContestantID = " + CID.ToString());
            //need ko nalang ng personid,name at score tapos mag add sa new datatable
            resultaccount.Rows.Add(cont.Field <int>(2).ToString(), fullname, final.ToString());
        }



        return(DTSerializer(resultaccount));
    }
예제 #2
0
    public string index_login_OnClick(string uname, string pass)
    {
        bool isjudge = false;
        bool iseo    = false;

        databaseCon      = new dbConnect();
        _judges          = new DataTable();
        _eventorganizers = new DataTable();
        resultaccount    = new DataTable();

        databaseCon.ExecuteCommand("Select * from Judge");
        if (databaseCon.Data.Rows.Count > 0)
        {
            _judges = databaseCon.Data;
        }

        foreach (DataRow j in _judges.Rows)
        {
            if (uname == j.Field <string>(2).ToString() && pass == j.Field <string>(3).ToString())
            {
                resultaccount = _judges.Clone();
                resultaccount.ImportRow(j);
                resultaccount.Columns.Add("accounttype");
                resultaccount.Rows[0][resultaccount.Columns.Count - 1] = "1";
                isjudge = true;
            }
        }

        if (!isjudge)
        {
            databaseCon.ExecuteCommand("Select * from Eventorganizer");
            if (databaseCon.Data.Rows.Count > 0)
            {
                _eventorganizers = databaseCon.Data;
                foreach (DataRow o in _eventorganizers.Rows)
                {
                    if (uname == o.Field <string>(1).ToString() && pass == o.Field <string>(2).ToString())
                    {
                        isjudge       = true;
                        resultaccount = _eventorganizers.Clone();
                        resultaccount.ImportRow(o);
                        databaseCon.ExecuteCommand("SELECT E.IsFinalize FROM EVENT AS E INNER JOIN EVENTORGANIZER AS EO ON EO.EventID = E.EventID WHERE EO.adminUname = N'" + o.Field <string>(1).ToString() + "'");

                        if (!databaseCon.Data.Rows[0].Field <bool>(0))
                        //event is not yet finalized, can proceed to eventwindow
                        {
                            resultaccount.Columns.Add("accounttype");
                            resultaccount.Rows[0][resultaccount.Columns.Count - 1] = "2";
                        }
                        else
                        //event is finalized, cannot proceed to event window
                        {
                            resultaccount.Columns.Add("accounttype");
                            resultaccount.Rows[0][resultaccount.Columns.Count - 1] = "3";
                        }
                    }
                }
            }
        }
        if (!iseo && !isjudge)
        {
            resultaccount.Columns.Add("accounttype");
            resultaccount.Rows.Add("4");
        }

        // 1 judge 2 eo 3 eo finalized 4 not avail

        return(DTSerializer(resultaccount));
    }