Вы находитесь на странице: 1из 2

using

using
using
using
using
using
using
using
using

System;
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
System.Linq;
System.Text;
System.Windows.Forms;
System.Xml.Linq;

namespace WinForm_Vendvotimi_cs
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void VenjaVotes(string theVote)
{
try
{
XDocument xmlDoc = XDocument.Load("Vendvotimi.xml");
xmlDoc.Element("Vendvotimi").Add(new XElement("Vota", new XElement("Zgjedhja", t
heVota)));
xmlDoc.Save("Vendvotimi.xml");
lblResults.Text = "Faleminderit per voten tuaj.";
readXML();
}
catch
{
lblResults.Text = "Na falni, procesi deshtoi. Provoni perseri.";
}
}
private void butRezultatet_Click(object sender, EventArgs e)
{
readXML();
}
private void readXML()
{
XDocument xmlDoc = XDocument.Load("Vendvotimi.xml");
var votes = from vote in xmlDoc.Descendants("Vota")
select new
{
Vote = vote.Element("Zgjedhja").Value,
};
int mCount;
int oCount;
thCount = 0;
vvCount = 0;
foreach (var vote in votes)
{

if (vote.Vote == "Thaqi")
th++;
else if (vote.Vote == "VV")
vvCount++;
}
double theTotal;
theTotal = thCount + vvCount;
double thPercent;
double vvPercent;
thPercent = (thCount/theTotal)*100;
vvPercent = (vvCount/theTotal)*100;
lblResults.Text = "Thaqi: " + thCount + " votes (" + thPercent + "%).\n";
lblResults.Text = lblResults.Text + "VV: " + vvCount + " votes (" + vvPercent +
"%).\n\n";
}
private void butSubmit_Click(object sender, EventArgs e)
{
if (radThaqi.Checked == true)
submitVote("Thaqi");
else if (radVV.Checked == true)
submitVote("VV");
}
}
}

Вам также может понравиться