コード例 #1
0
        private void editEmployee_Click(object sender, EventArgs e)
        {
            var tmp = employeesView.SelectedRows.Count != 0 ? employeesView.SelectedRows[0] : null;

            if (tmp == null || tmp.Index == employeesView.Rows.Count - 1)
            {
                MessageBox.Show("Ничего не выбрано!", "Предупреждение", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            var editForm = new EditEmployeesForm(tmp)
            {
                Text = "Редактировать"
            };

            editForm.ShowDialog();
            if (!editForm.IsSaved)
            {
                return;
            }
            var emp        = editForm.Employee;
            var parameters = new List <SQLiteParameter>()
            {
                new SQLiteParameter($"@{Db.Employees.surname}", emp.Surname),
                new SQLiteParameter($"@{Db.Employees.name}", emp.Name),
                new SQLiteParameter($"@{Db.Employees.patronymic}", emp.Patronymic),
                new SQLiteParameter($"@{Db.Employees.position}", emp.Position),
                new SQLiteParameter($"@{Db.Employees.mobile}", emp.Mobile),
                new SQLiteParameter($"@{Db.Employees.surname}1", tmp.Cells[0].Value),
                new SQLiteParameter($"@{Db.Employees.name}1", tmp.Cells[1].Value),
                new SQLiteParameter($"@{Db.Employees.patronymic}1", tmp.Cells[2].Value)
            };

            DatabaseService.Execute(Db.Employees.Update, parameters);
            ViewData();
        }
コード例 #2
0
        private void addEmployee_Click(object sender, EventArgs e)
        {
            var addForm = new EditEmployeesForm()
            {
                Text = "Добавить"
            };

            addForm.ShowDialog();
            if (!addForm.IsSaved)
            {
                return;
            }

            var emp        = addForm.Employee;
            var parameters = new List <SQLiteParameter>()
            {
                new SQLiteParameter($"@{Db.Employees.surname}", emp.Surname),
                new SQLiteParameter($"@{Db.Employees.name}", emp.Name),
                new SQLiteParameter($"@{Db.Employees.patronymic}", emp.Patronymic),
                new SQLiteParameter($"@{Db.Employees.position}", emp.Position),
                new SQLiteParameter($"@{Db.Employees.mobile}", emp.Mobile)
            };

            DatabaseService.Execute(Db.Employees.Insert, parameters);
            ViewData();
        }