private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "" && textBox2.Text != "")
            {
                string squery = "SELECT * FROM voter WHERE uname = '" + textBox1.Text + "' AND pw = '" + textBox2.Text + "' ";
                if (con.State == ConnectionState.Closed)
                {
                    con.Open();
                }
                msc = new MySqlCommand(squery, con);
                mda.SelectCommand = msc;
                mda.SelectCommand = msc;
                DataTable dt1 = new DataTable();
                mda.Fill(dt1);
                if (dt1.Rows.Count == 1)
                {
                    vid = Convert.ToInt32(dt1.Rows[0][0]);
                    eid = Convert.ToInt32(dt1.Rows[0][4]);

                    string str1 = "SELECT `voteid` FROM `vote` WHERE vid = '" + vid + "' AND eid = '" + eid + "'";
                    if (con.State == ConnectionState.Closed)
                    {
                        con.Open();
                    }
                    msc = new MySqlCommand(str1, con);
                    DataTable dt2 = new DataTable();
                    mda.SelectCommand = msc;
                    mda.Fill(dt2);
                    if (dt2.Rows.Count >= 1)
                    {
                        MessageBox.Show("You have already voted..");
                        textBox1.Text = "";
                        textBox2.Text = "";
                    }
                    else
                    {
                        MessageBox.Show("You can Vote..");
                        this.Hide();
                        var v = new Voting();
                        v.Closed += (s, args) => this.Close();
                        v.Show();
                    }
                }
                else
                {
                    MessageBox.Show("Please Check your Username and Password");
                }
                con.Close();
                msc.Parameters.Clear();
            }
            else
            {
                MessageBox.Show("Please fill all fields.");
            }
        }
Example #2
0
 private void AssignUsers(object sender, RoutedEventArgs e)
 {
     if (VotingsList.SelectedIndex != -1)
     {
         Voting        Vote   = AllVotings[VotingsList.SelectedIndex];
         AssignedUsers window = new AssignedUsers(Vote.VoteNum);
         window.Owner = Window.GetWindow(this);
         window.ShowDialog();
         if (!(window.result).Equals("true"))
         {
             System.Windows.MessageBox.Show("Error! " + window.result);
         }
     }
 }
Example #3
0
 private void EditVoting(object sender, RoutedEventArgs e)
 {
     if (VotingsList.SelectedIndex != -1)
     {
         Voting     Vote   = AllVotings[VotingsList.SelectedIndex];
         EditVoting window = new EditVoting(Vote);
         window.Owner = Window.GetWindow(this);
         window.ShowDialog();
         if (!(window.result).Equals("true"))
         {
             System.Windows.MessageBox.Show("Error! " + window.result);
         }
         else
         {
             VotingsLoading(sender, e);
         }
         VotingsList.SelectedIndex = 0;
     }
 }
Example #4
0
 private void RemoveVoting(object sender, RoutedEventArgs e)
 {
     if (VotingsList.SelectedIndex != -1)
     {
         MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Are you sure you want to delete this election?", null, System.Windows.MessageBoxButton.YesNo);
         if (messageBoxResult == MessageBoxResult.Yes)
         {
             Voting Vote   = AllVotings[VotingsList.SelectedIndex];
             string answer = new Server().RemoveVoting(Vote.VoteNum);
             if (!answer.Equals("true"))
             {
                 System.Windows.MessageBox.Show("Error! " + answer);
             }
             else
             {
                 VotingsLoading(sender, e);
             }
             VotingsList.SelectedIndex = 0;
         }
     }
 }
Example #5
0
        private void VotingsListBox_Click(object sender, SelectionChangedEventArgs e)
        {
            if (VotingsList.SelectedIndex != -1)
            {
                GroupBox1.Visibility = Visibility.Visible;
                GroupBox2.Visibility = Visibility.Hidden;

                VotingInformation.IsSelected = true;

                Voting Vote = FilteredVotings[VotingsList.SelectedIndex];
                VotingTitle.Text      = Vote.VoteName;
                VotingDescript.Text   = Vote.VoteDescription;
                VotingStartDate.Text  = Vote.Start.ToString("dd/MM/yyyy");                                                     //yyyy-MM-dd
                VotingFinishDate.Text = Vote.Finish.ToString("dd/MM/yyyy");
                VotingStartTime.Text  = "  " + Vote.Start.Hour.ToString("D2") + "        " + Vote.Start.Minute.ToString("D2"); //  08        05
                VotingFinishTime.Text = "  " + Vote.Finish.Hour.ToString("D2") + "        " + Vote.Finish.Minute.ToString("D2");
                if (Vote.AvailableVoting())
                {
                    DeleteVoting.Visibility = Visibility.Hidden;
                }
                else
                {
                    DeleteVoting.Visibility = Visibility.Visible;
                }
                if (Vote.FutureVoting())
                {
                    EditVote.Visibility          = Visibility.Visible;
                    EditAssignedUsers.Visibility = Visibility.Visible;
                    EditCustomers.Visibility     = Visibility.Visible;
                }
                else
                {
                    EditVote.Visibility          = Visibility.Hidden;
                    EditAssignedUsers.Visibility = Visibility.Hidden;
                    EditCustomers.Visibility     = Visibility.Hidden;
                }
                //showColumnChart(Vote.VoteNum);
                // showCandidates(Vote.VoteNum);
                if (AvailableVoting(Vote.Start, Vote.Finish))
                {
                    VotingResults.IsEnabled = false;
                    Timer = Vote.Finish;
                    TimerLabel.Foreground = new SolidColorBrush(Colors.Green);
                }
                else if (!PastVoting(Vote.Finish))
                {
                    VotingResults.IsEnabled = false;
                    Timer = Vote.Start;
                    TimerLabel.Foreground = new SolidColorBrush(Colors.LightBlue);
                }
                else
                {
                    VotingResults.IsEnabled = true;
                    Timer = new DateTime(0);
                    TimerLabel.Foreground = new SolidColorBrush(Colors.Red);
                }
                DispatcherTimer dispatcher = new DispatcherTimer();
                dispatcher.Tick    += new EventHandler(dispatcherTick);
                dispatcher.Interval = new TimeSpan(0, 0, 1);
                dispatcher.Start();
                showResults(Vote.VoteNum);
            }
            //else System.Windows.MessageBox.Show(Convert.ToString("Bad"));
        }