コード例 #1
0
        private void departamentAddButton_Click(object sender, EventArgs e)
        {
            if (departamentNameTextBox.TextLength == 0)
            {
                MessageBox.Show("Enter name", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                departamentNameTextBox.Focus();
                return;
            }
            using (var cn = Database.CreateConnection())
            {
                cn.Open();
                OracleCommand cmd = new OracleCommand("INSERT INTO departaments (name) VALUES (:name)", cn);
                cmd.Parameters.Add(new OracleParameter("name", departamentNameTextBox.Text));
                try
                {
                    cmd.ExecuteNonQuery();
                    DepartamentsDataSet.Update();
                    departaments = DepartamentsDataSet.GetData();
                    ProjectsDataSet.Update();
                    projects = ProjectsDataSet.GetData();
                    departamentsDataGridView.DataSource   = departaments;
                    projectDepartamnetComboBox.DataSource = departaments;
                    projectsDataGridView.DataSource       = projects;

                    departamentNameTextBox.Text = "";
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
コード例 #2
0
        private void departamentDeleteButton_Click(object sender, EventArgs e)
        {
            using (var cn = Database.CreateConnection())
            {
                cn.Open();
                OracleCommand cmd = new OracleCommand("DELETE FROM departaments WHERE id=:id", cn);
                cmd.Parameters.Add(new OracleParameter("id", departaments[departamentsDataGridView.CurrentCell.RowIndex].id));
                try
                {
                    cmd.ExecuteNonQuery();
                    DepartamentsDataSet.Update();
                    departaments = DepartamentsDataSet.GetData();
                    ProjectsDataSet.Update();
                    projects = ProjectsDataSet.GetData();
                    departamentsDataGridView.DataSource   = departaments;
                    projectDepartamnetComboBox.DataSource = departaments;
                    projectsDataGridView.DataSource       = projects;

                    departamentNameTextBox.Text = "";
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
コード例 #3
0
        public MainForm()
        {
            InitializeComponent();

            ProjectsDataSet.Update();
            projects = ProjectsDataSet.GetData();

            DepartamentsDataSet.Update();
            departaments = DepartamentsDataSet.GetData();

            EmployeesDataSet.Update();
            employees = EmployeesDataSet.GetData();

            projectsDataGridView.DataSource            = projects;
            projectsDataGridView.Columns[0].Visible    = false;
            projectsDataGridView.Columns[3].HeaderText = "departament";
            projectsDataGridView.Columns[4].HeaderText = "begin date";
            projectsDataGridView.Columns[5].HeaderText = "end date";
            projectsDataGridView.Columns[6].HeaderText = "real end date";

            projectDepartamnetComboBox.DataSource = departaments;

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

            employeesDataGridView.DataSource            = employees;
            employeesDataGridView.Columns[0].Visible    = false;
            employeesDataGridView.Columns[1].HeaderText = "first name";
            employeesDataGridView.Columns[2].HeaderText = "last name";
            employeesDataGridView.Columns[3].HeaderText = "father name";
        }
コード例 #4
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);
                }
            }
        }
コード例 #5
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);
                }
            }
        }
コード例 #6
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;
        }