Exemplo n.º 1
0
 /// <summary>
 /// Event to be triggered when a value is selected in order to perform it searches
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void searchComboBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     //var test = CUDOperations.getAllEmp();
     if (searchComboBox.SelectedIndex == 0)
     {
         dataGridView1.DataSource = ResEmp.GetAllEmpAndDept();
     }
     else if (searchComboBox.SelectedIndex == 1)
     {
         dataGridView1.DataSource = ResEmp.GetAllEmpAndDeptGroupedByDept();
     }
     else if (searchComboBox.SelectedIndex == 2)
     {
         dataGridView1.DataSource = ResEmp.GetEmployeeBySalaryAbove150000();
     }
     else if (searchComboBox.SelectedIndex == 3)
     {
         dataGridView1.DataSource = ResEmp.GetAllDeptNotAssignedAnEmp();
     }
     else if (searchComboBox.SelectedIndex == 4)
     {
         dataGridView1.DataSource = ResEmp.GetAllEmpAndDeptAssignedAndNotAssigned();
     }
     else if (searchComboBox.SelectedIndex == 5)
     {
         dataGridView1.DataSource = ResEmp.GetAllEmp();
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Event to be triggered when Update a Department
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnUpdateDept_Click(object sender, EventArgs e)
        {
            try
            {
                ResDept.UpdateDept(
                    new Department
                {
                    DepartmentId   = DeptID,
                    DepartmentName = textBox10.Text
                }
                    );

                dataGridView2.DataSource = ResDept.GetAllDept();
                dataGridView1.DataSource = ResEmp.GetAllEmp();

                comboBox1.Items.Clear();
                var comboDept = ResDept.GetAllDeptToCombo();
                foreach (var item in comboDept)
                {
                    comboBox1.Items.Add(item);
                }

                textBox10.Clear();
            }
            catch (Exception)
            {
                MessageBox.Show("Department could not be Updated");
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// On Form Load, Methods to Perform
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CompanyForm_Load(object sender, EventArgs e)
        {
            var comboDept = ResDept.GetAllDeptToCombo();
            var dept      = ResDept.GetAllDept();
            var emp       = ResEmp.GetAllEmp();

            dataGridView1.DataSource = emp;
            dataGridView2.DataSource = dept;

            foreach (var item in comboDept)
            {
                comboBox1.Items.Add(item);
            }

            searchComboBox.Items.Add("");
        }
Exemplo n.º 4
0
        /// <summary>
        /// Event to be triggered when Deleting an Employee
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnDeleteEmp_Click(object sender, EventArgs e)
        {
            try
            {
                ResEmp.DeleteEmp(EmpID);
                dataGridView1.DataSource = ResEmp.GetAllEmp();

                textBox1.Clear();
                textBox2.Clear();
                textBox3.Clear();
                textBox4.Clear();
                textBox6.Clear();
            }
            catch (Exception)
            {
                MessageBox.Show("Employee details could not be Deleted");
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Event to be triggered when Add an Employee
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAddEmp_Click(object sender, EventArgs e)
        {
            try
            {
                decimal.TryParse(textBox6.Text, out decimal d);

                if (decimal.TryParse(textBox6.Text, out decimal _))
                {
                    ResEmp.AddEmp(new Employee
                    {
                        FirstName   = textBox1.Text,
                        LastName    = textBox2.Text,
                        Email       = textBox3.Text,
                        PhoneNumber = textBox4.Text,
                        HireDate    = dateTimePicker1.Value,
                        Salary      = d
                    },
                                  comboBox1.Text
                                  );

                    dataGridView1.DataSource = ResEmp.GetAllEmp();
                }
                else
                {
                    MessageBox.Show("Enter Valid Input");
                }

                textBox1.Clear();
                textBox2.Clear();
                textBox3.Clear();
                textBox4.Clear();
                textBox6.Clear();
            }
            catch (Exception)
            {
                MessageBox.Show("Fill up Relevant Fields. New Employee details could not be Added");
            }
        }