Exemplo n.º 1
0
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            if (oMVotedCandidatelstRes.Count > 0)
            {
                oFrmMsgBox             = new frmMessageBox("ARE YOU SURE YOU WANT TO PROCEED TO THE TRANSACTION");
                oFrmMsgBox.MessageType = frmMessageBox.MESSAGE_TYPE.QUERY;
                oFrmMsgBox.ShowDialog();

                if (oFrmMsgBox.sAnswer == "YES")
                {
                    foreach (var iTem in oMVotedCandidatelstRes)
                    {
                        oVotersLogin     = new DataAccess.VotersLogin();
                        oMVotedCandidate = new Model.VotedCandidate();

                        oMVotedCandidate.CANDIDATE_ID  = iTem.CANDIDATE_ID;
                        oMVotedCandidate.FIRST_NAME    = iTem.FIRST_NAME;
                        oMVotedCandidate.MIDDLE_NAME   = iTem.MIDDLE_NAME;
                        oMVotedCandidate.LAST_NAME     = iTem.LAST_NAME;
                        oMVotedCandidate.DOB           = iTem.DOB;
                        oMVotedCandidate.COURSE        = iTem.COURSE;
                        oMVotedCandidate.SECTION       = iTem.SECTION;
                        oMVotedCandidate.POSITION      = iTem.POSITION;
                        oMVotedCandidate.PARTY         = iTem.PARTY;
                        oMVotedCandidate.DATE_ADDED    = iTem.DATE_ADDED;
                        oMVotedCandidate.VOTERS_ID     = iTem.VOTERS_ID.ToUpper();
                        oMVotedCandidate.ELECTION_CODE = iTem.ELECTION_CODE;

                        oVotersLogin.VoteCandidate(oMVotedCandidate);
                    }

                    oFrmMsgBox             = new frmMessageBox("YOU HAVE SUCCESSFULLY VOTED. THANK YOU.");
                    oFrmMsgBox.MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                    oFrmMsgBox.ShowDialog();

                    oVotersLogin = new DataAccess.VotersLogin();
                    oVotersLogin.UpdateVotersKey(oMVotedCandidate);

                    frmCandidate oFrmCandidate = new frmCandidate();
                    oFrmCandidate.CloseApplication();
                    Close();

                    frmLogin oFrm = new frmLogin();
                    oFrm.ShowDialog();
                }
            }
        }
Exemplo n.º 2
0
        void AddCandidate()
        {
            try
            {
                Boolean bFound = false;

                if (dgAddedList.Rows.Count > 0)
                {
                    foreach (DataGridViewRow row in dgAddedList.Rows)
                    {
                        if (row.Cells[2].Value.ToString() == txtPosition.Text)
                        {
                            bFound = true;
                            break;
                        }
                    }
                    if (bFound)
                    {
                        oFrmMsgBox             = new frmMessageBox("ONLY ONE CANDIDATE PER POSITION AT A TIME.");
                        oFrmMsgBox.MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                        oFrmMsgBox.ShowDialog();
                    }
                    else
                    {
                        oMVotedCandidate = new Model.VotedCandidate();

                        dgAddedList.Rows.Add(txtStudentID.Text, (txtLname.Text + ", " + txtFname.Text + " " + txtMname.Text).ToString(), txtPosition.Text, txtParty.Text);

                        oMVotedCandidate.ELECTION_CODE = sElectionCode;
                        oMVotedCandidate.CANDIDATE_ID  = txtStudentID.Text;
                        oMVotedCandidate.FIRST_NAME    = txtFname.Text;
                        oMVotedCandidate.MIDDLE_NAME   = txtMname.Text;
                        oMVotedCandidate.LAST_NAME     = txtLname.Text;
                        oMVotedCandidate.DOB           = Convert.ToDateTime(txtDOB.Text);
                        oMVotedCandidate.AGE           = txtAge.Text;
                        oMVotedCandidate.COURSE        = txtCourse.Text;
                        oMVotedCandidate.SECTION       = txtSection.Text;
                        oMVotedCandidate.POSITION      = txtPosition.Text;
                        oMVotedCandidate.PARTY         = txtParty.Text;
                        oMVotedCandidate.DATE_ADDED    = DateTime.Now;

                        oMVotedCandidate.VOTERS_ID = sVoters_ID;

                        oStringUtility = new CommonFunction.CommonFunction();
                        if (pImage.Image != null)
                        {
                            oMVotedCandidate.PROFILE_PIC = oStringUtility.CompressString(oImageConvert.ImageToBaseString(pImage.Image, ImageFormat.Png));
                        }
                        oMVotedCandidatelst.Add(oMVotedCandidate);
                    }
                }
                else
                {
                    oMVotedCandidate = new Model.VotedCandidate();

                    dgAddedList.Rows.Add(txtStudentID.Text, (txtLname.Text + ", " + txtFname.Text + " " + txtMname.Text).ToString(), txtPosition.Text, txtParty.Text);

                    oMVotedCandidate.ELECTION_CODE = sElectionCode;
                    oMVotedCandidate.CANDIDATE_ID  = txtStudentID.Text;
                    oMVotedCandidate.FIRST_NAME    = txtFname.Text;
                    oMVotedCandidate.MIDDLE_NAME   = txtMname.Text;
                    oMVotedCandidate.LAST_NAME     = txtLname.Text;
                    oMVotedCandidate.DOB           = Convert.ToDateTime(txtDOB.Text);
                    oMVotedCandidate.AGE           = txtAge.Text;
                    oMVotedCandidate.COURSE        = txtCourse.Text;
                    oMVotedCandidate.SECTION       = txtSection.Text;
                    oMVotedCandidate.POSITION      = txtPosition.Text;
                    oMVotedCandidate.PARTY         = txtParty.Text;
                    oMVotedCandidate.DATE_ADDED    = DateTime.Now;

                    oMVotedCandidate.VOTERS_ID = sVoters_ID;

                    if (pImage.Image != null)
                    {
                        oMVotedCandidate.PROFILE_PIC = oStringUtility.CompressString(oImageConvert.ImageToBaseString(pImage.Image, ImageFormat.Png));
                    }

                    oMVotedCandidatelst.Add(oMVotedCandidate);
                }
            }
            catch (Exception ex)
            {
            }
        }