private void pictureBox1_Click(object sender, EventArgs e) { PwClientSetting mChild = new PwClientSetting(this); if (mChild.ShowDialog() == DialogResult.OK) { MessageBox.Show("Completed Password Setting!", "Success", MessageBoxButtons.OK, MessageBoxIcon.None); //성공 메시지 띄우기 } //해당 팀 정보 불러오기 this.m_Team_Info = new Team_Info(); this.m_Team_Info.Type = (int)PacketType.로그인정보확인; this.m_Team_Info.t_name = team_name; Packet.Serialize(this.m_Team_Info).CopyTo(this.sendBuf, 0); this.m_networkstream = m_client.GetStream(); this.Send(); this.Recv(); Packet pack = (Packet)Packet.Deserialize(this.readBuf); if ((int)pack.Type == (int)PacketType.로그인정보확인) { this.m_Team_Info = (Team_Info)Packet.Deserialize(this.readBuf); this.team_pw = this.m_Team_Info.pw; this.st_count = this.m_Team_Info.stCount; } }
private void person_num() { Team_Info m_Team_Info = new Team_Info(); m_Team_Info.Type = (int)PacketType.팀인원수; m_Team_Info.t_name = curID; int count = 0; Packet.Serialize(m_Team_Info).CopyTo(this.sendBuffer, 0); this.Send(); //(정상인지 오류인지) 해당 팀 이름이 이미 사용중인지 아닌지 정보 받기 this.Recv(); Packet packet = (Packet)Packet.Deserialize(this.readBuffer); if ((int)packet.Type == (int)PacketType.팀인원수) { m_Team_Info = (Team_Info)Packet.Deserialize(this.readBuffer); count = m_Team_Info.stCount; if (count < 4) { MessageBox.Show("Team Match 불가 \n(팀 인원 수 최소 3명)"); pForm.sel_num = -1; this.Close(); } } comboBox1.Items.Clear(); for (int i = count; i > 2; i--) { comboBox1.Items.Add(i + " 명"); } comboBox1.SelectedIndex = 0; }
private void register_btn_Click(object sender, EventArgs e) { if (ID_txtBox.Text != "" && PW_txtBox.Text != "" && Confirm_txtBox.Text != "" && PW_txtBox.Text != "New Password" && Confirm_txtBox.Text != "Confirm New Password") { if (PW_txtBox.Text.Equals(Confirm_txtBox.Text)) { //패스워드 정보 서버에 보내기 this.m_Team_Info = new Team_Info(); this.m_Team_Info.Type = (int)PacketType.패스워드확인; this.m_Team_Info.t_name = team_name; this.m_Team_Info.pw = ID_txtBox.Text; Packet.Serialize(this.m_Team_Info).CopyTo(this.sendBuf, 0); this.m_networkstream = m_client.GetStream(); this.Send(); //(정상인지 오류인지) 해당 패스워드가 맞는지 확인하는 정보 받기 this.Recv(); Packet packet2 = (Packet)Packet.Deserialize(this.readBuf); if ((int)packet2.Type == (int)PacketType.패스워드확인) { this.m_Team_Info = (Team_Info)Packet.Deserialize(this.readBuf); if ((int)m_Team_Info.Error == (int)PacketSendERROR.정상 || (int)m_Team_Info.Error == (int)PacketSendERROR.존재) //패스워드정상 { //패스워드 정보 서버에 보내기 this.m_Team_Info = new Team_Info(); this.m_Team_Info.Type = (int)PacketType.패스워드변경; this.m_Team_Info.t_name = team_name; this.m_Team_Info.pw = PW_txtBox.Text; Packet.Serialize(this.m_Team_Info).CopyTo(this.sendBuf, 0); this.m_networkstream = m_client.GetStream(); this.Send(); this.DialogResult = DialogResult.OK; //완료 결과 } else if ((int)m_Team_Info.Error == (int)PacketSendERROR.에러) { MessageBox.Show("Password Incorrect!", "Failed", MessageBoxButtons.OK, MessageBoxIcon.None); //에러 메시지 띄우기 } } } else { MessageBox.Show("Password Incorrect!", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); //에러 메시지 띄우기 } } else { MessageBox.Show("Input your Previous Password!", "Empty", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btn_logout_Click(object sender, EventArgs e) { //팀이름 정보 서버에 보내기 this.m_Team_Info = new Team_Info(); this.m_Team_Info.Type = (int)PacketType.로그아웃; this.m_Team_Info.t_name = this.Text; Packet.Serialize(this.m_Team_Info).CopyTo(this.sendBuffer, 0); this.stream = clientSocket.GetStream(); this.Send(); unVisible(); pn_menu.Visible = false; pn_sideMenu.Visible = false; panel1.Visible = true; ID_txtBox.Text = "Team Name"; PW_txtBox.Text = "password"; this.Text = "SoccerClient"; }
private void Team_chk_btn_Click(object sender, EventArgs e) { if (ID_txtBox.Text != "" && team_check == false) { //팀이름 정보 서버에 보내기 this.m_Team_Info = new Team_Info(); this.m_Team_Info.Type = (int)PacketType.팀이름확인; this.m_Team_Info.t_name = ID_txtBox.Text; Packet.Serialize(this.m_Team_Info).CopyTo(this.sendBuf, 0); this.m_networkstream = m_client.GetStream(); this.Send(); //(정상인지 오류인지) 해당 팀 이름이 이미 사용중인지 아닌지 정보 받기 this.Recv(); Packet packet = (Packet)Packet.Deserialize(this.readBuf); if ((int)packet.Type == (int)PacketType.팀이름확인) { this.m_Team_Info = (Team_Info)Packet.Deserialize(this.readBuf); if ((int)m_Team_Info.Error == (int)PacketSendERROR.에러) //이미 존재하는 팀이름 { MessageBox.Show("Already Using Team Name!", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); //에러 메시지 띄우기 } else if ((int)m_Team_Info.Error == (int)PacketSendERROR.정상) //존재하지 않음 { team_name = ID_txtBox.Text; //팀이름 저장해놓기 Team_chk_btn.Image = soccerForm.Properties.Resources.green_check; //체크이미지 바꾸기 ID_txtBox.Enabled = false; team_check = true; MessageBox.Show("Valid Team Name!", "Success", MessageBoxButtons.OK, MessageBoxIcon.None); //확인 메시지 띄우기 } } } else if (ID_txtBox.Text == "") { MessageBox.Show("Input your Team Name!", "Empty", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void register_btn_Click(object sender, EventArgs e) { if (team_check) { if (id_check1 || id_check2 || id_check3 || id_check4 || id_check5) { if (PW_txtBox.Text.Equals(Confirm_txtBox.Text)) { //학번 보내기 foreach (string s_id in si) { //저장한 학번들 정보 서버에 보내기 this.m_Student_ID = new Student_ID(); this.m_Student_ID.Type = (int)PacketType.학번저장; this.m_Student_ID.s_id = s_id; this.m_Student_ID.t_name = team_name; Packet.Serialize(this.m_Student_ID).CopyTo(this.sendBuf, 0); this.m_networkstream = m_client.GetStream(); this.Send(); //(정상인지 오류인지) 학번저장이 안되었다는 메시지오면 오류 메시지! this.Recv(); Packet pack = (Packet)Packet.Deserialize(this.readBuf); if ((int)pack.Type == (int)PacketType.학번저장) { this.m_Student_ID = (Student_ID)Packet.Deserialize(this.readBuf); if ((int)m_Student_ID.Error == (int)PacketSendERROR.에러) { MessageBox.Show("Student ID can Not be Saved!", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); //에러 메시지 띄우기 } } } //팀이름, 패스워드, 팀 인원수 보내기 this.m_Team_Info = new Team_Info(); this.m_Team_Info.Type = (int)PacketType.로그인정보저장; this.m_Team_Info.t_name = team_name; this.m_Team_Info.pw = PW_txtBox.Text; this.m_Team_Info.stCount = si.Count; Packet.Serialize(this.m_Team_Info).CopyTo(this.sendBuf, 0); this.m_networkstream = m_client.GetStream(); this.Send(); //(정상인지 오류인지) 팀이름, 패스워드 저장이 안되었다는 메시지오면 오류 메시지! this.Recv(); Packet packet = (Packet)Packet.Deserialize(this.readBuf); if ((int)packet.Type == (int)PacketType.로그인정보저장) { this.m_Team_Info = (Team_Info)Packet.Deserialize(this.readBuf); if ((int)m_Team_Info.Error == (int)PacketSendERROR.에러) { MessageBox.Show("User Information can Not be Saved!", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); //에러 메시지 띄우기 } else if ((int)m_Team_Info.Error == (int)PacketSendERROR.정상) { this.DialogResult = DialogResult.OK; //완료 결과 //this.Close(); } } } else { MessageBox.Show("Password Incorrect!", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); //에러 메시지 띄우기 } } else { MessageBox.Show("Input Student ID!", "Empty", MessageBoxButtons.OK, MessageBoxIcon.Error); //에러 메시지 띄우기 } } else { MessageBox.Show("Input your Team Name!", "Empty", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Client_Setting_Load(object sender, EventArgs e) { //정보 텍스트 박스 비활 SI_txtBox1.Enabled = false; SI_txtBox2.Enabled = false; SI_txtBox3.Enabled = false; SI_txtBox4.Enabled = false; SI_txtBox5.Enabled = false; //해당 팀 정보 보여주기 ID_txtBox.Text = team_name; //해당 팀 정보 불러오기 this.m_Team_Info = new Team_Info(); this.m_Team_Info.Type = (int)PacketType.로그인정보확인; this.m_Team_Info.t_name = team_name; Packet.Serialize(this.m_Team_Info).CopyTo(this.sendBuf, 0); this.m_networkstream = m_client.GetStream(); this.Send(); this.Recv(); Packet pack = (Packet)Packet.Deserialize(this.readBuf); if ((int)pack.Type == (int)PacketType.로그인정보확인) { this.m_Team_Info = (Team_Info)Packet.Deserialize(this.readBuf); this.team_pw = this.m_Team_Info.pw; this.st_count = this.m_Team_Info.stCount; } //서버한테 해당 팀이름 정보 보내주기 this.m_Student_ID = new Student_ID(); this.m_Student_ID.Type = (int)PacketType.학번정보; this.m_Student_ID.t_name = team_name; Packet.Serialize(this.m_Student_ID).CopyTo(this.sendBuf, 0); this.m_networkstream = m_client.GetStream(); this.Send(); for (int i = 0; i < st_count; i++) { //해당 팀의 팀원수 만큼 학번 정보 불러오기 this.Recv(); pack = (Packet)Packet.Deserialize(this.readBuf); if ((int)pack.Type == (int)PacketType.학번정보) { this.m_Student_ID = (Student_ID)Packet.Deserialize(this.readBuf); this.student_List.Add(this.m_Student_ID.s_id); switch (i) { case 0: SI_txtBox1.Text = student_List[i]; id_chk1.Image = soccerForm.Properties.Resources.change; SI_txtBox1.Enabled = true; break; case 1: SI_txtBox2.Text = student_List[i]; id_chk2.Image = soccerForm.Properties.Resources.change; SI_txtBox2.Enabled = true; break; case 2: SI_txtBox3.Text = student_List[i]; id_chk3.Image = soccerForm.Properties.Resources.change; SI_txtBox3.Enabled = true; break; case 3: SI_txtBox4.Text = student_List[i]; id_chk4.Image = soccerForm.Properties.Resources.change; SI_txtBox4.Enabled = true; break; case 4: SI_txtBox5.Text = student_List[i]; id_chk5.Image = soccerForm.Properties.Resources.change; SI_txtBox5.Enabled = true; break; } } } }
private void register_btn_Click(object sender, EventArgs e) { //실제 패스워드와 같은지 확인 if (PW_txtBox.Text.Equals(team_pw)) { //패스워드 확인과 같은지 확인 if (PW_txtBox.Text.Equals(Confirm_txtBox.Text)) { Image compareImage = soccerForm.Properties.Resources.green_check; //팀이름 정보를 수정했으면 MemoryStream Team = new MemoryStream(); Team_chk_btn.Image.Save(Team, System.Drawing.Imaging.ImageFormat.Png); String one0 = Convert.ToBase64String(Team.ToArray()); Team.Position = 0; compareImage.Save(Team, System.Drawing.Imaging.ImageFormat.Png); String two0 = Convert.ToBase64String(Team.ToArray()); Team.Close(); if (one0.Equals(two0)) { //팀이름 정보 서버에 보내기 this.m_Change_Team_Info = new Change_Team_Info(); this.m_Change_Team_Info.Type = (int)PacketType.팀이름수정; this.m_Change_Team_Info.old_tName = team_name; this.m_Change_Team_Info.new_tName = ID_txtBox.Text; Packet.Serialize(this.m_Change_Team_Info).CopyTo(this.sendBuf, 0); this.m_networkstream = m_client.GetStream(); this.Send(); team_name = ID_txtBox.Text; } //학번1 정보 수정했으면 MemoryStream student1 = new MemoryStream(); id_chk1.Image.Save(student1, System.Drawing.Imaging.ImageFormat.Png); String one1 = Convert.ToBase64String(student1.ToArray()); student1.Position = 0; compareImage.Save(student1, System.Drawing.Imaging.ImageFormat.Png); String two1 = Convert.ToBase64String(student1.ToArray()); student1.Close(); if (one1.Equals(two1)) { this.m_Change_SI_Info = new Change_SI_Info(); this.m_Change_SI_Info.Type = (int)PacketType.학번수정; this.m_Change_SI_Info.tName = team_name; this.m_Change_SI_Info.old_SI = student_List[0]; this.m_Change_SI_Info.new_SI = SI_txtBox1.Text; Packet.Serialize(this.m_Change_SI_Info).CopyTo(this.sendBuf, 0); this.m_networkstream = m_client.GetStream(); this.Send(); } //학번2 정보 수정했으면 MemoryStream student2 = new MemoryStream(); id_chk2.Image.Save(student2, System.Drawing.Imaging.ImageFormat.Png); String one2 = Convert.ToBase64String(student2.ToArray()); student2.Position = 0; compareImage.Save(student2, System.Drawing.Imaging.ImageFormat.Png); String two2 = Convert.ToBase64String(student2.ToArray()); student2.Close(); if (one2.Equals(two2)) { this.m_Change_SI_Info = new Change_SI_Info(); this.m_Change_SI_Info.Type = (int)PacketType.학번수정; this.m_Change_SI_Info.tName = team_name; if (student_List.Count - 1 < 1) { this.m_Change_SI_Info.old_SI = "-1"; } else { this.m_Change_SI_Info.old_SI = student_List[1]; } this.m_Change_SI_Info.new_SI = SI_txtBox2.Text; Packet.Serialize(this.m_Change_SI_Info).CopyTo(this.sendBuf, 0); this.m_networkstream = m_client.GetStream(); this.Send(); } //학번3 정보 수정했으면 MemoryStream student3 = new MemoryStream(); id_chk3.Image.Save(student3, System.Drawing.Imaging.ImageFormat.Png); String one3 = Convert.ToBase64String(student3.ToArray()); student3.Position = 0; compareImage.Save(student3, System.Drawing.Imaging.ImageFormat.Png); String two3 = Convert.ToBase64String(student3.ToArray()); student3.Close(); if (one3.Equals(two3)) { this.m_Change_SI_Info = new Change_SI_Info(); this.m_Change_SI_Info.Type = (int)PacketType.학번수정; this.m_Change_SI_Info.tName = team_name; if (student_List.Count - 1 < 2) { this.m_Change_SI_Info.old_SI = "-1"; } else { this.m_Change_SI_Info.old_SI = student_List[2]; } this.m_Change_SI_Info.new_SI = SI_txtBox3.Text; Packet.Serialize(this.m_Change_SI_Info).CopyTo(this.sendBuf, 0); this.m_networkstream = m_client.GetStream(); this.Send(); } //학번4 정보 수정했으면 MemoryStream student4 = new MemoryStream(); id_chk4.Image.Save(student4, System.Drawing.Imaging.ImageFormat.Png); String one4 = Convert.ToBase64String(student4.ToArray()); student4.Position = 0; compareImage.Save(student4, System.Drawing.Imaging.ImageFormat.Png); String two4 = Convert.ToBase64String(student4.ToArray()); student4.Close(); if (one4.Equals(two4)) { this.m_Change_SI_Info = new Change_SI_Info(); this.m_Change_SI_Info.Type = (int)PacketType.학번수정; this.m_Change_SI_Info.tName = team_name; if (student_List.Count - 1 < 3) { this.m_Change_SI_Info.old_SI = "-1"; } else { this.m_Change_SI_Info.old_SI = student_List[3]; } this.m_Change_SI_Info.new_SI = SI_txtBox4.Text; Packet.Serialize(this.m_Change_SI_Info).CopyTo(this.sendBuf, 0); this.m_networkstream = m_client.GetStream(); this.Send(); } //학번5 정보 수정했으면 MemoryStream student5 = new MemoryStream(); id_chk5.Image.Save(student5, System.Drawing.Imaging.ImageFormat.Png); String one5 = Convert.ToBase64String(student5.ToArray()); student5.Position = 0; compareImage.Save(student5, System.Drawing.Imaging.ImageFormat.Png); String two5 = Convert.ToBase64String(student5.ToArray()); student5.Close(); if (one5.Equals(two5)) { this.m_Change_SI_Info = new Change_SI_Info(); this.m_Change_SI_Info.Type = (int)PacketType.학번수정; this.m_Change_SI_Info.tName = team_name; if (student_List.Count - 1 < 4) { this.m_Change_SI_Info.old_SI = "-1"; } else { this.m_Change_SI_Info.old_SI = student_List[4]; } this.m_Change_SI_Info.new_SI = SI_txtBox5.Text; Packet.Serialize(this.m_Change_SI_Info).CopyTo(this.sendBuf, 0); this.m_networkstream = m_client.GetStream(); this.Send(); } //팀인워수 정보 보내기 this.m_Team_Info = new Team_Info(); this.m_Team_Info.Type = (int)PacketType.팀인원수수정; this.m_Team_Info.t_name = team_name; this.m_Team_Info.stCount = st_count; Packet.Serialize(this.m_Team_Info).CopyTo(this.sendBuf, 0); this.m_networkstream = m_client.GetStream(); this.Send(); this.DialogResult = DialogResult.OK; //완료 결과 } else { MessageBox.Show("Password Incorrect!", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); //에러 메시지 띄우기 } } else { MessageBox.Show("Password Incorrect!", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); //에러 메시지 띄우기 } }
private void Login_btn_Click(object sender, EventArgs e) { if (ID_txtBox.Text != "") { if (PW_txtBox.Text != "") { //팀이름 정보 서버에 보내기 this.m_Team_Info = new Team_Info(); this.m_Team_Info.Type = (int)PacketType.팀이름확인; this.m_Team_Info.t_name = ID_txtBox.Text; Packet.Serialize(this.m_Team_Info).CopyTo(this.sendBuffer, 0); this.stream = clientSocket.GetStream(); this.Send(); //(정상인지 오류인지) 해당 팀 이름이 이미 사용중인지 아닌지 정보 받기 this.Recv(); Packet packet = (Packet)Packet.Deserialize(this.readBuffer); if ((int)packet.Type == (int)PacketType.팀이름확인) { this.m_Team_Info = (Team_Info)Packet.Deserialize(this.readBuffer); if ((int)m_Team_Info.Error == (int)PacketSendERROR.에러) //이미 존재하는 팀이름 { //패스워드 정보 서버에 보내기 this.m_Team_Info = new Team_Info(); this.m_Team_Info.Type = (int)PacketType.패스워드확인; this.m_Team_Info.t_name = ID_txtBox.Text; this.m_Team_Info.pw = PW_txtBox.Text; Packet.Serialize(this.m_Team_Info).CopyTo(this.sendBuffer, 0); this.stream = clientSocket.GetStream(); this.Send(); //(정상인지 오류인지) 해당 패스워드가 맞는지 확인하는 정보 받기 this.Recv(); Packet packet2 = (Packet)Packet.Deserialize(this.readBuffer); if ((int)packet2.Type == (int)PacketType.패스워드확인) { this.m_Team_Info = (Team_Info)Packet.Deserialize(this.readBuffer); if ((int)m_Team_Info.Error == (int)PacketSendERROR.정상) //패스워드정상 { // 현재 날짜 기준 이전경기 결과 존재 확인 this.m_pre_result = new previous_result(); this.m_pre_result.Type = (int)PacketType.이전경기결과확인; this.m_pre_result.myTeam = ID_txtBox.Text; this.m_pre_result.curDate = DateTime.Today.ToShortDateString(); Packet.Serialize(this.m_pre_result).CopyTo(this.sendBuffer, 0); this.stream = clientSocket.GetStream(); this.Send(); this.Recv(); Packet packet3 = (Packet)Packet.Deserialize(this.readBuffer); if ((int)packet3.Type == (int)PacketType.이전경기결과확인) { this.m_pre_result = (previous_result)Packet.Deserialize(this.readBuffer); if ((int)m_pre_result.pre_result == 1) { Result myResult = new Result(this); if (myResult.ShowDialog() == DialogResult.OK) { MessageBox.Show("Completed!", "Success", MessageBoxButtons.OK, MessageBoxIcon.None); //성공 메시지 띄우기 } } } pn_reser.Controls.Add(picker); unVisible(); res_inform(); pn_menu.Visible = true; pn_sideMenu.Visible = true; update_msg_panel(); pn_reser.Visible = true; btn_reser.BackgroundImage = Image.FromFile("onReservation.png"); pn_sideMenu.BringToFront(); // sideMenu Panel 맨 앞으로 this.Text = ID_txtBox.Text; } else if ((int)m_Team_Info.Error == (int)PacketSendERROR.존재) { MessageBox.Show("Existing Client!", "Failed", MessageBoxButtons.OK, MessageBoxIcon.None); //에러 메시지 띄우기 } else if ((int)m_Team_Info.Error == (int)PacketSendERROR.에러) { MessageBox.Show("Password Incorrect!", "Failed", MessageBoxButtons.OK, MessageBoxIcon.None); //에러 메시지 띄우기 } } } else if ((int)m_Team_Info.Error == (int)PacketSendERROR.정상)//존재하지 않음 { MessageBox.Show("Team Name Incorrect!\n If you don't have your Team Name, Just Please Join, First!", "Failed", MessageBoxButtons.OK, MessageBoxIcon.None); //에러 메시지 띄우기 } } } else { MessageBox.Show("Input your Password!", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); //에러 메시지 띄우기 } } else { MessageBox.Show("Input your Team Name!", "Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); //에러 메시지 띄우기 } }
// Handle text file creation public void UpdateData() { // Run the function to re-run this function after completion StartCoroutine(SetInfoAndRerunUpdate()); // Print Donation Total to a Text File StartCoroutine(GetDonationTotal(theTeamID, donationTotalSuccess => { Team_Info data = new Team_Info(); // create or update the donation total text file data = JsonConvert.DeserializeObject <Team_Info>(donationTotalSuccess); // Set the information on the goal handler GoalHandler.GetComponent <GoalHandler>().SetGoalInformation(data.totalRaisedAmount, data.fundraisingGoal); string path = PlayerPrefs.GetString("totalDonationPath", System.Environment.GetFolderPath(System.Environment.SpecialFolder.DesktopDirectory) + "\\donation_total.txt"); string donationTotal = "$" + data.totalRaisedAmount; File.WriteAllText(path, donationTotal); })); // Handle Participant Donations foreach (string participant in participants) { StartCoroutine(GetParticipantDonations(participant, participantDonationSuccess => { List <Donation> data; data = JsonConvert.DeserializeObject <List <Donation> >(participantDonationSuccess); if (data.Count > 0) { foreach (Donation d in data) { //Handle Top Donation if (d.donationAmount != null) { double temp = double.Parse(d.donationAmount); if (temp > topDonationAmount) { topDonationAmount = temp; if (d.donorName == null) { topDonationName = "Anonymous"; } else { topDonationName = d.donorName; } } } // Handle Most recent donation if (d.timestamp > mostRecentDonationDate) { mostRecentDonationDate = d.timestamp; if (d.donationAmount != null) { mostRecentDonationAmount = double.Parse(d.donationAmount); } else { mostRecentDonationAmount = 0; } if (d.donorName == null) { mostRecentDonationName = "Anonymous"; } else { mostRecentDonationName = d.donorName; } } // Handle 3 Most Recent Donations // If there are no donations in here yet, just pull the first 3 if (recentThreeDonations.Count < 3 && !recentThreeDonations.Contains(d)) { recentThreeDonations.Add(d); } else { // If the recent donations list is already 3, check if the timestamp is recent // If the new timestamp is greater(newer) the the last one in the list // remove the first one from the list, and add the new one to the list Donation x = recentThreeDonations[2]; // Most recent donation if (d.timestamp > x.timestamp) { recentThreeDonations[0] = recentThreeDonations[1]; recentThreeDonations[1] = x; recentThreeDonations[2] = d; } } } } participantsCount += 1; })); } }