示例#1
0
 public void InsertKey(Model.GenerateKey oData)
 {
     try
     {
         osb.ConnectionString = sConnectionString;
         ddq = new DatabaseQuery.DBQuery();
         ddq.ConnectionString = osb.ConnectionString;
         ddq.CommandText      = "Insert Into tbl_VotersKey (VOTERS_ID,GENERATED_KEY,DATE_ADDED,ELECTION_CODE) Values ('" + oData.VOTERS_ID + "','" + oData.GENERATED_KEY + "','" + oData.DATED_ADDED + "','" + oData.ELECTION_CODE + "')";
         ddq.ExecuteNonQuery(CommandType.Text);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
示例#2
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();
        }