Exemplo n.º 1
0
        private void addEmployeeButton_Click(object sender, EventArgs e)
        {
            if (employeesDataGridView.CurrentCell is null)
            {
                return;
            }
            using (var cn = Database.CreateConnection())
            {
                cn.Open();
                OracleCommand cmd = new OracleCommand("INSERT INTO departaments_employees (departament_id, employee_id) " +
                                                      "VALUES (:dep, :empl)", cn);
                cmd.Parameters.Add(new OracleParameter("dep", departament_id));
                cmd.Parameters.Add(new OracleParameter("empl", employees[employeesDataGridView.CurrentCell.RowIndex].id));
                try
                {
                    cmd.ExecuteNonQuery();
                    employees = EmployeesDataSet.GetAvailableEmployees(departament_id);
                    employeesDataGridView.DataSource = employees;

                    DepartsEmplsDataSet.Update();
                    records = DepartsEmplsDataSet.GetRecordsForDepartament(departament_id);
                    recordsDataGridView.DataSource = records;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Exemplo n.º 2
0
        private void deleteEmployeeButton_Click(object sender, EventArgs e)
        {
            if (recordsDataGridView.CurrentCell is null)
            {
                return;
            }
            using (var cn = Database.CreateConnection())
            {
                cn.Open();
                OracleCommand cmd = new OracleCommand("DELETE FROM departaments_employees WHERE id=:id", cn);
                cmd.Parameters.Add(new OracleParameter("id", records[recordsDataGridView.CurrentCell.RowIndex].id));
                try
                {
                    cmd.ExecuteNonQuery();
                    employees = EmployeesDataSet.GetAvailableEmployees(departament_id);
                    employeesDataGridView.DataSource = employees;

                    DepartsEmplsDataSet.Update();
                    records = DepartsEmplsDataSet.GetRecordsForDepartament(departament_id);
                    recordsDataGridView.DataSource = records;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Exemplo n.º 3
0
        public ManageDepartamentEmployeesForm(Departament departament)
        {
            InitializeComponent();

            departament_id = departament.id;

            departamentNameTextBox.Text = departament.name;

            employees = EmployeesDataSet.GetAvailableEmployees(departament_id);

            employeesDataGridView.DataSource         = employees;
            employeesDataGridView.Columns[0].Visible = false;

            DepartsEmplsDataSet.Update();
            records = DepartsEmplsDataSet.GetRecordsForDepartament(departament_id);

            recordsDataGridView.DataSource         = records;
            recordsDataGridView.Columns[0].Visible = false;
        }
Exemplo n.º 4
0
        public ManageEmployeeDepartamentsForm(Employee employee)
        {
            InitializeComponent();

            employee_id = employee.id;

            employeeFirstNameTextBox.Text     = employee.first_name;
            employeeLastNameTextBox.Text      = employee.last_name;
            employeeFatherNameTextBox.Text    = employee.father_name;
            employeePositionTextBox.Text      = employee.position;
            employeeSalaryNumericUpDown.Value = employee.salary;

            departaments = DepartamentsDataSet.GetAvailableDepartamnets(employee_id);

            departamentsDataGridView.DataSource         = departaments;
            departamentsDataGridView.Columns[0].Visible = false;

            DepartsEmplsDataSet.Update();
            records = DepartsEmplsDataSet.GetRecordsForEmployee(employee_id);

            recordsDataGridView.DataSource         = records;
            recordsDataGridView.Columns[0].Visible = false;
        }