Example #1
0
        private void btnGenerate_Click(object sender, EventArgs e)
        {
            oStudent = new DataAccess.Student();

            oElection = new DataAccess.SystemFunction();

            if (!oElection.IsElectionCodeActive())
            {
                oFrmMsgBox             = new Forms.frmMessageBox("THERE IS NO ACTIVE ELECTION TICKET NUMBER. PLEASE OPEN FIRST TO START. THANK YOU. CLICK : UTILITY ELECTION TICKET NO");
                oFrmMsgBox.MessageType = Forms.frmMessageBox.MESSAGE_TYPE.INFO;
                oFrmMsgBox.ShowDialog();
                return;
            }

            foreach (DataRow row in oElection.getElectionCode("", "").Rows)
            {
                sElectionCode = row["CODE"].ToString();
            }

            foreach (DataRow row in oStudent.getStudent("", "").Rows)
            {
                oKeyGenerator = new CommonFunction.CommonFunction();
                oGenerateKey  = new DataAccess.SystemFunction();
                oMGenerateKey = new Model.GenerateKey();

                oMGenerateKey.GENERATED_KEY = oKeyGenerator.GetAssortedString(5);
                oMGenerateKey.VOTERS_ID     = row["STUDENT_ID"].ToString();
                oMGenerateKey.DATED_ADDED   = DateTime.Now.ToString("yyyy-MM-dd");
                oMGenerateKey.ELECTION_CODE = sElectionCode;
                oMGenerateKey.STATUS        = "ACTIVE";

                if (!oGenerateKey.IsKeyExists(oMGenerateKey.VOTERS_ID))
                {
                    oGenerateKey.InsertKey(oMGenerateKey);
                }
            }

            LoadRecords();
        }