Exemplo n.º 1
0
        /// <summary>
        /// Window where the user can register the voter and where the voter's information is shown
        /// </summary>
        /// <param name="voter">The voter to be shown.</param>
        public NormVW(VoterDO voter)
        {
            InitializeComponent();

            voterNameLabel.Text = voter.Name;
            voterAddressLabel.Text = voter.Address;
            voterCityLabel.Text = voter.City;

            this.MaximumSize = new System.Drawing.Size(368, 218);
            this.MinimumSize = new System.Drawing.Size(368, 218);
        }
Exemplo n.º 2
0
        public WarningVW(VoterDO voter)
        {
            InitializeComponent();

            voterNameLabel.Text = voter.Name;
            voterAddressLabel.Text = voter.Address;
            voterCityLabel.Text = voter.City;

            Size size = new Size(384, 277);
            this.MaximumSize = size;
            this.MinimumSize = size;
        }
Exemplo n.º 3
0
        public UnRegVW(VoterDO voter)
        {
            InitializeComponent();

            voterNameLabel.Text = voter.Name;
            voterAddressLabel.Text = voter.Address;
            voterCityLabel.Text = voter.City;

            //Window is not resizable
            var size = new System.Drawing.Size(377, 345);
            this.MinimumSize = size;
            this.MaximumSize = size;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Set the values of this object to the values of the dummy object, if the dummys value is non-null.
        /// </summary>
        /// <param name="dummy">
        /// The dummy object, representing new values.
        /// </param>
        public void UpdateValues(IDataObject dummy)
        {
            Contract.Requires(dummy != null); // Re-stipulate this contract, since it must be checked before the added contracts.
            Contract.Requires(dummy.GetType() == this.GetType());
            Contract.Requires(dummy.PrimaryKey == null || (((VoterDO)dummy).PrimaryKey >= 101000001 && ((VoterDO)dummy).PrimaryKey <= 3012999999));

            VoterDO voterDummy = dummy as VoterDO;

            Contract.Assert(voterDummy != null);

            this.PollingStationId = voterDummy.PollingStationId ?? this.PollingStationId;
            this.PrimaryKey       = voterDummy.PrimaryKey ?? this.PrimaryKey;
            this.Name             = voterDummy.Name ?? this.Name;
            this.City             = voterDummy.City ?? this.City;
            this.Address          = voterDummy.Address ?? this.Address;
            this.CardPrinted      = voterDummy.CardPrinted ?? this.CardPrinted;
            this.Voted            = voterDummy.Voted ?? this.Voted;
        }
Exemplo n.º 5
0
        public void showSpecificVoter(VoterDO voter)
        {
            ///Ordinary voter window
            //VoterWindow vw1 = new VoterWindow(voter);
            //vw1.Height = 220;
            //vw1.panel1.Controls.Add(new RegAndCancelUC());
            //vw1.Show();

            ///Voter window with error message
            VoterWindow vw = new VoterWindow(voter);
            vw.Height = 280;
            vw.panel1.Controls.Add(new WarningUC());
            vw.Show();

            ///Voter window with unreg functionality
            //VoterWindow vw = new VoterWindow(voter);
            //vw.Height = 340;
            //vw.panel1.Controls.Add(new UnregUC());
            //vw.Show();
        }
Exemplo n.º 6
0
        /// <summary>
        /// (To be called when a group has finished being generated)
        /// Prepares for and starts the generation of the next group, if any remain.
        /// If no groups remain; the voters are updated in the database.
        /// </summary>
        /// <param name="sender">BackgroundWorker that just completed a generation process.</param>
        /// <param name="e">Worker event completion parameters (currently not used).</param>
        private void GroupGenerated(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Cancelled) return;
            var worker = sender as BackgroundWorker;
            this.GroupDoneCount++;

            // Prepare and start generation of next group, if any remain.
            if (this.groupsEnumerator.MoveNext())
            {
                this.currentGroup = this.groupsEnumerator.Current;
                this.CurrentGroupName = this.currentGroup.Key;
                this.voterCount = this.currentGroup.Count();
                this.voterDoneCount = 0;
                this.VoterDonePerc = 0;

                worker.RunWorkerAsync();
            }
            // ..Otherwise update voters in db and declare completed.
            else
            {
                this.CurrentGroupName = "Updating Database..";

                var voterDAO = new VoterDAO();
                var template = new VoterDO(null, null, null, null, null, true, null);
                var predicate = filter != null ? filter.ToPredicate() : v => true;
                voterDAO.Update(predicate, template);

                GenerationEnded("Completed");
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// Populate a voter card with the information of a given voter.
        /// </summary>
        /// <param name="page">The page containing the card.</param>
        /// <param name="pdf">The pdf containing the page.</param>
        /// <param name="xO">The horizontal offset of the card in points.</param>
        /// <param name="yO">The vertical offset of the card in points.</param>
        /// <param name="voter">The voter whose information to be populated onto the card.</param>
        private static void PopulateCard(Page page, PDF pdf, double xO, double yO, VoterDO voter)
        {
            // ----- POPULATE: POLLING STATION -----
            PollingStationDO ps = voter.PollingStation;

            var font = new Font(pdf, CoreFont.HELVETICA);
            font.SetSize(9);

            var t = new TextLine(font, ps.Name);
            t.SetPosition(xO + 9 * U, yO + 27.5 * U);
            t.DrawOn(page);

            t = new TextLine(font, ps.Address);
            t.SetPosition(xO + 9 * U, yO + 32 * U);
            t.DrawOn(page);

            t = new TextLine(font, "valgfrit");
            t.SetPosition(xO + 29 * U, yO + 48.8 * U);
            t.DrawOn(page);

            t = new TextLine(font, "02-04861");
            t.SetPosition(xO + 29 * U, yO + 58.7 * U);
            t.DrawOn(page);

            t = new TextLine(font, "09:00 - 20:00");
            t.SetPosition(xO + 29 * U, yO + 68.2 * U);
            t.DrawOn(page);

            // ----- POPULATE: VOTER -----
            MunicipalityDO mun = voter.PollingStation.Municipality;

            font = new Font(pdf, CoreFont.COURIER);
            font.SetSize(10);

            // Add top voter number 'Vælgernr.'
            t = new TextLine(font, "02-04861");
            t.SetPosition(xO + 102 * U, yO + 12 * U);
            t.DrawOn(page);

            // Add sender 'Afsender'
            t = new TextLine(font, mun.Name);
            t.SetPosition(xO + 102 * U, yO + 32.5 * U);
            t.DrawOn(page);

            t = new TextLine(font, mun.Address);
            t.SetPosition(xO + 102 * U, yO + 36.5 * U);
            t.DrawOn(page);

            t = new TextLine(font, mun.City);
            t.SetPosition(xO + 102 * U, yO + 40.5 * U);
            t.DrawOn(page);

            // Add reciever 'Modtager'
            t = new TextLine(font, voter.Name);
            t.SetPosition(xO + 102 * U, yO + 62.5 * U);
            t.DrawOn(page);

            t = new TextLine(font, voter.Address);
            t.SetPosition(xO + 102 * U, yO + 66.5 * U);
            t.DrawOn(page);

            t = new TextLine(font, voter.City);
            t.SetPosition(xO + 102 * U, yO + 70.5 * U);
            t.DrawOn(page);

            // Add CPR barcode
            string barcode = BarCodeHashing.Hash(voter.PrimaryKey.Value).ToString();
            var b = new BarCode(BarCode.CODE128, barcode);
            b.SetPosition(xO + 160 * U, yO + 60 * U);
            b.DrawOn(page);

            t = new TextLine(font, barcode);
            t.SetPosition(xO + 160 * U, yO + 72 * U);
            t.DrawOn(page);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Unregisters the current voter.
        /// </summary>
        public void UnregisterCurrentVoter()
        {
            Contract.Requires(currentVoter.Voted == true);
            Contract.Requires(currentVoter != null);
            Contract.Ensures(currentVoter.Voted == false);

            try
            {
                staticPvdao.Update((uint)currentVoter.PrimaryKey, false);
                //refresh the current voter to reflect the new voted status
                currentVoter = FetchVoter((uint)currentVoter.PrimaryKey);
                staticPvdao.EndTransaction();
                this.UpdateLog(ActivityEnum.U); //Update log with unregister entry
            }
            catch (Exception)
            {
                ConnectionError();
                return;
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Updates the current voter with the voter matching the cprno.
        ///  
        /// </summary>
        /// <param name="cprno">The cpr number of the voter to be found</param>
        public void FindVoter(uint cprno)
        {
            Contract.Requires(cprno != null);
            Contract.Ensures(cprno == currentVoter.PrimaryKey);
            try
            {
                currentVoter = staticPvdao.Read(cprno);

                //Update the current voter with the found voter
                CurrentVoterChanged(currentVoter);
                //Update log with read entry
                this.UpdateLog(ActivityEnum.R);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                ConnectionError(); // notify that the connection has been lost.
                return;
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Fetches the voter matching the cprno.
        /// </summary>
        /// <param name="cprno">The cprno of the voter to be fetched in the voter box.</param>
        /// <returns>The voter matching </returns>
        public VoterDO FetchVoter(uint cprno)
        {
            Contract.Requires(cprno != null);
            VoterDO voter;

            try
            {
                voter = staticPvdao.Read(cprno);
            }
            catch (Exception)
            {
                voter = new VoterDO();
                ConnectionError();
            }
            return voter;
        }