Пример #1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtEmpID.Text))
            {
                MessageBox.Show("Please select employee first!", "Update Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            ActionResult updateResult = formCtrl._updateFormData(new LecturersFormModel()
            {
                EmployeeId    = txtEmpID.Text.Trim(),
                EmployeeName  = txtEmpName.Text.Trim(),
                Faculty       = comboFaculty.SelectedItem.ToString(),
                Department    = comboDept.SelectedItem.ToString(),
                Center        = comboCenter.SelectedItem.ToString(),
                Building      = comboBulding.SelectedItem.ToString(),
                EmployeeLevel = comboLevel.SelectedIndex,
                Rank          = txtRank.Text.Trim()
            });

            if (updateResult.State)
            {
                LecturersFormModel updateObj = updateResult.Data;
                MessageBox.Show("Employee " + updateObj.EmployeeId + " Sucessfully Updated!", "Update Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                initForm();
            }
            else
            {
                MessageBox.Show(updateResult.Data, "Update Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #2
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            string searchTag = txtLecture.Text.Trim();

            ActionResult lecturersResult = formCtrl._getFormData(typeof(LecturersFormModel), "Lecturers");

            if (lecturersResult.State)
            {
                List <LecturersFormModel> LecturerList = lecturersResult.Data;
                LecturersFormModel        lecturer     = LecturerList.Find(lec => lec.EmployeeId == searchTag);
                if (lecturer == null)
                {
                    MessageBox.Show("Lecture Id Does Not Exist.Please Enter Valid One.", "Info Message", MessageBoxButtons.OK, MessageBoxIcon.Question);
                }
                else if (string.IsNullOrEmpty(txtLecture.Text))
                {
                    MessageBox.Show("Plese Enter Lecture ID", "Info Message", MessageBoxButtons.OK, MessageBoxIcon.Question);
                }
                else
                {
                    panel1.Visible  = true;
                    btnBack.Visible = true;

                    txtId.Text      = lecturer.EmployeeId;
                    lblName.Text    = lecturer.EmployeeName;
                    lblfaculty.Text = lecturer.Faculty;
                    lblDept.Text    = lecturer.Department;
                    lblCen.Text     = lecturer.Center;
                    lblBul.Text     = lecturer.Building;
                    lblLevel.Text   = lecturer.EmployeeLevel + "";
                    lblRank.Text    = lecturer.Rank;
                }
            }
        }
Пример #3
0
        private void btnInsert_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtEmpName.Text))
            {
                MessageBox.Show("Please Enter Employee Name!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtEmpName.Focus();
            }
            else if (comboFaculty.SelectedIndex == 0)
            {
                MessageBox.Show("Please Select Faculty!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                comboFaculty.Focus();
            }
            else if (comboDept.SelectedIndex == 0)
            {
                MessageBox.Show("Please Select Department!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                comboDept.Focus();
            }
            else if (comboCenter.SelectedIndex == 0)
            {
                MessageBox.Show("Please Select Center!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                comboCenter.Focus();
            }
            else if (comboBulding.SelectedIndex == 0)
            {
                MessageBox.Show("Please Select Buidling!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                comboBulding.Focus();
            }
            else if (comboLevel.SelectedIndex == 0)
            {
                MessageBox.Show("Please Select Employee Level!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                comboLevel.Focus();
            }
            else
            {
                ActionResult saveResult = formCtrl._saveFormData(new LecturersFormModel()
                {
                    EmployeeName  = txtEmpName.Text.Trim(),
                    Faculty       = comboFaculty.SelectedItem.ToString(),
                    Department    = comboDept.SelectedItem.ToString(),
                    Center        = comboCenter.SelectedItem.ToString(),
                    Building      = comboBulding.SelectedItem.ToString(),
                    EmployeeLevel = comboLevel.SelectedIndex,
                }, true);

                if (saveResult.State)
                {
                    LecturersFormModel saveObj = saveResult.Data;
                    MessageBox.Show("Employee " + saveObj.EmployeeId + " Sucessfully Saved!", "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    initForm();
                }
                else
                {
                    MessageBox.Show(saveResult.Data, "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtSessionCode.Text))
            {
                MessageBox.Show("Please select session first!", "Update Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            string Lecturers = "", LecturersList = "";

            foreach (var lecturer in chkListLecturers.CheckedItems)
            {
                if (Lecturers != "" && LecturersList != "")
                {
                    Lecturers     += ",";
                    LecturersList += ",";
                }
                LecturersFormModel lecObj = lecturerList.Where(lec => lec.EmployeeName == lecturer.ToString()).FirstOrDefault();
                Lecturers     += lecObj.EmployeeId;
                LecturersList += lecObj.EmployeeName;
            }

            SubjectsFormModel subModel = subList.Where(sub => sub.SubjectName == comboSubjects.SelectedItem.ToString().Trim()).FirstOrDefault();

            ActionResult updateResult = formCtrl._updateFormData(new SessionsSubFormModel()
            {
                SessionCode   = Convert.ToInt32(txtSessionCode.Text),
                Lecturers     = Lecturers,
                LecturersList = LecturersList,
                Tags          = comboTags.SelectedItem.ToString(),
                GroupId       = comboGroup.SelectedItem.ToString(),
                SubjectCode   = subModel.SubjectCode,
                SubjectName   = subModel.SubjectName,
                NoOfStudent   = Convert.ToInt32(txtNoOfStudents.Text),
                Duration      = Convert.ToInt32(txtDurations.Text)
            });

            if (updateResult.State)
            {
                SessionsSubFormModel updateObj = updateResult.Data;
                MessageBox.Show("Session " + updateObj.SessionCode + " Sucessfully Updated!", "Update Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                initForm();
            }
            else
            {
                MessageBox.Show(updateResult.Data, "Update Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #5
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtEmpID.Text))
            {
                MessageBox.Show("Please select employee first!", "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            ActionResult deleteResult = formCtrl._deleteFormData(new LecturersFormModel()
            {
                EmployeeId = txtEmpID.Text.Trim()
            });

            if (deleteResult.State)
            {
                LecturersFormModel deleteObj = deleteResult.Data;
                MessageBox.Show("Employee " + deleteObj.EmployeeId + " Sucessfully Deleted!", "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                initForm();
            }
            else
            {
                MessageBox.Show(deleteResult.Data, "Delete Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void gridLecturersDetails_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow selectedRow = this.gridSessionDetails.SelectedRows[0];

            if (selectedRow != null)
            {
                List <string>             selectedLecturers = selectedRow.Cells[1].Value.ToString().Split(",").ToList();
                List <LecturersFormModel> LecturerList      = new List <LecturersFormModel>();

                foreach (var lecName in selectedLecturers)
                {
                    LecturersFormModel lecObj = lecturerList.Where(lec => lec.EmployeeId == lecName.ToString()).FirstOrDefault();
                    LecturerList.Add(lecObj);
                }

                for (int count = 0; count < chkListLecturers.Items.Count; count++)
                {
                    LecturersFormModel emp = LecturerList.Where(lec => lec.EmployeeName == chkListLecturers.Items[count].ToString()).FirstOrDefault();

                    if (selectedLecturers.Contains(emp.EmployeeId))
                    {
                        chkListLecturers.SetItemChecked(count, true);
                    }
                }

                txtSessionCode.Text         = selectedRow.Cells[0].Value.ToString();
                comboTags.SelectedIndex     = comboTags.FindStringExact(selectedRow.Cells[3].Value.ToString());
                comboGroup.SelectedIndex    = comboGroup.FindStringExact(selectedRow.Cells[4].Value.ToString());
                comboSubjects.SelectedIndex = comboSubjects.FindStringExact(selectedRow.Cells[6].Value.ToString());
                txtNoOfStudents.Text        = selectedRow.Cells[7].Value.ToString();
                txtDurations.Text           = selectedRow.Cells[8].Value.ToString();

                btnInsert.Enabled = false;
                btnUpdate.Enabled = true;
                btnDelete.Enabled = true;
            }
        }
        private void btnInsert_Click(object sender, EventArgs e)
        {
            if (chkListLecturers.CheckedItems.Count == 0)
            {
                MessageBox.Show("Please Select The Lecturers!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (comboTags.SelectedIndex == 0)
            {
                MessageBox.Show("Please Select Tag!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                comboTags.Focus();
            }
            else if (comboGroup.SelectedIndex == 0)
            {
                MessageBox.Show("Please Select Group Or Subgroup!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                comboGroup.Focus();
            }
            else if (comboSubjects.SelectedIndex == 0)
            {
                MessageBox.Show("Please Select Subject!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                comboSubjects.Focus();
            }
            else if (string.IsNullOrEmpty(txtNoOfStudents.Text))
            {
                MessageBox.Show("Please Enter No Of Students!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtNoOfStudents.Focus();
            }
            else if (string.IsNullOrEmpty(txtDurations.Text))
            {
                MessageBox.Show("Please Enter Duration!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtDurations.Focus();
            }
            else
            {
                string Lecturers = "", LecturersList = "";
                foreach (var lecturer in chkListLecturers.CheckedItems)
                {
                    if (Lecturers != "" && LecturersList != "")
                    {
                        Lecturers     += ",";
                        LecturersList += ",";
                    }
                    LecturersFormModel lecObj = lecturerList.Where(lec => lec.EmployeeName == lecturer.ToString()).FirstOrDefault();
                    Lecturers     += lecObj.EmployeeId;
                    LecturersList += lecObj.EmployeeName;
                }

                SubjectsFormModel subModel = subList.Where(sub => sub.SubjectName == comboSubjects.SelectedItem.ToString().Trim()).FirstOrDefault();

                ActionResult saveResult = formCtrl._saveFormData(new SessionsSubFormModel()
                {
                    Lecturers     = Lecturers,
                    LecturersList = LecturersList,
                    Tags          = comboTags.SelectedItem.ToString(),
                    GroupId       = comboGroup.SelectedItem.ToString(),
                    SubjectCode   = subModel.SubjectCode,
                    SubjectName   = subModel.SubjectName,
                    NoOfStudent   = Convert.ToInt32(txtNoOfStudents.Text),
                    Duration      = Convert.ToInt32(txtDurations.Text)
                });

                if (saveResult.State)
                {
                    SessionsSubFormModel saveObj = saveResult.Data;
                    MessageBox.Show("Session " + saveObj.SessionCode + " Sucessfully Saved!", "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    initForm();
                }
                else
                {
                    MessageBox.Show(saveResult.Data, "Save Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }