Ejemplo n.º 1
0
        //
        //Добавление пользователей
        //
        private void bAddUser_Click(object sender, EventArgs e)
        {
            FormUser addForm = new FormUser(null);

            db.Positions.Load();
            var fibNumbers = db.Positions.Local.ToList();

            foreach (Positions rrr in fibNumbers)
            {
                addForm.cbPosition.Items.Add(rrr.Position);
            }

            DialogResult result = addForm.ShowDialog(this);

            if (result == DialogResult.Cancel)
            {
                return;
            }

            addForm.user.Position = db.Positions.Find(addForm.cbPosition.SelectedItem.ToString());
            if (dbAdd.UserAdd(addForm.user, db))
            {
                MessageBox.Show("Новый объект добавлен");
            }
            else
            {
                MessageBox.Show("Ай-ай");
            }
        }
Ejemplo n.º 2
0
        //
        //Редактирование Пользователей
        //
        private void bEditUser_Click(object sender, EventArgs e)
        {
            int id = IdConverter(dGVUserList);

            if (id > 0)
            {
                Users    user     = db.Users.Find(id);
                FormUser editForm = new FormUser(user);

                db.Positions.Load();
                var fibNumbers = db.Positions.Local.ToList();
                foreach (Positions rrr in fibNumbers)
                {
                    editForm.cbPosition.Items.Add(rrr.Position);
                }

                editForm.cbPosition.SelectedItem = editForm.user.Position.ToString();

                DialogResult result = editForm.ShowDialog(this);

                switch (result)
                {
                case DialogResult.Cancel:
                    return;

                case DialogResult.Abort:
                    dbDelete.UserDel(editForm.user, db);
                    dGVUserList.Refresh();
                    break;

                case DialogResult.OK:
                    editForm.user.Position = db.Positions.Find(editForm.cbPosition.SelectedItem.ToString());
                    dbEdit.UserEdit(user, editForm.user, db);
                    dGVUserList.Refresh();
                    break;

                default:
                    Console.WriteLine("Ой-ой");
                    break;
                }
            }
        }