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) { } }
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(); }
void GetCandidatesByPosition(string sData) { try { oCandidate = new DataAccess.Candidate(); dgDetails.Rows.Clear(); foreach (DataRow row in oCandidate.getCandidatesByPosition(sData).Rows) { dgDetails.Rows.Add(row["CANDIDATE_ID"], row["LAST_NAME"] + ", " + row["FIRST_NAME"] + " " + row["MIDDLE_NAME"]); } ClearFields(); } catch (Exception ex) { } }
public void LoadCandidates() { try { eVariable.DisableGridColumnSort(dgCandidates); oCandidate = new DataAccess.Candidate(); dgCandidates.Rows.Clear(); foreach (DataRow row in oCandidate.getCandidates(cboSearchBy.Text, tbxSearch.Text).Rows) { dgCandidates.Rows.Add(row["CANDIDATE_ID"], row["FIRST_NAME"], row["MIDDLE_NAME"], row["LAST_NAME"], row["DOB"], row["AGE"], row["COURSE"], row["SECTION"], row["CONTACT_NO"], row["ADDRESS"], row["POSITION_ID"], row["POSITION"], row["PARTY_ID"], row["PARTY"], row["PROFILE_PIC"], row["ELECTION_CODE"]); } lblTotalRecords.Text = dgCandidates.Rows.Count.ToString(); } catch (Exception ex) { } }
private void btnButton_Click(object sender, EventArgs e) { if (btnButton.Text.Trim() == "IMPORT") { if (txtImportPath.Text.Trim() == String.Empty) { MessageBox.Show("Please select file to import"); return; } #region Import try { if (cboImport.SelectedText == "STUDENT" || cboImport.Text == "STUDENT") { if (dgImport.Rows.Count > 0) { foreach (var iData in lstStudent) { oStudent = new DataAccess.Student(); if (!oStudent.IsRecordExists(iData)) { oStudent.InsertStudent(iData); } } MessageBox.Show("Record has been succesfully saved", sTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } } if (cboImport.SelectedText == "POSITION" || cboImport.Text == "POSITION") { if (dgImport.Rows.Count > 0) { foreach (var iData in lstCandidate) { oCandidate = new DataAccess.Candidate(); oCandidate.InsertCandidate(iData); } MessageBox.Show("Record has been succesfully saved", sTitle, MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { } #endregion } else { if (txtExportPath.Text.Trim() == string.Empty) { MessageBox.Show("PLEASE SELECT DISTINATION FILE PATH"); return; } if (dgExport.Rows.Count == 0) { MessageBox.Show("POPULATE RECORD FIRST"); return; } #region Export ExtractData(); #endregion } }