Exemple #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            oStudent  = new DataAccess.Student();
            oMStudent = new Model.Student();

            foreach (var oText in pnlMain.Controls.OfType <TextBox>().ToList())
            {
                if (oText.Text.Trim() == String.Empty)
                {
                    oFrmMsgBox             = new Forms.frmMessageBox(eVariable.MESSAGE.ALL_FIELDS_ARE_ALL_REQUIRED.ToString().Replace("_", " "));
                    oFrmMsgBox.MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                    oFrmMsgBox.ShowDialog();
                    return;
                }
            }

            oMStudent.UNIQUE_ID   = txtStudentID.Text;
            oMStudent.FIRST_NAME  = txtFname.Text;
            oMStudent.MIDDLE_NAME = txtMname.Text;
            oMStudent.LAST_NAME   = txtLname.Text;
            oMStudent.DOB         = dtDOB.Value.ToString("yyyy-MM-dd");
            oMStudent.AGE         = txtAge.Text;
            oMStudent.COURSE      = txtCourse.Text;
            oMStudent.SECTION     = txtSection.Text;
            oMStudent.CONTACT_NO  = txtContactNo.Text;
            oMStudent.ADDRESS     = txtAddress.Text;

            if (TransactionType == eVariable.TransactionType.EDIT)
            {
                oStudent.UpdateStudent(oMStudent);
            }
            else
            {
                if (!oStudent.IsRecordExists(oMStudent))
                {
                    oStudent.InsertStudent(oMStudent);
                }
                else
                {
                    oFrmMsgBox             = new frmMessageBox(eVariable.MESSAGE.RECORD_ALREADY_EXISTS.ToString().Replace("_", " "));
                    oFrmMsgBox.MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
                    oFrmMsgBox.ShowDialog();
                    return;
                }
            }
            oFrmStudents.LoadStudents();
            oFrmMsgBox             = new frmMessageBox(eVariable.MESSAGE.RECORD_HAS_BEEN_SUCCESSFULLY_SAVE.ToString().Replace("_", " "));
            oFrmMsgBox.MessageType = frmMessageBox.MESSAGE_TYPE.INFO;
            oFrmMsgBox.ShowDialog();
            TransactionType = eVariable.TransactionType.ADD;
            Close();
        }
Exemple #2
0
        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
            }
        }