void DisPlayCandidates() { oImageConvert = new CommonFunction.CommonFunction(); if (TransactionType == eVariable.TransactionType.EDIT) { eVariable.sID = oMCandidate.UNIQUE_ID; txtCandidateID.Text = oMCandidate.UNIQUE_ID; txtFullname.Text = oMCandidate.FIRST_NAME + " " + oMCandidate.MIDDLE_NAME + " " + oMCandidate.LAST_NAME; txtAge.Text = oMCandidate.AGE.ToString(); txtDOB.Text = oMCandidate.DOB; txtContactNo.Text = oMCandidate.CONTACT_NO; txtAddress.Text = oMCandidate.ADDRESS; txtSection.Text = oMCandidate.SECTION; txtCourse.Text = oMCandidate.COURSE; txtPosition.Text = oMCandidate._Position.POSITION; txtParty.Text = oMCandidate._Party.PARTY; oStringUtility = new CommonFunction.CommonFunction(); if (oMCandidate.PROFILE_PIC != string.Empty) { pImage.Image = oImageConvert.BaseStringToImage(oStringUtility.DecompressString(oMCandidate.PROFILE_PIC)); } EDFields(true); } else { EDFields(false); } }
private void dgAddedList_CellClick(object sender, DataGridViewCellEventArgs e) { try { String sCandidateID = String.Empty; if (dgAddedList.Rows.Count > 0) { sCandidateID = dgAddedList.Rows[e.RowIndex].Cells[0].Value.ToString(); foreach (var iTem in oMVotedCandidatelst.Where(fw => fw.CANDIDATE_ID == sCandidateID).ToList()) { sElectionCode = iTem.ELECTION_CODE; txtStudentID.Text = iTem.CANDIDATE_ID; txtFname.Text = iTem.FIRST_NAME; txtMname.Text = iTem.MIDDLE_NAME; txtLname.Text = iTem.LAST_NAME; txtDOB.Text = iTem.DOB.ToString("yyyy-MM-dd"); txtAge.Text = iTem.AGE; txtPosition.Text = iTem.POSITION; txtParty.Text = iTem.PARTY; txtCourse.Text = iTem.COURSE; txtSection.Text = iTem.SECTION; oStringUtility = new CommonFunction.CommonFunction(); if (iTem.PROFILE_PIC.Trim() != String.Empty) { pImage.Image = oImageConvert.BaseStringToImage(oStringUtility.DecompressString(iTem.PROFILE_PIC)); } } } } catch (Exception ex) { } }
private void dgDetails_CellClick(object sender, DataGridViewCellEventArgs e) { try { if (dgDetails.Rows.Count > 0) { ClearFields(); oImageConvert = new CommonFunction.CommonFunction(); foreach (DataRow row in oCandidate.getCandidates("ID", dgDetails.Rows[e.RowIndex].Cells[0].Value.ToString()).Rows) { sElectionCode = row["ELECTION_CODE"].ToString(); txtStudentID.Text = row["CANDIDATE_ID"].ToString(); txtFname.Text = row["FIRST_NAME"].ToString(); txtMname.Text = row["MIDDLE_NAME"].ToString(); txtLname.Text = row["LAST_NAME"].ToString(); txtPosition.Text = row["POSITION"].ToString(); txtParty.Text = row["PARTY"].ToString(); txtDOB.Text = row["DOB"].ToString(); txtAge.Text = row["AGE"].ToString(); txtCourse.Text = row["COURSE"].ToString(); txtSection.Text = row["SECTION"].ToString(); oStringUtility = new CommonFunction.CommonFunction(); if (row["PROFILE_PIC"].ToString().Trim() != String.Empty) { pImage.Image = oImageConvert.BaseStringToImage(oStringUtility.DecompressString(row["PROFILE_PIC"].ToString())); } } } } catch (Exception ex) { } }
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) { } }
void LoadRecords() { if (eVariable.m_ActionType == eVariable.ACTION_TYPE.EDIT) { txtBorrowerID.Enabled = false; txtBorrowerID.Text = oMBorrower.PERSON_ID; txtFname.Text = oMBorrower.FIRST_NAME; txtMname.Text = oMBorrower.MIDDLE_NAME; txtLname.Text = oMBorrower.LAST_NAME; dtDOB.Value = Convert.ToDateTime(oMBorrower.DOB); txtAge.Text = oMBorrower.AGE; txtContactNo.Text = oMBorrower.CONTACT_NO; txtAddress.Text = oMBorrower.ADDRESS; oCommonFunction = new CommonFunction.CommonFunction(); oImageFunction = new CommonFunction.CommonFunction(); if (oMBorrower.PROFILE_PIC != string.Empty) { pImage.Image = oCommonFunction.BaseStringToImage(oImageFunction.DecompressString(oMBorrower.PROFILE_PIC)); } } else { txtBorrowerID.Focus(); } }
private void dgDetails_CellEnter(object sender, DataGridViewCellEventArgs e) { try { if (dgDetails.Rows.Count > 0) { txtStudentID.Text = dgDetails.Rows[e.RowIndex].Cells[0].Value.ToString(); txtFname.Text = dgDetails.Rows[e.RowIndex].Cells[1].Value.ToString(); txtMname.Text = dgDetails.Rows[e.RowIndex].Cells[2].Value.ToString(); txtLname.Text = dgDetails.Rows[e.RowIndex].Cells[3].Value.ToString(); txtDOB.Text = dgDetails.Rows[e.RowIndex].Cells[4].Value.ToString(); txtAge.Text = dgDetails.Rows[e.RowIndex].Cells[5].Value.ToString(); txtCourse.Text = dgDetails.Rows[e.RowIndex].Cells[6].Value.ToString(); txtSection.Text = dgDetails.Rows[e.RowIndex].Cells[7].Value.ToString(); txtPosition.Text = dgDetails.Rows[e.RowIndex].Cells[11].Value.ToString(); txtParty.Text = dgDetails.Rows[e.RowIndex].Cells[13].Value.ToString(); oStringUtility = new CommonFunction.CommonFunction(); oImageConvert = new CommonFunction.CommonFunction(); if (dgDetails.Rows[e.RowIndex].Cells[14].Value.ToString() != string.Empty) { pImage.Image = oImageConvert.BaseStringToImage(oStringUtility.DecompressString(dgDetails.Rows[e.RowIndex].Cells[14].Value.ToString())); } } } 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(); }
private void btnLogin_Click(object sender, EventArgs e) { oUser = new DataAccess.User(); oUtility = new CommonFunction.CommonFunction(); if (oUtility.Decrypt(oDefUser.USERNAME.Trim()) == txtUsername.Text && oUtility.Decrypt(oDefUser.PASSWORD.Trim()) == txtPassword.Text) //Default Login { this.Hide(); this.ShowInTaskbar = false; ePublicVariable.eVariable.sUsername = txtUsername.Text; ePublicVariable.eVariable.sPassword = txtPassword.Text; ePublicVariable.eVariable.sFullname = oUtility.Decrypt(oDefUser.FULLNAME); ePublicVariable.eVariable.sRole = oUtility.Decrypt(oDefUser.ROLE); oMainForm = new MAIN(); oMainForm.ShowDialog(); } else { #region CheckDatabase oDatabase = new DataAccess.SystemFunction(); if (!oDatabase.IsDatabaseExits()) { oFrmMsgBox = new frmMessageBox("DATABASE DOES NOT EXISTS. PLEASE RESTORE FIRST THE DATABASE. THANK YOU"); oFrmMsgBox.MessageType = frmMessageBox.MESSAGE_TYPE.INFO; oFrmMsgBox.ShowDialog(); Maintenance.frmBackupRestoreDB oFrm = new Maintenance.frmBackupRestoreDB(); oFrm.ShowDialog(); } #endregion #region DBLogin if (oUser.IsLogin(txtUsername.Text.Trim(), txtPassword.Text.Trim())) { this.ShowInTaskbar = false; this.Hide(); ePublicVariable.eVariable.sUsername = txtUsername.Text; ePublicVariable.eVariable.sPassword = txtPassword.Text; oMainForm = new MAIN(); oMainForm.ShowDialog(); } else { oFrmMsgBox = new Forms.frmMessageBox("PLEASE ENTER CORRECT USERNAME AND PASSWORD."); oFrmMsgBox.MessageType = frmMessageBox.MESSAGE_TYPE.INFO; oFrmMsgBox.ShowDialog(); txtUsername.Focus(); } #endregion } }
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(); }
private void LoadAccess(string sRole) { oUser = new DataAccess.User(); oMUserConfig = new Model.UserConfig(); oCommonFunction = new CommonFunction.CommonFunction(); foreach (DataRow row in oUser.GetUserAccess(sRole).Rows) { oMUserConfig.BookDetail = Convert.ToBoolean(row["BookDetails"]); oMUserConfig.BookEntry = Convert.ToBoolean(row["BookEntry"]); oMUserConfig.BookAuthor = Convert.ToBoolean(row["BookAuthor"]); oMUserConfig.BookCategory = Convert.ToBoolean(row["BookCategory"]); oMUserConfig.BookLocation = Convert.ToBoolean(row["BookLocation"]); oMUserConfig.BookPolicy = Convert.ToBoolean(row["BookPolicy"]); oMUserConfig.BorrowerDetails = Convert.ToBoolean(row["BorrowerDetails"]); oMUserConfig.BorrowerEntry = Convert.ToBoolean(row["BorrowerEntry"]); oMUserConfig.BorrowBook = Convert.ToBoolean(row["BorrowBook"]); oMUserConfig.ReturnBook = Convert.ToBoolean(row["ReturnBook"]); oMUserConfig.PayBook = Convert.ToBoolean(row["PayBook"]); oMUserConfig.BorrowerRequest = Convert.ToBoolean(row["BorrowerRequest"]); oMUserConfig.UserAccount = Convert.ToBoolean(row["UserAccount"]); oMUserConfig.UserAccess = Convert.ToBoolean(row["UserAccess"]); oMUserConfig.UserRole = Convert.ToBoolean(row["UserRole"]); oMUserConfig.ImportExport = Convert.ToBoolean(row["ImportExport"]); oMUserConfig.RBookList = Convert.ToBoolean(row["RBookList"]); oMUserConfig.RBorrowerList = Convert.ToBoolean(row["RBorrowerList"]); } chkBookDetail.Checked = oMUserConfig.BookDetail; chkBookEntry.Checked = oMUserConfig.BookEntry; chkAuthor.Checked = oMUserConfig.BookAuthor; chkCategory.Checked = oMUserConfig.BookCategory; chkLocation.Checked = oMUserConfig.BookLocation; chkPolicy.Checked = oMUserConfig.BookPolicy; chkBorrowerDetails.Checked = oMUserConfig.BorrowerDetails; chkBorrowerEntry.Checked = oMUserConfig.BorrowerEntry; chkBorrowBook.Checked = oMUserConfig.BorrowBook; chkReturnBook.Checked = oMUserConfig.ReturnBook; chkPayBook.Checked = oMUserConfig.PayBook; chkBorrowerRequest.Checked = oMUserConfig.BorrowerRequest; chkUserAccount.Checked = oMUserConfig.UserAccount; chkUserAccess.Checked = oMUserConfig.UserAccess; chkUserRole.Checked = oMUserConfig.UserRole; chkImportExport.Checked = oMUserConfig.ImportExport; chkRBookList.Checked = oMUserConfig.RBookList; chkRBorrowerList.Checked = oMUserConfig.RBorrowerList; oMUserConfig.ROLE = oMUserConfig.ROLE; }
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(); }
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) { } }
private void btnLogin_Click(object sender, EventArgs e) { oUser = new DataAccess.User(); oCommonFunction = new CommonFunction.CommonFunction(); if (oCommonFunction.Decrypt(oDefUser.USERNAME.Trim()) == txtUsername.Text && oCommonFunction.Decrypt(oDefUser.PASSWORD.Trim()) == txtPassword.Text) //Default Login { this.ShowInTaskbar = false; this.Hide(); oMainForm = new MAIN(txtUsername.Text, txtPassword.Text, oCommonFunction.Decrypt(oDefUser.FULLNAME), oCommonFunction.Decrypt(oDefUser.ROLE)); oMainForm.ShowDialog(); return; } else { #region CheckDatabase oDatabase = new DataAccess.BackupRestoreDB(); if (!oDatabase.IsDatabaseExits()) { oFrmMsgBox = new frmMessageBox(ePublicVariable.eVariable.TransactionMessage.THE_DATABASE_DOES_NOT_EXITS.ToString().Replace("_", " ")); oFrmMsgBox.m_MessageType = frmMessageBox.MESSAGE_TYPE.INFO; oFrmMsgBox.ShowDialog(); Maintenance.frmBackupRestoreDB oFrm = new Maintenance.frmBackupRestoreDB(); oFrm.ShowDialog(); } #endregion #region DBLogin if (oUser.IsLogin(txtUsername.Text.Trim(), txtPassword.Text.Trim())) { foreach (DataRow row in oUser.GetUser("username", txtUsername.Text).Rows) { oMUser = new Model.User(); oMUser.USERNAME = row[0].ToString(); oMUser.FULLNAME = row[1].ToString(); oMUser.PASSWORD = row[2].ToString(); oMUser.ROLE = row[3].ToString(); oMUser.CONTACT_NO = row[4].ToString(); oMUser.ADDRESS = row[5].ToString(); } this.ShowInTaskbar = false; this.Hide(); oMainForm = new MAIN(oMUser); oMainForm.ShowDialog(); return; } else { lblNotification.Text = "THE USERNAME AND PASSWORD YOU HAVE ENTERED ARE INCORRECT"; txtUsername.Focus(); } #endregion } }