Пример #1
0
        public void Execute(GUIActionState action)
        {
            MainSelection.action = action;
            switch (MainSelection.action)
            {
            case GUIActionState.EmpresaDelete:
                MainDb.deleteEmpresa(MainSelection.emp);
                MainPool.empresas.Remove(MainSelection.emp);
                break;

            case GUIActionState.EmpresaDeleteConfirmation:
                if (MainSelection.state == GUIState.EmpresaAlta)
                {
                    Execute(GUIActionState.EmpresaCancelDelete);
                }
                else
                {
                    if (MessageBox.Show("Eliminar ", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes)
                    {
                        Execute(GUIActionState.EmpresaDelete);
                        AdvanceState(GUIState.BusquedaEmpresa);
                    }
                }
                break;

            case GUIActionState.EmpresaCancelDelete:
                AdvanceState(GUIState.BusquedaEmpresa);
                break;

            case GUIActionState.EmpresaInsertar:
                Emp emp = new Emp()
                {
                    name                = txtEmpName.Text,
                    type                = ((EmpType)txtEmpTipo.Items[txtEmpTipo.SelectedIndex]),
                    addresses           = txtAddress.Text,
                    phones              = txtPhones.Text,
                    contactoAlternativo = txtContactoAlternativo.Text,
                    cuil                = txtCUIL.Text,
                    deParteDe           = txtDeParteDe.Text
                };
                MainPool.empresas.Add(emp);
                MainDb.SaveEmpresa(emp);
                AdvanceState(GUIState.BusquedaEmpresa);
                seleccionarEmpresa(emp);
                AdvanceState(GUIState.EmpresaSeleccionada);
                break;

            case GUIActionState.EmpresaModificar:
                MainSelection.emp.name                = txtEmpName.Text;
                MainSelection.emp.type                = ((EmpType)txtEmpTipo.Items[txtEmpTipo.SelectedIndex]);
                MainSelection.emp.addresses           = txtAddress.Text;
                MainSelection.emp.phones              = txtPhones.Text;
                MainSelection.emp.contactoAlternativo = txtContactoAlternativo.Text;
                MainSelection.emp.cuil                = txtCUIL.Text;
                MainSelection.emp.deParteDe           = txtDeParteDe.Text;
                MainDb.SaveEmpresa(MainSelection.emp);
                AdvanceState(GUIState.BusquedaEmpresa);
                AdvanceState(GUIState.EmpresaSeleccionada);
                break;
            }
        }