Пример #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            oCandidate    = new DataAccess.Candidate();
            oImageConvert = new CommonFunction.CommonFunction();

            foreach (var oText in pnlMain.Controls.OfType <TextBox>().ToList())
            {
                if (oText.Text.Trim() == String.Empty)
                {
                    oFrmMsgBox             = new frmMessageBox("All fields are required.");
                    oFrmMsgBox.MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                    oFrmMsgBox.ShowDialog();
                    return;
                }
            }

            oMCandidate               = new Model.Candidate();
            oMCandidate.UNIQUE_ID     = eVariable.sID;
            oMCandidate._Position.ID  = eVariable.sPositionID;
            oMCandidate._Party.ID     = eVariable.sPartyID;
            oMCandidate.ELECTION_CODE = lblElectionNo.Text;
            oMCandidate.DATE_ADDED    = DateTime.Now.ToString("yyyy-MM-dd");
            oMCandidate.ADDED_BY      = eVariable.sUsername;

            if (txtParty.Text != "INDEPENDENT")
            {
                if (oCandidate.IsSamePositionAndParty(oMCandidate))
                {
                    oFrmMsgBox             = new frmMessageBox("THERE SHOULD BE ONLY ONE POSITION PER PARTY");
                    oFrmMsgBox.MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                    oFrmMsgBox.ShowDialog();
                    return;
                }
            }

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


            if (TransactionType == eVariable.TransactionType.EDIT)
            {
                oMCandidate.MODIFIED_DATE = DateTime.Now.ToString("yyyy-MM-dd");
                oMCandidate.MODIFIED_BY   = eVariable.sUsername;
                oCandidate.UpdateCandidate(oMCandidate);
            }
            else
            {
                oCandidate.InsertCandidate(oMCandidate);
            }

            oFrmCandidateList.LoadCandidates();
            oFrmMsgBox             = new frmMessageBox("Record has been successfully saved.");
            oFrmMsgBox.MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
            oFrmMsgBox.ShowDialog();
            Close();
        }
Пример #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            oMBorrower      = new Model.Borrower();
            oBorrower       = new DataAccess.Borrower();
            oCommonFunction = new CommonFunction.CommonFunction();
            oImageFunction  = new CommonFunction.CommonFunction();

            if (eVariable.IsFieldEmpty(pnlMain))
            {
                oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.ALL_FIELDS_ARE_REQUIRED.ToString().Replace("_", " "));
                oFrmMsgBox.ShowDialog();
                return;
            }

            oMBorrower.PERSON_ID   = txtBorrowerID.Text;
            oMBorrower.FIRST_NAME  = txtFname.Text;
            oMBorrower.MIDDLE_NAME = txtMname.Text;
            oMBorrower.LAST_NAME   = txtLname.Text;
            oMBorrower.DOB         = dtDOB.Value.ToString("yyyy-MM-dd");
            oMBorrower.AGE         = txtAge.Text;
            oMBorrower.CONTACT_NO  = txtContactNo.Text;
            oMBorrower.ADDRESS     = txtAddress.Text;

            if (pImage.Image != null)
            {
                oMBorrower.PROFILE_PIC = oCommonFunction.CompressString(oImageFunction.ImageToBaseString(pImage.Image, ImageFormat.Png));
            }


            if (eVariable.m_ActionType == eVariable.ACTION_TYPE.EDIT)
            {
                oMBorrower.MODIFIED_BY   = eVariable.sUsername;
                oMBorrower.MODIFIED_DATE = DateTime.Now.ToString("yyyy-MM-dd");
                oBorrower.UpdateBorrower(oMBorrower);
            }
            else
            {
                oMBorrower.ADDED_BY   = eVariable.sUsername;
                oMBorrower.ADDED_DATE = DateTime.Now.ToString("yyyy-MM-dd");
                oBorrower.InsertBorrower(oMBorrower);
            }

            oFrmMsgBox = new frmMessageBox(eVariable.TransactionMessage.RECORD_HAS_BEEN_SUCESSFULLY_SAVED.ToString().Replace("_", " "));
            oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
            oFrmMsgBox.ShowDialog();
            oFrmBorrowerLst.LoadBorrower();
            eVariable.ClearText(pnlMain);
            ResetFields();
            Close();
        }
Пример #3
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)
            {
            }
        }