//显示控件上的各个值 void CCommonSetDlg::ShowValuesOnCtrls() { //前4个均为1023,最后一个127 UINT nValue = GetCommonInfo(COMMON_BATLOWTHRD+2*(m_nCurrentRow-1)); UINT nPos = 0; CString str; if (m_nCurrentRow==m_Grid.GetRowCount()-1) { nPos = MIN_MAX_VALUE; } else nPos = MIDDLE_MAX_VALUE; m_ScrBar.SetScrollRange(0,nPos); m_ScrBar.SetScrollPos(nValue); m_EditValue.SetInteger(nValue); //还需要在grid上显示 int i=1; for (;i<m_Grid.GetRowCount();i++) { nValue = GetCommonInfo(COMMON_BATLOWTHRD+2*(i-1)); str.Format("%d",nValue); m_Grid.SetItemText(i,1,str.GetBuffer()); str.ReleaseBuffer(); } }
/********************************************************************************* bool CVotePageBuilder::CreateVotePage() Author: Mark Howitt Created: 20/05/2004 Inputs: - Outputs: - Returns: true if ok, false if not Purpose: Just gets the common info for now. NOT USED!!!! *********************************************************************************/ bool CVotePageBuilder::CreateVotePage() { // Setup the create page info m_pPage->AddInside("VOTING-PAGE","<ACTION>create</ACTION>"); // Get the basic info if (!GetCommonInfo(false)) { return false; } return true; }
bool CVotePageBuilder::ViewVote() { // Get the basic info if (!GetCommonInfo(true, false)) { return false; } if (m_iType == VOTETYPE_CLUB) { // Now get all the users who voted with the same Response if (!AddClubLinksXml()) { return false; } if (!AddPollXml()) { return false; } } //This is not optimal, but will give ican team opportunity to //see the xml and to decide on it. If they are happy with the //xml a new methods could be added to CVote returning the //same xml as these two calls combined // Now get all the users who voted with Response 1 if (!m_CurrentVote.GetAllUsersWithResponse(m_iVoteID, 1)) { m_pPage->SetError(m_CurrentVote.GetLastErrorMessage()); return false; } if (m_pPage->AddInside("VOTING-PAGE",&m_CurrentVote) == false) { return false; } // Now get all the users who voted with Response 0 if (!m_CurrentVote.GetAllUsersWithResponse(m_iVoteID, 0)) { m_pPage->SetError(m_CurrentVote.GetLastErrorMessage()); return false; } return m_pPage->AddInside("VOTING-PAGE",&m_CurrentVote); }
/********************************************************************************* bool CVotePageBuilder::FinishPage() Author: Mark Howitt Created: 20/05/2004 Inputs: - Outputs: - Returns: true if everything ok, false if not Purpose: Adds the users response to the vote and returns all the current Users with the same response. *********************************************************************************/ bool CVotePageBuilder::FinishPage() { // Set the action flag m_pPage->AddInside("VOTING-PAGE","<ACTION>finish</ACTION>"); // Get the basic info if (!GetCommonInfo(true)) { return false; } // Get the showuser flag if (m_iUserID > 0 && m_InputContext.ParamExists("showuser")) { m_bShowUser = m_InputContext.GetParamInt("showuser") > 0 ? true : false; } else { m_bShowUser = false; } bool bAlreadyVoted = false; if (!m_CurrentVote.HasUserAlreadyVoted(m_iVoteID,m_iUserID,m_sBBCUID,bAlreadyVoted)) { m_pPage->SetError(m_CurrentVote.GetLastErrorMessage()); return false; } if (!bAlreadyVoted) { // Add the response if (!m_CurrentVote.AddResponceToVote(m_iVoteID,m_iUserID,m_sBBCUID,m_iResponse,m_bShowUser,m_iThreadID)) { m_pPage->SetError(m_CurrentVote.GetLastErrorMessage()); return false; } } // Now get all the users who voted with the same Response if (!m_CurrentVote.GetAllUsersWithResponse(m_iVoteID,m_iResponse)) { m_pPage->SetError(m_CurrentVote.GetLastErrorMessage()); return false; } // Now insert the vote XML, and return the verdict! return m_pPage->AddInside("VOTING-PAGE",&m_CurrentVote); }
/********************************************************************************* bool CVotePageBuilder::AddResponce() Author: Mark Howitt Created: 20/05/2004 Inputs: - Outputs: - Returns: true if ok, false if not Purpose: Adds the users response to the vote *********************************************************************************/ bool CVotePageBuilder::AddResponce() { // Set the action flag m_pPage->AddInside("VOTING-PAGE","<ACTION>add</ACTION>"); // Get the basic info if (!GetCommonInfo(true)) { return false; } // Now get all the users who voted with the same Response if (!m_CurrentVote.GetAllUsersWithResponse(m_iVoteID,m_iResponse)) { m_pPage->SetError(m_CurrentVote.GetLastErrorMessage()); return false; } // Now insert the vote XML, and return the verdict! return m_pPage->AddInside("VOTING-PAGE",&m_CurrentVote); }
/********************************************************************************* bool CVotePageBuilder::CreateNewVote() Author: Mark Howitt Created: 20/05/2004 Inputs: - Outputs: - Returns: true if ok, false if not Purpose: Creates a new vote for a given club or noticeboard *********************************************************************************/ bool CVotePageBuilder::CreateNewVote() { // Set the action flag m_pPage->AddInside("VOTING-PAGE","<ACTION>new</ACTION>"); // The user must be logged in before we can do this! CUser* pUser = m_InputContext.GetCurrentUser(); if (pUser == NULL) { m_pPage->SetError("UserNotLoggedIn"); return false; } // Get the basic info if (!GetCommonInfo(false)) { return false; } // First check the Objectid to atach the vote to. m_iObjectID = m_InputContext.GetParamInt("objectid"); if (m_iObjectID <= 0) { m_pPage->SetError("NoObjectID"); return false; } // Get the type from the url m_iType = m_InputContext.GetParamInt("type"); // Check to make sure the current user is the owner of the club or that they are an editor bool bIsAllowed = pUser->GetIsEditor() || pUser->GetIsSuperuser(); if (!bIsAllowed) { // Check to see if the user is a member of a club or thread owner m_CurrentVote.IsUserAuthorisedToCreateVote(m_iObjectID,m_iType,pUser->GetUserID(),bIsAllowed); if (!bIsAllowed) { m_pPage->SetError("UserNotAuthorised"); return false; } } // Get the closing date for the vote int iDay = m_InputContext.GetParamInt("day"); int iMonth = m_InputContext.GetParamInt("month"); int iYear = m_InputContext.GetParamInt("year"); m_tClosingDate = NULL; CTDVString sDate; if (iDay > 0 && iMonth > 0 && iYear > 0) { m_tClosingDate.SetDate(iYear,iMonth,iDay); } if (m_tClosingDate > m_tClosingDate.GetCurrentTime()) { sDate << (-m_tClosingDate.DaysElapsed()); } // Now see if we want to do a simple yes no vote m_bSimpleYesNo = m_InputContext.GetParamInt("useyesno") > 0 ? true : false; // Now create the new object m_iVoteID = m_CurrentVote.CreateVote(m_iType,m_tClosingDate,m_iOwnerID,m_bSimpleYesNo); // Make sure the vote id is valid! if (m_iVoteID <= 0) { m_pPage->SetError("FailedToCreateVote"); return false; } CTDVString sXML; CDBXMLBuilder XML; XML.Initialise(&sXML); XML.AddIntTag("VOTEID",m_iVoteID); XML.OpenTag("OBJECT",true); if (m_iType == VOTETYPE_CLUB) { XML.AddAttribute("TYPE","CLUB"); } else if (m_iType == VOTETYPE_NOTICE) { XML.AddAttribute("TYPE","NOTICE"); } XML.AddIntAttribute("ID",m_iObjectID,true); XML.CloseTag("OBJECT"); XML.AddTag("CLOSINGDATE",sDate); m_CurrentVote.GetCreatedDate(m_tDateCreated); XML.AddDateTag("CREATEDDATE",m_tDateCreated,true); // Now upsate the ClubVotes table with the new vote m_CurrentVote.AddVoteToClubTable(m_iVoteID,m_iObjectID,&m_sVoteName); XML.AddTag("VOTENAME",m_sVoteName); // Put the XML into the page and return return m_pPage->AddInside("VOTING-PAGE",sXML); }