示例#1
0
        private void deleteDepartmentButton_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();
                    departaments = DepartamentsDataSet.GetAvailableDepartamnets(employee_id);
                    departamentsDataGridView.DataSource = departaments;

                    DepartsEmplsDataSet.Update();
                    records = DepartsEmplsDataSet.GetRecordsForEmployee(employee_id);
                    recordsDataGridView.DataSource = records;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
示例#2
0
        private void addDepartamentButton_Click(object sender, EventArgs e)
        {
            if (departamentsDataGridView.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", departaments[departamentsDataGridView.CurrentCell.RowIndex].id));
                cmd.Parameters.Add(new OracleParameter("empl", employee_id));
                try
                {
                    cmd.ExecuteNonQuery();
                    departaments = DepartamentsDataSet.GetAvailableDepartamnets(employee_id);
                    departamentsDataGridView.DataSource = departaments;

                    DepartsEmplsDataSet.Update();
                    records = DepartsEmplsDataSet.GetRecordsForEmployee(employee_id);
                    recordsDataGridView.DataSource = records;
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
示例#3
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;
        }