Exemplo n.º 1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                oCandidate     = new DataAccess.Candidate();
                oGeneratedKey  = new DataAccess.SystemFunction();
                oStringUtility = new CommonFunction.CommonFunction();

                sElectionCode = DateTime.Now.ToString("yyyy") + "-" + oStringUtility.GetRandomString(5);

                if (oCandidate.IsCandidateNotEmpty())
                {
                    oFrmMsgBox             = new Forms.frmMessageBox("WARNING! YOU HAVE EXISTING ACTIVE CANDIDATE WITH CURRENT ELECTION TICKET NUMBER [ " + sCurrentCode + " ] USED. PROCEDING THIS ACTIVITY WILL MAKE THEM ALL INACTIVE. WOULD YOU LIKE TO PROCEED?");
                    oFrmMsgBox.MessageType = Forms.frmMessageBox.MESSAGE_TYPE.QUERY;
                    oFrmMsgBox.ShowDialog();
                    if (oFrmMsgBox.sAnswer.ToUpper() != "YES")
                    {
                        return;
                    }
                }

                oElection  = new DataAccess.SystemFunction();
                oMElection = new Model.ElectionCode();

                oMElection.CODE       = sElectionCode;
                oMElection.ADDED_DATE = DateTime.Now;
                oMElection.ADDED_BY   = "Rolly";


                if (rdCloseElection.Checked)
                {
                    oElection.UpdateElectionCode();

                    oCandidate = new DataAccess.Candidate();
                    oCandidate.UpdateCandidateStatus(sCurrentCode);

                    oGeneratedKey = new DataAccess.SystemFunction();
                    oGeneratedKey.UpdateGeneratedKey(sCurrentCode);
                }
                else
                {
                    oElection.UpdateElectionCode();
                    oElection.InsertElectionCode(oMElection);

                    oCandidate = new DataAccess.Candidate();
                    oCandidate.UpdateCandidateStatus(sCurrentCode);

                    oGeneratedKey = new DataAccess.SystemFunction();
                    oGeneratedKey.UpdateGeneratedKey(sCurrentCode);
                }

                LoadKeys();
                oFrmMsgBox             = new Forms.frmMessageBox("RECORD SUCESSFULLY SAVED.");
                oFrmMsgBox.MessageType = Forms.frmMessageBox.MESSAGE_TYPE.INFO;
                oFrmMsgBox.ShowDialog();
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 2
0
        public void InsertElectionCode(Model.ElectionCode oData)
        {
            try
            {
                osb.ConnectionString = sConnectionString;
                ddq = new DatabaseQuery.DBQuery();
                ddq.ConnectionString = osb.ConnectionString;


                ddq.CommandText = "Insert Into tbl_ElectionCode (CODE,DATE_ADDED,ADDED_BY) Values ('" + oData.CODE + "','" + oData.ADDED_DATE + "','" + oData.ADDED_BY + "')";
                ddq.ExecuteNonQuery(CommandType.Text);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }