Beispiel #1
0
        void registroConvenio_Closed(object sender, EventArgs e)
        {
            RegistroConvenioPlanoSaude registro = (RegistroConvenioPlanoSaude)sender;
            AdministracaoContext       context  = (AdministracaoContext)convenioPlanoSaudeSetDomainDataSource.DomainContext;

            if (registro.DialogResult == true && registro.novoConvenio != null)
            {
                context.ConvenioPlanoSaudeSets.Add(registro.novoConvenio);
                convenioPlanoSaudeSetDomainDataSource.SubmitChanges();
                dfrConvenio.CurrentItem = registro.novoConvenio;

                ConvenioPlanoSaudeSet convenio = (ConvenioPlanoSaudeSet)registro.novoConvenio;
                ConvenioServicoSet    desconto = null;

                AdministracaoContext             administracaoContext  = new AdministracaoContext();
                LoadOperation <ServicoMedicoSet> loadOpServicosMedicos = administracaoContext.Load <ServicoMedicoSet>(administracaoContext.GetServicoMedicoSetQuery());
                loadOpServicosMedicos.Completed += (s2, e2) =>
                {
                    foreach (ServicoMedicoSet servico in ((LoadOperation)s2).Entities)
                    {
                        desconto = new ConvenioServicoSet();
                        desconto.ConvenioPlanoSaude_codigo = convenio.codigo;
                        desconto.ServicoMedicoSet_codigo   = servico.codigo;
                        desconto.porcentagem_desconto      = 0;

                        context.ConvenioServicoSets.Add(desconto);
                    }
                    convenioPlanoSaudeSetDomainDataSource.SubmitChanges();
                };
            }
        }
Beispiel #2
0
        void convenioPlanoSaudeSetDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (((DataGrid)sender).SelectedItem != null)
            {
                dgrDescontosServicos.Visibility = Visibility.Visible;

                AdministracaoContext  administracaoContext = new AdministracaoContext();
                ConvenioPlanoSaudeSet convenioSelecionado  = (ConvenioPlanoSaudeSet)((DataGrid)sender).SelectedItem;

                listaDescontosServicos = new ObservableCollection <DescontoServico>();
                DescontoServico descontoServico = null;

                LoadOperation <ServicoMedicoSet> loadOpServicosMedicos = administracaoContext.Load <ServicoMedicoSet>(administracaoContext.GetServicoMedicoSetQuery());
                loadOpServicosMedicos.Completed += (s2, e2) =>
                {
                    LoadOperation <ConvenioServicoSet> loadOp = administracaoContext.Load <ConvenioServicoSet>(administracaoContext.GetConvenioServicoSet_CodigoConvenioQuery(convenioSelecionado.codigo));
                    loadOp.Completed += (s3, e3) =>
                    {
                        foreach (ConvenioServicoSet servico in ((LoadOperation)s3).Entities)
                        {
                            descontoServico = new DescontoServico(servico.id, servico.ServicoMedicoSet.nome, servico.ServicoMedicoSet.descricao, servico.porcentagem_desconto);
                            listaDescontosServicos.Add(descontoServico);
                        }

                        dgrDescontosServicos.ItemsSource = listaDescontosServicos;
                    };
                };
            }
            else
            {
                dgrDescontosServicos.Visibility = Visibility.Collapsed;
            }
        }
Beispiel #3
0
        private void btnDeletar_Click(object sender, RoutedEventArgs e)
        {
            ServicoMedicoSet     produtoDeletado = (ServicoMedicoSet)servicoMedicoSetDataGrid.SelectedItem;
            AdministracaoContext context         = (AdministracaoContext)servicoMedicoSetDomainDataSource.DomainContext;

            if (produtoDeletado != null)
            {
                context.ServicoMedicoSets.Remove(produtoDeletado);
                servicoMedicoSetDomainDataSource.SubmitChanges();
            }
        }
Beispiel #4
0
        void registroProduto_Closed(object sender, EventArgs e)
        {
            RegistroServicoMedico registro = (RegistroServicoMedico)sender;
            AdministracaoContext  context  = (AdministracaoContext)servicoMedicoSetDomainDataSource.DomainContext;

            if (registro.DialogResult == true && registro.novoServico != null)
            {
                context.ServicoMedicoSets.Add(registro.novoServico);
                servicoMedicoSetDomainDataSource.SubmitChanges();
            }
        }
Beispiel #5
0
        private void dgrDescontosServicos_RowEditEnded(object sender, DataGridRowEditEndedEventArgs e)
        {
            AdministracaoContext  administracaoContext    = new AdministracaoContext();
            ConvenioPlanoSaudeSet convenioSelecionado     = (ConvenioPlanoSaudeSet)convenioPlanoSaudeSetDataGrid.SelectedItem;
            DescontoServico       descontoServicoAlterado = (DescontoServico)((DataGrid)sender).SelectedItem;

            LoadOperation <ConvenioServicoSet> loadOp = administracaoContext.Load <ConvenioServicoSet>(administracaoContext.GetConvenioServicoSet_IdQuery(descontoServicoAlterado.Id));

            loadOp.Completed += (s3, e3) =>
            {
                ConvenioServicoSet descontoServico = administracaoContext.ConvenioServicoSets.Where <ConvenioServicoSet>(desc => desc.id == descontoServicoAlterado.Id).Single <ConvenioServicoSet>();
                descontoServico.porcentagem_desconto = descontoServicoAlterado.Desconto;
                administracaoContext.SubmitChanges();
            };
        }